Allow snippets tool to be run from arbitrary CWDs (#25243)
* Allow snippets tool to be run from arbitrary CWDs * Drop use of absolute when using Platform.executable (path is not relative, might require PATH resolution) * canonicalize paths * Use path.fromUri consistently to resolve file URIs * Force commit to try to kick Cirrus * Force commit to kick Cirrus, again
This commit is contained in:
parent
e29b023a6b
commit
4a110b6227
@ -124,7 +124,7 @@ class SampleChecker {
|
||||
|
||||
/// Finds the location of the snippets script.
|
||||
String get _snippetsExecutable {
|
||||
final String platformScriptPath = path.dirname(Platform.script.toFilePath());
|
||||
final String platformScriptPath = path.dirname(path.fromUri(Platform.script));
|
||||
return path.canonicalize(path.join(platformScriptPath, '..', 'snippets', 'lib', 'main.dart'));
|
||||
}
|
||||
|
||||
@ -206,18 +206,18 @@ class SampleChecker {
|
||||
if (_snippetsSnapshotPath == null) {
|
||||
_snippetsSnapshotPath = '$_snippetsExecutable.snapshot';
|
||||
return Process.runSync(
|
||||
path.absolute(Platform.executable),
|
||||
path.canonicalize(Platform.executable),
|
||||
<String>[
|
||||
'--snapshot=$_snippetsSnapshotPath',
|
||||
'--snapshot-kind=app-jit',
|
||||
path.absolute(_snippetsExecutable),
|
||||
path.canonicalize(_snippetsExecutable),
|
||||
]..addAll(args),
|
||||
workingDirectory: workingDirectory,
|
||||
);
|
||||
} else {
|
||||
return Process.runSync(
|
||||
path.absolute(Platform.executable),
|
||||
<String>[path.absolute(_snippetsSnapshotPath)]..addAll(args),
|
||||
path.canonicalize(Platform.executable),
|
||||
<String>[path.canonicalize(_snippetsSnapshotPath)]..addAll(args),
|
||||
workingDirectory: workingDirectory,
|
||||
);
|
||||
}
|
||||
|
@ -30,8 +30,8 @@ class _ComponentTuple {
|
||||
class SnippetGenerator {
|
||||
SnippetGenerator({Configuration configuration})
|
||||
: configuration = configuration ??
|
||||
// This script must be run from dev/docs, so the root is up two levels.
|
||||
Configuration(flutterRoot: Directory(path.canonicalize(path.join('..', '..')))) {
|
||||
// Flutter's root is four directories up from this script.
|
||||
Configuration(flutterRoot: Directory(Platform.environment['FLUTTER_ROOT'] ?? path.canonicalize(path.join(path.dirname(path.fromUri(Platform.script)), '..', '..', '..')))) {
|
||||
this.configuration.createOutputDirectory();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user