mirror of
https://github.com/firebase/firebase-ios-sdk
synced 2026-11-10 22:45:59 +05:45
* Add an -all_load linker flag to all example apps This fixes macOS and tvOS builds such that they no longer need to explicitly link against the built FirebaseFirestore framework, which is good because this wasn't working right: changes to the framework would take two builds to get tests to actually see them. The mechanism here is to amend the .xcconfig files that CocoaPods plugs into the project, just after it generates them. This avoids the need to actually modify the project.xcodeproj file, which reduces the potential for conflicts. Going forward all manual modifications to the project's configuration will be handled this way to avoid needing special project configuration. This also moves us incrementally closer to be being able to use test specs and cocoapods-generate. There's too much custom configuration yet (and several other blockers) but figuring out what's required to build will make it such that we can eventually transition. * xcodeproj: Remove -all_load and -framework flags -all_load is now being supplied by sync_project.rb. Remove manually specified -framework flags from the project file. The -framework flags are actually coming from CocoaPods, but we copied the others when manually linking against FirebaseFirestore. Now that that's no longer required these can go away. * Add a test-only mode to sync_project.rb * Re-add CodableIntegrationTests.swift A previous commit merged this incorrectly.
269 lines
6.9 KiB
Bash
Executable File
269 lines
6.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Copyright 2019 Google
|
|
#
|
|
# 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.
|
|
|
|
# Checks that the current state of the tree is sane and optionally auto-fixes
|
|
# errors automatically. Meant for interactive use.
|
|
|
|
function usage() {
|
|
cat <<EOF
|
|
USAGE: scripts/check.sh [--allow-dirty] [--commit] [<revision>]
|
|
|
|
Runs auto-formatting scripts, source-tree checks, and linters on any files that
|
|
have changed since origin/master.
|
|
|
|
By default, any changes are left as uncommited changes in the working tree. You
|
|
can review them with git diff. Pass --commit to automatically commit any changes.
|
|
|
|
Pass an alternate revision to use as the basis for checking changes.
|
|
|
|
OPTIONS:
|
|
|
|
--allow-dirty
|
|
By default, check.sh requires a clean working tree to keep any generated
|
|
changes separate from logical changes.
|
|
|
|
--commit
|
|
Commit any auto-generated changes with a message indicating which tool made
|
|
the changes.
|
|
|
|
--amend
|
|
Commit any auto-generated changes by amending the HEAD commit.
|
|
|
|
--fixup
|
|
Commit any auto-generated changes with a fixup! message for the HEAD
|
|
commit. The next rebase will squash these fixup commits.
|
|
|
|
--test-only
|
|
Run all checks without making any changes to local files.
|
|
|
|
<revision>
|
|
Specifies a starting revision other than the default of origin/master.
|
|
|
|
|
|
EXAMPLES:
|
|
|
|
check.sh
|
|
Runs automated checks and formatters on all changed files since
|
|
origin/master. Check for changes with git diff.
|
|
|
|
check.sh --commit
|
|
Runs automated checks and formatters on all changed files since
|
|
origin/master and commits the results.
|
|
|
|
check.sh --amend HEAD
|
|
Runs automated checks and formatters on all changed files since the last
|
|
commit and amends the last commit with the difference.
|
|
|
|
check.sh --allow-dirty HEAD
|
|
Runs automated checks and formatters on all changed files since the last
|
|
commit and intermingles the changes with any pending changes. Useful for
|
|
interactive use from an editor.
|
|
|
|
EOF
|
|
}
|
|
|
|
set -euo pipefail
|
|
unset CDPATH
|
|
|
|
# Change to the top-directory of the working tree
|
|
top_dir=$(git rev-parse --show-toplevel)
|
|
cd "${top_dir}"
|
|
|
|
ALLOW_DIRTY=false
|
|
COMMIT_METHOD="none"
|
|
START_REVISION="origin/master"
|
|
TEST_ONLY=false
|
|
VERBOSE=false
|
|
|
|
# Default to verbose operation if this isn't an interactive build.
|
|
if [[ ! -t 1 ]]; then
|
|
VERBOSE=true
|
|
fi
|
|
|
|
# When travis clones a repo for building, it uses a shallow clone. After the
|
|
# first commit on a non-master branch, TRAVIS_COMMIT_RANGE is not set, master
|
|
# is not available and we need to compute the START_REVISION from the common
|
|
# ancestor of $TRAVIS_COMMIT and origin/master.
|
|
if [[ -n "${TRAVIS_COMMIT_RANGE:-}" ]] ; then
|
|
START_REVISION="$TRAVIS_COMMIT_RANGE"
|
|
elif [[ -n "${TRAVIS_COMMIT:-}" ]] ; then
|
|
if ! git rev-parse origin/master >& /dev/null; then
|
|
git remote set-branches --add origin master
|
|
git fetch origin
|
|
fi
|
|
START_REVISION=$(git merge-base origin/master "${TRAVIS_COMMIT}")
|
|
fi
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--)
|
|
# Do nothing: explicitly allow this, but ignore it
|
|
;;
|
|
|
|
-h | --help)
|
|
usage
|
|
exit 1
|
|
;;
|
|
|
|
--allow-dirty)
|
|
ALLOW_DIRTY=true
|
|
;;
|
|
|
|
--amend)
|
|
COMMIT_METHOD=amend
|
|
;;
|
|
|
|
--fixup)
|
|
COMMIT_METHOD=fixup
|
|
;;
|
|
|
|
--commit)
|
|
COMMIT_METHOD=message
|
|
;;
|
|
|
|
--verbose)
|
|
VERBOSE=true
|
|
;;
|
|
|
|
--test-only)
|
|
# In test-only mode, no changes are made, so there's no reason to
|
|
# require a clean source tree.
|
|
ALLOW_DIRTY=true
|
|
TEST_ONLY=true
|
|
;;
|
|
|
|
*)
|
|
START_REVISION="$1"
|
|
shift
|
|
break
|
|
;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if [[ "${TEST_ONLY}" == true && "${COMMIT_METHOD}" != "none" ]]; then
|
|
echo "--test-only cannot be combined with --amend, --fixup, or --commit"
|
|
exit 1
|
|
fi
|
|
|
|
if [[ "${ALLOW_DIRTY}" == true && "${COMMIT_METHOD}" == "message" ]]; then
|
|
echo "--allow-dirty and --commit are mutually exclusive"
|
|
exit 1
|
|
fi
|
|
|
|
if ! git diff-index --quiet HEAD --; then
|
|
if [[ "${ALLOW_DIRTY}" != true ]]; then
|
|
echo "You have local changes that could be overwritten by this script."
|
|
echo "Please commit your changes first or pass --allow-dirty."
|
|
exit 2
|
|
fi
|
|
fi
|
|
|
|
# Show Travis-related environment variables, to help with debuging failures.
|
|
if [[ "${VERBOSE}" == true ]]; then
|
|
env | egrep '^TRAVIS_(BRANCH|COMMIT|PULL|REPO)' | sort || true
|
|
fi
|
|
|
|
if [[ "${START_REVISION}" == *..* ]]; then
|
|
RANGE_START="${START_REVISION/..*/}"
|
|
RANGE_END="${START_REVISION/*../}"
|
|
|
|
# Figure out if we have access to master. If not add it to the repo.
|
|
if ! git rev-parse origin/master >& /dev/null; then
|
|
git remote set-branches --add origin master
|
|
git fetch origin
|
|
fi
|
|
|
|
NEW_RANGE_START=$(git merge-base origin/master "${RANGE_END}")
|
|
START_REVISION="${START_REVISION/$RANGE_START/$NEW_RANGE_START}"
|
|
START_SHA="${START_REVISION}"
|
|
|
|
else
|
|
START_SHA=$(git rev-parse "${START_REVISION}")
|
|
fi
|
|
|
|
if [[ "${VERBOSE}" == true ]]; then
|
|
echo "START_REVISION=$START_REVISION"
|
|
echo "START_SHA=$START_SHA"
|
|
fi
|
|
|
|
# If committing --fixup, avoid messages with fixup! fixup! that might come from
|
|
# multiple fixup commits.
|
|
HEAD_SHA=$(git rev-parse HEAD)
|
|
|
|
function maybe_commit() {
|
|
local message="$1"
|
|
|
|
if [[ "${COMMIT_METHOD}" == "none" ]]; then
|
|
return
|
|
fi
|
|
|
|
echo "${message}"
|
|
case "${COMMIT_METHOD}" in
|
|
amend)
|
|
git commit -a --amend -C "${HEAD_SHA}"
|
|
;;
|
|
|
|
fixup)
|
|
git commit -a --fixup="${HEAD_SHA}"
|
|
;;
|
|
|
|
message)
|
|
git commit -a -m "${message}"
|
|
;;
|
|
|
|
*)
|
|
echo "Unknown commit method ${COMMIT_METHOD}" 1>&2
|
|
exit 2
|
|
;;
|
|
esac
|
|
}
|
|
|
|
style_cmd=("${top_dir}/scripts/style.sh")
|
|
if [[ "${TEST_ONLY}" == true ]]; then
|
|
style_cmd+=(test-only)
|
|
fi
|
|
style_cmd+=("${START_SHA}")
|
|
|
|
# Restyle and commit any changes
|
|
"${style_cmd[@]}"
|
|
if ! git diff --quiet; then
|
|
maybe_commit "style.sh generated changes"
|
|
fi
|
|
|
|
# If there are changes to the Firestore project, ensure they're ordered
|
|
# correctly to minimize conflicts.
|
|
if ! git diff --quiet "${START_SHA}" -- Firestore; then
|
|
sync_project_cmd=("${top_dir}/scripts/sync_project.rb")
|
|
if [[ "${TEST_ONLY}" == true ]]; then
|
|
sync_project_cmd+=(--test-only)
|
|
fi
|
|
"${sync_project_cmd[@]}"
|
|
if ! git diff --quiet; then
|
|
maybe_commit "sync_project.rb generated changes"
|
|
fi
|
|
fi
|
|
|
|
# Check lint errors.
|
|
"${top_dir}/scripts/check_whitespace.sh"
|
|
"${top_dir}/scripts/check_filename_spaces.sh"
|
|
"${top_dir}/scripts/check_copyright.sh"
|
|
"${top_dir}/scripts/check_no_module_imports.sh"
|
|
"${top_dir}/scripts/check_test_inclusion.py"
|
|
|
|
# Google C++ style
|
|
"${top_dir}/scripts/check_lint.py" "${START_SHA}"
|