Merge changes I1c5f06d2,Ib9d74e11,I628cb0ad
* changes:
Add type of unconverteds to bp2build-progress
Handle filegroups differently in bp2build-progress
bp2build-progress: collect type for blueprint mods
diff --git a/bazel.WORKSPACE b/bazel.WORKSPACE
index fc03df7..a5373e4 100644
--- a/bazel.WORKSPACE
+++ b/bazel.WORKSPACE
@@ -37,6 +37,10 @@
"com.android.adbd": ["system/apex/com.android.adbd.apex"],
"build.bazel.examples.apex.minimal": ["system/product/apex/build.bazel.examples.apex.minimal.apex"],
},
+ watch_android_bp_files = [
+ "//:build/bazel/examples/apex/minimal/Android.bp", # for build.bazel.examples.apex.minimal
+ # TODO(b/210399979) - add the other .bp files to watch for the other modules built in these rule
+ ],
)
local_repository(
diff --git a/ci/bp2build.sh b/ci/bp2build.sh
index 1718a4f..42cc0f1 100755
--- a/ci/bp2build.sh
+++ b/ci/bp2build.sh
@@ -91,4 +91,4 @@
done
# Dist the entire workspace of generated BUILD files, rooted from out/soong/bp2build.
-tar -czvf "${DIST_DIR}/bp2build_generated_workspace.tar.gz" -C out/soong/bp2build .
+tar -czf "${DIST_DIR}/bp2build_generated_workspace.tar.gz" -C out/soong/bp2build .
diff --git a/examples/apex/minimal/Android.bp b/examples/apex/minimal/Android.bp
index c32e116..7f96acd 100644
--- a/examples/apex/minimal/Android.bp
+++ b/examples/apex/minimal/Android.bp
@@ -74,6 +74,17 @@
src: "dummy_prebuilt_etc_data_3",
}
+cc_binary {
+ name: "build.bazel.examples.apex.cc_binary",
+ srcs: ["main.cc"],
+
+ apex_available: ["build.bazel.examples.apex.minimal"],
+
+ // Because the APEX sets these
+ product_specific: true,
+ min_sdk_version: "30",
+}
+
apex {
name: "build.bazel.examples.apex.minimal",
manifest: "manifest.json",
@@ -94,4 +105,8 @@
"build.bazel.examples.apex.minimal_dummy_unnamed_prebuilt_etc",
"build.bazel.examples.apex.minimal_dummy_prebuilt_etc_without_subdir",
],
+
+ binaries: [
+ "build.bazel.examples.apex.cc_binary",
+ ],
}
diff --git a/examples/apex/minimal/main.cc b/examples/apex/minimal/main.cc
new file mode 100644
index 0000000..76e8197
--- /dev/null
+++ b/examples/apex/minimal/main.cc
@@ -0,0 +1 @@
+int main() { return 0; }
diff --git a/mk2rbc/apply_scripted_change.sh b/mk2rbc/apply_scripted_change.sh
new file mode 100755
index 0000000..06554c6
--- /dev/null
+++ b/mk2rbc/apply_scripted_change.sh
@@ -0,0 +1,46 @@
+#! /bin/bash
+# Run given scripted change and commit the changes.
+#
+# Assumes that the current directory is the top-level directory of
+# the Android source code, created with 'repo init', and that 'repo'
+# tool is on the path.
+# For each of the given repo git repositories:
+# 1. Checks there are neither modified not untracked files in it.
+# 2. Runs the given script, which is supposed to change some files
+# 3. Creates a development branch if necessary
+# 4. Commits changed files. The commit message is extracted from the
+# script and contains all the lines in it starting with ##CL
+#
+# As an example, running
+# build/bazel/mk2rbc/apply_scripted_change.sh build/bazel/mk2rbc/replace_is_board_platform.sh hardware/qcom/media
+# replaces the old is-board-platform calls with the new is-board-platform2 calls.
+
+set -eu
+
+function die() { format=$1; shift; printf "$format\n" $@; exit 1; }
+function usage() { die "Usage: %s script git-repo ..." ${0##*/}; }
+
+(($#>=2)) || usage
+declare -r script=$(realpath $1); shift
+rc=0
+
+[[ -x $script ]] || die "%s is not an executable script" $script
+[[ -d .repo ]] || die "$PWD is not an Android source tree (.repo/ is missing)"
+declare -r bugid="$(sed -nr 's/^##CL (Bug:|Fixes:) +([0-9]+)$/\2/p' $script)"
+[[ -n "$bugid" ]] || die "$script contains neither '##CL Bug: ' nor '##CL Fixes: 'tag"
+
+
+for gr in $@; do
+ [[ -d $gr/.git ]] || { echo $gr is not a Git directory; rc=1; continue; }
+ out=$(git -C $gr status --porcelain --untracked-files=no) || { die "so skipping $gr because of the above"; rc=1; continue; }
+ [[ -z "$out" ]] || { echo $gr contains uncommitted changes:; echo "$out" >&2; rc=1; continue; }
+ (cd $gr && $script)
+ modified="$(git -C $gr status --porcelain | sed -nr 's/^ M (.*)/\1/p')"
+ [[ -n "$modified" ]] || { echo no files changed in $gr; continue; }
+ [[ -z "$(repo status -q $gr 2>/dev/null)" ]] || repo start b$bugid $gr
+ git -C $gr add $modified
+ git -C $gr commit -q \
+ -F <(sed -nr 's/^##CL *//p' $script; echo -e '\nThis change has been generated by the following script:\n\n```'; grep -vP '^##CL' $script; echo '```')
+done
+
+exit $rc
diff --git a/mk2rbc/replace_dynamic_qcpath.sh b/mk2rbc/replace_dynamic_qcpath.sh
new file mode 100755
index 0000000..e1e743f
--- /dev/null
+++ b/mk2rbc/replace_dynamic_qcpath.sh
@@ -0,0 +1,11 @@
+#! /bin/bash
+##CL Provide location hint for the dynamically calculated paths.
+##CL
+##CL For the paths using QC_PROP_PATH or QC_PROP_ROOT
+##CL Bug: 203582721
+##CL Test: treehugger
+declare -r files="$(grep -rlP '^ *(\$\(call inherit-product|-?include).*\$\(QC_PROP_(PATH|ROOT)\)' --include 'BoardConfig*.mk')"
+[[ -z "$files" ]] || sed -i -r -f <(cat <<"EOF"
+/^ *(\$\(call inherit-product|-?include).*\$\(QC_PROP_(PATH|ROOT)\)/i#RBC# include_top vendor/qcom
+EOF
+) $files
diff --git a/mk2rbc/replace_is_board_platform.sh b/mk2rbc/replace_is_board_platform.sh
new file mode 100755
index 0000000..d83d811
--- /dev/null
+++ b/mk2rbc/replace_is_board_platform.sh
@@ -0,0 +1,17 @@
+#! /bin/bash
+##CL Replace is-board-platform[-in-list] with is-board-platform[-in-list]2
+##CL
+##CL Bug: 201477826
+##CL Test: treehugger
+declare -r files="$(grep -rlP '^[^#]*call +is-board-platform' --include '*.mk' --exclude 'utils_test.mk' --exclude 'utils_sample_usage.mk')"
+[[ -z "$files" ]] || sed -i -r -f <(cat <<"EOF"
+s/ifeq +\(\$\(call is-board-platform,(.*)\), *true\)/ifneq (,$(call is-board-platform2,\1))/
+s/ifeq +\(\$\(call is-board-platform,(.*)\), *\)/ifeq (,$(call is-board-platform2,\1))/
+s/ifneq +\(\$\(call is-board-platform,(.*)\), *true\)/ifeq (,$(call is-board-platform2,\1))/
+s/ifeq +\(\$\(call is-board-platform-in-list,(.*)\), *true\)/ifneq (,$(call is-board-platform-in-list2,\1))/
+s/ifeq +\(\$\(call is-board-platform-in-list,(.*)\), *\)/ifeq (,$(call is-board-platform-in-list2,\1))/
+s/ifeq +\(\$\(call is-board-platform-in-list,(.*)\), *false\)/ifeq (,T) # TODO: remove useless check/
+s/ifneq +\(\$\(call is-board-platform-in-list,(.*)\), *true\)/ifeq (,$(call is-board-platform-in-list2,\1))/
+s/\$\(call is-board-platform,(.*)\)/$(call is-board-platform2,\1)/
+EOF
+) $files
diff --git a/mk2rbc/replace_is_platform_sdk_version_at_least.sh b/mk2rbc/replace_is_platform_sdk_version_at_least.sh
new file mode 100755
index 0000000..4f4d4c8
--- /dev/null
+++ b/mk2rbc/replace_is_platform_sdk_version_at_least.sh
@@ -0,0 +1,16 @@
+#! /bin/bash
+##CL Replace is-platform-sdk-version-at-least calls with checking IS_AT_LEAST_xxx.
+##CL
+##CL Bug: 201477826
+##CL Test: treehugger
+declare -r files="$(grep -rlP '^[^#]*call +is-platform-sdk-version-at-least' --include '*.mk')"
+[[ -z "$files" ]] || sed -i -r -f <(cat <<"EOF"
+s/^([^#]*ifn?eq) +\(\$\(call is-platform-sdk-version-at-least, *(16|17|18|19|20|21|22|23|24|25)\), *true\)/\1 \(T,T\) \# TODO: Obsolete, please remove/
+s/^([^#]*)if(n?)eq +\(\$\(call is-platform-sdk-version-at-least, *26\), *true\)/\1if\2def IS_AT_LEAST_OPR1/
+s/^([^#]*)if(n?)eq +\(\$\(call is-platform-sdk-version-at-least, *27\), *true\)/\1if\2def IS_AT_LEAST_OPM1/
+s/^([^#]*)if(n?)eq +\(\$\(call is-platform-sdk-version-at-least, *28\), *true\)/\1if\2def IS_AT_LEAST_PPR1/
+s/^([^#]*)if(n?)eq +\(\$\(call is-platform-sdk-version-at-least, *29\), *true\)/\1if\2def IS_AT_LEAST_QP1A/
+s/^([^#]*)if(n?)eq +\(\$\(call is-platform-sdk-version-at-least, *30\), *true\)/\1if\2def IS_AT_LEAST_RP1A/
+s/^([^#]*)if(n?)eq +\(\$\(call is-platform-sdk-version-at-least, *31\), *true\)/\1if\2def IS_AT_LEAST_SP1A/
+EOF
+) $files
diff --git a/mk2rbc/replace_is_vendor_board_platform.sh b/mk2rbc/replace_is_vendor_board_platform.sh
new file mode 100755
index 0000000..ea15e8d
--- /dev/null
+++ b/mk2rbc/replace_is_vendor_board_platform.sh
@@ -0,0 +1,11 @@
+#! /bin/bash
+##CL Replace is-vendor-board-platform with is-vendor-board-qcom.
+##CL
+##CL Bug: 201477826
+##CL Test: treehugger
+declare -r files="$(grep -rlP '^[^#]*call +is-vendor-board-platform' --include '*.mk')"
+[[ -z "$files" ]] || sed -i -r -f <(cat <<"EOF"
+s/ifeq \(\$\(call is-vendor-board-platform,QCOM\),true\)/ifneq (,$(call is-vendor-board-qcom))/
+s/ifneq \(\$\(call is-vendor-board-platform,QCOM\),true\)/ifeq (,$(call is-vendor-board-qcom))/
+EOF
+) $files
diff --git a/rules/apex.bzl b/rules/apex.bzl
index a8822e8..21db21c 100644
--- a/rules/apex.bzl
+++ b/rules/apex.bzl
@@ -17,6 +17,7 @@
load(":apex_key.bzl", "ApexKeyInfo")
load(":prebuilt_etc.bzl", "PrebuiltEtcInfo")
load(":sh_binary.bzl", "ShBinaryInfo")
+load(":stripped_cc_common.bzl", "StrippedCcBinaryInfo")
load(":android_app_certificate.bzl", "AndroidAppCertificateInfo")
load("//build/bazel/rules/apex:transition.bzl", "apex_transition")
load("//build/bazel/rules/apex:cc.bzl", "ApexCcInfo", "apex_cc_aspect")
@@ -60,20 +61,24 @@
# Handle binaries
for dep in ctx.attr.binaries:
- # TODO: Support more binaries than just sh_binary
- sh_binary_info = dep[ShBinaryInfo]
- default_info = dep[DefaultInfo]
- if sh_binary_info != None:
- directory = "bin"
- if sh_binary_info.sub_dir != None and sh_binary_info.sub_dir != "":
- directory = "/".join([directory, sh_binary_info.sub_dir])
+ if ShBinaryInfo in dep:
+ # sh_binary requires special handling on directory/filename construction.
+ sh_binary_info = dep[ShBinaryInfo]
+ default_info = dep[DefaultInfo]
+ if sh_binary_info != None:
+ directory = "bin"
+ if sh_binary_info.sub_dir != None and sh_binary_info.sub_dir != "":
+ directory = "/".join([directory, sh_binary_info.sub_dir])
- if sh_binary_info.filename != None and sh_binary_info.filename != "":
- filename = sh_binary_info.filename
- else:
- filename = dep.label.name
+ if sh_binary_info.filename != None and sh_binary_info.filename != "":
+ filename = sh_binary_info.filename
+ else:
+ filename = dep.label.name
- apex_manifest[(directory, filename)] = default_info.files_to_run.executable
+ apex_manifest[(directory, filename)] = default_info.files_to_run.executable
+ elif CcInfo in dep:
+ # cc_binary just takes the final executable from the runfiles.
+ apex_manifest[("bin", dep.label.name)] = dep[DefaultInfo].files_to_run.executable
apex_content_inputs = []
@@ -191,8 +196,19 @@
"min_sdk_version": attr.string(),
"updatable": attr.bool(default = True),
"installable": attr.bool(default = True),
- "native_shared_libs": attr.label_list(providers = [ApexCcInfo], aspects = [apex_cc_aspect], cfg = apex_transition),
- "binaries": attr.label_list(providers = [ShBinaryInfo], cfg = apex_transition),
+ "native_shared_libs": attr.label_list(
+ providers = [ApexCcInfo],
+ aspects = [apex_cc_aspect],
+ cfg = apex_transition
+ ),
+ "binaries": attr.label_list(
+ providers = [
+ # The dependency must produce _all_ of the providers in _one_ of these lists.
+ [ShBinaryInfo], # sh_binary
+ [StrippedCcBinaryInfo, CcInfo], # cc_binary (stripped)
+ ],
+ cfg = apex_transition
+ ),
"prebuilts": attr.label_list(providers = [PrebuiltEtcInfo], cfg = apex_transition),
# Required to use apex_transition. This is an acknowledgement to the risks of memory bloat when using transitions.
"_allowlist_function_transition": attr.label(default = "@bazel_tools//tools/allowlists/function_transition_allowlist"),
diff --git a/rules/cc_library_shared.bzl b/rules/cc_library_shared.bzl
index 85e8254..8780e6e 100644
--- a/rules/cc_library_shared.bzl
+++ b/rules/cc_library_shared.bzl
@@ -51,7 +51,7 @@
local_includes = [],
absolute_includes = [],
rtti = False,
- use_libcrt = True,
+ use_libcrt = True, # FIXME: Unused below?
stl = "",
cpp_std = "",
c_std = "",
@@ -64,9 +64,15 @@
# TODO(b/202299295): Handle data attribute.
data = [],
+
+ use_version_lib = False,
**kwargs):
"Bazel macro to correspond with the cc_library_shared Soong module."
+ if use_version_lib:
+ libbuildversionLabel = "//build/soong/cc/libbuildversion:libbuildversion"
+ whole_archive_deps = whole_archive_deps + [libbuildversionLabel]
+
shared_root_name = name + "_root"
unstripped_name = name + "_unstripped"
stripped_name = name + "_stripped"
@@ -107,6 +113,7 @@
system_dynamic_deps = system_dynamic_deps,
deps = deps + whole_archive_deps,
features = features,
+ use_version_lib = use_version_lib,
)
stl_static, stl_shared = shared_stl_deps(stl)
diff --git a/rules/cc_library_static.bzl b/rules/cc_library_static.bzl
index 91d445f..50894d4 100644
--- a/rules/cc_library_static.bzl
+++ b/rules/cc_library_static.bzl
@@ -58,8 +58,10 @@
alwayslink = None,
target_compatible_with = [],
# TODO(b/202299295): Handle data attribute.
- data = []):
+ data = [],
+ use_version_lib = False):
"Bazel macro to correspond with the cc_library_static Soong module."
+
exports_name = "%s_exports" % name
locals_name = "%s_locals" % name
cpp_name = "%s_cpp" % name
@@ -69,6 +71,10 @@
toolchain_features = []
toolchain_features += features
+ if use_version_lib:
+ libbuildversionLabel = "//build/soong/cc/libbuildversion:libbuildversion"
+ whole_archive_deps = whole_archive_deps + [libbuildversionLabel]
+
if rtti:
toolchain_features += ["rtti"]
if not use_libcrt:
diff --git a/rules/make_injection.bzl b/rules/make_injection.bzl
index 7a4dba8..79d42f4 100644
--- a/rules/make_injection.bzl
+++ b/rules/make_injection.bzl
@@ -74,5 +74,7 @@
attrs = {
"binaries": attr.string_list(default = [], doc = "A list of host binary modules built for linux-x86."),
"target_module_files": attr.string_list_dict(default = {}, doc = "A dict of modules to the target files that should be exported."),
+ # See b/210399979
+ "watch_android_bp_files": attr.label_list(allow_files = [".bp"], default = [], doc = "A list of Android.bp files to watch for changes to invalidate this repository rule."),
},
)
diff --git a/rules/stripped_cc_common.bzl b/rules/stripped_cc_common.bzl
index c3038a3..aae334f 100644
--- a/rules/stripped_cc_common.bzl
+++ b/rules/stripped_cc_common.bzl
@@ -156,12 +156,17 @@
toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
)
+# A marker provider to distinguish a cc_binary from everything else that exports
+# a CcInfo.
+StrippedCcBinaryInfo = provider()
+
def _stripped_binary_impl(ctx):
- commonProviders = [
+ common_providers = [
ctx.attr.src[CcInfo],
ctx.attr.src[InstrumentedFilesInfo],
ctx.attr.src[DebugPackageInfo],
ctx.attr.src[OutputGroupInfo],
+ StrippedCcBinaryInfo(), # a marker for dependents
]
out_file = _stripped_impl(ctx)
@@ -170,8 +175,8 @@
DefaultInfo(
files = depset([out_file]),
executable = out_file,
- ),
- ] + commonProviders
+ ),
+ ] + common_providers
stripped_binary = rule(
implementation = _stripped_binary_impl,
diff --git a/tests/apex/expected_build.bazel.examples.apex.minimal b/tests/apex/expected_build.bazel.examples.apex.minimal
index 7b9d9c2..bc4435d 100644
--- a/tests/apex/expected_build.bazel.examples.apex.minimal
+++ b/tests/apex/expected_build.bazel.examples.apex.minimal
@@ -1,6 +1,6 @@
-5d4
+6d5
< ./lib/arm/build.bazel.examples.apex.minimal_dummy_cc_lib.so
-7c6
+8c7
< ./lib64/build.bazel.examples.apex.minimal_dummy_cc_lib.so
---
> ./lib/libc++.so