From 1a1319d7130e7604e4da84fa5eb58cdf55325dae Mon Sep 17 00:00:00 2001 From: Carmelo Messina Date: Mon, 7 Aug 2023 15:05:50 +0200 Subject: [PATCH] Allow the download of clang for windows crossbuild download prebuild rc (linux version) from google storage --- build/bromite_patches_list.txt | 3 +- ...load-of-clang-for-windows-crossbuild.patch | 72 +++++++++++++++++++ tools/images/bromite-build/pre-start.sh | 11 +++ tools/images/chr-source/prepare-build.sh | 13 ---- 4 files changed, 85 insertions(+), 14 deletions(-) create mode 100644 build/patches/00allow-the-download-of-clang-for-windows-crossbuild.patch diff --git a/build/bromite_patches_list.txt b/build/bromite_patches_list.txt index 1e62097e..80e08522 100644 --- a/build/bromite_patches_list.txt +++ b/build/bromite_patches_list.txt @@ -282,4 +282,5 @@ Timezone-customization.patch 00Disable-Feeback-Collector.patch 00Disable-remote-altsvc-for-h3-connections.patch 00do-not-block-build-incompatible-profiles.patch -00Allow-DocumentPiP-if-PopupsAndRedirects-are-active.patch \ No newline at end of file +00Allow-DocumentPiP-if-PopupsAndRedirects-are-active.patch +00allow-the-download-of-clang-for-windows-crossbuild.patch \ No newline at end of file diff --git a/build/patches/00allow-the-download-of-clang-for-windows-crossbuild.patch b/build/patches/00allow-the-download-of-clang-for-windows-crossbuild.patch new file mode 100644 index 00000000..063d402a --- /dev/null +++ b/build/patches/00allow-the-download-of-clang-for-windows-crossbuild.patch @@ -0,0 +1,72 @@ +From: uazo +Date: Mon, 7 Aug 2023 11:05:03 +0000 +Subject: allow the download of clang for windows crossbuild + +In the linux2win crossbuild some libraries are not checkout by default +and launching tools/clang/scripts/update.py deletes by default the +previous package. +this patch bypasses the output directory deletion, allowing the windows +toolchain to be downloaded on top of the android one +--- + tools/clang/scripts/update.py | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/tools/clang/scripts/update.py b/tools/clang/scripts/update.py +--- a/tools/clang/scripts/update.py ++++ b/tools/clang/scripts/update.py +@@ -12,6 +12,8 @@ near-tip-of-tree clang version: + $ curl -s https://raw.githubusercontent.com/chromium/chromium/main/tools/clang/scripts/update.py | python3 - --output-dir=/tmp/clang + + (Note that the output dir may be deleted and re-created if it exists.) ++ ++exec: tools/clang/scripts/update.py --package=clang --host-os=win --no-clear=true + """ + + import sys +@@ -237,7 +239,7 @@ def DownloadAndUnpackClangWinRuntime(output_dir): + sys.exit(1) + + +-def UpdatePackage(package_name, host_os, dir=LLVM_BUILD_DIR): ++def UpdatePackage(package_name, host_os, no_clear, dir=LLVM_BUILD_DIR): + stamp_file = None + package_file = None + +@@ -269,6 +271,8 @@ def UpdatePackage(package_name, host_os, dir=LLVM_BUILD_DIR): + target_os = env.get('target_os', target_os) + except: + pass ++ if host_os != "": ++ target_os = [ host_os ] + + if os.path.exists(OLD_STAMP_FILE): + # Delete the old stamp file so it doesn't look like an old version of clang +@@ -282,7 +286,7 @@ def UpdatePackage(package_name, host_os, dir=LLVM_BUILD_DIR): + + # Updating the main clang package nukes the output dir. Any other packages + # need to be updated *after* the clang package. +- if package_name == 'clang' and os.path.exists(dir): ++ if not no_clear and (package_name == 'clang' and os.path.exists(dir)): + RmTree(dir) + + DownloadAndUnpackPackage(package_file, dir, host_os) +@@ -332,6 +336,8 @@ def main(): + 'and exit.')) + parser.add_argument('--verify-version', + help='Verify that clang has the passed-in version.') ++ parser.add_argument('--no-clear', ++ help='Do not remove old file before extracting.') + args = parser.parse_args() + + if args.verify_version and args.verify_version != RELEASE_VERSION: +@@ -373,7 +379,7 @@ def main(): + print('--llvm-force-head-revision can only be used for --print-revision') + return 1 + +- return UpdatePackage(args.package, args.host_os, output_dir) ++ return UpdatePackage(args.package, args.host_os, args.no_clear, output_dir) + + + if __name__ == '__main__': +-- +2.25.1 diff --git a/tools/images/bromite-build/pre-start.sh b/tools/images/bromite-build/pre-start.sh index 8d7cded4..1ad6c15e 100644 --- a/tools/images/bromite-build/pre-start.sh +++ b/tools/images/bromite-build/pre-start.sh @@ -65,3 +65,14 @@ cd $WORKSPACE/ wget https://github.com/clangd/clangd/releases/download/snapshot_20211205/clangd_indexing_tools-linux-snapshot_20211205.zip unzip clangd_indexing_tools-linux-snapshot_20211205.zip rm clangd_indexing_tools-linux-snapshot_20211205.zip + +echo -e ${RED} -------- download rc ${NC} +cd $WORKSPACE/chromium/src +third_party/depot_tools/download_from_google_storage.py \ + --no_resume --no_auth \ + --bucket chromium-browser-clang/rc \ + -s build/toolchain/win/rc/linux64/rc.sha1 + +echo -e ${RED} -------- download win clang prebuilds ${NC} +cd $WORKSPACE/chromium/src +tools/clang/scripts/update.py --package=clang --host-os=win --no-clear=true \ No newline at end of file diff --git a/tools/images/chr-source/prepare-build.sh b/tools/images/chr-source/prepare-build.sh index 7e7fd6aa..437a2673 100644 --- a/tools/images/chr-source/prepare-build.sh +++ b/tools/images/chr-source/prepare-build.sh @@ -73,16 +73,3 @@ gclient runhooks echo -e ${RED} -------- download objdump ${NC} tools/clang/scripts/update.py --package=objdump - -echo -e ${RED} -------- download rc ${NC} -cd build/toolchain/win/rc -git clone -q https://github.com/nico/hack -cd hack/res - -../../../../../../third_party/llvm-build/Release+Asserts/bin/clang++ \ - -std=c++14 rc.cc -Wall \ - -Wno-c++11-narrowing -O2 -fno-rtti -fno-exceptions -DNDEBUG \ - -o rc-linux64 -fuse-ld=lld -target x86_64-unknown-linux-gnu -cd ../../../../../../ -cp build/toolchain/win/rc/hack/res/rc-linux64 build/toolchain/win/rc/linux64/rc -