diff options
| -rw-r--r-- | android/arch.go | 2 | ||||
| -rw-r--r-- | android/neverallow.go | 10 | ||||
| -rw-r--r-- | android/neverallow_test.go | 13 | ||||
| -rw-r--r-- | apex/apex.go | 6 | ||||
| -rw-r--r-- | cc/builder.go | 96 | ||||
| -rw-r--r-- | cc/rs.go | 9 | ||||
| -rw-r--r-- | java/config/kotlin.go | 1 | ||||
| -rw-r--r-- | java/hiddenapi_singleton.go | 48 | ||||
| -rw-r--r-- | java/java_test.go | 2 | ||||
| -rw-r--r-- | java/kotlin.go | 1 | ||||
| -rw-r--r-- | java/sdk_test.go | 15 |
11 files changed, 93 insertions, 110 deletions
diff --git a/android/arch.go b/android/arch.go index f4a3c064f..46e582c26 100644 --- a/android/arch.go +++ b/android/arch.go @@ -713,7 +713,7 @@ func (target Target) String() string { // If host is supported for the module, the Host and HostCross OsClasses are selected. If device is supported // for the module, the Device OsClass is selected. // Within each selected OsClass, the multilib selection is determined by: -// - The compile_multilib property if it set (which may be overriden by target.android.compile_multlib or +// - The compile_multilib property if it set (which may be overridden by target.android.compile_multilib or // target.host.compile_multilib). // - The default multilib passed to InitAndroidArchModule if compile_multilib was not set. // Valid multilib values include: diff --git a/android/neverallow.go b/android/neverallow.go index ee3bf4a5e..ecff62d05 100644 --- a/android/neverallow.go +++ b/android/neverallow.go @@ -52,6 +52,7 @@ func createNeverAllows() []*rule { rules = append(rules, createTrebleRules()...) rules = append(rules, createLibcoreRules()...) rules = append(rules, createJavaDeviceForHostRules()...) + rules = append(rules, createJavaLibraryHostRules()...) return rules } @@ -127,6 +128,15 @@ func createJavaDeviceForHostRules() []*rule { } } +func createJavaLibraryHostRules() []*rule { + return []*rule{ + neverallow(). + moduleType("java_library_host"). + with("no_standard_libs", "true"). + because("no_standard_libs makes no sense with java_library_host"), + } +} + func neverallowMutator(ctx BottomUpMutatorContext) { m, ok := ctx.Module().(Module) if !ok { diff --git a/android/neverallow_test.go b/android/neverallow_test.go index 40ccf14a1..9c43d53e6 100644 --- a/android/neverallow_test.go +++ b/android/neverallow_test.go @@ -178,6 +178,18 @@ var neverallowTests = []struct { }`), }, }, + // java_library_host rule tests + { + name: "java_library_host with no_standard_libs: true", + fs: map[string][]byte{ + "libcore/Blueprints": []byte(` + java_library_host { + name: "inside_core_libraries", + no_standard_libs: true, + }`), + }, + expectedError: "module \"inside_core_libraries\": violates neverallow", + }, } func TestNeverallow(t *testing.T) { @@ -200,6 +212,7 @@ func testNeverallow(t *testing.T, config Config, fs map[string][]byte) (*TestCon ctx := NewTestContext() ctx.RegisterModuleType("cc_library", ModuleFactoryAdaptor(newMockCcLibraryModule)) ctx.RegisterModuleType("java_library", ModuleFactoryAdaptor(newMockJavaLibraryModule)) + ctx.RegisterModuleType("java_library_host", ModuleFactoryAdaptor(newMockJavaLibraryModule)) ctx.RegisterModuleType("java_device_for_host", ModuleFactoryAdaptor(newMockJavaLibraryModule)) ctx.PostDepsMutators(registerNeverallowMutator) ctx.Register() diff --git a/apex/apex.go b/apex/apex.go index 11b433c95..84e5497ce 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -61,7 +61,7 @@ var ( `--key ${key} ${opt_flags} ${image_dir} ${out} `, CommandDeps: []string{"${apexer}", "${avbtool}", "${e2fsdroid}", "${merge_zips}", "${mke2fs}", "${resize2fs}", "${sefcontext_compile}", - "${soong_zip}", "${zipalign}", "${aapt2}"}, + "${soong_zip}", "${zipalign}", "${aapt2}", "prebuilts/sdk/current/public/android.jar"}, Description: "APEX ${image_dir} => ${out}", }, "tool_path", "image_dir", "copy_commands", "manifest", "file_contexts", "canned_fs_config", "key", "opt_flags") @@ -1062,6 +1062,10 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext, apexType ap Description: "signapk", Output: a.outputFiles[apexType], Input: unsignedOutputFile, + Implicits: []android.Path{ + a.container_certificate_file, + a.container_private_key_file, + }, Args: map[string]string{ "certificates": a.container_certificate_file.String() + " " + a.container_private_key_file.String(), "flags": "-a 4096", //alignment diff --git a/cc/builder.go b/cc/builder.go index 3a8afc0d8..1e1236173 100644 --- a/cc/builder.go +++ b/cc/builder.go @@ -22,7 +22,6 @@ import ( "fmt" "path/filepath" "runtime" - "strconv" "strings" "github.com/google/blueprint" @@ -93,20 +92,6 @@ var ( }, "arCmd", "arFlags") - darwinAr = pctx.AndroidStaticRule("darwinAr", - blueprint.RuleParams{ - Command: "rm -f ${out} && ${config.MacArPath} $arFlags $out $in", - CommandDeps: []string{"${config.MacArPath}"}, - }, - "arFlags") - - darwinAppendAr = pctx.AndroidStaticRule("darwinAppendAr", - blueprint.RuleParams{ - Command: "cp -f ${inAr} ${out}.tmp && ${config.MacArPath} $arFlags ${out}.tmp $in && mv ${out}.tmp ${out}", - CommandDeps: []string{"${config.MacArPath}", "${inAr}"}, - }, - "arFlags", "inAr") - darwinStrip = pctx.AndroidStaticRule("darwinStrip", blueprint.RuleParams{ Command: "${config.MacStripPath} -u -r -o $out $in", @@ -515,11 +500,6 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and func TransformObjToStaticLib(ctx android.ModuleContext, objFiles android.Paths, flags builderFlags, outputFile android.ModuleOutPath, deps android.Paths) { - if ctx.Darwin() { - transformDarwinObjToStaticLib(ctx, objFiles, flags, outputFile, deps) - return - } - arCmd := "${config.ClangBin}/llvm-ar" arFlags := "crsD" if !ctx.Darwin() { @@ -542,82 +522,6 @@ func TransformObjToStaticLib(ctx android.ModuleContext, objFiles android.Paths, }) } -// Generate a rule for compiling multiple .o files to a static library (.a) on -// darwin. The darwin ar tool doesn't support @file for list files, and has a -// very small command line length limit, so we have to split the ar into multiple -// steps, each appending to the previous one. -func transformDarwinObjToStaticLib(ctx android.ModuleContext, objFiles android.Paths, - flags builderFlags, outputFile android.ModuleOutPath, deps android.Paths) { - - arFlags := "cqs" - - if len(objFiles) == 0 { - dummy := android.PathForModuleOut(ctx, "dummy"+objectExtension) - dummyAr := android.PathForModuleOut(ctx, "dummy"+staticLibraryExtension) - - ctx.Build(pctx, android.BuildParams{ - Rule: emptyFile, - Description: "empty object file", - Output: dummy, - Implicits: deps, - }) - - ctx.Build(pctx, android.BuildParams{ - Rule: darwinAr, - Description: "empty static archive", - Output: dummyAr, - Input: dummy, - Args: map[string]string{ - "arFlags": arFlags, - }, - }) - - ctx.Build(pctx, android.BuildParams{ - Rule: darwinAppendAr, - Description: "static link " + outputFile.Base(), - Output: outputFile, - Input: dummy, - Args: map[string]string{ - "arFlags": "d", - "inAr": dummyAr.String(), - }, - }) - - return - } - - // ARG_MAX on darwin is 262144, use half that to be safe - objFilesLists, err := splitListForSize(objFiles, 131072) - if err != nil { - ctx.ModuleErrorf("%s", err.Error()) - } - - var in, out android.WritablePath - for i, l := range objFilesLists { - in = out - out = outputFile - if i != len(objFilesLists)-1 { - out = android.PathForModuleOut(ctx, outputFile.Base()+strconv.Itoa(i)) - } - - build := android.BuildParams{ - Rule: darwinAr, - Description: "static link " + out.Base(), - Output: out, - Inputs: l, - Implicits: deps, - Args: map[string]string{ - "arFlags": arFlags, - }, - } - if i != 0 { - build.Rule = darwinAppendAr - build.Args["inAr"] = in.String() - } - ctx.Build(pctx, build) - } -} - // Generate a rule for compiling multiple .o files, plus static libraries, whole static libraries, // and shared libraries, to a shared library (.so) or dynamic executable func TransformObjToDynamicBinary(ctx android.ModuleContext, @@ -72,11 +72,12 @@ func rsGenerateCpp(ctx android.ModuleContext, rsFiles android.Paths, rsFlags str stampFile := android.PathForModuleGen(ctx, "rs", "rs.stamp") depFiles := make(android.WritablePaths, 0, len(rsFiles)) genFiles := make(android.WritablePaths, 0, 2*len(rsFiles)) + headers := make(android.Paths, 0, len(rsFiles)) for _, rsFile := range rsFiles { depFiles = append(depFiles, rsGeneratedDepFile(ctx, rsFile)) - genFiles = append(genFiles, - rsGeneratedCppFile(ctx, rsFile), - rsGeneratedHFile(ctx, rsFile)) + headerFile := rsGeneratedHFile(ctx, rsFile) + genFiles = append(genFiles, rsGeneratedCppFile(ctx, rsFile), headerFile) + headers = append(headers, headerFile) } ctx.Build(pctx, android.BuildParams{ @@ -92,7 +93,7 @@ func rsGenerateCpp(ctx android.ModuleContext, rsFiles android.Paths, rsFlags str }, }) - return android.Paths{stampFile} + return headers } func rsFlags(ctx ModuleContext, flags Flags, properties *BaseCompilerProperties) Flags { diff --git a/java/config/kotlin.go b/java/config/kotlin.go index 7cea0429e..fd8e3dbe9 100644 --- a/java/config/kotlin.go +++ b/java/config/kotlin.go @@ -32,6 +32,7 @@ func init() { pctx.SourcePathVariable("KotlinScriptRuntimeJar", "external/kotlinc/lib/kotlin-script-runtime.jar") pctx.SourcePathVariable("KotlinTrove4jJar", "external/kotlinc/lib/trove4j.jar") pctx.SourcePathVariable("KotlinKaptJar", "external/kotlinc/lib/kotlin-annotation-processing.jar") + pctx.SourcePathVariable("KotlinAnnotationJar", "external/kotlinc/lib/annotations-13.0.jar") pctx.SourcePathVariable("KotlinStdlibJar", KotlinStdlibJar) // These flags silence "Illegal reflective access" warnings when running kotlinc in OpenJDK9 diff --git a/java/hiddenapi_singleton.go b/java/hiddenapi_singleton.go index b1ddab48d..cf9f49285 100644 --- a/java/hiddenapi_singleton.go +++ b/java/hiddenapi_singleton.go @@ -15,11 +15,14 @@ package java import ( + "fmt" + "android/soong/android" ) func init() { android.RegisterSingletonType("hiddenapi", hiddenAPISingletonFactory) + android.RegisterModuleType("hiddenapi_flags", hiddenAPIFlagsFactory) } type hiddenAPISingletonPathsStruct struct { @@ -307,3 +310,48 @@ func commitChangeForRestat(rule *android.RuleBuilder, tempPath, outputPath andro Text("fi"). Text(")") } + +type hiddenAPIFlagsProperties struct { + // name of the file into which the flags will be copied. + Filename *string +} + +type hiddenAPIFlags struct { + android.ModuleBase + + properties hiddenAPIFlagsProperties + + outputFilePath android.OutputPath +} + +func (h *hiddenAPIFlags) GenerateAndroidBuildActions(ctx android.ModuleContext) { + filename := String(h.properties.Filename) + + inputPath := hiddenAPISingletonPaths(ctx).flags + h.outputFilePath = android.PathForModuleOut(ctx, filename).OutputPath + + // This ensures that outputFilePath has the correct name for others to + // use, as the source file may have a different name. + ctx.Build(pctx, android.BuildParams{ + Rule: android.Cp, + Output: h.outputFilePath, + Input: inputPath, + }) +} + +func (h *hiddenAPIFlags) OutputFiles(tag string) (android.Paths, error) { + switch tag { + case "": + return android.Paths{h.outputFilePath}, nil + default: + return nil, fmt.Errorf("unsupported module reference tag %q", tag) + } +} + +// hiddenapi-flags provides access to the hiddenapi-flags.csv file generated during the build. +func hiddenAPIFlagsFactory() android.Module { + module := &hiddenAPIFlags{} + module.AddProperties(&module.properties) + android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibCommon) + return module +} diff --git a/java/java_test.go b/java/java_test.go index 4d161c5ac..4c8367bb9 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -212,7 +212,7 @@ func run(t *testing.T, ctx *android.TestContext, config android.Config) { setDexpreoptTestGlobalConfig(config, dexpreopt.GlobalConfigForTests(pathCtx)) ctx.Register() - _, errs := ctx.ParseFileList(".", []string{"Android.bp", "prebuilts/sdk/Android.bp"}) + _, errs := ctx.ParseBlueprintsFiles("Android.bp") android.FailIfErrored(t, errs) _, errs = ctx.PrepareBuildActions(config) android.FailIfErrored(t, errs) diff --git a/java/kotlin.go b/java/kotlin.go index 33167bafd..83069072c 100644 --- a/java/kotlin.go +++ b/java/kotlin.go @@ -44,6 +44,7 @@ var kotlinc = pctx.AndroidGomaStaticRule("kotlinc", "${config.KotlinScriptRuntimeJar}", "${config.KotlinStdlibJar}", "${config.KotlinTrove4jJar}", + "${config.KotlinAnnotationJar}", "${config.GenKotlinBuildFileCmd}", "${config.SoongZipCmd}", "${config.ZipSyncCmd}", diff --git a/java/sdk_test.go b/java/sdk_test.go index cc4da2eca..23d7a98be 100644 --- a/java/sdk_test.go +++ b/java/sdk_test.go @@ -47,6 +47,14 @@ func TestClasspath(t *testing.T) { aidl: "-Iframework/aidl", }, { + name: "no_framework_libs:true", + properties: `no_framework_libs:true`, + bootclasspath: config.DefaultBootclasspathLibraries, + system: config.DefaultSystemModules, + classpath: []string{}, + aidl: "", + }, + { name: "blank sdk version", properties: `sdk_version: "",`, bootclasspath: config.DefaultBootclasspathLibraries, @@ -129,13 +137,6 @@ func TestClasspath(t *testing.T) { classpath: []string{}, }, { - name: "host nostdlib", - moduleType: "java_library_host", - host: android.Host, - properties: `no_standard_libs: true`, - classpath: []string{}, - }, - { name: "host supported default", host: android.Host, |