mirror of
https://github.com/flutter/packages.git
synced 2025-07-01 07:08:10 +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
|
## 0.1.13
|
||||||
|
|
||||||
* Fixed execution on Windows with certain setups where Dart didn't allow
|
* 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:path/path.dart' as path;
|
||||||
import 'package:pigeon/pigeon_lib.dart';
|
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 {
|
Future<void> main(List<String> args) async {
|
||||||
final PigeonOptions opts = Pigeon.parseArgs(args);
|
final PigeonOptions opts = Pigeon.parseArgs(args);
|
||||||
final Directory tempDir = Directory.systemTemp.createTempSync();
|
final Directory tempDir = Directory.systemTemp.createTempSync();
|
||||||
|
|
||||||
String importLine = '';
|
String importLine = '';
|
||||||
if (opts.input != null) {
|
if (opts.input != null) {
|
||||||
final String rawInputPath = opts.input;
|
final String relInputPath = _posixRelative(opts.input, from: tempDir.path);
|
||||||
final String absInputPath = File(rawInputPath).absolute.path;
|
importLine = 'import \'$relInputPath\';\n';
|
||||||
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 code = """$importLine
|
final String code = """$importLine
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
@ -8,7 +8,7 @@ import 'dart:mirrors';
|
|||||||
import 'ast.dart';
|
import 'ast.dart';
|
||||||
|
|
||||||
/// The current version of pigeon.
|
/// 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.
|
/// Read all the content from [stdin] to a String.
|
||||||
String readStdin() {
|
String readStdin() {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: pigeon
|
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.
|
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
|
homepage: https://github.com/flutter/packages/tree/master/packages/pigeon
|
||||||
dependencies:
|
dependencies:
|
||||||
|
Reference in New Issue
Block a user