Merge "Don't run SoongBuildInvocation for bp2build + dist"
diff --git a/android/arch.go b/android/arch.go
index 3cc5e82..e08fd5c 100644
--- a/android/arch.go
+++ b/android/arch.go
@@ -168,7 +168,7 @@
return archType
}
-// ArchTypeList returns the a slice copy of the 4 supported ArchTypes for arm,
+// ArchTypeList returns a slice copy of the 4 supported ArchTypes for arm,
// arm64, x86 and x86_64.
func ArchTypeList() []ArchType {
return append([]ArchType(nil), archTypeList...)
@@ -408,7 +408,7 @@
// addPathDepsForProps does not descend into sub structs, so we need to descend into the
// arch-specific properties ourselves
- properties := []interface{}{}
+ var properties []interface{}
for _, archProperties := range m.archProperties {
for _, archProps := range archProperties {
archPropValues := reflect.ValueOf(archProps).Elem()
@@ -995,8 +995,11 @@
// Store the original list of top level property structs
base.generalProperties = m.GetProperties()
+ if len(base.archProperties) != 0 {
+ panic(fmt.Errorf("module %s already has archProperties", m.Name()))
+ }
- for _, properties := range base.generalProperties {
+ getStructType := func(properties interface{}) reflect.Type {
propertiesValue := reflect.ValueOf(properties)
t := propertiesValue.Type()
if propertiesValue.Kind() != reflect.Ptr {
@@ -1006,10 +1009,14 @@
propertiesValue = propertiesValue.Elem()
if propertiesValue.Kind() != reflect.Struct {
- panic(fmt.Errorf("properties must be a pointer to a struct, got %T",
+ panic(fmt.Errorf("properties must be a pointer to a struct, got a pointer to %T",
propertiesValue.Interface()))
}
+ return t
+ }
+ for _, properties := range base.generalProperties {
+ t := getStructType(properties)
// Get or create the arch-specific property struct types for this property struct type.
archPropTypes := archPropTypeMap.Once(NewCustomOnceKey(t), func() interface{} {
return createArchPropTypeDesc(t)
diff --git a/android/bazel.go b/android/bazel.go
index 8c63204..51870c3 100644
--- a/android/bazel.go
+++ b/android/bazel.go
@@ -296,6 +296,7 @@
"external/libcxx": Bp2BuildDefaultTrueRecursively,
"external/libcxxabi": Bp2BuildDefaultTrueRecursively,
"external/libevent": Bp2BuildDefaultTrueRecursively,
+ "external/libpng": Bp2BuildDefaultTrueRecursively,
"external/lz4/lib": Bp2BuildDefaultTrue,
"external/lzma/C": Bp2BuildDefaultTrueRecursively,
"external/mdnsresponder": Bp2BuildDefaultTrueRecursively,
@@ -303,9 +304,9 @@
"external/pcre": Bp2BuildDefaultTrueRecursively,
"external/protobuf": Bp2BuildDefaultTrueRecursively,
"external/python/six": Bp2BuildDefaultTrueRecursively,
- "external/selinux/libsepol": Bp2BuildDefaultTrueRecursively,
"external/scudo": Bp2BuildDefaultTrueRecursively,
"external/selinux/libselinux": Bp2BuildDefaultTrueRecursively,
+ "external/selinux/libsepol": Bp2BuildDefaultTrueRecursively,
"external/zlib": Bp2BuildDefaultTrueRecursively,
"external/zstd": Bp2BuildDefaultTrueRecursively,
"frameworks/base/media/tests/MediaDump": Bp2BuildDefaultTrue,
@@ -322,6 +323,7 @@
"packages/apps/HTMLViewer": Bp2BuildDefaultTrue,
"packages/apps/Protips": Bp2BuildDefaultTrue,
"packages/modules/adb": Bp2BuildDefaultTrue,
+ "packages/modules/adb/apex": Bp2BuildDefaultTrue,
"packages/modules/adb/crypto": Bp2BuildDefaultTrueRecursively,
"packages/modules/adb/libs": Bp2BuildDefaultTrueRecursively,
"packages/modules/adb/pairing_auth": Bp2BuildDefaultTrueRecursively,
@@ -333,7 +335,7 @@
"packages/services/Car/tests/SampleRearViewCamera": Bp2BuildDefaultTrue,
"prebuilts/clang/host/linux-x86": Bp2BuildDefaultTrueRecursively,
"system/apex": Bp2BuildDefaultFalse, // TODO(b/207466993): flaky failures
- "system/core/debuggerd": Bp2BuildDefaultTrue,
+ "system/core/debuggerd": Bp2BuildDefaultTrueRecursively,
"system/core/diagnose_usb": Bp2BuildDefaultTrueRecursively,
"system/core/libasyncio": Bp2BuildDefaultTrue,
"system/core/libcrypto_utils": Bp2BuildDefaultTrueRecursively,
@@ -394,9 +396,13 @@
"libbacktrace", // depends on unconverted module libunwindstack
"libdebuggerd_handler", // depends on unconverted module libdebuggerd_handler_core
"libdebuggerd_handler_core", "libdebuggerd_handler_fallback", // depends on unconverted module libdebuggerd
- "unwind_for_offline", // depends on unconverted module libunwindstack_utils
- "libdebuggerd", // depends on unconverted modules libdexfile_support, libunwindstack, gwp_asan_crash_handler, libtombstone_proto, libprotobuf-cpp-lite
- "libdexfile_static", // depends on libartpalette, libartbase, libdexfile, which are of unsupported type: art_cc_library.
+ "unwind_for_offline", // depends on unconverted module libunwindstack_utils
+ "libdebuggerd", // depends on unconverted modules libdexfile_support, libunwindstack, gwp_asan_crash_handler, libtombstone_proto, libprotobuf-cpp-lite
+ "libdexfile_static", // depends on libartpalette, libartbase, libdexfile, which are of unsupported type: art_cc_library.
+
+ "crasher", // depends on unconverted modules: libseccomp_policy
+ "static_crasher", // depends on unconverted modules: libdebuggerd_handler, libseccomp_policy
+
"host_bionic_linker_asm", // depends on extract_linker, a go binary.
"host_bionic_linker_script", // depends on extract_linker, a go binary.
@@ -409,8 +415,6 @@
"libbase_ndk", // http://b/186826477, fails to link libctscamera2_jni for device (required for CtsCameraTestCases)
- "lib_linker_config_proto_lite", // contains .proto sources
-
"libprotobuf-python", // contains .proto sources
"libprotobuf-internal-protos", // b/210751803, we don't handle path property for filegroups
"libprotobuf-internal-python-srcs", // b/210751803, we don't handle path property for filegroups
diff --git a/android/defaults.go b/android/defaults.go
index 7b3d38c..5677638 100644
--- a/android/defaults.go
+++ b/android/defaults.go
@@ -92,6 +92,7 @@
if module.base().module == nil {
panic("InitAndroidModule must be called before InitDefaultableModule")
}
+
module.setProperties(module.GetProperties(), module.base().variableProperties)
module.AddProperties(module.defaults())
@@ -118,6 +119,11 @@
type DefaultsModuleBase struct {
DefaultableModuleBase
+
+ // Included to support setting bazel_module.label for multiple Soong modules to the same Bazel
+ // target. This is primarily useful for modules that were architecture specific and instead are
+ // handled in Bazel as a select().
+ BazelModuleBase
}
// The common pattern for defaults modules is to register separate instances of
@@ -160,6 +166,7 @@
type DefaultsModule interface {
Module
Defaults
+ Bazelable
}
func (d *DefaultsModuleBase) properties() []interface{} {
@@ -170,8 +177,7 @@
return d.defaultableVariableProperties
}
-func (d *DefaultsModuleBase) GenerateAndroidBuildActions(ctx ModuleContext) {
-}
+func (d *DefaultsModuleBase) GenerateAndroidBuildActions(ctx ModuleContext) {}
// ConvertWithBp2build to fulfill Bazelable interface; however, at this time defaults module are
// *NOT* converted with bp2build
@@ -186,6 +192,8 @@
&ApexProperties{},
&distProperties{})
+ // Bazel module must be initialized _before_ Defaults to be included in cc_defaults module.
+ InitBazelModule(module)
initAndroidModuleBase(module)
initProductVariableModule(module)
initArchModule(module)
@@ -212,7 +220,6 @@
// The applicable licenses property for defaults is 'licenses'.
setPrimaryLicensesProperty(module, "licenses", &commonProperties.Licenses)
- base.module = module
}
var _ Defaults = (*DefaultsModuleBase)(nil)
diff --git a/android/module.go b/android/module.go
index 189781a..c479b59 100644
--- a/android/module.go
+++ b/android/module.go
@@ -2096,18 +2096,18 @@
return GlobFiles(e, globPattern, excludes)
}
-func (b *earlyModuleContext) IsSymlink(path Path) bool {
- fileInfo, err := b.config.fs.Lstat(path.String())
+func (e *earlyModuleContext) IsSymlink(path Path) bool {
+ fileInfo, err := e.config.fs.Lstat(path.String())
if err != nil {
- b.ModuleErrorf("os.Lstat(%q) failed: %s", path.String(), err)
+ e.ModuleErrorf("os.Lstat(%q) failed: %s", path.String(), err)
}
return fileInfo.Mode()&os.ModeSymlink == os.ModeSymlink
}
-func (b *earlyModuleContext) Readlink(path Path) string {
- dest, err := b.config.fs.Readlink(path.String())
+func (e *earlyModuleContext) Readlink(path Path) string {
+ dest, err := e.config.fs.Readlink(path.String())
if err != nil {
- b.ModuleErrorf("os.Readlink(%q) failed: %s", path.String(), err)
+ e.ModuleErrorf("os.Readlink(%q) failed: %s", path.String(), err)
}
return dest
}
diff --git a/android/package_test.go b/android/package_test.go
index 7ea10a4..65c4240 100644
--- a/android/package_test.go
+++ b/android/package_test.go
@@ -11,7 +11,7 @@
}{
// Package default_visibility handling is tested in visibility_test.go
{
- name: "package must not accept visibility and name properties",
+ name: "package must not accept visibility, name or licenses properties",
fs: map[string][]byte{
"top/Android.bp": []byte(`
package {
@@ -48,8 +48,7 @@
default_visibility: ["//visibility:private"],
default_applicable_licenses: ["license"],
}
-
- package {
+ package {
}`),
},
expectedErrors: []string{
diff --git a/android/util.go b/android/util.go
index a0394f6..0ee253e 100644
--- a/android/util.go
+++ b/android/util.go
@@ -65,22 +65,6 @@
return buf.String()
}
-// SortedIntKeys returns the keys of the given integer-keyed map in the ascending order
-// TODO(asmundak): once Go has generics, combine this with SortedStringKeys below.
-func SortedIntKeys(m interface{}) []int {
- v := reflect.ValueOf(m)
- if v.Kind() != reflect.Map {
- panic(fmt.Sprintf("%#v is not a map", m))
- }
- keys := v.MapKeys()
- s := make([]int, 0, len(keys))
- for _, key := range keys {
- s = append(s, int(key.Int()))
- }
- sort.Ints(s)
- return s
-}
-
// SorterStringKeys returns the keys of the given string-keyed map in the ascending order
func SortedStringKeys(m interface{}) []string {
v := reflect.ValueOf(m)
@@ -96,21 +80,6 @@
return s
}
-// SortedStringMapValues returns the values of the string-values map in the ascending order
-func SortedStringMapValues(m interface{}) []string {
- v := reflect.ValueOf(m)
- if v.Kind() != reflect.Map {
- panic(fmt.Sprintf("%#v is not a map", m))
- }
- keys := v.MapKeys()
- s := make([]string, 0, len(keys))
- for _, key := range keys {
- s = append(s, v.MapIndex(key).String())
- }
- sort.Strings(s)
- return s
-}
-
// IndexList returns the index of the first occurrence of the given string in the list or -1
func IndexList(s string, list []string) int {
for i, l := range list {
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index b4eb28f..eaceea9 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -2041,3 +2041,121 @@
},
})
}
+
+func TestCcLibraryProtoFilegroups(t *testing.T) {
+ runCcLibraryTestCase(t, bp2buildTestCase{
+ moduleTypeUnderTest: "cc_library",
+ moduleTypeUnderTestFactory: cc.LibraryFactory,
+ blueprint: soongCcProtoPreamble +
+ simpleModuleDoNotConvertBp2build("filegroup", "a_fg_proto") +
+ simpleModuleDoNotConvertBp2build("filegroup", "b_protos") +
+ simpleModuleDoNotConvertBp2build("filegroup", "c-proto-srcs") +
+ simpleModuleDoNotConvertBp2build("filegroup", "proto-srcs-d") + `
+cc_library {
+ name: "a",
+ srcs: [":a_fg_proto"],
+ proto: {
+ canonical_path_from_root: false,
+ export_proto_headers: true,
+ },
+ include_build_directory: false,
+}
+
+cc_library {
+ name: "b",
+ srcs: [":b_protos"],
+ proto: {
+ canonical_path_from_root: false,
+ export_proto_headers: true,
+ },
+ include_build_directory: false,
+}
+
+cc_library {
+ name: "c",
+ srcs: [":c-proto-srcs"],
+ proto: {
+ canonical_path_from_root: false,
+ export_proto_headers: true,
+ },
+ include_build_directory: false,
+}
+
+cc_library {
+ name: "d",
+ srcs: [":proto-srcs-d"],
+ proto: {
+ canonical_path_from_root: false,
+ export_proto_headers: true,
+ },
+ include_build_directory: false,
+}`,
+ expectedBazelTargets: []string{
+ makeBazelTarget("proto_library", "a_proto", attrNameToString{
+ "srcs": `[":a_fg_proto"]`,
+ }), makeBazelTarget("cc_lite_proto_library", "a_cc_proto_lite", attrNameToString{
+ "deps": `[":a_proto"]`,
+ }), makeBazelTarget("cc_library_static", "a_bp2build_cc_library_static", attrNameToString{
+ "deps": `[":libprotobuf-cpp-lite"]`,
+ "whole_archive_deps": `[":a_cc_proto_lite"]`,
+ "srcs": `[":a_fg_proto_cpp_srcs"]`,
+ "srcs_as": `[":a_fg_proto_as_srcs"]`,
+ "srcs_c": `[":a_fg_proto_c_srcs"]`,
+ }), makeBazelTarget("cc_library_shared", "a", attrNameToString{
+ "dynamic_deps": `[":libprotobuf-cpp-lite"]`,
+ "whole_archive_deps": `[":a_cc_proto_lite"]`,
+ "srcs": `[":a_fg_proto_cpp_srcs"]`,
+ "srcs_as": `[":a_fg_proto_as_srcs"]`,
+ "srcs_c": `[":a_fg_proto_c_srcs"]`,
+ }), makeBazelTarget("proto_library", "b_proto", attrNameToString{
+ "srcs": `[":b_protos"]`,
+ }), makeBazelTarget("cc_lite_proto_library", "b_cc_proto_lite", attrNameToString{
+ "deps": `[":b_proto"]`,
+ }), makeBazelTarget("cc_library_static", "b_bp2build_cc_library_static", attrNameToString{
+ "deps": `[":libprotobuf-cpp-lite"]`,
+ "whole_archive_deps": `[":b_cc_proto_lite"]`,
+ "srcs": `[":b_protos_cpp_srcs"]`,
+ "srcs_as": `[":b_protos_as_srcs"]`,
+ "srcs_c": `[":b_protos_c_srcs"]`,
+ }), makeBazelTarget("cc_library_shared", "b", attrNameToString{
+ "dynamic_deps": `[":libprotobuf-cpp-lite"]`,
+ "whole_archive_deps": `[":b_cc_proto_lite"]`,
+ "srcs": `[":b_protos_cpp_srcs"]`,
+ "srcs_as": `[":b_protos_as_srcs"]`,
+ "srcs_c": `[":b_protos_c_srcs"]`,
+ }), makeBazelTarget("proto_library", "c_proto", attrNameToString{
+ "srcs": `[":c-proto-srcs"]`,
+ }), makeBazelTarget("cc_lite_proto_library", "c_cc_proto_lite", attrNameToString{
+ "deps": `[":c_proto"]`,
+ }), makeBazelTarget("cc_library_static", "c_bp2build_cc_library_static", attrNameToString{
+ "deps": `[":libprotobuf-cpp-lite"]`,
+ "whole_archive_deps": `[":c_cc_proto_lite"]`,
+ "srcs": `[":c-proto-srcs_cpp_srcs"]`,
+ "srcs_as": `[":c-proto-srcs_as_srcs"]`,
+ "srcs_c": `[":c-proto-srcs_c_srcs"]`,
+ }), makeBazelTarget("cc_library_shared", "c", attrNameToString{
+ "dynamic_deps": `[":libprotobuf-cpp-lite"]`,
+ "whole_archive_deps": `[":c_cc_proto_lite"]`,
+ "srcs": `[":c-proto-srcs_cpp_srcs"]`,
+ "srcs_as": `[":c-proto-srcs_as_srcs"]`,
+ "srcs_c": `[":c-proto-srcs_c_srcs"]`,
+ }), makeBazelTarget("proto_library", "d_proto", attrNameToString{
+ "srcs": `[":proto-srcs-d"]`,
+ }), makeBazelTarget("cc_lite_proto_library", "d_cc_proto_lite", attrNameToString{
+ "deps": `[":d_proto"]`,
+ }), makeBazelTarget("cc_library_static", "d_bp2build_cc_library_static", attrNameToString{
+ "deps": `[":libprotobuf-cpp-lite"]`,
+ "whole_archive_deps": `[":d_cc_proto_lite"]`,
+ "srcs": `[":proto-srcs-d_cpp_srcs"]`,
+ "srcs_as": `[":proto-srcs-d_as_srcs"]`,
+ "srcs_c": `[":proto-srcs-d_c_srcs"]`,
+ }), makeBazelTarget("cc_library_shared", "d", attrNameToString{
+ "dynamic_deps": `[":libprotobuf-cpp-lite"]`,
+ "whole_archive_deps": `[":d_cc_proto_lite"]`,
+ "srcs": `[":proto-srcs-d_cpp_srcs"]`,
+ "srcs_as": `[":proto-srcs-d_as_srcs"]`,
+ "srcs_c": `[":proto-srcs-d_c_srcs"]`,
+ }),
+ },
+ })
+}
diff --git a/bp2build/testing.go b/bp2build/testing.go
index 15cf486..8ae1a38 100644
--- a/bp2build/testing.go
+++ b/bp2build/testing.go
@@ -133,8 +133,8 @@
android.FailIfErrored(t, errs)
}
if actualCount, expectedCount := len(bazelTargets), len(tc.expectedBazelTargets); actualCount != expectedCount {
- t.Errorf("%s: Expected %d bazel target, got `%d``",
- tc.description, expectedCount, actualCount)
+ t.Errorf("%s: Expected %d bazel target (%s), got `%d`` (%s)",
+ tc.description, expectedCount, tc.expectedBazelTargets, actualCount, bazelTargets)
} else {
for i, target := range bazelTargets {
if w, g := tc.expectedBazelTargets[i], target.content; w != g {
diff --git a/cc/bp2build.go b/cc/bp2build.go
index 6c1646c..fad40be 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -16,6 +16,7 @@
import (
"fmt"
"path/filepath"
+ "regexp"
"strings"
"android/soong/android"
@@ -33,6 +34,12 @@
protoSrcPartition = "proto"
)
+var (
+ // ignoring case, checks for proto or protos as an independent word in the name, whether at the
+ // beginning, end, or middle. e.g. "proto.foo", "bar-protos", "baz_proto_srcs" would all match
+ filegroupLikelyProtoPattern = regexp.MustCompile("(?i)(^|[^a-z])proto(s)?([^a-z]|$)")
+)
+
// staticOrSharedAttributes are the Bazel-ified versions of StaticOrSharedProperties --
// properties which apply to either the shared or static version of a cc_library module.
type staticOrSharedAttributes struct {
@@ -77,18 +84,18 @@
if !exists || !isFilegroup(m) {
return labelStr, false
}
- likelyProtos := strings.HasSuffix(labelStr, "proto") || strings.HasSuffix(labelStr, "protos")
+ likelyProtos := filegroupLikelyProtoPattern.MatchString(label.OriginalModuleName)
return labelStr, likelyProtos
}
// TODO(b/190006308): Handle language detection of sources in a Bazel rule.
partitioned := bazel.PartitionLabelListAttribute(ctx, &srcs, bazel.LabelPartitions{
- cSrcPartition: bazel.LabelPartition{Extensions: []string{".c"}, LabelMapper: addSuffixForFilegroup("_c_srcs")},
- asSrcPartition: bazel.LabelPartition{Extensions: []string{".s", ".S"}, LabelMapper: addSuffixForFilegroup("_as_srcs")},
+ protoSrcPartition: bazel.LabelPartition{Extensions: []string{".proto"}, LabelMapper: isProtoFilegroup},
+ cSrcPartition: bazel.LabelPartition{Extensions: []string{".c"}, LabelMapper: addSuffixForFilegroup("_c_srcs")},
+ asSrcPartition: bazel.LabelPartition{Extensions: []string{".s", ".S"}, LabelMapper: addSuffixForFilegroup("_as_srcs")},
// C++ is the "catch-all" group, and comprises generated sources because we don't
// know the language of these sources until the genrule is executed.
- cppSrcPartition: bazel.LabelPartition{Extensions: []string{".cpp", ".cc", ".cxx", ".mm"}, LabelMapper: addSuffixForFilegroup("_cpp_srcs"), Keep_remainder: true},
- protoSrcPartition: bazel.LabelPartition{Extensions: []string{".proto"}, LabelMapper: isProtoFilegroup},
+ cppSrcPartition: bazel.LabelPartition{Extensions: []string{".cpp", ".cc", ".cxx", ".mm"}, LabelMapper: addSuffixForFilegroup("_cpp_srcs"), Keep_remainder: true},
})
return partitioned
diff --git a/cc/builder.go b/cc/builder.go
index 8af2255..fa7f7a3 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -529,6 +529,14 @@
cppflags += " ${config.NoOverrideGlobalCflags}"
toolingCppflags += " ${config.NoOverrideGlobalCflags}"
+ modulePath := android.PathForModuleSrc(ctx).String()
+ if android.IsThirdPartyPath(modulePath) {
+ cflags += " ${config.NoOverrideExternalGlobalCflags}"
+ toolingCflags += " ${config.NoOverrideExternalGlobalCflags}"
+ cppflags += " ${config.NoOverrideExternalGlobalCflags}"
+ toolingCppflags += " ${config.NoOverrideExternalGlobalCflags}"
+ }
+
// Multiple source files have build rules usually share the same cFlags or tidyFlags.
// Define only one version in this module and share it in multiple build rules.
// To simplify the code, the shared variables are all named as $flags<nnn>.
diff --git a/cc/cc.go b/cc/cc.go
index 5c4edb9..215ef9c 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -3496,10 +3496,6 @@
type Defaults struct {
android.ModuleBase
android.DefaultsModuleBase
- // Included to support setting bazel_module.label for multiple Soong modules to the same Bazel
- // target. This is primarily useful for modules that were architecture specific and instead are
- // handled in Bazel as a select().
- android.BazelModuleBase
android.ApexModuleBase
}
@@ -3547,8 +3543,6 @@
&prebuiltLinkerProperties{},
)
- // Bazel module must be initialized _before_ Defaults to be included in cc_defaults module.
- android.InitBazelModule(module)
android.InitDefaultsModule(module)
return module
diff --git a/cc/cc_test.go b/cc/cc_test.go
index 9ffe48d..bcc6fcd 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -4005,12 +4005,12 @@
{
name: "c",
src: "foo.c",
- expected: combineSlices(baseExpectedFlags, conly, expectedIncludes, cflags, cstd, lastIncludes, []string{"${config.NoOverrideGlobalCflags}"}),
+ expected: combineSlices(baseExpectedFlags, conly, expectedIncludes, cflags, cstd, lastIncludes, []string{"${config.NoOverrideGlobalCflags}", "${config.NoOverrideExternalGlobalCflags}"}),
},
{
name: "cc",
src: "foo.cc",
- expected: combineSlices(baseExpectedFlags, cppOnly, expectedIncludes, cflags, cppstd, lastIncludes, []string{"${config.NoOverrideGlobalCflags}"}),
+ expected: combineSlices(baseExpectedFlags, cppOnly, expectedIncludes, cflags, cppstd, lastIncludes, []string{"${config.NoOverrideGlobalCflags}", "${config.NoOverrideExternalGlobalCflags}"}),
},
{
name: "assemble",
diff --git a/cc/config/global.go b/cc/config/global.go
index a340e46..2091e18 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -233,6 +233,12 @@
"-Wno-error=unused-but-set-parameter", // http://b/197240255
}
+ noOverrideExternalGlobalCflags = []string{
+ // http://b/197240255
+ "-Wno-unused-but-set-variable",
+ "-Wno-unused-but-set-parameter",
+ }
+
// Extra cflags for external third-party projects to disable warnings that
// are infeasible to fix in all the external projects and their upstream repos.
extraExternalCflags = []string{
@@ -346,6 +352,7 @@
exportStringListStaticVariable("HostGlobalCflags", hostGlobalCflags)
exportStringListStaticVariable("NoOverrideGlobalCflags", noOverrideGlobalCflags)
+ exportStringListStaticVariable("NoOverrideExternalGlobalCflags", noOverrideExternalGlobalCflags)
exportStringListStaticVariable("CommonGlobalCppflags", commonGlobalCppflags)
exportStringListStaticVariable("ExternalCflags", extraExternalCflags)
diff --git a/cc/makevars.go b/cc/makevars.go
index 8d7a163..b7aaaad 100644
--- a/cc/makevars.go
+++ b/cc/makevars.go
@@ -95,6 +95,7 @@
ctx.Strict("CLANG_EXTERNAL_CFLAGS", "${config.ExternalCflags}")
ctx.Strict("GLOBAL_CLANG_CFLAGS_NO_OVERRIDE", "${config.NoOverrideGlobalCflags}")
ctx.Strict("GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE", "")
+ ctx.Strict("GLOBAL_CLANG_EXTERNAL_CFLAGS_NO_OVERRIDE", "${config.NoOverrideExternalGlobalCflags}")
ctx.Strict("BOARD_VNDK_VERSION", ctx.DeviceConfig().VndkVersion())
ctx.Strict("RECOVERY_SNAPSHOT_VERSION", ctx.DeviceConfig().RecoverySnapshotVersion())
diff --git a/mk2rbc/mk2rbc.go b/mk2rbc/mk2rbc.go
index d5ff181..839dea2 100644
--- a/mk2rbc/mk2rbc.go
+++ b/mk2rbc/mk2rbc.go
@@ -105,7 +105,7 @@
"dist-for-goals": {baseName + ".mkdist_for_goals", starlarkTypeVoid, hiddenArgGlobal},
"enforce-product-packages-exist": {baseName + ".enforce_product_packages_exist", starlarkTypeVoid, hiddenArgNone},
"error": {baseName + ".mkerror", starlarkTypeVoid, hiddenArgNone},
- "findstring": {"!findstring", starlarkTypeInt, hiddenArgNone},
+ "findstring": {baseName + ".findstring", starlarkTypeString, hiddenArgNone},
"find-copy-subdir-files": {baseName + ".find_and_copy", starlarkTypeList, hiddenArgNone},
"find-word-in-list": {"!find-word-in-list", starlarkTypeUnknown, hiddenArgNone}, // internal macro
"filter": {baseName + ".filter", starlarkTypeList, hiddenArgNone},
@@ -1288,8 +1288,21 @@
right: &intLiteralExpr{-1},
isEq: !negate,
}
+ } else if s, ok := maybeString(xValue); ok {
+ if s2, ok := maybeString(xCall.args[0]); ok && s == s2 {
+ return &eqExpr{
+ left: &callExpr{
+ object: xCall.args[1],
+ name: "find",
+ args: []starlarkExpr{xCall.args[0]},
+ returnType: starlarkTypeInt,
+ },
+ right: &intLiteralExpr{-1},
+ isEq: negate,
+ }
+ }
}
- return ctx.newBadExpr(directive, "findstring result can be compared only to empty: %s", xValue)
+ return ctx.newBadExpr(directive, "$(findstring) can only be compared to nothing or its first argument")
}
func (ctx *parseContext) parseCompareStripFuncResult(directive *mkparser.Directive,
diff --git a/mk2rbc/mk2rbc_test.go b/mk2rbc/mk2rbc_test.go
index 78444c9..a1731a2 100644
--- a/mk2rbc/mk2rbc_test.go
+++ b/mk2rbc/mk2rbc_test.go
@@ -633,15 +633,42 @@
desc: "findstring call",
mkname: "product.mk",
in: `
+result := $(findstring a,a b c)
+result := $(findstring b,x y z)
+`,
+ expected: `load("//build/make/core:product_config.rbc", "rblf")
+
+def init(g, handle):
+ cfg = rblf.cfg(handle)
+ _result = rblf.findstring("a", "a b c")
+ _result = rblf.findstring("b", "x y z")
+`,
+ },
+ {
+ desc: "findstring in if statement",
+ mkname: "product.mk",
+ in: `
+ifeq ($(findstring foo,$(PRODUCT_PACKAGES)),)
+endif
ifneq ($(findstring foo,$(PRODUCT_PACKAGES)),)
endif
+ifeq ($(findstring foo,$(PRODUCT_PACKAGES)),foo)
+endif
+ifneq ($(findstring foo,$(PRODUCT_PACKAGES)),foo)
+endif
`,
expected: `load("//build/make/core:product_config.rbc", "rblf")
def init(g, handle):
cfg = rblf.cfg(handle)
+ if (cfg.get("PRODUCT_PACKAGES", [])).find("foo") == -1:
+ pass
if (cfg.get("PRODUCT_PACKAGES", [])).find("foo") != -1:
pass
+ if (cfg.get("PRODUCT_PACKAGES", [])).find("foo") != -1:
+ pass
+ if (cfg.get("PRODUCT_PACKAGES", [])).find("foo") == -1:
+ pass
`,
},
{
diff --git a/rust/test.go b/rust/test.go
index 3eea0ad..250b765 100644
--- a/rust/test.go
+++ b/rust/test.go
@@ -210,6 +210,12 @@
func RustTestFactory() android.Module {
module, _ := NewRustTest(android.HostAndDeviceSupported)
+
+ // NewRustTest will set MultilibBoth true, however the host variant
+ // cannot produce the non-primary target. Therefore, add the
+ // rustTestHostMultilib load hook to set MultilibFirst for the
+ // host target.
+ android.AddLoadHook(module, rustTestHostMultilib)
return module.Init()
}
@@ -236,3 +242,16 @@
func (test *testDecorator) testBinary() bool {
return true
}
+
+func rustTestHostMultilib(ctx android.LoadHookContext) {
+ type props struct {
+ Target struct {
+ Host struct {
+ Compile_multilib *string
+ }
+ }
+ }
+ p := &props{}
+ p.Target.Host.Compile_multilib = proptools.StringPtr("first")
+ ctx.AppendProperties(p)
+}
diff --git a/scripts/OWNERS b/scripts/OWNERS
index 88787cd..3f4f9c0 100644
--- a/scripts/OWNERS
+++ b/scripts/OWNERS
@@ -1,5 +1,4 @@
per-file system-clang-format,system-clang-format-2 = enh@google.com,smoreland@google.com
-per-file build-mainline-modules.sh = ngeoffray@google.com,paulduffin@google.com,mast@google.com
per-file build-aml-prebuilts.sh = ngeoffray@google.com,paulduffin@google.com,mast@google.com
per-file construct_context.py = ngeoffray@google.com,calin@google.com,skvadrik@google.com
per-file conv_linker_config.py = kiyoungkim@google.com, jiyong@google.com, jooyung@google.com
diff --git a/scripts/build-mainline-modules.sh b/scripts/build-mainline-modules.sh
deleted file mode 100755
index 1e3f6ce..0000000
--- a/scripts/build-mainline-modules.sh
+++ /dev/null
@@ -1,108 +0,0 @@
-#!/bin/bash -e
-
-# Non exhaustive list of modules where we want prebuilts. More can be added as
-# needed.
-MAINLINE_MODULES=(
- com.android.art
- com.android.art.debug
- com.android.art.testing
- com.android.conscrypt
- com.android.i18n
- com.android.os.statsd
- com.android.runtime
- com.android.tzdata
-)
-
-# List of SDKs and module exports we know of.
-MODULES_SDK_AND_EXPORTS=(
- art-module-sdk
- art-module-test-exports
- conscrypt-module-host-exports
- conscrypt-module-sdk
- conscrypt-module-test-exports
- i18n-module-host-exports
- i18n-module-sdk
- i18n-module-test-exports
- platform-mainline-sdk
- platform-mainline-test-exports
- runtime-module-host-exports
- runtime-module-sdk
- statsd-module-sdk
- tzdata-module-test-exports
-)
-
-# List of libraries installed on the platform that are needed for ART chroot
-# testing.
-PLATFORM_LIBRARIES=(
- heapprofd_client_api
- libartpalette-system
- liblog
-)
-
-# We want to create apex modules for all supported architectures.
-PRODUCTS=(
- aosp_arm
- aosp_arm64
- aosp_x86
- aosp_x86_64
-)
-
-if [ ! -e "build/make/core/Makefile" ]; then
- echo "$0 must be run from the top of the tree"
- exit 1
-fi
-
-echo_and_run() {
- echo "$*"
- "$@"
-}
-
-lib_dir() {
- case $1 in
- (aosp_arm|aosp_x86) echo "lib";;
- (aosp_arm64|aosp_x86_64) echo "lib64";;
- esac
-}
-
-# Make sure this build builds from source, regardless of the default.
-export SOONG_CONFIG_art_module_source_build=true
-
-# This script does not intend to handle compressed APEX
-export OVERRIDE_PRODUCT_COMPRESSED_APEX=false
-
-OUT_DIR=$(source build/envsetup.sh > /dev/null; TARGET_PRODUCT= get_build_var OUT_DIR)
-DIST_DIR=$(source build/envsetup.sh > /dev/null; TARGET_PRODUCT= get_build_var DIST_DIR)
-
-for product in "${PRODUCTS[@]}"; do
- echo_and_run build/soong/soong_ui.bash --make-mode $@ \
- TARGET_PRODUCT=${product} \
- ${MAINLINE_MODULES[@]} \
- ${PLATFORM_LIBRARIES[@]}
-
- PRODUCT_OUT=$(source build/envsetup.sh > /dev/null; TARGET_PRODUCT=${product} get_build_var PRODUCT_OUT)
- TARGET_ARCH=$(source build/envsetup.sh > /dev/null; TARGET_PRODUCT=${product} get_build_var TARGET_ARCH)
- rm -rf ${DIST_DIR}/${TARGET_ARCH}/
- mkdir -p ${DIST_DIR}/${TARGET_ARCH}/
- for module in "${MAINLINE_MODULES[@]}"; do
- echo_and_run cp ${PWD}/${PRODUCT_OUT}/system/apex/${module}.apex ${DIST_DIR}/${TARGET_ARCH}/
- done
- for library in "${PLATFORM_LIBRARIES[@]}"; do
- libdir=$(lib_dir $product)
- echo_and_run cp ${PWD}/${PRODUCT_OUT}/system/${libdir}/${library}.so ${DIST_DIR}/${TARGET_ARCH}/
- done
-done
-
-# We use force building LLVM components flag (even though we actually don't
-# compile them) because we don't have bionic host prebuilts
-# for them.
-export FORCE_BUILD_LLVM_COMPONENTS=true
-
-# Create multi-archs SDKs in a different out directory. The multi-arch script
-# uses Soong in --soong-only mode which cannot use the same directory as normal
-# mode with make.
-export OUT_DIR=${OUT_DIR}/aml
-echo_and_run build/soong/scripts/build-aml-prebuilts.sh \
- TARGET_PRODUCT=mainline_sdk ${MODULES_SDK_AND_EXPORTS[@]}
-
-rm -rf ${DIST_DIR}/mainline-sdks
-echo_and_run cp -R ${OUT_DIR}/soong/mainline-sdks ${DIST_DIR}