platform_build_soong/cmd/soong_build/Android.bp

37 lines
1 KiB
Text
Raw Normal View History

// Copyright 2015 Google Inc. All rights reserved.
//
// 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.
Add LOCAL_LICENSE_KINDS to build/soong Added SPDX-license-identifier-Apache-2.0 to: Android.bp android/Android.bp android/soongconfig/Android.bp androidmk/Android.bp apex/Android.bp bazel/Android.bp bp2build/Android.bp bpf/Android.bp bpfix/Android.bp cc/Android.bp cc/config/Android.bp cc/libbuildversion/Android.bp cc/libbuildversion/tests/Android.bp cc/ndk_api_coverage_parser/Android.bp cc/ndkstubgen/Android.bp cc/symbolfile/Android.bp cmd/dep_fixer/Android.bp cmd/diff_target_files/Android.bp cmd/extract_apks/Android.bp cmd/extract_jar_packages/Android.bp cmd/extract_linker/Android.bp cmd/fileslist/Android.bp cmd/host_bionic_inject/Android.bp cmd/javac_wrapper/Android.bp cmd/merge_zips/Android.bp cmd/multiproduct_kati/Android.bp cmd/path_interposer/Android.bp cmd/pom2bp/Android.bp cmd/pom2mk/Android.bp cmd/sbox/Android.bp cmd/soong_build/Android.bp cmd/soong_env/Android.bp cmd/soong_ui/Android.bp cmd/zip2zip/Android.bp cmd/zipsync/Android.bp cuj/Android.bp dexpreopt/Android.bp dexpreopt/dexpreopt_gen/Android.bp env/Android.bp etc/Android.bp filesystem/Android.bp finder/Android.bp finder/cmd/Android.bp genrule/Android.bp jar/Android.bp java/Android.bp java/config/Android.bp kernel/Android.bp linkerconfig/Android.bp linkerconfig/proto/Android.bp makedeps/Android.bp partner/Android.bp phony/Android.bp python/Android.bp python/tests/Android.bp remoteexec/Android.bp rust/Android.bp rust/config/Android.bp scripts/Android.bp sdk/Android.bp sh/Android.bp shared/Android.bp symbol_inject/Android.bp symbol_inject/cmd/Android.bp sysprop/Android.bp tradefed/Android.bp ui/build/Android.bp ui/logger/Android.bp ui/metrics/Android.bp ui/metrics/proc/Android.bp ui/status/Android.bp ui/terminal/Android.bp ui/tracer/Android.bp xml/Android.bp zip/Android.bp zip/cmd/Android.bp Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD to: finder/fs/Android.bp third_party/zip/Android.bp Bug: 68860345 Bug: 151177513 Bug: 151953481 Test: m all Exempt-From-Owner-Approval: janitorial work Change-Id: Ia47ca14f16b8c9f84f9d533a07e5b00e2c04e8d4
2021-02-04 03:08:28 +01:00
package {
default_applicable_licenses: ["Android-Apache-2.0"],
}
blueprint_go_binary {
name: "soong_build",
deps: [
"blueprint",
"blueprint-bootstrap",
"golang-protobuf-proto",
"soong",
"soong-android",
"soong-bp2build",
"soong-ui-metrics_proto",
],
srcs: [
"main.go",
"writedocs.go",
"queryview.go",
Surface module properties as Bazel BUILD target attributes in the Bazel overlay This patchset changes bazel_overlay to generate soong_module as a macro, instead of a rule, and generate module properties in the BUILD files as kwargs to the soong_module macro. Here's a sample of the new BUILD files with module properties: bionic/libdl/BUILD.bazel: https://paste.googleplex.com/6484466996346880?raw art/build/apex/BUILD.bazel: https://paste.googleplex.com/5461276001042432?raw bionic/apex/BUILD.bazel: https://paste.googleplex.com/4932795173437440?raw soong_module is now a macro that conditionally expands to underlying soong_<module type> rules with statically defined attributes. In this CL, we are starting with a hardcoded filegroup rule definition to demonstrate the conditional rule loading within the soong_module macro. If the module_type matches an existing Bazel rule, soong_module forwards the entire **kwargs into the rule, which Bazel typechecks. Non-filegroup module types will be expanded into generic_soong_module, but with the kwargs dropped. This approach allows us to: 1) Programmtically generate soong_<module type> rules for all module types available in Soong, together with the statically defined attribute types in `attrs`. 2) Incrementally migrate and test individual module types from generic_soong_module to their module rule shims. 3) Swap out the module rule shims to the actual Bazel rules (e.g cc_library, java_library) and perform attribute manipulation in Starlark itself. Example of querying against the 'srcs' attribute in soong_filegroup: ``` $ bazel cquery 'kind(soong_filegroup, //...)' | wc -l 590 $ bazel cquery --output=build 'attr(srcs, "linker.cpp", kind(soong_filegroup, //bionic/...))' INFO: Analyzed 3907 targets (0 packages loaded, 0 targets configured). INFO: Found 3907 targets... /usr/local/google/home/jingwen/aosp/out/soong/bazel_overlay/bionic/linker/BUILD.bazel:4144:13 soong_filegroup( name = "linker_sources", generator_name = "linker_sources", generator_function = "soong_module", generator_location = "bionic/linker/BUILD.bazel:4144:13", srcs = ["dlfcn.cpp", "linker.cpp", "linker_block_allocator.cpp", "linker_dlwarning.cpp", "linker_cfi.cpp", "linker_config.cpp", "linker_debug.cpp", "linker_gdb_support.cpp", "linker_globals.cpp", "linker_libc_support.c", "linker_libcxx_support.cpp", "linker_namespaces.cpp", "linker_logger.cpp", "linker_mapped_file_fragment.cpp", "linker_phdr.cpp", "linker_relocate.cpp", "linker_sdk_versions.cpp", "linker_soinfo.cpp", "linker_tls.cpp", "linker_utils.cpp", "rt.cpp"], deps = [], ) /usr/local/google/home/jingwen/aosp/out/soong/bazel_overlay/soong_module.bzl:32:23 in <toplevel> ``` This CL is known to be lacking the following features, and will be looked at in follow up CLs: 1) Pretty printing reflect.Interface properties, like arch, multilib and dists. 2) Generating module Bazel rule shims for all module types, instead of hardcoding them like `soong_filegroup`. Bug: 162720644 Test: bazel_overlay_test.go (soong build test) Test: m bazel_overlay && cd out/soong/bazel_overlay && bazel cquery //... Signed-off-by: Jingwen Chen <jingwen@google.com> Change-Id: Ic1e448887eb540ed15a55bc4090cf75a4d832d41
2020-08-07 16:16:34 +02:00
],
primaryBuilder: true,
}