Skip to content

Commit e9904b4

Browse files
Merge pull request #240 from firebase/feature/ak-simplify-flags
Simplify build_testapps.py flags
2 parents 5d29d1a + 8882833 commit e9904b4

File tree

3 files changed

+34
-33
lines changed

3 files changed

+34
-33
lines changed

.github/workflows/cpp-packaging.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ jobs:
672672
python scripts/gha/restore_secrets.py --passphrase "${{ secrets.TEST_SECRET }}"
673673
- name: Build integration tests
674674
run: |
675-
python scripts/gha/build_testapps.py --t ${{ env.apis }} --p ${{ matrix.target_platform }} --sdk_dir firebase_cpp_sdk --output_directory "${{ github.workspace }}" --noadd_timestamp
675+
python scripts/gha/build_testapps.py --t ${{ env.apis }} --p ${{ matrix.target_platform }} --packaged_sdk firebase_cpp_sdk --output_directory "${{ github.workspace }}" --noadd_timestamp
676676
677677
- name: Run desktop integration tests
678678
if: matrix.target_platform == 'Desktop' && !cancelled()

.github/workflows/integration_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ jobs:
136136
if [[ "${{ matrix.ssl_variant }}" == "boringssl" ]]; then
137137
ssl_option=--cmake_flag=-DFIREBASE_USE_BORINGSSL=ON
138138
fi
139-
python scripts/gha/build_testapps.py --t ${{ github.event.inputs.apis }} --p ${{ matrix.target_platform }} --output_directory "${{ github.workspace }}" --use_vcpkg --noadd_timestamp ${ssl_option}
139+
python scripts/gha/build_testapps.py --t ${{ github.event.inputs.apis }} --p ${{ matrix.target_platform }} --output_directory "${{ github.workspace }}" --noadd_timestamp ${ssl_option}
140140
141141
- name: Run desktop integration tests
142142
if: matrix.target_platform == 'Desktop' && !cancelled()

scripts/gha/build_testapps.py

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,24 @@
2525
--t (full name: testapps, default: None)
2626
--p (full name: platforms, default: None)
2727
28+
By default, this tool will build integration tests from source, which involves
29+
building the underlying SDK libraries. To build from a packaged/released SDK,
30+
supply the path to the SDK to --packaged_sdk:
31+
32+
python build_testapps.py --t auth --p iOS --packaged_sdk ~/firebase_cpp_sdk
33+
2834
Under most circumstances the other flags don't need to be set, but can be
2935
seen by running --help. Note that all path flags will forcefully expand
3036
the user ~.
3137
38+
3239
DEPENDENCIES:
3340
34-
----Firebase SDK----
35-
The Firebase SDK (prebuilt) or repo must be locally present.
41+
----Firebase Repo----
42+
The Firebase C++ SDK repo must be locally present.
3643
Path specified by the flag:
3744
38-
--sdk_dir (default: current working directory)
45+
--repo_dir (default: current working directory)
3946
4047
----Python Dependencies----
4148
The requirements.txt file has the required dependencies for this Python tool.
@@ -107,18 +114,16 @@
107114
FLAGS = flags.FLAGS
108115

109116
flags.DEFINE_string(
110-
"sdk_dir", os.getcwd(), "Unzipped Firebase C++ sdk OR Github repo.")
117+
"packaged_sdk", None, "(Optional) Firebase SDK directory. If not"
118+
" supplied, will build from source.")
111119

112120
flags.DEFINE_string(
113121
"output_directory", "~",
114122
"Build output will be placed in this directory.")
115123

116124
flags.DEFINE_string(
117-
"root_dir", os.getcwd(),
118-
"Directory with which to join the relative paths in the config."
119-
" Used to find e.g. the integration test projects. If using the SDK repo"
120-
" this will be the same as the sdk dir, but not if using prebuilts."
121-
" Defaults to the current directory.")
125+
"repo_dir", os.getcwd(),
126+
"Firebase C++ SDK Git repository. Current directory by default.")
122127

123128
flags.DEFINE_list(
124129
"testapps", None, "Which testapps (Firebase APIs) to build, e.g."
@@ -152,13 +157,6 @@
152157
" Check the config file to see valid choices for this flag."
153158
" If none, will invoke cmake without specifying a compiler.")
154159

