Skip to content

Commit c69d476

Browse files
smilesa-maurice
authored andcommitted
Script which integrates Android packages into a release branch.
PiperOrigin-RevId: 286444479
1 parent 2c6bf1e commit c69d476

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

gms_package_versions_integrate.sh

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/bin/bash -eu
2+
#
3+
# Copyright 2019 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
help_and_exit() {
18+
echo "\
19+
Integrates Android libraries referenced by the Firebase C++ SDK into a release
20+
branch.
21+
22+
$(basename "$0") \\
23+
-c citc_client_to_query_for_android_libraries \\
24+
[-t target_citc_client_to_add_android_libraries_to] \\
25+
[-b branch_name] \\
26+
[-d] \\
27+
[-h]
28+
29+
-c citc_client_to_query_for_android_libraries:
30+
Name of the CITC client to query for Android libraries. This will perform
31+
a blaze query at the head of this client.
32+
-t target_citc_client_to_add_android_libraries_to:
33+
Name of the CITC client to add Android libraries to.
34+
-b branch_name:
35+
Name of the branch in the target CITC client to modify.
36+
e.g firebase.cpp_release_branch/281913092.1
37+
You can retrieve the branch associated with a candidate by:
38+
- Navigating to a Rapid project in the web UI http://rapid
39+
- Reading the Branch string
40+
You can checkout a candidate's branch using 'rapid-tool checkout_branch'
41+
-d:
42+
Print branch commands without executing them.
43+
-h:
44+
Display this help message.
45+
"
46+
exit 1
47+
}
48+
49+
main() {
50+
local citc_client=
51+
local target_citc_client=
52+
local branch=""
53+
local dryrun=0
54+
while getopts "c:t:b:dh" option "$@"; do
55+
case ${option} in
56+
c ) citc_client="${OPTARG}";;
57+
t ) target_citc_client="${OPTARG}";;
58+
b ) branch="${OPTARG}";;
59+
d ) dryrun=1;;
60+
h ) help_and_exit;;
61+
* ) help_and_exit;;
62+
esac
63+
done
64+
65+
# Retrieve the set of Android library directories.
66+
local -a android_library_dirs=($(
67+
cd "$(p4 g4d "${citc_client}")" >/dev/null &&
68+
blaze query '
69+
filter("//third_party/java/android_libs/gcore/prebuilts/.*",
70+
kind(android_library,
71+
deps(filter("firebase/(?!invites).*/client/cpp:.*android.*deps",
72+
//firebase/...))))' | \
73+
sed 's@^//@@;s@:android_library$@@'))
74+
75+
# If a target branch and CITC client is specified modify the branch spec.
76+
if [[ "${branch}" != "" && "${target_citc_client}" != "" ]]; then
77+
(
78+
cd "$(p4 g4d "${target_citc_client}")/../branches/${branch}"
79+
for android_library_dir in "${android_library_dirs[@]}"; do
80+
echo "${android_library_dir}" >&2
81+
for mapping in \
82+
//depot/google3/"${android_library_dir}"'/...' \
83+
//depot/google3/"$(echo "${android_library_dir}" | \
84+
sed -r 's@/x[0-9]+_.*@@')"'/*'; do
85+
if [[ $((dryrun)) -eq 1 ]]; then
86+
echo g4 branch "${branch}" -a "${mapping}"
87+
else
88+
g4 branch "${branch}" -a "${mapping}"
89+
# Integrate all files added to the branchspec's view.
90+
g4 integrate "${mapping}" \
91+
"$(echo "${mapping}" | \
92+
sed "s@/google3/@/branches/${branch}/google3/@")"
93+
fi
94+
done
95+
done
96+
echo "Branch spec modified in $(pwd)"
97+
)
98+
else
99+
# Just print the Android library package directories.
100+
for android_library_dir in "${android_library_dirs[@]}"; do
101+
echo "${android_library_dir}"
102+
done
103+
fi
104+
}
105+
106+
main "$@"

0 commit comments

Comments
 (0)