Skip to content

Add a generic run_dart_tool command #210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ $(LIBRARY_OUT): $(SOURCES) $(HEADERS) $(LIBRARIES)
# avoiding unnecessary relinks.
$(FLUTTER_ENGINE_LIB_FILE) $(FLUTTER_ENGINE_HEADER_DIR)/$(FLUTTER_ENGINE_HEADER): \
$(FLUTTER_DIR)/bin/internal/engine.version
$(ENGINE_UPDATER) --flutter_root=$(FLUTTER_DIR) ./
$(ENGINE_UPDATER) ./
if [ -f $(FLUTTER_ENGINE_HEADER) ]; then \
mkdir -p $(FLUTTER_ENGINE_HEADER_DIR) && \
mv $(FLUTTER_ENGINE_HEADER) $(FLUTTER_ENGINE_HEADER_DIR)/; \
Expand Down
2 changes: 1 addition & 1 deletion library/macos/FlutterEmbedderMac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/bash;
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";
shellScript = "readonly TOOLS_DIR=\"$PROJECT_DIR\"/../../tools\n\"$TOOLS_DIR\"/update_flutter_engine \"$PROJECT_DIR\"/../../../flutter_engine_framework/macos";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
32 changes: 32 additions & 0 deletions tools/run_dart_tool
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
#
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Takes the name of a tool in dart_tools/bin (without the .dart extension),
# as well as any parameters to that tool, then runs it with those parameters
# using the version of Dart from the Flutter tree.

readonly base_dir="$(dirname "$0")"
readonly flutter_dir="$("${base_dir}/flutter_location")"
readonly flutter_bin_dir="${flutter_dir}/bin"
readonly dart_bin_dir="${flutter_bin_dir}/cache/dart-sdk/bin"

# Ensure that the Dart SDK has been downloaded.
if [[ ! -e ${dart_bin_dir} ]]; then
"${flutter_bin_dir}/flutter" precache
fi

readonly tool_script="${base_dir}/dart_tools/bin/$1.dart"
exec "${dart_bin_dir}/dart" "${tool_script}" "${@:2}"
26 changes: 26 additions & 0 deletions tools/run_dart_tool.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
:: Copyright 2019 Google LLC
::
:: Licensed under the Apache License, Version 2.0 (the "License");
:: you may not use this file except in compliance with the License.
:: You may obtain a copy of the License at
::
:: http://www.apache.org/licenses/LICENSE-2.0
::
:: Unless required by applicable law or agreed to in writing, software
:: distributed under the License is distributed on an "AS IS" BASIS,
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.
@echo off

for /f "delims=" %%i in ('%~dp0flutter_location') do set FLUTTER_DIR=%%i
set FLUTTER_BIN_DIR=%FLUTTER_DIR%\bin
set DART_BIN_DIR=%FLUTTER_BIN_DIR%\cache\dart-sdk\bin

:: Ensure that the Dart SDK has been downloaded.
if not exist %DART_BIN_DIR%\ call %FLUTTER_BIN_DIR%\flutter precache

set DART_TOOL=%1
for /f "tokens=1,*" %%a in ("%*") do set TOOL_PARAMS=%%b

call %DART_BIN_DIR%\dart %~dp0.\dart_tools\bin\%DART_TOOL%.dart %TOOL_PARAMS%
17 changes: 8 additions & 9 deletions tools/update_flutter_engine
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
#
#
# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -13,12 +13,11 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Runs update_flutter_engine.dart, using the output of flutter_location as
# --flutter_root

readonly base_dir="$(dirname "$0")"
readonly flutter_dir="$("$base_dir/flutter_location")"
readonly flutter_bin_dir="$flutter_dir/bin"
readonly dart_bin_dir="$flutter_bin_dir/cache/dart-sdk/bin"
# Ensure that the Dart SDK has been downloaded.
if [[ ! -e $dart_bin_dir ]]; then
"$flutter_bin_dir/flutter" precache
fi
exec "$dart_bin_dir/dart" "$base_dir/dart_tools/bin/update_flutter_engine.dart" "$@"
readonly flutter_dir="$("${base_dir}/flutter_location")"
exec "${base_dir}/run_dart_tool" update_flutter_engine \
--flutter_root="${flutter_dir}" "$@"
10 changes: 4 additions & 6 deletions tools/update_flutter_engine.bat
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@
:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
:: See the License for the specific language governing permissions and
:: limitations under the License.

:: Runs update_flutter_engine.dart, using the output of flutter_location.bat as
:: --flutter_root
@echo off

for /f "delims=" %%i in ('%~dp0flutter_location') do set FLUTTER_DIR=%%i
set FLUTTER_BIN_DIR=%FLUTTER_DIR%\bin
set DART_BIN_DIR=%FLUTTER_BIN_DIR%\cache\dart-sdk\bin

:: Ensure that the Dart SDK has been downloaded.
if not exist %DART_BIN_DIR%\ call %FLUTTER_BIN_DIR%\flutter precache

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