flutter_flutter/sky/build/PackagerInvoke
Adam Barth ececda8986 Remove packages/material_design_icons
We no longer use a pub package to distribute these icons.
2016-03-03 10:59:10 -08:00

81 lines
2.0 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
# The 'flutter' command assumes the 'dart' binary is in $PATH
RunCommand export PATH=${PATH}:${DART_SDK_PATH}/bin
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
# Remove old build artifacts
RunCommand rm -f ${derived_dir}/app.flx
local src_dir=${SOURCE_ROOT}/Tools/common
AssertExists $src_dir
local precompilation_flag=""
if [ $CURRENT_ARCH != "x86_64" ]; then
precompilation_flag="--precompiled"
fi
# 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 \
--target ${dart_main} \
--output-file ${derived_dir}/app.flx \
--package-root ${package_root} \
--compiler ${src_dir}/ScriptSnapshotter \
${precompilation_flag} \
if [[ $? -ne 0 ]]; then
EchoError "Failed to package $1 ..."
exit -1
fi
RunCommand popd
echo "Project $1 successfully packaged..."
return 0
}
PackageProject $1