Skip to content

Commit a247075

Browse files
Deduplicate vcpkg logic from testapp builder
Rely on the vcpkg logic in the build script for the SDK and the utils file instead of duplicating it. The duplicated logic has broken due to a change in the response files: this refactoring will avoid similar issues in the future.
1 parent 1dda499 commit a247075

File tree

3 files changed

+18
-66
lines changed

3 files changed

+18
-66
lines changed

scripts/gha/build_testapps.py

Lines changed: 18 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@
6969
import datetime
7070
from distutils import dir_util
7171
import os
72-
import pathlib
7372
import platform
7473
import shutil
7574
import subprocess
75+
import sys
7676

7777
from absl import app
7878
from absl import flags
@@ -81,8 +81,8 @@
8181
import attr
8282

8383
from integration_testing import config_reader
84-
from integration_testing import provisioning
8584
from integration_testing import xcodebuild
85+
import utils
8686

8787
# Environment variables
8888
_JAVA_HOME = "JAVA_HOME"
@@ -195,14 +195,18 @@ def main(argv):
195195

196196
if update_pod_repo and _IOS in platforms:
197197
_run(["pod", "repo", "update"])
198-
198+
199199
config = config_reader.read_config()
200200
cmake_flags = _get_desktop_compiler_flags(FLAGS.compiler, config.compilers)
201201
if _DESKTOP in platforms and FLAGS.use_vcpkg:
202-
_run(["git", "submodule", "update", "--init"])
203-
vcpkg = Vcpkg.generate(os.path.join(sdk_dir, config.vcpkg_dir))
204-
vcpkg.install_and_run()
205-
cmake_flags.extend(vcpkg.cmake_flags)
202+
installer = os.path.join(sdk_dir, "scripts", "gha", "build_desktop.py")
203+
_run([sys.executable, installer, "--vcpkg_step_only"])
204+
toolchain_file = os.path.join(
205+
sdk_dir, "external", "vcpkg", "scripts", "buildsystems", "vcpkg.cmake")
206+
cmake_flags.extend((
207+
"-DCMAKE_TOOLCHAIN_FILE=%s" % toolchain_file,
208+
"-DVCPKG_TARGET_TRIPLET=%s" % utils.get_vcpkg_triplet(arch="x64")
209+
))
206210

207211
failures = []
208212
for testapp in testapps:
@@ -226,7 +230,7 @@ def main(argv):
226230

227231

228232
def _build(
229-
testapp, platforms, api_config, output_dir, sdk_dir, ios_framework_exist,
233+
testapp, platforms, api_config, output_dir, sdk_dir, ios_framework_exist,
230234
timestamp, root_dir, ios_sdk, cmake_flags, execute_desktop_testapp):
231235
"""Builds one testapp on each of the specified platforms."""
232236
testapp_dir = os.path.join(root_dir, api_config.testapp_path)
@@ -382,7 +386,7 @@ def _validate_android_environment_variables():
382386
"Neither %s nor %s is set", _ANDROID_SDK_HOME, _ANDROID_HOME)
383387

384388

