first commit
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2021 Sony Group Corporation. All rights reserved.
|
||||
# Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved.
|
||||
# Copyright 2014 The Flutter Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
set -e
|
||||
|
||||
# Needed because if it is set, cd may print the path it changed to.
|
||||
unset CDPATH
|
||||
|
||||
# On Mac OS, readlink -f doesn't work, so follow_links traverses the path one
|
||||
# link at a time, and then cds into the link destination and find out where it
|
||||
# ends up.
|
||||
#
|
||||
# The returned filesystem path must be a format usable by Dart's URI parser,
|
||||
# since the Dart command line tool treats its argument as a file URI, not a
|
||||
# filename. For instance, multiple consecutive slashes should be reduced to a
|
||||
# single slash, since double-slashes indicate a URI "authority", and these are
|
||||
# supposed to be filenames. There is an edge case where this will return
|
||||
# multiple slashes: when the input resolves to the root directory. However, if
|
||||
# that were the case, we wouldn't be running this shell, so we don't do anything
|
||||
# about it.
|
||||
#
|
||||
# The function is enclosed in a subshell to avoid changing the working directory
|
||||
# of the caller.
|
||||
function follow_links() (
|
||||
cd -P "$(dirname -- "$1")"
|
||||
file="$PWD/$(basename -- "$1")"
|
||||
while [[ -h "$file" ]]; do
|
||||
cd -P "$(dirname -- "$file")"
|
||||
file="$(readlink -- "$file")"
|
||||
cd -P "$(dirname -- "$file")"
|
||||
file="$PWD/$(basename -- "$file")"
|
||||
done
|
||||
echo "$file"
|
||||
)
|
||||
|
||||
PROG_NAME="$(follow_links "${BASH_SOURCE[0]}")"
|
||||
BIN_DIR="$(cd "${PROG_NAME%/*}" ; pwd -P)"
|
||||
OS="$(uname -s)"
|
||||
|
||||
# Allow only 64-bit host platform.
|
||||
if [ "$(getconf LONG_BIT)" != "64" ]; then
|
||||
echo "$(basename $PROG_NAME) only supports 64 bit platforms."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# If we're on Windows, invoke the batch script instead to get proper locking.
|
||||
if [[ $OS =~ MINGW.* || $OS =~ CYGWIN.* ]]; then
|
||||
echo "Window platforms are not supported."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source "$BIN_DIR/internal/shared.sh"
|
||||
|
||||
# Clone or update the flutter repo.
|
||||
update_flutter
|
||||
|
||||
# Upgrade flutter-elinux if needed.
|
||||
update_flutter_elinux
|
||||
|
||||
# Run the snapshot.
|
||||
exec_snapshot "$@"
|
||||
@@ -0,0 +1,12 @@
|
||||
// Copyright 2021 Sony Group Corporation. All rights reserved.
|
||||
// Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:flutter_elinux/executable.dart' as executable;
|
||||
|
||||
void main(List<String> args) {
|
||||
executable.main(args);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
9d517f475ba1282b619477bde8e708d6a34287cf
|
||||
@@ -0,0 +1 @@
|
||||
615957513eb43b128a16048ab5aa2daaba1656cd
|
||||
@@ -0,0 +1,101 @@
|
||||
#!/usr/bin/env bash
|
||||
# Copyright 2021 Sony Group Corporation. All rights reserved.
|
||||
# Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
# ---------------------------------- NOTE ---------------------------------- #
|
||||
#
|
||||
# Please keep the logic in this file consistent with the logic in the
|
||||
# `shared.bat` script in the same directory to ensure that Flutter continue
|
||||
# to work across all platforms!
|
||||
#
|
||||
# -------------------------------------------------------------------------- #
|
||||
|
||||
set -e
|
||||
|
||||
# Needed because if it is set, cd may print the path it changed to.
|
||||
unset CDPATH
|
||||
|
||||
FLUTTER_REPO="https://github.com/flutter/flutter.git"
|
||||
|
||||
if [[ -z "$BIN_DIR" ]]; then
|
||||
echo "BIN_DIR is not set."
|
||||
exit 1
|
||||
fi
|
||||
ROOT_DIR="$(cd "${BIN_DIR}/.." ; pwd -P)"
|
||||
FLUTTER_DIR="$ROOT_DIR/flutter"
|
||||
SNAPSHOT_PATH="$ROOT_DIR/bin/cache/flutter-elinux.snapshot"
|
||||
|
||||
FLUTTER_EXE="$FLUTTER_DIR/bin/flutter"
|
||||
DART_EXE="$FLUTTER_DIR/bin/cache/dart-sdk/bin/dart"
|
||||
|
||||
function update_flutter() {
|
||||
if [[ -e "$FLUTTER_DIR" && ! -d "$FLUTTER_DIR/.git" ]]; then
|
||||
echo "$FLUTTER_DIR is not a git directory. Remove it and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Clone flutter repo if not installed.
|
||||
if [[ ! -d "$FLUTTER_DIR" ]]; then
|
||||
git clone --depth=1 "$FLUTTER_REPO" "$FLUTTER_DIR"
|
||||
fi
|
||||
|
||||
# GIT_DIR and GIT_WORK_TREE are used in the git command.
|
||||
export GIT_DIR="$FLUTTER_DIR/.git"
|
||||
export GIT_WORK_TREE="$FLUTTER_DIR"
|
||||
|
||||
# Update flutter repo if needed.
|
||||
local version="$(cat "$ROOT_DIR/bin/internal/flutter.version")"
|
||||
if [[ "$version" != "$(git rev-parse HEAD)" ]]; then
|
||||
git reset --hard
|
||||
git clean -xdf
|
||||
git fetch --depth=1 "$FLUTTER_REPO" "$version"
|
||||
git checkout FETCH_HEAD
|
||||
|
||||
# Invalidate the cache.
|
||||
rm -fr "$ROOT_DIR/bin/cache"
|
||||
fi
|
||||
|
||||
if [[ "$version" != "$(git rev-parse HEAD)" ]]; then
|
||||
echo "Something went wrong when upgrading the Flutter SDK." \
|
||||
"Remove directory $FLUTTER_DIR and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
unset GIT_DIR
|
||||
unset GIT_WORK_TREE
|
||||
|
||||
# Invalidate the flutter cache.
|
||||
local stamp_path="$FLUTTER_DIR/bin/cache/flutter_tools.stamp"
|
||||
if [[ ! -f "$stamp_path" || "$version" != "$(cat "$stamp_path")" ]]; then
|
||||
"$FLUTTER_EXE" --version
|
||||
fi
|
||||
}
|
||||
|
||||
function update_flutter_elinux() {
|
||||
mkdir -p "$ROOT_DIR/bin/cache"
|
||||
|
||||
local revision="$(git --git-dir="$ROOT_DIR/.git" rev-parse HEAD)"
|
||||
local stamp_path="$ROOT_DIR/bin/cache/flutter-elinux.stamp"
|
||||
|
||||
if [[ ! -f "$SNAPSHOT_PATH" || ! -s "$stamp_path" || "$revision" != "$(cat "$stamp_path")"
|
||||
|| "$ROOT_DIR/pubspec.yaml" -nt "$ROOT_DIR/pubspec.lock" ]]; then
|
||||
echo "Running pub upgrade..."
|
||||
(cd "$ROOT_DIR" && "$FLUTTER_EXE" pub upgrade) || {
|
||||
>&2 echo "Error: Unable to 'pub upgrade' flutter-elinux."
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "Compiling flutter-elinux..."
|
||||
"$DART_EXE" --disable-dart-dev --no-enable-mirrors \
|
||||
--snapshot="$SNAPSHOT_PATH" --packages="$ROOT_DIR/.packages" \
|
||||
"$ROOT_DIR/bin/flutter_elinux.dart"
|
||||
|
||||
echo "$revision" > "$stamp_path"
|
||||
fi
|
||||
}
|
||||
|
||||
function exec_snapshot() {
|
||||
"$DART_EXE" --disable-dart-dev --packages="$ROOT_DIR/.packages" "$SNAPSHOT_PATH" "$@"
|
||||
}
|
||||
Reference in New Issue
Block a user