mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

This makes the flutter and dart scripts invoke their batch file equivalents if running under MINGW (i.e. git-bash) on Windows. This allows for proper locking, and makes sure that people aren't using two different (and non-mutally-aware) locking systems when running flutter on Windows. I also fixed a couple of places where we look for MINGW32, which fails under MINGW64. It just looks for MINGW now.
59 lines
2.0 KiB
Bash
Executable File
59 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# 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.
|
|
|
|
# ---------------------------------- NOTE ---------------------------------- #
|
|
#
|
|
# Please keep the logic in this file consistent with the logic in the
|
|
# `dart.bat` script in the same directory to ensure that Flutter & Dart continue
|
|
# to work across all platforms!
|
|
#
|
|
# -------------------------------------------------------------------------- #
|
|
|
|
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)"
|
|
|
|
if [[ $OS =~ MINGW.* ]]; then
|
|
# If we're on Windows, invoke the batch script instead, to get proper locking.
|
|
exec "${BIN_DIR}/dart.bat" "$@"
|
|
fi
|
|
|
|
# To define `shared::execute()` function
|
|
source "$BIN_DIR/internal/shared.sh"
|
|
|
|
shared::execute "$@"
|