aboutsummaryrefslogtreecommitdiff
path: root/bazel.WORKSPACE
blob: d0fe5d7b968db51102669580a7f642fd89fb38b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# This repository provides files that Soong emits during bp2build (other than
# converted BUILD files), mostly .bzl files containing constants to support the
# converted BUILD files.
load("//build/bazel/rules:soong_injection.bzl", "soong_injection_repository")

soong_injection_repository(name = "soong_injection")

# ! WARNING ! WARNING ! WARNING !
# make_injection is a repository rule to allow Bazel builds to depend on
# Soong-built prebuilts for experimental purposes. It is fragile, slow, and
# works for very limited use cases. Do not add a dependency that will cause
# make_injection to run for any prod builds or tests.
#
# If you need to add something in this list, please contact the Roboleaf
# team and ask jingwen@ for a review.
load("//build/bazel/rules:make_injection.bzl", "make_injection_repository")

make_injection_repository(
    name = "make_injection",
    binaries = [
        "build_image",
        "mkuserimg_mke2fs",
    ],
    target_module_files = {},
    watch_android_bp_files = [
        "//:build/make/tools/releasetools/Android.bp",  # for build_image
        "//:system/extras/ext4_utils/Android.bp",  # for mkuserimg_mke2fs
    ],
)
# ! WARNING ! WARNING ! WARNING !

load("//build/bazel/rules:env.bzl", "env_repository")

env_repository(
    name = "env",
)

# This repository is a containter for API surface stub libraries.
load("//build/bazel/rules:api_surfaces_injection.bzl", "api_surfaces_repository")

# TODO: Once BUILD files for stubs are checked-in, this should be converted to a local_repository.
api_surfaces_repository(name = "api_surfaces")

load("//build/bazel_common_rules/workspace:external.bzl", "import_external_repositories")

import_external_repositories(
    bazel_skylib = True,
    io_abseil_py = True,
)

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()

local_repository(
    name = "rules_android",
    path = "external/bazelbuild-rules_android",
)

local_repository(
    name = "rules_license",
    path = "external/bazelbuild-rules_license",
)

register_toolchains(
    "//prebuilts/build-tools:py_toolchain",

    # For Android rules
    "//prebuilts/sdk:all",

    # For APEX rules
    "//build/bazel/rules/apex:all",

    # For partition rules
    "//build/bazel/rules/partitions:all",
)

bind(
    name = "databinding_annotation_processor",
    actual = "//prebuilts/sdk:compiler_annotation_processor",
)

bind(
    name = "android/dx_jar_import",
    actual = "//prebuilts/sdk:dx_jar_import",
)

# The r8.jar in prebuilts/r8 happens to have the d8 classes needed
# for Android app building, whereas the d8.jar in prebuilts/sdk/tools doesn't.
bind(
    name = "android/d8_jar_import",
    actual = "//prebuilts/bazel/common/r8:r8_jar_import",
)

# TODO(b/201242197): Avoid downloading remote_coverage_tools (on CI) by creating
# a stub workspace. Test rules (e.g. sh_test) depend on this external dep, but
# we don't support coverage yet. Either vendor the external dep into AOSP, or
# cut the dependency from test rules to the external repo.
local_repository(
    name = "remote_coverage_tools",
    path = "build/bazel_common_rules/rules/coverage/remote_coverage_tools",
)

# Stubbing the local_jdk both ensures that we don't accidentally download remote
# repositories and allows us to let the Kotlin rules continue to access
# @local_jdk//jar.
local_repository(
    name = "local_jdk",
    path = "build/bazel/rules/java/stub_local_jdk",
)

# The following 2 repositories contain prebuilts that are necessary to the Java Rules.
# They are vendored locally to avoid the need for CI bots to download them.
local_repository(
    name = "remote_java_tools",
    path = "prebuilts/bazel/common/remote_java_tools",
)

local_repository(
    name = "remote_java_tools_linux",
    path = "prebuilts/bazel/linux-x86_64/remote_java_tools_linux",
)

# The following repository contains android_tools prebuilts.
local_repository(
    name = "android_tools",
    path = "prebuilts/bazel/common/android_tools",
)

# The rules_java repository is stubbed and points to the native Java rules until
# it can be properly vendored.
local_repository(
    name = "rules_java",
    path = "build/bazel/rules/java/rules_java",
)

register_toolchains(
    "//prebuilts/jdk/jdk17:runtime_toolchain_definition",
    "//build/bazel/rules/java:jdk17_host_toolchain_java_definition",
)

local_repository(
    name = "kotlin_maven_interface",
    path = "build/bazel/rules/kotlin/maven_interface",
)

local_repository(
    name = "rules_kotlin",
    path = "external/bazelbuild-kotlin-rules",
    repo_mapping = {
        "@maven": "@kotlin_maven_interface",
        "@bazel_platforms": "@platforms",
    },
)

new_local_repository(
    name = "kotlinc",
    build_file = "//build/bazel/rules/kotlin:kotlinc.BUILD",
    path = "external/kotlinc",
)

register_toolchains("@rules_kotlin//toolchains/kotlin_jvm:kt_jvm_toolchain")

load("//prebuilts/clang/host/linux-x86:cc_toolchain_config.bzl", "cc_register_toolchains")

cc_register_toolchains()