diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b27c5c7ae..b3a93b374c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -907,7 +907,7 @@ if(USE_CUSTOM_LIBCXX) set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -nostdlib++") include_directories( SYSTEM - util/bot/libcxx-config + tests/ci/libcxx-config ${LLVM_PROJECT_HOME}/libcxx/include ${LLVM_PROJECT_HOME}/libcxxabi/include ) diff --git a/util/bot/libcxx-config/__config_site b/tests/ci/libcxx-config/__config_site similarity index 100% rename from util/bot/libcxx-config/__config_site rename to tests/ci/libcxx-config/__config_site diff --git a/util/bot/DEPS b/util/bot/DEPS deleted file mode 100644 index c064e6515a..0000000000 --- a/util/bot/DEPS +++ /dev/null @@ -1,183 +0,0 @@ -# Copyright (c) 2015, Google Inc. -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION -# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -vars = { - 'chromium_git': 'https://chromium.googlesource.com', - - 'checkout_clang': False, - 'checkout_sde': False, - 'checkout_nasm': False, - 'checkout_libcxx': False, - 'vs_version': '2015', - - # Run the following command to see the latest builds in CIPD: - # cipd describe PACKAGE_NAME -version latest - - # infra/3pp/tools/cmake/linux-amd64 - 'cmake_version': 'version:2@3.26.4.chromium.7', - # infra/3pp/tools/go/linux-amd64 - 'go_version': 'version:2@1.20.5', - # infra/3pp/tools/perl/windows-amd64 - 'perl_version': 'version:2@5.32.1.1', - - # Update the following from - # https://chromium.googlesource.com/chromium/src/+/main/DEPS - 'android_sdk_platform-tools_version': 'RSI3iwryh7URLGRgJHsCvUxj092woTPnKt4pwFcJ6L8C', - 'android_ndk_revision': '310956bd122ec2b96049f8d7398de6b717f3452e', - 'libfuzzer_revision': 'debe7d2d1982e540fbd6bd78604bf001753f9e74', - 'libcxx_revision': 'f8279b01085b800724f5c5629dc365b9f040dc53', - 'libcxxabi_revision': '899caea3814eeb45c689fc206052968943fd5cb8', - 'ninja_version': 'version:2@1.11.1.chromium.6', -} - -deps = { - 'boringssl/util/bot/android_ndk': { - 'url': Var('chromium_git') + '/android_ndk.git' + '@' + Var('android_ndk_revision'), - 'condition': 'checkout_android', - }, - - 'boringssl/util/bot/android_sdk/public': { - 'packages': [{ - 'package': 'chromium/third_party/android_sdk/public/platform-tools', - 'version': Var('android_sdk_platform-tools_version'), - }], - 'condition': 'checkout_android', - 'dep_type': 'cipd', - }, - - 'boringssl/util/bot/cmake': { - 'packages': [{ - 'package': 'infra/3pp/tools/cmake/${{platform}}', - 'version': Var('cmake_version'), - }], - 'dep_type': 'cipd', - }, - - 'boringssl/util/bot/golang': { - 'packages': [{ - 'package': 'infra/3pp/tools/go/${{platform}}', - 'version': Var('go_version'), - }], - 'dep_type': 'cipd', - }, - - 'boringssl/util/bot/perl-win32': { - 'packages': [{ - 'package': 'infra/3pp/tools/perl/${{platform}}', - 'version': Var('perl_version'), - }], - 'condition': 'host_os == "win"', - 'dep_type': 'cipd', - }, - - 'boringssl/util/bot/libFuzzer': { - 'url': Var('chromium_git') + '/chromium/llvm-project/compiler-rt/lib/fuzzer.git' +'@' + Var('libfuzzer_revision'), - 'condition': 'checkout_fuzzer', - }, - - 'boringssl/util/bot/libcxx': { - 'url': Var('chromium_git') + '/external/github.com/llvm/llvm-project/libcxx.git' + '@' + Var('libcxx_revision'), - 'condition': 'checkout_libcxx', - }, - 'boringssl/util/bot/libcxxabi': { - 'url': Var('chromium_git') + '/external/github.com/llvm/llvm-project/libcxxabi.git' + '@' + Var('libcxxabi_revision'), - 'condition': 'checkout_libcxx', - }, - - 'boringssl/util/bot/ninja': { - 'packages': [{ - 'package': 'infra/3pp/tools/ninja/${{platform}}', - 'version': Var('ninja_version'), - }], - 'dep_type': 'cipd', - } -} - -recursedeps = [ - # android_tools pulls in the NDK from a separate repository. - 'boringssl/util/bot/android_tools', -] - -hooks = [ - { - 'name': 'nasm_win32', - 'pattern': '.', - 'condition': 'host_os == "win" and checkout_nasm', - 'action': [ 'download_from_google_storage', - '--no_resume', - '--platform=win32', - '--no_auth', - '--bucket', 'chromium-tools', - '-s', 'boringssl/util/bot/nasm-win32.exe.sha1', - ], - }, - { - 'name': 'win_toolchain', - 'pattern': '.', - 'condition': 'host_os == "win"', - 'action': [ 'python3', - 'boringssl/util/bot/vs_toolchain.py', - 'update', - Var('vs_version'), - ], - }, - { - 'name': 'clang', - 'pattern': '.', - 'condition': 'checkout_clang', - 'action': [ 'python3', - 'boringssl/util/bot/update_clang.py', - ], - }, - { - 'name': 'sde_linux64', - 'pattern': '.', - 'condition': 'checkout_sde and host_os == "linux"', - 'action': [ 'download_from_google_storage', - '--no_resume', - '--bucket', 'chrome-boringssl-sde', - '-s', 'boringssl/util/bot/sde-linux64.tar.xz.sha1' - ], - }, - { - 'name': 'sde_linux64_extract', - 'pattern': '.', - 'condition': 'checkout_sde and host_os == "linux"', - 'action': [ 'python3', - 'boringssl/util/bot/extract.py', - 'boringssl/util/bot/sde-linux64.tar.xz', - 'boringssl/util/bot/sde-linux64/', - ], - }, - { - 'name': 'sde_win32', - 'pattern': '.', - 'condition': 'checkout_sde and host_os == "win"', - 'action': [ 'download_from_google_storage', - '--no_resume', - '--bucket', 'chrome-boringssl-sde', - '-s', 'boringssl/util/bot/sde-win32.tar.xz.sha1' - ], - }, - { - 'name': 'sde_win32_extract', - 'pattern': '.', - 'condition': 'checkout_sde and host_os == "win"', - 'action': [ 'python3', - 'boringssl/util/bot/extract.py', - 'boringssl/util/bot/sde-win32.tar.xz', - 'boringssl/util/bot/sde-win32/', - ], - }, -] diff --git a/util/bot/README b/util/bot/README deleted file mode 100644 index b7a4332e85..0000000000 --- a/util/bot/README +++ /dev/null @@ -1,3 +0,0 @@ -This directory contains tools for setting up a hermetic toolchain on the -continuous integration bots. It is in the repository for convenience and can be -ignored in development. diff --git a/util/bot/UPDATING b/util/bot/UPDATING deleted file mode 100644 index bbe27c754c..0000000000 --- a/util/bot/UPDATING +++ /dev/null @@ -1,43 +0,0 @@ -This directory consumes tools from other repositories for use on the -bots. For a similarly-configured local checkout for testing, run: - - mkdir boringssl-gclient - cd boringssl-gclient - gclient config --unmanaged --deps-file=util/bot/DEPS https://boringssl.googlesource.com/boringssl/ - gclient sync - -To update to newer revisions, follow these instructions: - -DEPS: Update the variables as described in the comments. - -update_clang.py: Set CLANG_REVISION and CLANG_SUB_REVISION to the values used in - Chromium, found at - https://chromium.googlesource.com/chromium/src/+/main/tools/clang/scripts/update.py - -vs_toolchain.py: Update _GetDesiredVsToolchainHashes from Chromium, found at - https://chromium.googlesource.com/chromium/src/+/main/build/vs_toolchain.py - This may require taking other updates to that file. (Don't remove MSVC - versions if BoringSSL still needs to support them.) - -The .sha1 files correspond to files downloaded from Google Cloud Storage. To -update, place the updated files in their intended location and run: - - upload_to_google_storage.py -b chromium-tools FILE - -nasm-win32.exe: Update to the appropriate release of NASM, found at - https://www.nasm.us/. Use the same version as Chromium, found at - https://chromium.googlesource.com/chromium/deps/nasm/+/refs/heads/main/README.chromium - Extract nasm.exe from the download named nasm-VERSION-win64.zip. - - The current revision is nasm-2.13.03-win64.zip. - -Finally, update sde-linux64.tar.xz and sde-win32.tar.xz by downloading the -latet release from Intel at -https://software.intel.com/en-us/articles/intel-software-development-emulator, -but upload it with the following command. (Note the bucket is different.) - - upload_to_google_storage.py -b chrome-boringssl-sde sde-linux64.tar.xz sde-win32.tar.xz - -The current revision is sde-external-9.14.0-2022-10-25-*.tar.xz. - -When adding new files, remember to update .gitignore. diff --git a/util/bot/extract.py b/util/bot/extract.py deleted file mode 100644 index 4ef5f6517e..0000000000 --- a/util/bot/extract.py +++ /dev/null @@ -1,183 +0,0 @@ -# Copyright (c) 2015, Google Inc. -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION -# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -"""Extracts archives.""" - - -import hashlib -import optparse -import os -import os.path -import tarfile -import shutil -import sys -import zipfile - - -def CheckedJoin(output, path): - """ - CheckedJoin returns os.path.join(output, path). It does sanity checks to - ensure the resulting path is under output, but shouldn't be used on untrusted - input. - """ - path = os.path.normpath(path) - if os.path.isabs(path) or path.startswith('.'): - raise ValueError(path) - return os.path.join(output, path) - - -class FileEntry(object): - def __init__(self, path, mode, fileobj): - self.path = path - self.mode = mode - self.fileobj = fileobj - - -class SymlinkEntry(object): - def __init__(self, path, mode, target): - self.path = path - self.mode = mode - self.target = target - - -def IterateZip(path): - """ - IterateZip opens the zip file at path and returns a generator of entry objects - for each file in it. - """ - with zipfile.ZipFile(path, 'r') as zip_file: - for info in zip_file.infolist(): - if info.filename.endswith('/'): - continue - yield FileEntry(info.filename, None, zip_file.open(info)) - - -def IterateTar(path, compression): - """ - IterateTar opens the tar.gz or tar.bz2 file at path and returns a generator of - entry objects for each file in it. - """ - with tarfile.open(path, 'r:' + compression) as tar_file: - for info in tar_file: - if info.isdir(): - pass - elif info.issym(): - yield SymlinkEntry(info.name, None, info.linkname) - elif info.isfile(): - yield FileEntry(info.name, info.mode, tar_file.extractfile(info)) - else: - raise ValueError('Unknown entry type "%s"' % (info.name, )) - - -def main(args): - parser = optparse.OptionParser(usage='Usage: %prog ARCHIVE OUTPUT') - parser.add_option('--no-prefix', dest='no_prefix', action='store_true', - help='Do not remove a prefix from paths in the archive.') - options, args = parser.parse_args(args) - - if len(args) != 2: - parser.print_help() - return 1 - - archive, output = args - - if not os.path.exists(archive): - # Skip archives that weren't downloaded. - return 0 - - with open(archive, 'rb') as f: - sha256 = hashlib.sha256() - while True: - chunk = f.read(1024 * 1024) - if not chunk: - break - sha256.update(chunk) - digest = sha256.hexdigest() - - stamp_path = os.path.join(output, ".boringssl_archive_digest") - if os.path.exists(stamp_path): - with open(stamp_path) as f: - if f.read().strip() == digest: - print("Already up-to-date.") - return 0 - - if archive.endswith('.zip'): - entries = IterateZip(archive) - elif archive.endswith('.tar.gz'): - entries = IterateTar(archive, 'gz') - elif archive.endswith('.tar.bz2'): - entries = IterateTar(archive, 'bz2') - elif archive.endswith('.tar.xz'): - entries = IterateTar(archive, 'xz') - else: - raise ValueError(archive) - - try: - if os.path.exists(output): - print("Removing %s" % (output, )) - shutil.rmtree(output) - - print("Extracting %s to %s" % (archive, output)) - prefix = None - num_extracted = 0 - for entry in entries: - # Even on Windows, zip files must always use forward slashes. - if '\\' in entry.path or entry.path.startswith('/'): - raise ValueError(entry.path) - - if not options.no_prefix: - new_prefix, rest = entry.path.split('/', 1) - - # Ensure the archive is consistent. - if prefix is None: - prefix = new_prefix - if prefix != new_prefix: - raise ValueError((prefix, new_prefix)) - else: - rest = entry.path - - # Extract the file into the output directory. - fixed_path = CheckedJoin(output, rest) - if not os.path.isdir(os.path.dirname(fixed_path)): - os.makedirs(os.path.dirname(fixed_path)) - if isinstance(entry, FileEntry): - with open(fixed_path, 'wb') as out: - shutil.copyfileobj(entry.fileobj, out) - elif isinstance(entry, SymlinkEntry): - os.symlink(entry.target, fixed_path) - else: - raise TypeError('unknown entry type') - - # Fix up permissions if needbe. - # TODO(davidben): To be extra tidy, this should only track the execute bit - # as in git. - if entry.mode is not None: - os.chmod(fixed_path, entry.mode) - - # Print every 100 files, so bots do not time out on large archives. - num_extracted += 1 - if num_extracted % 100 == 0: - print("Extracted %d files..." % (num_extracted,)) - finally: - entries.close() - - with open(stamp_path, 'w') as f: - f.write(digest) - - print("Done. Extracted %d files." % (num_extracted,)) - return 0 - - -if __name__ == '__main__': - sys.exit(main(sys.argv[1:])) diff --git a/util/bot/go/env.py b/util/bot/go/env.py deleted file mode 100755 index b9c33e2b82..0000000000 --- a/util/bot/go/env.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python3 -# Copyright 2014 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -# Modified from go/env.py in Chromium infrastructure's repository to patch out -# everything but the core toolchain. -# -# https://chromium.googlesource.com/infra/infra/ - -"""Used to wrap a command: - -$ ./env.py go version -""" - -assert __name__ == '__main__' - -import os -import subprocess -import sys - -# /path/to/util/bot -ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) - -# Platform depended suffix for executable files. -EXE_SFX = '.exe' if sys.platform == 'win32' else '' - -def get_go_environ(goroot): - """Returns a copy of os.environ with added GOROOT and PATH variables.""" - env = os.environ.copy() - env['GOROOT'] = goroot - gobin = os.path.join(goroot, 'bin') - path = env['PATH'].split(os.pathsep) - if gobin not in path: - env['PATH'] = os.pathsep.join([gobin] + path) - return env - -def find_executable(name, goroot): - """Returns full path to an executable in GOROOT.""" - basename = name - if EXE_SFX and basename.endswith(EXE_SFX): - basename = basename[:-len(EXE_SFX)] - full_path = os.path.join(goroot, 'bin', basename + EXE_SFX) - if os.path.exists(full_path): - return full_path - return name - -# TODO(davidben): Now that we use CIPD to fetch Go, this script does not do -# much. Switch to setting up GOROOT and PATH in the recipe? -goroot = os.path.join(ROOT, 'golang') -new = get_go_environ(goroot) - -exe = sys.argv[1] -if exe == 'python': - exe = sys.executable -else: - # Help Windows to find the executable in new PATH, do it only when - # executable is referenced by name (and not by path). - if os.sep not in exe: - exe = find_executable(exe, goroot) -sys.exit(subprocess.call([exe] + sys.argv[2:], env=new)) diff --git a/util/bot/nasm-win32.exe.sha1 b/util/bot/nasm-win32.exe.sha1 deleted file mode 100644 index 62afef4dd7..0000000000 --- a/util/bot/nasm-win32.exe.sha1 +++ /dev/null @@ -1 +0,0 @@ -fe003e1128188bba6f54307802051f2eddfdee85 \ No newline at end of file diff --git a/util/bot/sde-linux64.tar.xz.sha1 b/util/bot/sde-linux64.tar.xz.sha1 deleted file mode 100644 index 96d3a0dff0..0000000000 --- a/util/bot/sde-linux64.tar.xz.sha1 +++ /dev/null @@ -1 +0,0 @@ -78e7af6ae04e807282d45828ca3c7d12f4eb1d91 \ No newline at end of file diff --git a/util/bot/sde-win32.tar.xz.sha1 b/util/bot/sde-win32.tar.xz.sha1 deleted file mode 100644 index 18553e83f5..0000000000 --- a/util/bot/sde-win32.tar.xz.sha1 +++ /dev/null @@ -1 +0,0 @@ -8d3b079358b548a930046fabb6124c943e1d48fb \ No newline at end of file diff --git a/util/bot/update_clang.py b/util/bot/update_clang.py deleted file mode 100644 index d0b188adbd..0000000000 --- a/util/bot/update_clang.py +++ /dev/null @@ -1,178 +0,0 @@ -#!/usr/bin/env python3 -# Copyright (c) 2012 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -"""This script is used to download prebuilt clang binaries.""" - -from __future__ import division -from __future__ import print_function - -import os -import platform -import shutil -import subprocess -import stat -import sys -import tarfile -import tempfile -import time - -try: - # Python 3.0 or later - from urllib.error import HTTPError, URLError - from urllib.request import urlopen -except ImportError: - from urllib2 import urlopen, HTTPError, URLError - - -# CLANG_REVISION and CLANG_SUB_REVISION determine the build of clang -# to use. These should be synced with tools/clang/scripts/update.py in -# Chromium. -CLANG_REVISION = 'llvmorg-17-init-12166-g7586aeab' -CLANG_SUB_REVISION = 3 - -PACKAGE_VERSION = '%s-%s' % (CLANG_REVISION, CLANG_SUB_REVISION) - -# Path constants. (All of these should be absolute paths.) -THIS_DIR = os.path.abspath(os.path.dirname(__file__)) -LLVM_BUILD_DIR = os.path.join(THIS_DIR, 'llvm-build') -STAMP_FILE = os.path.join(LLVM_BUILD_DIR, 'cr_build_revision') - -# URL for pre-built binaries. -CDS_URL = os.environ.get('CDS_CLANG_BUCKET_OVERRIDE', - 'https://commondatastorage.googleapis.com/chromium-browser-clang') - - -def DownloadUrl(url, output_file): - """Download url into output_file.""" - CHUNK_SIZE = 4096 - TOTAL_DOTS = 10 - num_retries = 3 - retry_wait_s = 5 # Doubled at each retry. - - while True: - try: - sys.stdout.write('Downloading %s ' % url) - sys.stdout.flush() - response = urlopen(url) - total_size = int(response.headers.get('Content-Length').strip()) - bytes_done = 0 - dots_printed = 0 - while True: - chunk = response.read(CHUNK_SIZE) - if not chunk: - break - output_file.write(chunk) - bytes_done += len(chunk) - num_dots = TOTAL_DOTS * bytes_done // total_size - sys.stdout.write('.' * (num_dots - dots_printed)) - sys.stdout.flush() - dots_printed = num_dots - if bytes_done != total_size: - raise URLError("only got %d of %d bytes" % (bytes_done, total_size)) - print(' Done.') - return - except URLError as e: - sys.stdout.write('\n') - print(e) - if num_retries == 0 or isinstance(e, HTTPError) and e.code == 404: - raise e - num_retries -= 1 - print('Retrying in %d s ...' % retry_wait_s) - time.sleep(retry_wait_s) - retry_wait_s *= 2 - - -def EnsureDirExists(path): - if not os.path.exists(path): - print("Creating directory %s" % path) - os.makedirs(path) - - -def DownloadAndUnpack(url, output_dir): - with tempfile.TemporaryFile() as f: - DownloadUrl(url, f) - f.seek(0) - EnsureDirExists(output_dir) - tarfile.open(mode='r:*', fileobj=f).extractall(path=output_dir) - - -def ReadStampFile(path=STAMP_FILE): - """Return the contents of the stamp file, or '' if it doesn't exist.""" - try: - with open(path, 'r') as f: - return f.read().rstrip() - except IOError: - return '' - - -def WriteStampFile(s, path=STAMP_FILE): - """Write s to the stamp file.""" - EnsureDirExists(os.path.dirname(path)) - with open(path, 'w') as f: - f.write(s) - f.write('\n') - - -def RmTree(dir): - """Delete dir.""" - def ChmodAndRetry(func, path, _): - # Subversion can leave read-only files around. - if not os.access(path, os.W_OK): - os.chmod(path, stat.S_IWUSR) - return func(path) - raise - - shutil.rmtree(dir, onerror=ChmodAndRetry) - - -def CopyFile(src, dst): - """Copy a file from src to dst.""" - print("Copying %s to %s" % (src, dst)) - shutil.copy(src, dst) - - -def UpdateClang(): - cds_file = "clang-%s.tar.xz" % PACKAGE_VERSION - if sys.platform == 'win32' or sys.platform == 'cygwin': - cds_full_url = CDS_URL + '/Win/' + cds_file - elif sys.platform.startswith('linux'): - cds_full_url = CDS_URL + '/Linux_x64/' + cds_file - elif sys.platform == 'darwin': - if platform.machine() == 'arm64': - cds_full_url = CDS_URL + '/Mac_arm64/' + cds_file - else: - cds_full_url = CDS_URL + '/Mac/' + cds_file - else: - return 0 - - print('Updating Clang to %s...' % PACKAGE_VERSION) - - if ReadStampFile() == PACKAGE_VERSION: - print('Clang is already up to date.') - return 0 - - # Reset the stamp file in case the build is unsuccessful. - WriteStampFile('') - - print('Downloading prebuilt clang') - if os.path.exists(LLVM_BUILD_DIR): - RmTree(LLVM_BUILD_DIR) - try: - DownloadAndUnpack(cds_full_url, LLVM_BUILD_DIR) - print('clang %s unpacked' % PACKAGE_VERSION) - WriteStampFile(PACKAGE_VERSION) - return 0 - except URLError: - print('Failed to download prebuilt clang %s' % cds_file) - print('Exiting.') - return 1 - - -def main(): - return UpdateClang() - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/util/bot/vs_env.py b/util/bot/vs_env.py deleted file mode 100644 index cbbdd430d9..0000000000 --- a/util/bot/vs_env.py +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (c) 2015, Google Inc. -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION -# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN -# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -from __future__ import print_function - -import subprocess -import sys - -import vs_toolchain - -if len(sys.argv) < 2: - print("Usage: vs_env.py TARGET_ARCH CMD...", file=sys.stderr) - sys.exit(1) - -target_arch = sys.argv[1] -cmd = sys.argv[2:] - -vs_toolchain.SetEnvironmentForCPU(target_arch) -sys.exit(subprocess.call(cmd)) diff --git a/util/bot/vs_toolchain.py b/util/bot/vs_toolchain.py deleted file mode 100644 index fc14f6b965..0000000000 --- a/util/bot/vs_toolchain.py +++ /dev/null @@ -1,114 +0,0 @@ -# Copyright 2014 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -from __future__ import print_function - -import json -import os -import os.path -import subprocess -import sys - - -script_dir = os.path.dirname(os.path.realpath(__file__)) -json_data_file = os.path.join(script_dir, 'win_toolchain.json') - - -def SetEnvironmentForCPU(cpu): - """Sets the environment to build with the selected toolchain for |cpu|.""" - with open(json_data_file, 'r') as tempf: - toolchain_data = json.load(tempf) - sdk_dir = toolchain_data['win_sdk'] - os.environ['WINDOWSSDKDIR'] = sdk_dir - os.environ['WDK_DIR'] = toolchain_data['wdk'] - # Include the VS runtime in the PATH in case it's not machine-installed. - vs_runtime_dll_dirs = toolchain_data['runtime_dirs'] - runtime_path = os.pathsep.join(vs_runtime_dll_dirs) - os.environ['PATH'] = runtime_path + os.pathsep + os.environ['PATH'] - - # Set up the architecture-specific environment from the SetEnv files. See - # _LoadToolchainEnv() from setup_toolchain.py in Chromium. - assert cpu in ('x86', 'x64', 'arm', 'arm64') - with open(os.path.join(sdk_dir, 'bin', 'SetEnv.%s.json' % cpu)) as f: - env = json.load(f)['env'] - if env['VSINSTALLDIR'] == [["..", "..\\"]]: - # Old-style paths were relative to the win_sdk\bin directory. - json_relative_dir = os.path.join(sdk_dir, 'bin') - else: - # New-style paths are relative to the toolchain directory. - json_relative_dir = toolchain_data['path'] - for k in env: - entries = [os.path.join(*([json_relative_dir] + e)) for e in env[k]] - # clang-cl wants INCLUDE to be ;-separated even on non-Windows, - # lld-link wants LIB to be ;-separated even on non-Windows. Path gets :. - sep = os.pathsep if k == 'PATH' else ';' - env[k] = sep.join(entries) - # PATH is a bit of a special case, it's in addition to the current PATH. - env['PATH'] = env['PATH'] + os.pathsep + os.environ['PATH'] - - for k, v in env.items(): - os.environ[k] = v - - -def FindDepotTools(): - """Returns the path to depot_tools in $PATH.""" - for path in os.environ['PATH'].split(os.pathsep): - if os.path.isfile(os.path.join(path, 'gclient.py')): - return path - raise Exception("depot_tools not found!") - - -def _GetDesiredVsToolchainHashes(version): - """Load a list of SHA1s corresponding to the toolchains that we want installed - to build with.""" - if version == '2015': - # Update 3 final with 10.0.15063.468 SDK and no vctip.exe. - return ['f53e4598951162bad6330f7a167486c7ae5db1e5'] - if version == '2017': - # VS 2017 Update 9 (15.9.12) with 10.0.18362 SDK, 10.0.17763 version of - # Debuggers, and 10.0.17134 version of d3dcompiler_47.dll, with ARM64 - # libraries. - return ['418b3076791776573a815eb298c8aa590307af63'] - if version == '2019': - # VS 2019 16.61 with 10.0.20348.0 SDK, 10.0.22621.755 version of Debuggers, - # with ARM64 libraries and UWP support. - return ['0b5ee4d2b1'] - if version == '2022': - # VS 2022 17.4 with 10.0.22621.0 SDK with ARM64 libraries and UWP support. - return ['27370823e7'] - raise Exception('Unsupported VS version %s' % version) - - -def Update(version): - """Requests an update of the toolchain to the specific hashes we have at - this revision. The update outputs a .json of the various configuration - information required to pass to vs_env.py which we use in - |SetEnvironmentForCPU()|. - """ - depot_tools_path = FindDepotTools() - get_toolchain_args = [ - sys.executable, - os.path.join(depot_tools_path, - 'win_toolchain', - 'get_toolchain_if_necessary.py'), - '--output-json', json_data_file, - ] + _GetDesiredVsToolchainHashes(version) - subprocess.check_call(get_toolchain_args) - return 0 - - -def main(): - if not sys.platform.startswith(('win32', 'cygwin')): - return 0 - commands = { - 'update': Update, - } - if len(sys.argv) < 2 or sys.argv[1] not in commands: - print('Expected one of: %s' % ', '.join(commands), file=sys.stderr) - return 1 - return commands[sys.argv[1]](*sys.argv[2:]) - - -if __name__ == '__main__': - sys.exit(main())