diff options
-rw-r--r-- | README.md | 13 | ||||
-rw-r--r-- | android/androidmk.go | 2 | ||||
-rw-r--r-- | android/bazel.go | 1 | ||||
-rw-r--r-- | android/soong_config_modules.go | 13 | ||||
-rw-r--r-- | apex/androidmk.go | 2 | ||||
-rw-r--r-- | apex/apex_test.go | 39 | ||||
-rw-r--r-- | bp2build/Android.bp | 1 | ||||
-rw-r--r-- | bp2build/python_library_conversion_test.go | 144 | ||||
-rw-r--r-- | cc/androidmk.go | 3 | ||||
-rw-r--r-- | cc/binary.go | 6 | ||||
-rw-r--r-- | cc/cc.go | 29 | ||||
-rw-r--r-- | cc/config/x86_linux_host.go | 2 | ||||
-rw-r--r-- | cc/coverage.go | 16 | ||||
-rw-r--r-- | cc/library.go | 8 | ||||
-rw-r--r-- | cc/ndk_library.go | 27 | ||||
-rw-r--r-- | cc/object_test.go | 34 | ||||
-rw-r--r-- | cc/sanitize.go | 1 | ||||
-rw-r--r-- | cc/testing.go | 21 | ||||
-rw-r--r-- | dexpreopt/dexpreopt.go | 5 | ||||
-rw-r--r-- | python/library.go | 71 | ||||
-rw-r--r-- | rust/config/allowed_list.go | 1 | ||||
-rwxr-xr-x | scripts/construct_context.py | 97 | ||||
-rwxr-xr-x | scripts/construct_context_test.py | 90 |
23 files changed, 467 insertions, 159 deletions
@@ -451,15 +451,10 @@ used. To specify that no properties should be amended for `soc_b`, you can set The values of the variables can be set from a product's `BoardConfig.mk` file: ``` -SOONG_CONFIG_NAMESPACES += acme -SOONG_CONFIG_acme += \ - board \ - feature \ - width \ - -SOONG_CONFIG_acme_board := soc_a -SOONG_CONFIG_acme_feature := true -SOONG_CONFIG_acme_width := 200 +$(call add_soong_config_namespace, acme) +$(call add_soong_config_var_value, acme, board, soc_a) +$(call add_soong_config_var_value, acme, feature, true) +$(call add_soong_config_var_value, acme, width, 200) ``` The `acme_cc_defaults` module type can be used anywhere after the definition in diff --git a/android/androidmk.go b/android/androidmk.go index f032f1bd4..9853d2cbe 100644 --- a/android/androidmk.go +++ b/android/androidmk.go @@ -571,7 +571,7 @@ func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod blueprint if host { makeOs := amod.Os().String() - if amod.Os() == Linux || amod.Os() == LinuxBionic { + if amod.Os() == Linux || amod.Os() == LinuxBionic || amod.Os() == LinuxMusl { makeOs = "linux" } a.SetString("LOCAL_MODULE_HOST_OS", makeOs) diff --git a/android/bazel.go b/android/bazel.go index fa19e52cb..cfb237fff 100644 --- a/android/bazel.go +++ b/android/bazel.go @@ -143,6 +143,7 @@ var ( "build/bazel/tests":/* recursive = */ true, "build/bazel/platforms":/* recursive = */ true, "build/bazel/product_variables":/* recursive = */ true, + "build/bazel_common_rules":/* recursive = */ true, "build/pesto":/* recursive = */ true, // external/bazelbuild-rules_android/... is needed by mixed builds, otherwise mixed builds analysis fails diff --git a/android/soong_config_modules.go b/android/soong_config_modules.go index 289e91088..17f6d66a8 100644 --- a/android/soong_config_modules.go +++ b/android/soong_config_modules.go @@ -122,15 +122,10 @@ type soongConfigModuleTypeImportProperties struct { // } // // If an acme BoardConfig.mk file contained: -// -// SOONG_CONFIG_NAMESPACES += acme -// SOONG_CONFIG_acme += \ -// board \ -// feature \ -// -// SOONG_CONFIG_acme_board := soc_a -// SOONG_CONFIG_acme_feature := true -// SOONG_CONFIG_acme_width := 200 +// $(call add_sonng_config_namespace, acme) +// $(call add_soong_config_var_value, acme, board, soc_a) +// $(call add_soong_config_var_value, acme, feature, true) +// $(call add_soong_config_var_value, acme, width, 200) // // Then libacme_foo would build with cflags "-DGENERIC -DSOC_A -DFEATURE -DWIDTH=200". // diff --git a/apex/androidmk.go b/apex/androidmk.go index ebf08330b..2f1090421 100644 --- a/apex/androidmk.go +++ b/apex/androidmk.go @@ -212,7 +212,7 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo } if host { makeOs := fi.module.Target().Os.String() - if fi.module.Target().Os == android.Linux || fi.module.Target().Os == android.LinuxBionic { + if fi.module.Target().Os == android.Linux || fi.module.Target().Os == android.LinuxBionic || fi.module.Target().Os == android.LinuxMusl { makeOs = "linux" } fmt.Fprintln(w, "LOCAL_MODULE_HOST_OS :=", makeOs) diff --git a/apex/apex_test.go b/apex/apex_test.go index f07bf6379..600f6c217 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -1874,6 +1874,45 @@ func TestApexMinSdkVersion_DefaultsToLatest(t *testing.T) { expectNoLink("libx", "shared_apex10000", "libz", "shared") } +func TestApexMinSdkVersion_crtobjectInVendorApex(t *testing.T) { + ctx := testApex(t, ` + apex { + name: "myapex", + key: "myapex.key", + native_shared_libs: ["mylib"], + updatable: false, + vendor: true, + min_sdk_version: "29", + } + + apex_key { + name: "myapex.key", + public_key: "testkey.avbpubkey", + private_key: "testkey.pem", + } + + cc_library { + name: "mylib", + vendor_available: true, + system_shared_libs: [], + stl: "none", + apex_available: [ "myapex" ], + min_sdk_version: "29", + } + `) + + vendorVariant := "android_vendor.29_arm64_armv8-a" + + // First check that the correct variant of crtbegin_so is used. + ldRule := ctx.ModuleForTests("mylib", vendorVariant+"_shared_apex29").Rule("ld") + crtBegin := names(ldRule.Args["crtBegin"]) + ensureListContains(t, crtBegin, "out/soong/.intermediates/"+cc.DefaultCcCommonTestModulesDir+"crtbegin_so/"+vendorVariant+"_apex29/crtbegin_so.o") + + // Ensure that the crtbegin_so used by the APEX is targeting 29 + cflags := ctx.ModuleForTests("crtbegin_so", vendorVariant+"_apex29").Rule("cc").Args["cFlags"] + android.AssertStringDoesContain(t, "cflags", cflags, "-target aarch64-linux-android29") +} + func TestPlatformUsesLatestStubsFromApexes(t *testing.T) { ctx := testApex(t, ` apex { diff --git a/bp2build/Android.bp b/bp2build/Android.bp index 78e3a74cb..b1ccc963c 100644 --- a/bp2build/Android.bp +++ b/bp2build/Android.bp @@ -42,6 +42,7 @@ bootstrap_go_package { "performance_test.go", "prebuilt_etc_conversion_test.go", "python_binary_conversion_test.go", + "python_library_conversion_test.go", "sh_conversion_test.go", "testing.go", ], diff --git a/bp2build/python_library_conversion_test.go b/bp2build/python_library_conversion_test.go new file mode 100644 index 000000000..b8659c6bf --- /dev/null +++ b/bp2build/python_library_conversion_test.go @@ -0,0 +1,144 @@ +package bp2build + +import ( + "fmt" + "testing" + + "android/soong/android" + "android/soong/python" +) + +// TODO(alexmarquez): Should be lifted into a generic Bp2Build file +type PythonLibBp2Build func(ctx android.TopDownMutatorContext) + +func TestPythonLibrary(t *testing.T) { + testPythonLib(t, "python_library", + python.PythonLibraryFactory, python.PythonLibraryBp2Build) +} + +func TestPythonLibraryHost(t *testing.T) { + testPythonLib(t, "python_library_host", + python.PythonLibraryHostFactory, python.PythonLibraryHostBp2Build) +} + +func testPythonLib(t *testing.T, modType string, + factory android.ModuleFactory, mutator PythonLibBp2Build) { + t.Helper() + // Simple + runBp2BuildTestCaseSimple(t, bp2buildTestCase{ + description: fmt.Sprintf("simple %s converts to a native py_library", modType), + moduleTypeUnderTest: modType, + moduleTypeUnderTestFactory: factory, + moduleTypeUnderTestBp2BuildMutator: mutator, + filesystem: map[string]string{ + "a.py": "", + "b/c.py": "", + "b/d.py": "", + "b/e.py": "", + "files/data.txt": "", + }, + blueprint: fmt.Sprintf(`%s { + name: "foo", + srcs: ["**/*.py"], + exclude_srcs: ["b/e.py"], + data: ["files/data.txt",], + bazel_module: { bp2build_available: true }, +}`, modType), + expectedBazelTargets: []string{`py_library( + name = "foo", + data = ["files/data.txt"], + srcs = [ + "a.py", + "b/c.py", + "b/d.py", + ], + srcs_version = "PY3", +)`, + }, + }) + + // PY2 + runBp2BuildTestCaseSimple(t, bp2buildTestCase{ + description: fmt.Sprintf("py2 %s converts to a native py_library", modType), + moduleTypeUnderTest: modType, + moduleTypeUnderTestFactory: factory, + moduleTypeUnderTestBp2BuildMutator: mutator, + blueprint: fmt.Sprintf(`%s { + name: "foo", + srcs: ["a.py"], + version: { + py2: { + enabled: true, + }, + py3: { + enabled: false, + }, + }, + + bazel_module: { bp2build_available: true }, +}`, modType), + expectedBazelTargets: []string{`py_library( + name = "foo", + srcs = ["a.py"], + srcs_version = "PY2", +)`, + }, + }) + + // PY3 + runBp2BuildTestCaseSimple(t, bp2buildTestCase{ + description: fmt.Sprintf("py3 %s converts to a native py_library", modType), + moduleTypeUnderTest: modType, + moduleTypeUnderTestFactory: factory, + moduleTypeUnderTestBp2BuildMutator: mutator, + blueprint: fmt.Sprintf(`%s { + name: "foo", + srcs: ["a.py"], + version: { + py2: { + enabled: false, + }, + py3: { + enabled: true, + }, + }, + + bazel_module: { bp2build_available: true }, +}`, modType), + expectedBazelTargets: []string{`py_library( + name = "foo", + srcs = ["a.py"], + srcs_version = "PY3", +)`, + }, + }) + + // Both + runBp2BuildTestCaseSimple(t, bp2buildTestCase{ + description: fmt.Sprintf("py2&3 %s converts to a native py_library", modType), + moduleTypeUnderTest: modType, + moduleTypeUnderTestFactory: factory, + moduleTypeUnderTestBp2BuildMutator: mutator, + blueprint: fmt.Sprintf(`%s { + name: "foo", + srcs: ["a.py"], + version: { + py2: { + enabled: true, + }, + py3: { + enabled: true, + }, + }, + + bazel_module: { bp2build_available: true }, +}`, modType), + expectedBazelTargets: []string{ + // srcs_version is PY2ANDPY3 by default. + `py_library( + name = "foo", + srcs = ["a.py"], +)`, + }, + }) +} diff --git a/cc/androidmk.go b/cc/androidmk.go index e95d5a793..cd52363e8 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -294,6 +294,9 @@ func (library *libraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries if library.buildStubs() { entries.SetBool("LOCAL_NO_NOTICE_FILE", true) } + if library.apiListCoverageXmlPath.String() != "" { + entries.SetString("SOONG_CC_API_XML", "$(SOONG_CC_API_XML) "+library.apiListCoverageXmlPath.String()) + } }) } // If a library providing a stub is included in an APEX, the private APIs of the library diff --git a/cc/binary.go b/cc/binary.go index 763d2b925..b423c50ae 100644 --- a/cc/binary.go +++ b/cc/binary.go @@ -156,6 +156,10 @@ func (binary *binaryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps { } } + if binary.static() { + deps.StaticLibs = append(deps.StaticLibs, deps.SystemSharedLibs...) + } + if ctx.toolchain().Bionic() { if binary.static() { if ctx.selectedStl() == "libc++_static" { @@ -208,7 +212,7 @@ func NewBinary(hod android.HostOrDeviceSupported) (*Module, *binaryDecorator) { func (binary *binaryDecorator) linkerInit(ctx BaseModuleContext) { binary.baseLinker.linkerInit(ctx) - if !ctx.toolchain().Bionic() { + if !ctx.toolchain().Bionic() && !ctx.toolchain().Musl() { if ctx.Os() == android.Linux { // Unless explicitly specified otherwise, host static binaries are built with -static // if HostStaticBinaries is true for the product configuration. @@ -975,16 +975,17 @@ func (c *Module) MinSdkVersion() string { return String(c.Properties.Min_sdk_version) } -func (c *Module) SplitPerApiLevel() bool { - if !c.canUseSdk() { - return false - } +func (c *Module) isCrt() bool { if linker, ok := c.linker.(*objectLinker); ok { return linker.isCrt() } return false } +func (c *Module) SplitPerApiLevel() bool { + return c.canUseSdk() && c.isCrt() +} + func (c *Module) AlwaysSdk() bool { return c.Properties.AlwaysSdk || Bool(c.Properties.Sdk_variant_only) } @@ -1446,12 +1447,20 @@ func (ctx *moduleContextImpl) minSdkVersion() string { // create versioned variants for. For example, if min_sdk_version is 16, then sdk variant of // the crt object has local variants of 16, 17, ..., up to the latest version. sdk_version // and min_sdk_version properties of the variants are set to the corresponding version - // numbers. However, the platform (non-sdk) variant of the crt object is left untouched. - // min_sdk_version: 16 doesn't actually mean that the platform variant has to support such - // an old version. Since the variant is for the platform, it's preferred to target the - // latest version. - if ctx.mod.SplitPerApiLevel() && !ctx.isSdkVariant() { - ver = strconv.Itoa(android.FutureApiLevelInt) + // numbers. However, the non-sdk variant (for apex or platform) of the crt object is left + // untouched. min_sdk_version: 16 doesn't actually mean that the non-sdk variant has to + // support such an old version. The version is set to the later version in case when the + // non-sdk variant is for the platform, or the min_sdk_version of the containing APEX if + // it's for an APEX. + if ctx.mod.isCrt() && !ctx.isSdkVariant() { + if ctx.isForPlatform() { + ver = strconv.Itoa(android.FutureApiLevelInt) + } else { // for apex + ver = ctx.apexSdkVersion().String() + if ver == "" { // in case when min_sdk_version was not set by the APEX + ver = ctx.sdkVersion() + } + } } // Also make sure that minSdkVersion is not greater than sdkVersion, if they are both numbers diff --git a/cc/config/x86_linux_host.go b/cc/config/x86_linux_host.go index 25f5c58f7..ac5d5f74e 100644 --- a/cc/config/x86_linux_host.go +++ b/cc/config/x86_linux_host.go @@ -107,7 +107,7 @@ var ( "util", }, "-l") - muslCrtBeginStaticBinary, muslCrtEndStaticBinary = []string{"libc_musl_crtbegin_static"}, []string{"crtend_android"} + muslCrtBeginStaticBinary, muslCrtEndStaticBinary = []string{"libc_musl_crtbegin_static"}, []string{"libc_musl_crtend"} muslCrtBeginSharedBinary, muslCrtEndSharedBinary = []string{"libc_musl_crtbegin_dynamic", "musl_linker_script"}, []string{"libc_musl_crtend"} muslCrtBeginSharedLibrary, muslCrtEndSharedLibrary = []string{"libc_musl_crtbegin_so"}, []string{"libc_musl_crtend_so"} diff --git a/cc/coverage.go b/cc/coverage.go index baf422637..8dd2db19d 100644 --- a/cc/coverage.go +++ b/cc/coverage.go @@ -244,3 +244,19 @@ func coverageMutator(mctx android.BottomUpMutatorContext) { m[1].(Coverage).EnableCoverageIfNeeded() } } + +func parseSymbolFileForAPICoverage(ctx ModuleContext, symbolFile string) android.ModuleOutPath { + apiLevelsJson := android.GetApiLevelsJson(ctx) + symbolFilePath := android.PathForModuleSrc(ctx, symbolFile) + outputFile := ctx.baseModuleName() + ".xml" + parsedApiCoveragePath := android.PathForModuleOut(ctx, outputFile) + rule := android.NewRuleBuilder(pctx, ctx) + rule.Command(). + BuiltTool("ndk_api_coverage_parser"). + Input(symbolFilePath). + Output(parsedApiCoveragePath). + Implicit(apiLevelsJson). + FlagWithArg("--api-map ", apiLevelsJson.String()) + rule.Build("native_library_api_list", "Generate native API list based on symbol files for coverage measurement") + return parsedApiCoveragePath +} diff --git a/cc/library.go b/cc/library.go index 1526f8157..196116bd6 100644 --- a/cc/library.go +++ b/cc/library.go @@ -536,6 +536,8 @@ type libraryDecorator struct { *baseInstaller collectedSnapshotHeaders android.Paths + + apiListCoverageXmlPath android.ModuleOutPath } type ccLibraryBazelHandler struct { @@ -951,6 +953,12 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa objs := compileStubLibrary(ctx, flags, nativeAbiResult.stubSrc) library.versionScriptPath = android.OptionalPathForPath( nativeAbiResult.versionScript) + + // Parse symbol file to get API list for coverage + if library.stubsVersion() == "current" && ctx.PrimaryArch() { + library.apiListCoverageXmlPath = parseSymbolFileForAPICoverage(ctx, symbolFile) + } + return objs } diff --git a/cc/ndk_library.go b/cc/ndk_library.go index 63e8261e9..51cdddfb0 100644 --- a/cc/ndk_library.go +++ b/cc/ndk_library.go @@ -29,7 +29,6 @@ import ( func init() { pctx.HostBinToolVariable("ndkStubGenerator", "ndkstubgen") - pctx.HostBinToolVariable("ndk_api_coverage_parser", "ndk_api_coverage_parser") pctx.HostBinToolVariable("abidiff", "abidiff") pctx.HostBinToolVariable("abitidy", "abitidy") pctx.HostBinToolVariable("abidw", "abidw") @@ -43,12 +42,6 @@ var ( CommandDeps: []string{"$ndkStubGenerator"}, }, "arch", "apiLevel", "apiMap", "flags") - parseNdkApiRule = pctx.AndroidStaticRule("parseNdkApiRule", - blueprint.RuleParams{ - Command: "$ndk_api_coverage_parser $in $out --api-map $apiMap", - CommandDeps: []string{"$ndk_api_coverage_parser"}, - }, "apiMap") - abidw = pctx.AndroidStaticRule("abidw", blueprint.RuleParams{ Command: "$abidw --type-id-style hash --no-corpus-path " + @@ -276,24 +269,6 @@ func compileStubLibrary(ctx ModuleContext, flags Flags, src android.Path) Object android.Paths{src}, nil, nil) } -func parseSymbolFileForCoverage(ctx ModuleContext, symbolFile string) android.ModuleOutPath { - apiLevelsJson := android.GetApiLevelsJson(ctx) - symbolFilePath := android.PathForModuleSrc(ctx, symbolFile) - outputFileName := strings.Split(symbolFilePath.Base(), ".")[0] - parsedApiCoveragePath := android.PathForModuleOut(ctx, outputFileName+".xml") - ctx.Build(pctx, android.BuildParams{ - Rule: parseNdkApiRule, - Description: "parse ndk api symbol file for api coverage: " + symbolFilePath.Rel(), - Outputs: []android.WritablePath{parsedApiCoveragePath}, - Input: symbolFilePath, - Implicits: []android.Path{apiLevelsJson}, - Args: map[string]string{ - "apiMap": apiLevelsJson.String(), - }, - }) - return parsedApiCoveragePath -} - func (this *stubDecorator) findImplementationLibrary(ctx ModuleContext) android.Path { dep := ctx.GetDirectDepWithTag(strings.TrimSuffix(ctx.ModuleName(), ndkLibrarySuffix), stubImplementation) @@ -454,7 +429,7 @@ func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) O } } if c.apiLevel.IsCurrent() && ctx.PrimaryArch() { - c.parsedCoverageXmlPath = parseSymbolFileForCoverage(ctx, symbolFile) + c.parsedCoverageXmlPath = parseSymbolFileForAPICoverage(ctx, symbolFile) } return objs } diff --git a/cc/object_test.go b/cc/object_test.go index 0e5508a4a..259a892ab 100644 --- a/cc/object_test.go +++ b/cc/object_test.go @@ -15,8 +15,9 @@ package cc import ( - "android/soong/android" "testing" + + "android/soong/android" ) func TestMinSdkVersionsOfCrtObjects(t *testing.T) { @@ -27,24 +28,23 @@ func TestMinSdkVersionsOfCrtObjects(t *testing.T) { crt: true, stl: "none", min_sdk_version: "28", - + vendor_available: true, }`) - arch := "android_arm64_armv8-a" - for _, v := range []string{"", "28", "29", "30", "current"} { - var variant string - // platform variant - if v == "" { - variant = arch - } else { - variant = arch + "_sdk_" + v - } - cflags := ctx.ModuleForTests("crt_foo", variant).Rule("cc").Args["cFlags"] - vNum := v - if v == "current" || v == "" { - vNum = "10000" - } - expected := "-target aarch64-linux-android" + vNum + " " + variants := []struct { + variant string + num string + }{ + {"android_arm64_armv8-a", "10000"}, + {"android_arm64_armv8-a_sdk_28", "28"}, + {"android_arm64_armv8-a_sdk_29", "29"}, + {"android_arm64_armv8-a_sdk_30", "30"}, + {"android_arm64_armv8-a_sdk_current", "10000"}, + {"android_vendor.29_arm64_armv8-a", "29"}, + } + for _, v := range variants { + cflags := ctx.ModuleForTests("crt_foo", v.variant).Rule("cc").Args["cFlags"] + expected := "-target aarch64-linux-android" + v.num + " " android.AssertStringDoesContain(t, "cflag", cflags, expected) } } diff --git a/cc/sanitize.go b/cc/sanitize.go index dd15ae13d..90974aa4f 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -41,7 +41,6 @@ var ( hwasanCflags = []string{"-fno-omit-frame-pointer", "-Wno-frame-larger-than=", "-fsanitize-hwaddress-abi=platform", - "-fno-experimental-new-pass-manager", // The following improves debug location information // availability at the cost of its accuracy. It increases // the likelihood of a stack variable's frame offset diff --git a/cc/testing.go b/cc/testing.go index 071f1ec3b..d0dca6b53 100644 --- a/cc/testing.go +++ b/cc/testing.go @@ -375,26 +375,42 @@ func commonDefaultModules() string { cc_object { name: "crtbegin_so", defaults: ["crt_defaults"], + srcs: ["crtbegin_so.c"], + objs: ["crtbrand"], } cc_object { name: "crtbegin_dynamic", defaults: ["crt_defaults"], + srcs: ["crtbegin.c"], + objs: ["crtbrand"], } cc_object { name: "crtbegin_static", defaults: ["crt_defaults"], + srcs: ["crtbegin.c"], + objs: ["crtbrand"], } cc_object { name: "crtend_so", defaults: ["crt_defaults"], + srcs: ["crtend_so.c"], + objs: ["crtbrand"], } cc_object { name: "crtend_android", defaults: ["crt_defaults"], + srcs: ["crtend.c"], + objs: ["crtbrand"], + } + + cc_object { + name: "crtbrand", + defaults: ["crt_defaults"], + srcs: ["crtbrand.c"], } cc_library { @@ -585,6 +601,11 @@ var PrepareForTestWithCcDefaultModules = android.GroupFixturePreparers( "defaults/cc/common/libm.map.txt": nil, "defaults/cc/common/ndk_libandroid_support": nil, "defaults/cc/common/ndk_libc++_shared": nil, + "defaults/cc/common/crtbegin_so.c": nil, + "defaults/cc/common/crtbegin.c": nil, + "defaults/cc/common/crtend_so.c": nil, + "defaults/cc/common/crtend.c": nil, + "defaults/cc/common/crtbrand.c": nil, }.AddToFixture(), // Place the default cc test modules that are common to all platforms in a location that will not diff --git a/dexpreopt/dexpreopt.go b/dexpreopt/dexpreopt.go index 4c6ae82e9..1401c75d9 100644 --- a/dexpreopt/dexpreopt.go +++ b/dexpreopt/dexpreopt.go @@ -430,11 +430,6 @@ func dexpreoptCommand(ctx android.PathContext, globalSoong *GlobalSoongConfig, g } } - // Never enable on eng. - if global.IsEng { - debugInfo = false - } - if debugInfo { cmd.Flag("--generate-mini-debug-info") } else { diff --git a/python/library.go b/python/library.go index 9663b3c75..45fc00227 100644 --- a/python/library.go +++ b/python/library.go @@ -17,11 +17,17 @@ package python // This file contains the module types for building Python library. import ( + "fmt" + "android/soong/android" + "android/soong/bazel" + "github.com/google/blueprint/proptools" ) func init() { registerPythonLibraryComponents(android.InitRegistrationContext) + android.RegisterBp2BuildMutator("python_library_host", PythonLibraryHostBp2Build) + android.RegisterBp2BuildMutator("python_library", PythonLibraryBp2Build) } func registerPythonLibraryComponents(ctx android.RegistrationContext) { @@ -32,11 +38,76 @@ func registerPythonLibraryComponents(ctx android.RegistrationContext) { func PythonLibraryHostFactory() android.Module { module := newModule(android.HostSupported, android.MultilibFirst) + android.InitBazelModule(module) + return module.init() } +type bazelPythonLibraryAttributes struct { + Srcs bazel.LabelListAttribute + Data bazel.LabelListAttribute + Srcs_version string +} + +func PythonLibraryHostBp2Build(ctx android.TopDownMutatorContext) { + pythonLibBp2Build(ctx, "python_library_host") +} + +func PythonLibraryBp2Build(ctx android.TopDownMutatorContext) { + pythonLibBp2Build(ctx, "python_library") +} + +func pythonLibBp2Build(ctx android.TopDownMutatorContext, modType string) { + m, ok := ctx.Module().(*Module) + if !ok || !m.ConvertWithBp2build(ctx) { + return + } + + // a Module can be something other than a `modType` + if ctx.ModuleType() != modType { + return + } + + // TODO(b/182306917): this doesn't fully handle all nested props versioned + // by the python version, which would have been handled by the version split + // mutator. This is sufficient for very simple python_library modules under + // Bionic. + py3Enabled := proptools.BoolDefault(m.properties.Version.Py3.Enabled, true) + py2Enabled := proptools.BoolDefault(m.properties.Version.Py2.Enabled, false) + var python_version string + if py2Enabled && !py3Enabled { + python_version = "PY2" + } else if !py2Enabled && py3Enabled { + python_version = "PY3" + } else if !py2Enabled && !py3Enabled { + panic(fmt.Errorf( + "error for '%s' module: bp2build's %s converter doesn't understand having "+ + "neither py2 nor py3 enabled", m.Name(), modType)) + } else { + // do nothing, since python_version defaults to PY2ANDPY3 + } + + srcs := android.BazelLabelForModuleSrcExcludes(ctx, m.properties.Srcs, m.properties.Exclude_srcs) + data := android.BazelLabelForModuleSrc(ctx, m.properties.Data) + + attrs := &bazelPythonLibraryAttributes{ + Srcs: bazel.MakeLabelListAttribute(srcs), + Data: bazel.MakeLabelListAttribute(data), + Srcs_version: python_version, + } + + props := bazel.BazelTargetModuleProperties{ + // Use the native py_library rule. + Rule_class: "py_library", + } + + ctx.CreateBazelTargetModule(m.Name(), props, attrs) +} + func PythonLibraryFactory() android.Module { module := newModule(android.HostAndDeviceSupported, android.MultilibBoth) + android.InitBazelModule(module) + return module.init() } diff --git a/rust/config/allowed_list.go b/rust/config/allowed_list.go index ee9be6e90..63a8f0415 100644 --- a/rust/config/allowed_list.go +++ b/rust/config/allowed_list.go @@ -13,6 +13,7 @@ var ( "external/minijail", "external/rust", "external/selinux/libselinux", + "external/uwb", "external/vm_tools/p9", "frameworks/native/libs/binder/rust", "frameworks/proto_logging/stats", diff --git a/scripts/construct_context.py b/scripts/construct_context.py index f0658baa2..3f601c308 100755 --- a/scripts/construct_context.py +++ b/scripts/construct_context.py @@ -25,57 +25,78 @@ from manifest import compare_version_gt def parse_args(args): - """Parse commandline arguments.""" - parser = argparse.ArgumentParser() - parser.add_argument('--target-sdk-version', default='', dest='sdk', - help='specify target SDK version (as it appears in the manifest)') - parser.add_argument('--host-context-for-sdk', dest='host_contexts', - action='append', nargs=2, metavar=('sdk','context'), - help='specify context on host for a given SDK version or "any" version') - parser.add_argument('--target-context-for-sdk', dest='target_contexts', - action='append', nargs=2, metavar=('sdk','context'), - help='specify context on target for a given SDK version or "any" version') - return parser.parse_args(args) + """Parse commandline arguments.""" + parser = argparse.ArgumentParser() + parser.add_argument( + '--target-sdk-version', + default='', + dest='sdk', + help='specify target SDK version (as it appears in the manifest)') + parser.add_argument( + '--host-context-for-sdk', + dest='host_contexts', + action='append', + nargs=2, + metavar=('sdk', 'context'), + help='specify context on host for a given SDK version or "any" version') + parser.add_argument( + '--target-context-for-sdk', + dest='target_contexts', + action='append', + nargs=2, + metavar=('sdk', 'context'), + help='specify context on target for a given SDK version or "any" ' + 'version' + ) + return parser.parse_args(args) + # Special keyword that means that the context should be added to class loader # context regardless of the target SDK version. any_sdk = 'any' + # We assume that the order of context arguments passed to this script is # correct (matches the order computed by package manager). It is possible to # sort them here, but Soong needs to use deterministic order anyway, so it can # as well use the correct order. def construct_context(versioned_contexts, target_sdk): - context = [] - for [sdk, ctx] in versioned_contexts: - if sdk == any_sdk or compare_version_gt(sdk, target_sdk): - context.append(ctx) - return context + context = [] + for [sdk, ctx] in versioned_contexts: + if sdk == any_sdk or compare_version_gt(sdk, target_sdk): + context.append(ctx) + return context + def construct_contexts(args): - host_context = construct_context(args.host_contexts, args.sdk) - target_context = construct_context(args.target_contexts, args.sdk) - context_sep = '#' - return ('class_loader_context_arg=--class-loader-context=PCL[]{%s} ; ' % context_sep.join(host_context) + - 'stored_class_loader_context_arg=--stored-class-loader-context=PCL[]{%s}' % context_sep.join(target_context)) + host_context = construct_context(args.host_contexts, args.sdk) + target_context = construct_context(args.target_contexts, args.sdk) + context_sep = '#' + return ( + 'class_loader_context_arg=--class-loader-context=PCL[]{%s} ; ' % + context_sep.join(host_context) + + 'stored_class_loader_context_arg=--stored-class-loader-context=PCL[]{%s}' #pylint: disable=line-too-long + % context_sep.join(target_context)) + def main(): - """Program entry point.""" - try: - args = parse_args(sys.argv[1:]) - if not args.sdk: - raise SystemExit('target sdk version is not set') - if not args.host_contexts: - args.host_contexts = [] - if not args.target_contexts: - args.target_contexts = [] - - print(construct_contexts(args)) - - # pylint: disable=broad-except - except Exception as err: - print('error: ' + str(err), file=sys.stderr) - sys.exit(-1) + """Program entry point.""" + try: + args = parse_args(sys.argv[1:]) + if not args.sdk: + raise SystemExit('target sdk version is not set') + if not args.host_contexts: + args.host_contexts = [] + if not args.target_contexts: + args.target_contexts = [] + + print(construct_contexts(args)) + + # pylint: disable=broad-except + except Exception as err: + print('error: ' + str(err), file=sys.stderr) + sys.exit(-1) + if __name__ == '__main__': - main() + main() diff --git a/scripts/construct_context_test.py b/scripts/construct_context_test.py index 3b05f9013..2ff5ac54a 100755 --- a/scripts/construct_context_test.py +++ b/scripts/construct_context_test.py @@ -23,53 +23,63 @@ import construct_context as cc sys.dont_write_bytecode = True + def construct_contexts(arglist): - args = cc.parse_args(arglist) - return cc.construct_contexts(args) + args = cc.parse_args(arglist) + return cc.construct_contexts(args) + contexts = [ - '--host-context-for-sdk', '28', 'PCL[out/zdir/z.jar]', - '--target-context-for-sdk', '28', 'PCL[/system/z.jar]', - '--host-context-for-sdk', '29', 'PCL[out/xdir/x.jar]#PCL[out/ydir/y.jar]', - '--target-context-for-sdk', '29', 'PCL[/system/x.jar]#PCL[/product/y.jar]', - '--host-context-for-sdk', 'any', 'PCL[out/adir/a.jar]#PCL[out/bdir/b.jar]', - '--target-context-for-sdk', 'any', 'PCL[/system/a.jar]#PCL[/product/b.jar]', + '--host-context-for-sdk', + '28', + 'PCL[out/zdir/z.jar]', + '--target-context-for-sdk', + '28', + 'PCL[/system/z.jar]', + '--host-context-for-sdk', + '29', + 'PCL[out/xdir/x.jar]#PCL[out/ydir/y.jar]', + '--target-context-for-sdk', + '29', + 'PCL[/system/x.jar]#PCL[/product/y.jar]', + '--host-context-for-sdk', + 'any', + 'PCL[out/adir/a.jar]#PCL[out/bdir/b.jar]', + '--target-context-for-sdk', + 'any', + 'PCL[/system/a.jar]#PCL[/product/b.jar]', ] +#pylint: disable=line-too-long class ConstructContextTest(unittest.TestCase): - def test_construct_context_28(self): - args = ['--target-sdk-version', '28'] + contexts - result = construct_contexts(args) - expect = ('class_loader_context_arg=--class-loader-context=PCL[]{PCL[out/xdir/x.jar]' - '#PCL[out/ydir/y.jar]' - '#PCL[out/adir/a.jar]' - '#PCL[out/bdir/b.jar]}' - ' ; ' - 'stored_class_loader_context_arg=--stored-class-loader-context=PCL[]{PCL[/system/x.jar]' - '#PCL[/product/y.jar]' - '#PCL[/system/a.jar]' - '#PCL[/product/b.jar]}') - self.assertEqual(result, expect) - def test_construct_context_29(self): - args = ['--target-sdk-version', '29'] + contexts - result = construct_contexts(args) - expect = ('class_loader_context_arg=--class-loader-context=PCL[]{PCL[out/adir/a.jar]' - '#PCL[out/bdir/b.jar]}' - ' ; ' - 'stored_class_loader_context_arg=--stored-class-loader-context=PCL[]{PCL[/system/a.jar]' - '#PCL[/product/b.jar]}') - self.assertEqual(result, expect) + def test_construct_context_28(self): + args = ['--target-sdk-version', '28'] + contexts + result = construct_contexts(args) + expect = ( + 'class_loader_context_arg=--class-loader-context=PCL[]{PCL[out/xdir/x.jar]#PCL[out/ydir/y.jar]#PCL[out/adir/a.jar]#PCL[out/bdir/b.jar]}' + ' ; ' + 'stored_class_loader_context_arg=--stored-class-loader-context=PCL[]{PCL[/system/x.jar]#PCL[/product/y.jar]#PCL[/system/a.jar]#PCL[/product/b.jar]}') + self.assertEqual(result, expect) + + def test_construct_context_29(self): + args = ['--target-sdk-version', '29'] + contexts + result = construct_contexts(args) + expect = ( + 'class_loader_context_arg=--class-loader-context=PCL[]{PCL[out/adir/a.jar]#PCL[out/bdir/b.jar]}' + ' ; ' + 'stored_class_loader_context_arg=--stored-class-loader-context=PCL[]{PCL[/system/a.jar]#PCL[/product/b.jar]}') + self.assertEqual(result, expect) - def test_construct_context_S(self): - args = ['--target-sdk-version', 'S'] + contexts - result = construct_contexts(args) - expect = ('class_loader_context_arg=--class-loader-context=PCL[]{PCL[out/adir/a.jar]' - '#PCL[out/bdir/b.jar]}' - ' ; ' - 'stored_class_loader_context_arg=--stored-class-loader-context=PCL[]{PCL[/system/a.jar]' - '#PCL[/product/b.jar]}') - self.assertEqual(result, expect) + def test_construct_context_S(self): + args = ['--target-sdk-version', 'S'] + contexts + result = construct_contexts(args) + expect = ( + 'class_loader_context_arg=--class-loader-context=PCL[]{PCL[out/adir/a.jar]#PCL[out/bdir/b.jar]}' + ' ; ' + 'stored_class_loader_context_arg=--stored-class-loader-context=PCL[]{PCL[/system/a.jar]#PCL[/product/b.jar]}') + self.assertEqual(result, expect) +#pylint: enable=line-too-long if __name__ == '__main__': - unittest.main(verbosity=2) + unittest.main(verbosity=2) |