Skip to content

Commit cf3a791

Browse files
authored
Add a generic run_dart_tool command (#210)
Adds a tool to run anything from tools/dart_tools/bin, rather than needing a custom wrapper for each tool. Changes the update_flutter_engine shell script to match the existing batch script behavior of automatically providing --flutter_root
1 parent 8835c7c commit cf3a791

File tree

6 files changed

+72
-17
lines changed

6 files changed

+72
-17
lines changed

library/linux/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ $(LIBRARY_OUT): $(SOURCES) $(HEADERS) $(LIBRARIES)
5151
# avoiding unnecessary relinks.
5252
$(FLUTTER_ENGINE_LIB_FILE) $(FLUTTER_ENGINE_HEADER_DIR)/$(FLUTTER_ENGINE_HEADER): \
5353
$(FLUTTER_DIR)/bin/internal/engine.version
54-
$(ENGINE_UPDATER) --flutter_root=$(FLUTTER_DIR) ./
54+
$(ENGINE_UPDATER) ./
5555
if [ -f $(FLUTTER_ENGINE_HEADER) ]; then \
5656
mkdir -p $(FLUTTER_ENGINE_HEADER_DIR) && \
5757
mv $(FLUTTER_ENGINE_HEADER) $(FLUTTER_ENGINE_HEADER_DIR)/; \

library/macos/FlutterEmbedderMac.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@
302302
);
303303
runOnlyForDeploymentPostprocessing = 0;
304304
shellPath = /bin/bash;
305-
shellScript = "readonly TOOLS_DIR=\"$PROJECT_DIR\"/../../tools\n\"$TOOLS_DIR\"/update_flutter_engine --flutter_root=\"$(\"$TOOLS_DIR\"/flutter_location)\" \"$PROJECT_DIR\"/../../../flutter_engine_framework/macos";
305+
shellScript = "readonly TOOLS_DIR=\"$PROJECT_DIR\"/../../tools\n\"$TOOLS_DIR\"/update_flutter_engine \"$PROJECT_DIR\"/../../../flutter_engine_framework/macos";
306306
};
307307
/* End PBXShellScriptBuildPhase section */
308308

tools/run_dart_tool

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright 2019 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# Takes the name of a tool in dart_tools/bin (without the .dart extension),
18+
# as well as any parameters to that tool, then runs it with those parameters
19+
# using the version of Dart from the Flutter tree.
20+
21+
readonly base_dir="$(dirname "$0")"
22+
readonly flutter_dir="$("${base_dir}/flutter_location")"
23+
readonly flutter_bin_dir="${flutter_dir}/bin"
24+
readonly dart_bin_dir="${flutter_bin_dir}/cache/dart-sdk/bin"
25+
26+
# Ensure that the Dart SDK has been downloaded.
27+
if [[ ! -e ${dart_bin_dir} ]]; then
28+
"${flutter_bin_dir}/flutter" precache
29+
fi
30+
31+
readonly tool_script="${base_dir}/dart_tools/bin/$1.dart"
32+
exec "${dart_bin_dir}/dart" "${tool_script}" "${@:2}"

tools/run_dart_tool.bat

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
:: Copyright 2019 Google LLC
2+
::
3+
:: Licensed under the Apache License, Version 2.0 (the "License");
4+
:: you may not use this file except in compliance with the License.
5+
:: You may obtain a copy of the License at
6+
::
7+
:: http://www.apache.org/licenses/LICENSE-2.0
8+
::
9+
:: Unless required by applicable law or agreed to in writing, software
10+
:: distributed under the License is distributed on an "AS IS" BASIS,
11+
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
:: See the License for the specific language governing permissions and
13+
:: limitations under the License.
14+
@echo off
15+
16+
for /f "delims=" %%i in ('%~dp0flutter_location') do set FLUTTER_DIR=%%i
17+
set FLUTTER_BIN_DIR=%FLUTTER_DIR%\bin
18+
set DART_BIN_DIR=%FLUTTER_BIN_DIR%\cache\dart-sdk\bin
19+
20+
:: Ensure that the Dart SDK has been downloaded.
21+
if not exist %DART_BIN_DIR%\ call %FLUTTER_BIN_DIR%\flutter precache
22+
23+
set DART_TOOL=%1
24+
for /f "tokens=1,*" %%a in ("%*") do set TOOL_PARAMS=%%b
25+
26+
call %DART_BIN_DIR%\dart %~dp0.\dart_tools\bin\%DART_TOOL%.dart %TOOL_PARAMS%

tools/update_flutter_engine

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
#
2+
#
33
# Copyright 2018 Google LLC
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,12 +13,11 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16+
17+
# Runs update_flutter_engine.dart, using the output of flutter_location as
18+
# --flutter_root
19+
1620
readonly base_dir="$(dirname "$0")"
17-
readonly flutter_dir="$("$base_dir/flutter_location")"
18-
readonly flutter_bin_dir="$flutter_dir/bin"
19-
readonly dart_bin_dir="$flutter_bin_dir/cache/dart-sdk/bin"
20-
# Ensure that the Dart SDK has been downloaded.
21-
if [[ ! -e $dart_bin_dir ]]; then
22-
"$flutter_bin_dir/flutter" precache
23-
fi
24-
exec "$dart_bin_dir/dart" "$base_dir/dart_tools/bin/update_flutter_engine.dart" "$@"
21+
readonly flutter_dir="$("${base_dir}/flutter_location")"
22+
exec "${base_dir}/run_dart_tool" update_flutter_engine \
23+
--flutter_root="${flutter_dir}" "$@"

tools/update_flutter_engine.bat

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@
1111
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
:: See the License for the specific language governing permissions and
1313
:: limitations under the License.
14+
15+
:: Runs update_flutter_engine.dart, using the output of flutter_location.bat as
16+
:: --flutter_root
1417
@echo off
1518

1619
for /f "delims=" %%i in ('%~dp0flutter_location') do set FLUTTER_DIR=%%i
17-
set FLUTTER_BIN_DIR=%FLUTTER_DIR%\bin
18-
set DART_BIN_DIR=%FLUTTER_BIN_DIR%\cache\dart-sdk\bin
19-
20-
:: Ensure that the Dart SDK has been downloaded.
21-
if not exist %DART_BIN_DIR%\ call %FLUTTER_BIN_DIR%\flutter precache
2220

23-
call %DART_BIN_DIR%\dart %~dp0.\dart_tools\bin\update_flutter_engine.dart --flutter_root %FLUTTER_DIR% %*
21+
call %~dp0.\run_dart_tool update_flutter_engine --flutter_root %FLUTTER_DIR% %*

0 commit comments

Comments
 (0)