Skip to content

Commit c678ca1

Browse files
Merge pull request #193 from firebase/feature/aks-vcpkg
Deduplicate vcpkg logic in testapp builder
2 parents 5936412 + de4a422 commit c678ca1

File tree

3 files changed

+12
-60
lines changed

3 files changed

+12
-60
lines changed

scripts/gha/build_testapps.py

Lines changed: 12 additions & 57 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"
@@ -199,10 +199,14 @@ def main(argv):
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:
@@ -462,7 +466,7 @@ def _build_ios(
462466
app_podfile_path = os.path.join(
463467
project_dir, "Podfile")
464468
podfile_patcher_args = [
465-
"python", podfile_tool_path,
469+
sys.executable, podfile_tool_path,
466470
"--sdk_podfile", sdk_podfile_path,
467471
"--app_podfile", app_podfile_path
468472
]
@@ -515,7 +519,7 @@ def _run_setup_script(root_dir, testapp_dir):
515519
"""Runs the setup_integration_tests.py script if needed."""
516520
script_path = os.path.join(root_dir, "setup_integration_tests.py")
517521
if os.path.isfile(script_path):
518-
_run(["python", script_path, testapp_dir])
522+
_run([sys.executable, script_path, testapp_dir])
519523
else:
520524
logging.info("setup_integration_tests.py not found")
521525

@@ -548,55 +552,6 @@ def _fix_path(path):
548552
return os.path.abspath(os.path.expanduser(path))
549553

550554

551-
@attr.s(frozen=True, eq=False)
552-
class Vcpkg(object):
553-
"""Holds data related to the vcpkg tool used for managing dependent tools."""
554-
installer = attr.ib()
555-
binary = attr.ib()
556-
triplet = attr.ib()
557-
response_file = attr.ib()
558-
toolchain_file = attr.ib()
559-
560-
@classmethod
561-
def generate(cls, vcpkg_dir):
562-
"""Generates the vcpkg data based on the given vcpkg submodule path."""
563-
installer = os.path.join(vcpkg_dir, "bootstrap-vcpkg")
564-
binary = os.path.join(vcpkg_dir, "vcpkg")
565-
response_file_fmt = vcpkg_dir + "_%s_response_file.txt"
566-
if platform.system() == "Windows":
567-
triplet = "x64-windows-static"
568-
installer += ".bat"
569-
binary += ".exe"
570-
elif platform.system() == "Darwin":
571-
triplet = "x64-osx"
572-
installer += ".sh"
573-
elif platform.system() == "Linux":
574-
triplet = "x64-linux"
575-
installer += ".sh"
576-
else:
577-
raise ValueError("Unrecognized system: %s" % platform.system())
578-
return cls(
579-
installer=installer,
580-
binary=binary,
581-
triplet=triplet,
582-
response_file=response_file_fmt % triplet,
583-
toolchain_file=os.path.join(
584-
vcpkg_dir, "scripts", "buildsystems", "vcpkg.cmake"))
585-
586-
def install_and_run(self):
587-
"""Installs vcpkg (if needed) and runs it to install dependencies."""
588-
if not os.path.exists(self.binary):
589-
_run([self.installer])
590-
_run([
591-
self.binary, "install", "@" + self.response_file, "--disable-metrics"])
592-
593-
@property
594-
def cmake_flags(self):
595-
return [
596-
"-DCMAKE_TOOLCHAIN_FILE=%s" % self.toolchain_file,
597-
"-DVCPKG_TARGET_TRIPLET=%s" % self.triplet]
598-
599-
600555
@attr.s(frozen=True, eq=False)
601556
class Failure(object):
602557
"""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)