385-
# If sdk_dir contains no framework, consider it is Github repo, then
389+
# If sdk_dir contains no framework, consider it is Github repo, then
386390
# generate makefiles for ios frameworks
387391
def _generate_makefiles_from_repo(sdk_dir):
388392
ios_framework_builder = os.path.join(
@@ -401,14 +405,14 @@ def _generate_makefiles_from_repo(sdk_dir):
401405
def _build_ios_framework_from_repo(sdk_dir, api_config):
402406
ios_framework_builder = os.path.join(
403407
sdk_dir, "build_scripts", "ios", "build.sh")
404-
408+
405409
# build only required targets to save time
406410
target = set()
407411
for framework in api_config.frameworks:
408412
target.add(os.path.splitext(framework)[0])
409413
# firebase is not a target in CMake, firebase_app is the target
410-
# firebase_app will be built by other target as well
411-
target.remove("firebase")
414+
# firebase_app will be built by other target as well
415+
target.remove("firebase")
412416

413417
framework_builder_args = [
414418
ios_framework_builder,
@@ -444,7 +448,7 @@ def _build_ios(
444448
app_podfile_path = os.path.join(
445449
project_dir, "Podfile")
446450
podfile_patcher_args = [
447-
"python", podfile_tool_path,
451+
sys.executable, podfile_tool_path,
448452
"--sdk_podfile", sdk_podfile_path,
449453
"--app_podfile", app_podfile_path
450454
]
@@ -496,7 +500,7 @@ def _run_setup_script(root_dir, testapp_dir):
496500
"""Runs the setup_integration_tests.py script if needed."""
497501
script_path = os.path.join(root_dir, "setup_integration_tests.py")
498502
if os.path.isfile(script_path):
499-
_run(["python", script_path, testapp_dir])
503+
_run([sys.executable, script_path, testapp_dir])
500504
else:
501505
logging.info("setup_integration_tests.py not found")
502506

@@ -529,55 +533,6 @@ def _fix_path(path):
529533
return os.path.abspath(os.path.expanduser(path))
530534

531535

532-
@attr.s(frozen=True, eq=False)
533-
class Vcpkg(object):
534-
"""Holds data related to the vcpkg tool used for managing dependent tools."""
535-
installer = attr.ib()
536-
binary = attr.ib()
537-
triplet = attr.ib()
538-
response_file = attr.ib()
539-
toolchain_file = attr.ib()
540-
541-
@classmethod
542-
def generate(cls, vcpkg_dir):
543-
"""Generates the vcpkg data based on the given vcpkg submodule path."""
544-
installer = os.path.join(vcpkg_dir, "bootstrap-vcpkg")
545-
binary = os.path.join(vcpkg_dir, "vcpkg")
546-
response_file_fmt = vcpkg_dir + "_%s_response_file.txt"
547-
if platform.system() == "Windows":
548-
triplet = "x64-windows-static"
549-
installer += ".bat"
550-
binary += ".exe"
551-
elif platform.system() == "Darwin":
552-
triplet = "x64-osx"
553-
installer += ".sh"
554-
elif platform.system() == "Linux":
555-
triplet = "x64-linux"
556-
installer += ".sh"
557-
else:
558-
raise ValueError("Unrecognized system: %s" % platform.system())
559-
return cls(
560-
installer=installer,
561-
binary=binary,
562-
triplet=triplet,
563-
response_file=response_file_fmt % triplet,
564-
toolchain_file=os.path.join(
565-
vcpkg_dir, "scripts", "buildsystems", "vcpkg.cmake"))
566-
567-
def install_and_run(self):
568-
"""Installs vcpkg (if needed) and runs it to install dependencies."""
569-
if not os.path.exists(self.binary):
570-
_run([self.installer])
571-
_run([
572-
self.binary, "install", "@" + self.response_file, "--disable-metrics"])
573-
574-
@property
575-
def cmake_flags(self):
576-
return [
577-
"-DCMAKE_TOOLCHAIN_FILE=%s" % self.toolchain_file,
578-
"-DVCPKG_TARGET_TRIPLET=%s" % self.triplet]
579-
580-
581536
@attr.s(frozen=True, eq=False)
582537
class Failure(object):
583538
"""Holds context for the failure of a testapp to build/run."""

scripts/gha/integration_testing/build_testapps.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@
174174
"provision": "Google_Development.mobileprovision"
175175
}
176176
],
177-
"vcpkg_dir": "external/vcpkg",
178177
"apple_team_id": "REPLACE_ME_TEMP_INVALID_ID",
179178
"compiler_dict": {
180179
"gcc-4.8": [

scripts/gha/integration_testing/config_reader.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ def read_config(path=None):
9797
return Config(
9898
apis=api_configs,
9999
apple_team_id=config["apple_team_id"],
100-
vcpkg_dir=config["vcpkg_dir"],
101100
compilers=config["compiler_dict"])
102101
except (KeyError, TypeError, IndexError):
103102
# The error will be cryptic on its own, so we dump the JSON to
@@ -112,7 +111,6 @@ def read_config(path=None):
112111
class Config(object):
113112
apis = attr.ib() # Mapping of str: APIConfig
114113
apple_team_id = attr.ib()
115-
vcpkg_dir = attr.ib() # Relative location of the vcpkg submodule in the repo.
116114
compilers = attr.ib()
117115

118116
def get_api(self, api):

0 commit comments

Comments
 (0)