mirror of
https://github.com/flutter/packages.git
synced 2025-06-30 23:03:11 +08:00
[pigeon] fixed windows across multiple drives (#233)
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
## 0.1.14
|
||||
|
||||
* [Windows] Fixed executing from drives other than C:.
|
||||
|
||||
## 0.1.13
|
||||
|
||||
* Fixed execution on Windows with certain setups where Dart didn't allow
|
||||
|
@ -9,20 +9,29 @@ import 'dart:isolate';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:pigeon/pigeon_lib.dart';
|
||||
|
||||
/// This creates a relative path from `from` to `input`, the output being a
|
||||
/// posix path on all platforms.
|
||||
String _posixRelative(String input, {String from}) {
|
||||
final path.Context context = path.Context(style: path.Style.posix);
|
||||
final String rawInputPath = input;
|
||||
final String absInputPath = File(rawInputPath).absolute.path;
|
||||
// By going through URI's we can make sure paths can go between drives in
|
||||
// Windows.
|
||||
final Uri inputUri = path.toUri(absInputPath);
|
||||
final String posixAbsInputPath = context.fromUri(inputUri);
|
||||
final Uri tempUri = path.toUri(from);
|
||||
final String posixTempPath = context.fromUri(tempUri);
|
||||
return context.relative(posixAbsInputPath, from: posixTempPath);
|
||||
}
|
||||
|
||||
Future<void> main(List<String> args) async {
|
||||
final PigeonOptions opts = Pigeon.parseArgs(args);
|
||||
final Directory tempDir = Directory.systemTemp.createTempSync();
|
||||
|
||||
String importLine = '';
|
||||
if (opts.input != null) {
|
||||
final String rawInputPath = opts.input;
|
||||
final String absInputPath = File(rawInputPath).absolute.path;
|
||||
final String relInputPath = path.relative(absInputPath, from: tempDir.path);
|
||||
|
||||
final List<String> relInputComponents = path.split(relInputPath);
|
||||
final path.Context context = path.Context(style: path.Style.posix);
|
||||
final String posixRelInputPath = context.joinAll(relInputComponents);
|
||||
importLine = 'import \'$posixRelInputPath\';\n';
|
||||
final String relInputPath = _posixRelative(opts.input, from: tempDir.path);
|
||||
importLine = 'import \'$relInputPath\';\n';
|
||||
}
|
||||
final String code = """$importLine
|
||||
import 'dart:io';
|
||||
|
@ -8,7 +8,7 @@ import 'dart:mirrors';
|
||||
import 'ast.dart';
|
||||
|
||||
/// The current version of pigeon.
|
||||
const String pigeonVersion = '0.1.13';
|
||||
const String pigeonVersion = '0.1.14';
|
||||
|
||||
/// Read all the content from [stdin] to a String.
|
||||
String readStdin() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
name: pigeon
|
||||
version: 0.1.13
|
||||
version: 0.1.14
|
||||
description: Code generator tool to make communication between Flutter and the host platform type-safe and easier.
|
||||
homepage: https://github.com/flutter/packages/tree/master/packages/pigeon
|
||||
dependencies:
|
||||
|
Reference in New Issue
Block a user