From 20408f1d5442127d8a41fbac5b007081fde2f497 Mon Sep 17 00:00:00 2001 From: Kirill Timofeev Date: Mon, 23 Dec 2024 17:30:44 +0000 Subject: [PATCH] Download Bazel using 'tools/install-build-deps'. We will use Bazel to build Android SDK in the follow-up CLs, so we want to run in from `tools/bazel`. Tested: ``` tools/install-build-deps --verify tools/install-build-deps --bazel tools/bazel build :all ``` Bug: N/A. Change-Id: Ic3037221d5a7e874a6d2d3e7a77d02d0f1012a5c --- tools/bazel | 23 +++++++++++++++++++++++ tools/install-build-deps | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100755 tools/bazel diff --git a/tools/bazel b/tools/bazel new file mode 100755 index 0000000000..5c618c7ba3 --- /dev/null +++ b/tools/bazel @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 +# Copyright (C) 2024 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import sys + +ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.append(ROOT_DIR) +__package__ = 'tools' +from .run_buildtools_binary import run_buildtools_binary +run_buildtools_binary(['bazel'] + sys.argv[1:]) diff --git a/tools/install-build-deps b/tools/install-build-deps index a555d560e2..a29618bd7c 100755 --- a/tools/install-build-deps +++ b/tools/install-build-deps @@ -330,6 +330,31 @@ BUILD_DEPS_HOST = [ '0ce01e934f95efb6a216a6efa35af1245151c779', 'all', 'all'), ] +# Dependencies required to build code on the host using Bazel build system. +# Only macOS and Linux. +BUILD_DEPS_BAZEL = [ + Dependency( + 'buildtools/mac/bazel', + 'https://github.com/bazelbuild/bazel/releases/download/7.4.1/bazel-7.4.1-darwin-x86_64', + '52dd34c17cc97b3aa5bdfe3d45c4e3938226f23dd0bfb47beedd625a953f1f05', + 'darwin', 'x64'), + Dependency( + 'buildtools/mac/bazel', + 'https://github.com/bazelbuild/bazel/releases/download/7.4.1/bazel-7.4.1-darwin-arm64', + '02b117b97d0921ae4d4f4e11d27e2c0930381df416e373435d5d0419c6a26f24', + 'darwin', 'arm64'), + Dependency( + 'buildtools/linux64/bazel', + 'https://github.com/bazelbuild/bazel/releases/download/7.4.1/bazel-7.4.1-linux-x86_64', + 'c97f02133adce63f0c28678ac1f21d65fa8255c80429b588aeeba8a1fac6202b', + 'linux', 'x64'), + Dependency( + 'buildtools/linux64/bazel', + 'https://github.com/bazelbuild/bazel/releases/download/7.4.1/bazel-7.4.1-linux-arm64', + 'd7aedc8565ed47b6231badb80b09f034e389c5f2b1c2ac2c55406f7c661d8b88', + 'linux', 'arm64'), +] + # Dependencies required to build Android code. # URLs and SHA1s taken from: # - https://dl.google.com/android/repository/repository-11.xml @@ -468,8 +493,8 @@ BUILD_DEPS_LINUX_CROSS_SYSROOTS = [ ] ALL_DEPS = ( - BUILD_DEPS_HOST + BUILD_DEPS_ANDROID + BUILD_DEPS_LINUX_CROSS_SYSROOTS + - TEST_DEPS_ANDROID + UI_DEPS) + BUILD_DEPS_HOST + BUILD_DEPS_BAZEL + BUILD_DEPS_ANDROID + + BUILD_DEPS_LINUX_CROSS_SYSROOTS + TEST_DEPS_ANDROID + UI_DEPS) ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) UI_DIR = os.path.join(ROOT_DIR, 'ui') @@ -675,6 +700,10 @@ def CheckDepotToolsIsRecent(): def Main(): parser = argparse.ArgumentParser() + parser.add_argument( + '--bazel', + action='store_true', + help='Bazel build tool executable to build the project using Bazel') parser.add_argument( '--android', action='store_true', @@ -720,6 +749,8 @@ def Main(): deps = BUILD_DEPS_HOST if not args.no_toolchain: deps += BUILD_DEPS_TOOLCHAIN_HOST + if args.bazel: + deps += BUILD_DEPS_BAZEL if args.android: deps += BUILD_DEPS_ANDROID + TEST_DEPS_ANDROID if args.linux_arm: