mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
81 lines
1.9 KiB
Bash
Executable File
81 lines
1.9 KiB
Bash
Executable File
#!/bin/sh
|
|
# Copyright 2015 The Chromium Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
RunCommand() {
|
|
$@ >/dev/null
|
|
return $?
|
|
}
|
|
|
|
EchoError() {
|
|
echo "$@" 1>&2
|
|
}
|
|
|
|
AssertExists() {
|
|
RunCommand ls $1
|
|
if [ $? -ne 0 ]; then
|
|
EchoError "The path $1 does not exist"
|
|
exit -1
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
PackageProject() {
|
|
# Check that the project path was specified
|
|
if [[ -z "$1" ]]; then
|
|
EchoError "Project path not specified"
|
|
exit -1
|
|
fi
|
|
|
|
# Check if pub exists
|
|
RunCommand which pub
|
|
if [[ $? -ne 0 ]]; then
|
|
EchoError "Could not find 'pub'."
|
|
EchoError "Did you install the Dart SDK?"
|
|
exit -1
|
|
fi
|
|
|
|
AssertExists $1
|
|
local project_path=$1
|
|
|
|
local derived_dir=${SOURCE_ROOT}/FlutterApplication/Generated
|
|
RunCommand mkdir -p $derived_dir
|
|
AssertExists $derived_dir
|
|
|
|
local dart_main=${project_path}/lib/main.dart
|
|
AssertExists $dart_main
|
|
|
|
local package_root=${project_path}/packages
|
|
AssertExists $package_root
|
|
|
|
local icons_path=${project_path}/packages/material_design_icons/icons
|
|
AssertExists $icons_path
|
|
|
|
# Remove old build artifacts
|
|
RunCommand rm -f ${derived_dir}/app.flx
|
|
|
|
# Generate the new FLX file. The pub command must be run from the directory
|
|
# containing the pubspec
|
|
RunCommand pushd ${project_path}
|
|
|
|
RunCommand ${FLUTTER_ROOT}/bin/flutter build \
|
|
--asset-base ${icons_path} \
|
|
--main ${dart_main} \
|
|
--output-file ${derived_dir}/app.flx \
|
|
--package-root ${package_root} \
|
|
--precompiled
|
|
|
|
if [[ $? -ne 0 ]]; then
|
|
EchoError "Failed to package $1 ..."
|
|
exit -1
|
|
fi
|
|
|
|
RunCommand popd
|
|
|
|
echo "Project $1 successfully packaged..."
|
|
return 0
|
|
}
|
|
|
|
PackageProject $1
|