155-
flags.DEFINE_bool(
156-
"use_vcpkg", False,
157-
"(Desktop only) Use the vcpkg repo inside the C++ repo. For"
158-
" this to work, sdk_dir must be set to the repo, not the prebuilt SDK."
159-
" Will install vcpkg, use it to install dependencies, and then configure"
160-
" CMake to use it.")
161-
162160
flags.DEFINE_multi_string(
163161
"cmake_flag", None,
164162
"Pass an additional flag to the CMake configure step."
@@ -178,9 +176,9 @@ def main(argv):
178176
platforms = FLAGS.platforms
179177
testapps = FLAGS.testapps
180178

181-
sdk_dir = _fix_path(FLAGS.sdk_dir)
179+
sdk_dir = _fix_path(FLAGS.packaged_sdk or FLAGS.repo_dir)
182180
output_dir = _fix_path(FLAGS.output_directory)
183-
root_dir = _fix_path(FLAGS.root_dir)
181+
repo_dir = _fix_path(FLAGS.repo_dir)
184182

185183
update_pod_repo = FLAGS.update_pod_repo
186184
if FLAGS.add_timestamp:
@@ -199,11 +197,14 @@ def main(argv):
199197

200198
config = config_reader.read_config()
201199
cmake_flags = _get_desktop_compiler_flags(FLAGS.compiler, config.compilers)
202-
if _DESKTOP in platforms and FLAGS.use_vcpkg:
203-
installer = os.path.join(sdk_dir, "scripts", "gha", "build_desktop.py")
200+
# VCPKG is used to install dependencies for the desktop SDK.
201+
# Building from source requires building the underlying SDK libraries,
202+
# so we need to use VCPKG as well.
203+
if _DESKTOP in platforms and not FLAGS.packaged_sdk:
204+
installer = os.path.join(repo_dir, "scripts", "gha", "build_desktop.py")
204205
_run([sys.executable, installer, "--vcpkg_step_only"])
205206
toolchain_file = os.path.join(
206-
sdk_dir, "external", "vcpkg", "scripts", "buildsystems", "vcpkg.cmake")
207+
repo_dir, "external", "vcpkg", "scripts", "buildsystems", "vcpkg.cmake")
207208
cmake_flags.extend((
208209
"-DCMAKE_TOOLCHAIN_FILE=%s" % toolchain_file,
209210
"-DVCPKG_TARGET_TRIPLET=%s" % utils.get_vcpkg_triplet(arch="x64")
@@ -222,7 +223,7 @@ def main(argv):
222223
output_dir=output_dir,
223224
sdk_dir=sdk_dir,
224225
ios_framework_exist=ios_framework_exist,
225-
root_dir=root_dir,
226+
repo_dir=repo_dir,
226227
ios_sdk=FLAGS.ios_sdk,
227228
cmake_flags=cmake_flags)
228229
logging.info("END building for %s", testapp)
@@ -233,9 +234,9 @@ def main(argv):
233234

234235
def _build(
235236
testapp, platforms, api_config, output_dir, sdk_dir, ios_framework_exist,
236-
root_dir, ios_sdk, cmake_flags):
237+
repo_dir, ios_sdk, cmake_flags):
237238
"""Builds one testapp on each of the specified platforms."""
238-
testapp_dir = os.path.join(root_dir, api_config.testapp_path)
239+
testapp_dir = os.path.join(repo_dir, api_config.testapp_path)
239240
project_dir = os.path.join(
240241
output_dir, api_config.full_name, os.path.basename(testapp_dir))
241242

@@ -246,8 +247,8 @@ def _build(
246247
logging.info("Changing directory to %s", project_dir)
247248
os.chdir(project_dir)
248249

249-
_run_setup_script(root_dir, project_dir)
250-
250+
_run_setup_script(repo_dir, project_dir)
251+
251252
failures = []
252253

253254
if _DESKTOP in platforms:
@@ -279,7 +280,7 @@ def _build(
279280
sdk_dir=sdk_dir,
280281
ios_framework_exist=ios_framework_exist,
281282
project_dir=project_dir,
282-
root_dir=root_dir,
283+
repo_dir=repo_dir,
283284
api_config=api_config,
284285
ios_sdk=ios_sdk)
285286
except subprocess.SubprocessError as e:
@@ -426,7 +427,7 @@ def _build_ios_framework_from_repo(sdk_dir, api_config):
426427

427428

428429
def _build_ios(
429-
sdk_dir, ios_framework_exist, project_dir, root_dir, api_config, ios_sdk):
430+
sdk_dir, ios_framework_exist, project_dir, repo_dir, api_config, ios_sdk):
430431
"""Builds an iOS application (.app, .ipa or both)."""
431432
if not ios_framework_exist:
432433
_build_ios_framework_from_repo(sdk_dir, api_config)
@@ -444,10 +445,10 @@ def _build_ios(
444445
framework_paths.append(framework_dest_path)
445446

446447
podfile_tool_path = os.path.join(
447-
root_dir, "scripts", "gha", "integration_testing", "update_podfile.py")
448+
repo_dir, "scripts", "gha", "integration_testing", "update_podfile.py")
448449
podfile_patcher_args = [
449450
sys.executable, podfile_tool_path,
450-
"--sdk_podfile", os.path.join(root_dir, "ios_pod", "Podfile"),
451+
"--sdk_podfile", os.path.join(repo_dir, "ios_pod", "Podfile"),
451452
"--app_podfile", os.path.join(project_dir, "Podfile")
452453
]
453454
_run(podfile_patcher_args)
@@ -456,7 +457,7 @@ def _build_ios(
456457
entitlements_path = os.path.join(
457458
project_dir, api_config.ios_target + ".entitlements")
458459
xcode_tool_path = os.path.join(
459-
root_dir, "scripts", "gha", "integration_testing", "xcode_tool.rb")
460+
repo_dir, "scripts", "gha", "integration_testing", "xcode_tool.rb")
460461
xcode_patcher_args = [
461462
"ruby", xcode_tool_path,
462463
"--XCodeCPP.xcodeProjectDir", project_dir,

0 commit comments

Comments
 (0)