[go: nahoru, domu]

Skip to content

Commit

Permalink
Add the ability to inject a bootstrap script (flutter#66897)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcus Tomlinson committed Sep 29, 2020
1 parent 1d93be3 commit 5f76bfb
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

# Flutter repo-specific
/bin/cache/
/bin/internal/bootstrap.bat
/bin/internal/bootstrap.sh
/bin/mingit/
/dev/benchmarks/mega_gallery/
/dev/bots/.recipe_deps
Expand Down
6 changes: 6 additions & 0 deletions bin/internal/shared.bat
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ IF NOT EXIST "%cache_dir%" (
GOTO :after_subroutine

:subroutine
REM If present, run the bootstrap script first
SET bootstrap_path=%FLUTTER_ROOT%\bin\internal\bootstrap.bat
IF EXIST "%bootstrap_path%" (
CALL "%bootstrap_path%"
)

PUSHD "%flutter_root%"
FOR /f %%r IN ('git rev-parse HEAD') DO SET revision=%%r
POPD
Expand Down
6 changes: 6 additions & 0 deletions bin/internal/shared.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ function upgrade_flutter () (
function shared::execute() {
export FLUTTER_ROOT="$(cd "${BIN_DIR}/.." ; pwd -P)"

# If present, run the bootstrap script first
BOOTSTRAP_PATH="$FLUTTER_ROOT/bin/internal/bootstrap.sh"
if [ -f "$BOOTSTRAP_PATH" ]; then
source "$BOOTSTRAP_PATH"
fi

FLUTTER_TOOLS_DIR="$FLUTTER_ROOT/packages/flutter_tools"
SNAPSHOT_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.snapshot"
STAMP_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.stamp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,28 @@ void main() {
expect(result.exitCode, 1);
expect(result.stderr, contains('Invalid `--debug-uri`: http://127.0.0.1:3333*/'));
});

testWithoutContext('will load bootstrap script before starting', () async {
final String flutterBin =
fileSystem.path.join(getFlutterRoot(), 'bin', 'flutter');

final File bootstrap = fileSystem.file(fileSystem.path.join(
getFlutterRoot(),
'bin',
'internal',
platform.isWindows ? 'bootstrap.bat' : 'bootstrap.sh'));

try {
bootstrap.writeAsStringSync('echo TESTING 1 2 3');

final ProcessResult result = await processManager.run(<String>[
flutterBin,
...getLocalEngineArguments(),
]);

expect(result.stdout, contains('TESTING 1 2 3'));
} finally {
bootstrap.deleteSync();
}
});
}

0 comments on commit 5f76bfb

Please sign in to comment.