Merge "Convert collectAppDeps to use ModuleProxy." into main
diff --git a/Android.bp b/Android.bp
index 47a195c..98552a7 100644
--- a/Android.bp
+++ b/Android.bp
@@ -256,5 +256,8 @@
all_apex_certs {
name: "all_apex_certs",
- visibility: ["//cts/tests/tests/security"],
+ visibility: [
+ "//cts/tests/tests/security",
+ "//cts/hostsidetests/appsecurity",
+ ],
}
diff --git a/android/android_info.go b/android/android_info.go
index a8d3d4e..225c8f0 100644
--- a/android/android_info.go
+++ b/android/android_info.go
@@ -58,17 +58,19 @@
androidInfoTxtName := proptools.StringDefault(p.properties.Stem, ctx.ModuleName()+".txt")
androidInfoTxt := PathForModuleOut(ctx, androidInfoTxtName)
androidInfoProp := androidInfoTxt.ReplaceExtension(ctx, "prop")
+ timestamp := PathForModuleOut(ctx, "timestamp")
if boardInfoFiles := PathsForModuleSrc(ctx, p.properties.Board_info_files); len(boardInfoFiles) > 0 {
ctx.Build(pctx, BuildParams{
- Rule: mergeAndRemoveComments,
- Inputs: boardInfoFiles,
- Output: androidInfoTxt,
+ Rule: mergeAndRemoveComments,
+ Inputs: boardInfoFiles,
+ Output: androidInfoTxt,
+ Validation: timestamp,
})
} else if bootloaderBoardName := proptools.String(p.properties.Bootloader_board_name); bootloaderBoardName != "" {
- WriteFileRule(ctx, androidInfoTxt, "board="+bootloaderBoardName)
+ WriteFileRule(ctx, androidInfoTxt, "board="+bootloaderBoardName, timestamp)
} else {
- WriteFileRule(ctx, androidInfoTxt, "")
+ WriteFileRule(ctx, androidInfoTxt, "", timestamp)
}
// Create android_info.prop
@@ -79,6 +81,19 @@
})
ctx.SetOutputFiles(Paths{androidInfoProp}, "")
+ ctx.SetOutputFiles(Paths{androidInfoTxt}, ".txt")
+
+ builder := NewRuleBuilder(pctx, ctx)
+ builder.Command().Text("touch").Output(timestamp)
+ if !ctx.Config().KatiEnabled() {
+ cpPath := PathForModuleInPartitionInstall(ctx, "").Join(ctx, androidInfoTxtName)
+ builder.Command().
+ Text("rsync").
+ Flag("-a").
+ Input(androidInfoTxt).
+ Text(cpPath.String())
+ }
+ builder.Build("copy_android_info", "Copy android-info.txt")
}
// android_info module generate a file named android-info.txt that contains various information
@@ -86,6 +101,6 @@
func AndroidInfoFactory() Module {
module := &androidInfoModule{}
module.AddProperties(&module.properties)
- InitAndroidModule(module)
+ InitAndroidArchModule(module, DeviceSupported, MultilibCommon)
return module
}
diff --git a/android/androidmk.go b/android/androidmk.go
index 590cce3..87a93e3 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -701,11 +701,6 @@
type androidMkSingleton struct{}
func (c *androidMkSingleton) GenerateBuildActions(ctx SingletonContext) {
- // Skip if Soong wasn't invoked from Make.
- if !ctx.Config().KatiEnabled() {
- return
- }
-
var androidMkModulesList []blueprint.Module
ctx.VisitAllModulesBlueprint(func(module blueprint.Module) {
@@ -718,6 +713,12 @@
return ctx.ModuleName(androidMkModulesList[i]) < ctx.ModuleName(androidMkModulesList[j])
})
+ // If running in soong-only mode, do a different, more limited version of this singleton
+ if !ctx.Config().KatiEnabled() {
+ c.soongOnlyBuildActions(ctx, androidMkModulesList)
+ return
+ }
+
transMk := PathForOutput(ctx, "Android"+String(ctx.Config().productVariables.Make_suffix)+".mk")
if ctx.Failed() {
return
@@ -736,6 +737,122 @@
})
}
+// In soong-only mode, we don't do most of the androidmk stuff. But disted files are still largely
+// defined through the androidmk mechanisms, so this function is an alternate implementation of
+// the androidmk singleton that just focuses on getting the dist contributions
+func (c *androidMkSingleton) soongOnlyBuildActions(ctx SingletonContext, mods []blueprint.Module) {
+ allDistContributions := getDistContributionsFromMods(ctx, mods)
+
+ distMkFile := absolutePath(filepath.Join(ctx.Config().katiPackageMkDir(), "dist.mk"))
+
+ var goalOutputPairs []string
+ var srcDstPairs []string
+ for _, contributions := range allDistContributions {
+ for _, copiesForGoal := range contributions.copiesForGoals {
+ goals := strings.Fields(copiesForGoal.goals)
+ for _, copy := range copiesForGoal.copies {
+ for _, goal := range goals {
+ goalOutputPairs = append(goalOutputPairs, fmt.Sprintf(" %s:%s", goal, copy.dest))
+ }
+ srcDstPairs = append(srcDstPairs, fmt.Sprintf(" %s:%s", copy.from.String(), copy.dest))
+ }
+ }
+ }
+ // There are duplicates in the lists that we need to remove
+ goalOutputPairs = SortedUniqueStrings(goalOutputPairs)
+ srcDstPairs = SortedUniqueStrings(srcDstPairs)
+ var buf strings.Builder
+ buf.WriteString("DIST_SRC_DST_PAIRS :=")
+ for _, srcDstPair := range srcDstPairs {
+ buf.WriteString(srcDstPair)
+ }
+ buf.WriteString("\nDIST_GOAL_OUTPUT_PAIRS :=")
+ for _, goalOutputPair := range goalOutputPairs {
+ buf.WriteString(goalOutputPair)
+ }
+ buf.WriteString("\n")
+
+ writeValueIfChanged(ctx, distMkFile, buf.String())
+}
+
+func writeValueIfChanged(ctx SingletonContext, path string, value string) {
+ if err := os.MkdirAll(filepath.Dir(path), 0777); err != nil {
+ ctx.Errorf("%s\n", err)
+ return
+ }
+ previousValue := ""
+ rawPreviousValue, err := os.ReadFile(path)
+ if err == nil {
+ previousValue = string(rawPreviousValue)
+ }
+
+ if previousValue != value {
+ if err = os.WriteFile(path, []byte(value), 0666); err != nil {
+ ctx.Errorf("Failed to write: %v", err)
+ }
+ }
+}
+
+func getDistContributionsFromMods(ctx fillInEntriesContext, mods []blueprint.Module) []distContributions {
+ var allDistContributions []distContributions
+ for _, mod := range mods {
+ if amod, ok := mod.(Module); ok && shouldSkipAndroidMkProcessing(ctx, amod.base()) {
+ continue
+ }
+ if info, ok := OtherModuleProvider(ctx, mod, AndroidMkInfoProvider); ok {
+ // Deep copy the provider info since we need to modify the info later
+ info := deepCopyAndroidMkProviderInfo(info)
+ info.PrimaryInfo.fillInEntries(ctx, mod)
+ if info.PrimaryInfo.disabled() {
+ continue
+ }
+ if contribution := info.PrimaryInfo.getDistContributions(ctx, mod); contribution != nil {
+ allDistContributions = append(allDistContributions, *contribution)
+ }
+ for _, ei := range info.ExtraInfo {
+ ei.fillInEntries(ctx, mod)
+ if ei.disabled() {
+ continue
+ }
+ if contribution := ei.getDistContributions(ctx, mod); contribution != nil {
+ allDistContributions = append(allDistContributions, *contribution)
+ }
+ }
+ } else {
+ switch x := mod.(type) {
+ case AndroidMkDataProvider:
+ data := x.AndroidMk()
+
+ if data.Include == "" {
+ data.Include = "$(BUILD_PREBUILT)"
+ }
+
+ data.fillInData(ctx, mod)
+ if data.Entries.disabled() {
+ continue
+ }
+ if contribution := data.Entries.getDistContributions(mod); contribution != nil {
+ allDistContributions = append(allDistContributions, *contribution)
+ }
+ case AndroidMkEntriesProvider:
+ entriesList := x.AndroidMkEntries()
+ for _, entries := range entriesList {
+ entries.fillInEntries(ctx, mod)
+ if entries.disabled() {
+ continue
+ }
+ if contribution := entries.getDistContributions(mod); contribution != nil {
+ allDistContributions = append(allDistContributions, *contribution)
+ }
+ }
+ default:
+ // Not exported to make so no make variables to set.
+ }
+ }
+ }
+ return allDistContributions
+}
+
func translateAndroidMk(ctx SingletonContext, absMkFile string, moduleInfoJSONPath WritablePath, mods []blueprint.Module) error {
buf := &bytes.Buffer{}
diff --git a/android/config.go b/android/config.go
index e9cb2cd..87aacd5 100644
--- a/android/config.go
+++ b/android/config.go
@@ -83,6 +83,7 @@
OutDir string
SoongOutDir string
SoongVariables string
+ KatiSuffix string
ModuleGraphFile string
ModuleActionsFile string
@@ -349,6 +350,7 @@
// Changes behavior based on whether Kati runs after soong_build, or if soong_build
// runs standalone.
katiEnabled bool
+ katiSuffix string
captureBuild bool // true for tests, saves build parameters for each module
ignoreEnvironment bool // true for tests, returns empty from all Getenv calls
@@ -620,6 +622,7 @@
outDir: cmdArgs.OutDir,
soongOutDir: cmdArgs.SoongOutDir,
runGoTests: cmdArgs.RunGoTests,
+ katiSuffix: cmdArgs.KatiSuffix,
multilibConflicts: make(map[ArchType]bool),
moduleListFile: cmdArgs.ModuleListFile,
@@ -1512,6 +1515,10 @@
return c.productVariables.GetBuildFlagBool("RELEASE_BOARD_API_LEVEL_FROZEN")
}
+func (c *config) katiPackageMkDir() string {
+ return filepath.Join(c.soongOutDir, "kati_packaging"+c.katiSuffix)
+}
+
func (c *deviceConfig) Arches() []Arch {
var arches []Arch
for _, target := range c.config.Targets[Android] {
@@ -2182,7 +2189,7 @@
"RELEASE_APEX_CONTRIBUTIONS_ADSERVICES": "com.android.adservices",
"RELEASE_APEX_CONTRIBUTIONS_APPSEARCH": "com.android.appsearch",
"RELEASE_APEX_CONTRIBUTIONS_ART": "com.android.art",
- "RELEASE_APEX_CONTRIBUTIONS_BLUETOOTH": "com.android.btservices",
+ "RELEASE_APEX_CONTRIBUTIONS_BLUETOOTH": "com.android.bt",
"RELEASE_APEX_CONTRIBUTIONS_CAPTIVEPORTALLOGIN": "",
"RELEASE_APEX_CONTRIBUTIONS_CELLBROADCAST": "com.android.cellbroadcast",
"RELEASE_APEX_CONTRIBUTIONS_CONFIGINFRASTRUCTURE": "com.android.configinfrastructure",
diff --git a/android/container_violations.go b/android/container_violations.go
index ba8f7d5..e1583c5 100644
--- a/android/container_violations.go
+++ b/android/container_violations.go
@@ -32,22 +32,22 @@
},
"Bluetooth": {
- "app-compat-annotations", // apex [com.android.btservices] -> system
- "framework-bluetooth-pre-jarjar", // apex [com.android.btservices] -> system
+ "app-compat-annotations", // apex [com.android.bt] -> system
+ "framework-bluetooth-pre-jarjar", // apex [com.android.bt] -> system
},
"bluetooth-nano-protos": {
- "libprotobuf-java-nano", // apex [com.android.btservices] -> apex [com.android.wifi, test_com.android.wifi]
+ "libprotobuf-java-nano", // apex [com.android.bt] -> apex [com.android.wifi, test_com.android.wifi]
},
"bluetooth.change-ids": {
- "app-compat-annotations", // apex [com.android.btservices] -> system
+ "app-compat-annotations", // apex [com.android.bt] -> system
},
"CarServiceUpdatable": {
"modules-utils-os", // apex [com.android.car.framework] -> apex [com.android.permission, test_com.android.permission]
"modules-utils-preconditions", // apex [com.android.car.framework] -> apex [com.android.adservices, com.android.appsearch, com.android.cellbroadcast, com.android.extservices, com.android.ondevicepersonalization, com.android.tethering, com.android.uwb, com.android.wifi, test_com.android.cellbroadcast, test_com.android.wifi]
- "modules-utils-shell-command-handler", // apex [com.android.car.framework] -> apex [com.android.adservices, com.android.art, com.android.art.debug, com.android.art.testing, com.android.btservices, com.android.configinfrastructure, com.android.mediaprovider, com.android.nfcservices, com.android.permission, com.android.scheduling, com.android.tethering, com.android.uwb, com.android.wifi, test_com.android.mediaprovider, test_com.android.permission, test_com.android.wifi, test_imgdiag_com.android.art, test_jitzygote_com.android.art]
+ "modules-utils-shell-command-handler", // apex [com.android.car.framework] -> apex [com.android.adservices, com.android.art, com.android.art.debug, com.android.art.testing, com.android.bt, com.android.configinfrastructure, com.android.mediaprovider, com.android.nfcservices, com.android.permission, com.android.scheduling, com.android.tethering, com.android.uwb, com.android.wifi, test_com.android.mediaprovider, test_com.android.permission, test_com.android.wifi, test_imgdiag_com.android.art, test_jitzygote_com.android.art]
},
"cellbroadcastreceiver_aconfig_flags_lib": {
@@ -414,10 +414,6 @@
"framework", // cts -> unstable
},
- "CtsMediaBetterTogetherTestCases": {
- "framework", // cts -> unstable
- },
-
"CtsMediaCodecTestCases": {
"framework", // cts -> unstable
},
@@ -478,6 +474,11 @@
"framework", // cts -> unstable
},
+ // TODO(b/387499846): Remove once migrated to sdk_version.
+ "CtsMediaRouterTestCases": {
+ "framework", // cts -> unstable
+ },
+
"CtsMediaRouterHostSideTestBluetoothPermissionsApp": {
"framework", // cts -> unstable
},
@@ -490,6 +491,11 @@
"framework", // cts -> unstable
},
+ // TODO(b/387500109): Remove once migrated to sdk_version.
+ "CtsMediaSessionTestCases": {
+ "framework", // cts -> unstable
+ },
+
"CtsMediaV2TestCases": {
"framework", // cts -> unstable
},
@@ -824,7 +830,7 @@
},
"devicelockcontroller-lib": {
- "modules-utils-expresslog", // apex [com.android.devicelock] -> apex [com.android.btservices, com.android.car.framework]
+ "modules-utils-expresslog", // apex [com.android.devicelock] -> apex [com.android.bt, com.android.car.framework]
},
"FederatedCompute": {
@@ -836,7 +842,7 @@
},
"framework-bluetooth.impl": {
- "app-compat-annotations", // apex [com.android.btservices] -> system
+ "app-compat-annotations", // apex [com.android.bt] -> system
},
"framework-configinfrastructure.impl": {
@@ -907,10 +913,6 @@
"libnativeloader_vendor_shared_lib", // system -> vendor
},
- "MctsMediaBetterTogetherTestCases": {
- "framework", // cts -> unstable
- },
-
"MctsMediaCodecTestCases": {
"framework", // cts -> unstable
},
@@ -947,6 +949,16 @@
"framework", // cts -> unstable
},
+ // TODO(b/387499846): Remove once migrated to sdk_version.
+ "MctsMediaRouterTestCases": {
+ "framework", // cts -> unstable
+ },
+
+ // TODO(b/387500109): Remove once migrated to sdk_version.
+ "MctsMediaSessionTestCases": {
+ "framework", // cts -> unstable
+ },
+
"MctsMediaTranscodingTestCases": {
"framework", // cts -> unstable
},
@@ -1005,7 +1017,7 @@
},
"PlatformProperties": {
- "sysprop-library-stub-platform", // apex [com.android.btservices, com.android.nfcservices, com.android.tethering, com.android.virt, com.android.wifi, test_com.android.wifi] -> system
+ "sysprop-library-stub-platform", // apex [com.android.bt, com.android.nfcservices, com.android.tethering, com.android.virt, com.android.wifi, test_com.android.wifi] -> system
},
"safety-center-config": {
@@ -1041,8 +1053,8 @@
},
"service-bluetooth-pre-jarjar": {
- "framework-bluetooth-pre-jarjar", // apex [com.android.btservices] -> system
- "service-bluetooth.change-ids", // apex [com.android.btservices] -> system
+ "framework-bluetooth-pre-jarjar", // apex [com.android.bt] -> system
+ "service-bluetooth.change-ids", // apex [com.android.bt] -> system
},
"service-connectivity": {
diff --git a/android/module.go b/android/module.go
index 5089564..9e620fb 100644
--- a/android/module.go
+++ b/android/module.go
@@ -1679,14 +1679,13 @@
}
})
- var deps Paths
-
var namespacePrefix string
nameSpace := ctx.Namespace().Path
if nameSpace != "." {
namespacePrefix = strings.ReplaceAll(nameSpace, "/", ".") + "-"
}
+ var deps Paths
var info FinalModuleBuildTargetsInfo
if len(allInstalledFiles) > 0 {
@@ -1853,9 +1852,9 @@
var SourceFilesInfoKey = blueprint.NewProvider[SourceFilesInfo]()
+// FinalModuleBuildTargetsInfo is used by buildTargetSingleton to create checkbuild and
+// per-directory build targets. Only set on the final variant of each module
type FinalModuleBuildTargetsInfo struct {
- // Used by buildTargetSingleton to create checkbuild and per-directory build targets
- // Only set on the final variant of each module
InstallTarget WritablePath
CheckbuildTarget WritablePath
BlueprintDir string
diff --git a/android/module_context.go b/android/module_context.go
index ba31cb2..f6a676d 100644
--- a/android/module_context.go
+++ b/android/module_context.go
@@ -75,7 +75,7 @@
// Validations is a slice of output path for a validation action. Validation outputs imply lower
// non-blocking priority to building non-validation outputs.
Validations Paths
- // Whether to skip outputting a default target statement which will be built by Ninja when no
+ // Whether to output a default target statement which will be built by Ninja when no
// targets are specified on Ninja's command line.
Default bool
// Args is a key value mapping for replacements of variables within the Rule
@@ -343,7 +343,7 @@
OrderOnly: params.OrderOnly.Strings(),
Validations: params.Validations.Strings(),
Args: params.Args,
- Optional: !params.Default,
+ Default: params.Default,
}
if params.Depfile != nil {
diff --git a/android/neverallow.go b/android/neverallow.go
index d211784..cf0b297 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -230,7 +230,7 @@
func createUncompressDexRules() []Rule {
return []Rule{
NeverAllow().
- NotIn("art").
+ NotIn("art", "cts/hostsidetests/compilation").
WithMatcher("uncompress_dex", isSetMatcherInstance).
Because("uncompress_dex is only allowed for certain jars for test in art."),
}
@@ -291,16 +291,20 @@
return []Rule{
NeverAllow().
ModuleType("dirgroup").
- WithMatcher("visibility", NotInList([]string{"//trusty/vendor/google/aosp/scripts"})).Because(reason),
+ WithMatcher("visibility", NotInList([]string{"//trusty/vendor/google/aosp/scripts", "//trusty/vendor/google/proprietary/scripts"})).Because(reason),
NeverAllow().
ModuleType("dirgroup").
- Without("visibility", "//trusty/vendor/google/aosp/scripts").Because(reason),
+ WithoutMatcher("visibility", InAllowedList([]string{"//trusty/vendor/google/aosp/scripts", "//trusty/vendor/google/proprietary/scripts"})).Because(reason),
NeverAllow().
ModuleType("genrule").
Without("name", "trusty-arm64.lk.elf.gen").
Without("name", "trusty-arm64-virt-test-debug.lk.elf.gen").
Without("name", "trusty-x86_64.lk.elf.gen").
Without("name", "trusty-x86_64-test.lk.elf.gen").
+ Without("name", "trusty-arm64.wv.lk.elf.gen").
+ Without("name", "trusty-arm64-virt-test-debug.wv.lk.elf.gen").
+ Without("name", "trusty-x86_64.wv.lk.elf.gen").
+ Without("name", "trusty-x86_64-test.wv.lk.elf.gen").
WithMatcher("dir_srcs", isSetMatcherInstance).Because(reason),
NeverAllow().
ModuleType("genrule").
@@ -308,6 +312,10 @@
Without("name", "trusty-arm64-virt-test-debug.lk.elf.gen").
Without("name", "trusty-x86_64.lk.elf.gen").
Without("name", "trusty-x86_64-test.lk.elf.gen").
+ Without("name", "trusty-arm64.wv.lk.elf.gen").
+ Without("name", "trusty-arm64-virt-test-debug.wv.lk.elf.gen").
+ Without("name", "trusty-x86_64.wv.lk.elf.gen").
+ Without("name", "trusty-x86_64-test.wv.lk.elf.gen").
With("keep_gendir", "true").Because(reason),
}
}
@@ -474,6 +482,18 @@
return ".not-in-list(" + strings.Join(m.allowed, ",") + ")"
}
+type InListMatcher struct {
+ allowed []string
+}
+
+func (m *InListMatcher) Test(value string) bool {
+ return InList(value, m.allowed)
+}
+
+func (m *InListMatcher) String() string {
+ return ".in-list(" + strings.Join(m.allowed, ",") + ")"
+}
+
type isSetMatcher struct{}
func (m *isSetMatcher) Test(value string) bool {
@@ -752,6 +772,10 @@
return ¬InListMatcher{allowed}
}
+func InAllowedList(allowed []string) ValueMatcher {
+ return &InListMatcher{allowed}
+}
+
// assorted utils
func cleanPaths(paths []string) []string {
diff --git a/android/phony.go b/android/phony.go
index f8db88d..7bdd9d3 100644
--- a/android/phony.go
+++ b/android/phony.go
@@ -15,6 +15,7 @@
package android
import (
+ "strings"
"sync"
"github.com/google/blueprint"
@@ -68,13 +69,25 @@
}
if !ctx.Config().KatiEnabled() {
+ // In soong-only builds, the phonies can conflict with dist targets that will
+ // be generated in the packaging step. Instead of emitting a blueprint/ninja phony directly,
+ // create a makefile that defines the phonies that will be included in the packaging step.
+ // Make will dedup the phonies there.
+ var buildPhonyFileContents strings.Builder
for _, phony := range p.phonyList {
- ctx.Build(pctx, BuildParams{
- Rule: blueprint.Phony,
- Outputs: []WritablePath{PathForPhony(ctx, phony)},
- Implicits: p.phonyMap[phony],
- })
+ buildPhonyFileContents.WriteString(".PHONY: ")
+ buildPhonyFileContents.WriteString(phony)
+ buildPhonyFileContents.WriteString("\n")
+ buildPhonyFileContents.WriteString(phony)
+ buildPhonyFileContents.WriteString(":")
+ for _, dep := range p.phonyMap[phony] {
+ buildPhonyFileContents.WriteString(" ")
+ buildPhonyFileContents.WriteString(dep.String())
+ }
+ buildPhonyFileContents.WriteString("\n")
}
+ buildPhonyFile := PathForOutput(ctx, "soong_phony_targets.mk")
+ writeValueIfChanged(ctx, absolutePath(buildPhonyFile.String()), buildPhonyFileContents.String())
}
}
diff --git a/android/raw_files.go b/android/raw_files.go
index 9d7f5e8..fd37196 100644
--- a/android/raw_files.go
+++ b/android/raw_files.go
@@ -18,7 +18,6 @@
"crypto/sha1"
"encoding/hex"
"fmt"
- "github.com/google/blueprint"
"io"
"io/fs"
"os"
@@ -26,25 +25,27 @@
"strings"
"testing"
+ "github.com/google/blueprint"
+
"github.com/google/blueprint/proptools"
)
// WriteFileRule creates a ninja rule to write contents to a file by immediately writing the
// contents, plus a trailing newline, to a file in out/soong/raw-${TARGET_PRODUCT}, and then creating
// a ninja rule to copy the file into place.
-func WriteFileRule(ctx BuilderContext, outputFile WritablePath, content string) {
- writeFileRule(ctx, outputFile, content, true, false)
+func WriteFileRule(ctx BuilderContext, outputFile WritablePath, content string, validations ...Path) {
+ writeFileRule(ctx, outputFile, content, true, false, validations)
}
// WriteFileRuleVerbatim creates a ninja rule to write contents to a file by immediately writing the
// contents to a file in out/soong/raw-${TARGET_PRODUCT}, and then creating a ninja rule to copy the file into place.
-func WriteFileRuleVerbatim(ctx BuilderContext, outputFile WritablePath, content string) {
- writeFileRule(ctx, outputFile, content, false, false)
+func WriteFileRuleVerbatim(ctx BuilderContext, outputFile WritablePath, content string, validations ...Path) {
+ writeFileRule(ctx, outputFile, content, false, false, validations)
}
// WriteExecutableFileRuleVerbatim is the same as WriteFileRuleVerbatim, but runs chmod +x on the result
-func WriteExecutableFileRuleVerbatim(ctx BuilderContext, outputFile WritablePath, content string) {
- writeFileRule(ctx, outputFile, content, false, true)
+func WriteExecutableFileRuleVerbatim(ctx BuilderContext, outputFile WritablePath, content string, validations ...Path) {
+ writeFileRule(ctx, outputFile, content, false, true, validations)
}
// tempFile provides a testable wrapper around a file in out/soong/.temp. It writes to a temporary file when
@@ -124,7 +125,7 @@
return tempFile, hex.EncodeToString(hash.Sum(nil))
}
-func writeFileRule(ctx BuilderContext, outputFile WritablePath, content string, newline bool, executable bool) {
+func writeFileRule(ctx BuilderContext, outputFile WritablePath, content string, newline bool, executable bool, validations Paths) {
// Write the contents to a temporary file while computing its hash.
tempFile, hash := writeContentToTempFileAndHash(ctx, content, newline)
@@ -186,6 +187,7 @@
Input: rawPath,
Output: outputFile,
Description: "raw " + outputFile.Base(),
+ Validations: validations,
})
}
diff --git a/android/variable.go b/android/variable.go
index 6e46e9d..4b61827 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -697,6 +697,8 @@
TargetScreenDensity string `json:",omitempty"`
PrivateRecoveryUiProperties map[string]string `json:",omitempty"`
+
+ PrebuiltBootloader string `json:",omitempty"`
}
func boolPtr(v bool) *bool {
diff --git a/apex/apex.go b/apex/apex.go
index 58960ac..d39a17f 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1056,7 +1056,7 @@
"com.android.appsearch",
"com.android.art",
"com.android.art.debug",
- "com.android.btservices",
+ "com.android.bt",
"com.android.cellbroadcast",
"com.android.configinfrastructure",
"com.android.conscrypt",
diff --git a/apex/builder.go b/apex/builder.go
index b74f4de..d9348c5 100644
--- a/apex/builder.go
+++ b/apex/builder.go
@@ -73,6 +73,7 @@
pctx.HostBinToolVariable("make_erofs", "mkfs.erofs")
pctx.HostBinToolVariable("apex_compression_tool", "apex_compression_tool")
pctx.HostBinToolVariable("dexdeps", "dexdeps")
+ pctx.HostBinToolVariable("apex_ls", "apex-ls")
pctx.HostBinToolVariable("apex_sepolicy_tests", "apex_sepolicy_tests")
pctx.HostBinToolVariable("deapexer", "deapexer")
pctx.HostBinToolVariable("debugfs_static", "debugfs_static")
@@ -210,9 +211,9 @@
}, "image_dir", "readelf")
apexSepolicyTestsRule = pctx.StaticRule("apexSepolicyTestsRule", blueprint.RuleParams{
- Command: `${deapexer} --debugfs_path ${debugfs_static} list -Z ${in} > ${out}.fc` +
+ Command: `${apex_ls} -Z ${in} > ${out}.fc` +
` && ${apex_sepolicy_tests} -f ${out}.fc --partition ${partition_tag} && touch ${out}`,
- CommandDeps: []string{"${apex_sepolicy_tests}", "${deapexer}", "${debugfs_static}"},
+ CommandDeps: []string{"${apex_sepolicy_tests}", "${apex_ls}"},
Description: "run apex_sepolicy_tests",
}, "partition_tag")
@@ -918,8 +919,7 @@
}
var validations android.Paths
validations = append(validations, runApexLinkerconfigValidation(ctx, unsignedOutputFile, imageDir))
- // TODO(b/279688635) deapexer supports [ext4]
- if !a.skipValidation(apexSepolicyTests) && suffix == imageApexSuffix && ext4 == a.payloadFsType {
+ if !a.skipValidation(apexSepolicyTests) && android.InList(a.payloadFsType, []fsType{ext4, erofs}) {
validations = append(validations, runApexSepolicyTests(ctx, a, unsignedOutputFile))
}
if !a.testApex && len(a.properties.Unwanted_transitive_deps) > 0 {
@@ -1204,7 +1204,7 @@
// Runs apex_sepolicy_tests
//
-// $ deapexer list -Z {apex_file} > {file_contexts}
+// $ apex-ls -Z {apex_file} > {file_contexts}
// $ apex_sepolicy_tests -f {file_contexts}
func runApexSepolicyTests(ctx android.ModuleContext, a *apexBundle, apexFile android.Path) android.Path {
timestamp := android.PathForModuleOut(ctx, "apex_sepolicy_tests.timestamp")
diff --git a/apex/key.go b/apex/key.go
index 9fa9d1e..1622c65 100644
--- a/apex/key.go
+++ b/apex/key.go
@@ -182,6 +182,7 @@
}
func (_ *allApexCerts) GenerateAndroidBuildActions(ctx android.ModuleContext) {
+ var avbpubkeys android.Paths
var certificatesPem android.Paths
ctx.VisitDirectDeps(func(m android.Module) {
if apex, ok := m.(*apexBundle); ok {
@@ -194,9 +195,12 @@
}
}
certificatesPem = append(certificatesPem, pem)
+ // avbpubkey for signing the apex payload
+ avbpubkeys = append(avbpubkeys, apex.publicKeyFile)
}
})
certificatesPem = android.SortedUniquePaths(certificatesPem) // For hermiticity
+ avbpubkeys = android.SortedUniquePaths(avbpubkeys) // For hermiticity
var certificatesDer android.Paths
for index, certificatePem := range certificatesPem {
certificateDer := android.PathForModuleOut(ctx, fmt.Sprintf("x509.%v.der", index))
@@ -209,6 +213,7 @@
}
ctx.SetOutputFiles(certificatesPem, ".pem")
ctx.SetOutputFiles(certificatesDer, ".der")
+ ctx.SetOutputFiles(avbpubkeys, ".avbpubkey")
}
func (_ *allApexCerts) GenerateSingletonBuildActions(ctx android.SingletonContext) {
diff --git a/cc/config/darwin_host.go b/cc/config/darwin_host.go
index 1783f49..716965a 100644
--- a/cc/config/darwin_host.go
+++ b/cc/config/darwin_host.go
@@ -54,6 +54,7 @@
"12",
"13",
"14",
+ "15",
}
darwinAvailableLibraries = append(
diff --git a/cc/config/global.go b/cc/config/global.go
index b19682d..d969e97 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -366,8 +366,6 @@
"-Wno-array-parameter",
"-Wno-gnu-offsetof-extensions",
"-Wno-pessimizing-move",
- // TODO: Enable this warning http://b/315245071
- "-Wno-fortify-source",
}
llvmNextExtraCommonGlobalCflags = []string{
diff --git a/cc/config/x86_windows_host.go b/cc/config/x86_windows_host.go
index 1f6cf23..505ddfa 100644
--- a/cc/config/x86_windows_host.go
+++ b/cc/config/x86_windows_host.go
@@ -112,6 +112,7 @@
"imagehlp",
"iphlpapi",
"netapi32",
+ "ntdll",
"oleaut32",
"ole32",
"opengl32",
diff --git a/cc/library.go b/cc/library.go
index de09d53..0566182 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -1386,6 +1386,11 @@
extraFlags = append(extraFlags,
"-allow-unreferenced-changes",
"-allow-unreferenced-elf-symbol-changes")
+ // The functions in standard libraries are not always declared in the headers.
+ // Allow them to be added or removed without changing the symbols.
+ if isBionic(ctx.ModuleName()) {
+ extraFlags = append(extraFlags, "-allow-adding-removing-referenced-apis")
+ }
}
if isLlndk {
extraFlags = append(extraFlags, "-consider-opaque-types-different")
diff --git a/cmd/soong_build/main.go b/cmd/soong_build/main.go
index 6642023..cd4e9bd 100644
--- a/cmd/soong_build/main.go
+++ b/cmd/soong_build/main.go
@@ -64,6 +64,7 @@
flag.StringVar(&usedEnvFile, "used_env", "", "File containing used environment variables")
flag.StringVar(&cmdlineArgs.OutDir, "out", "", "the ninja builddir directory")
flag.StringVar(&cmdlineArgs.ModuleListFile, "l", "", "file that lists filepaths to parse")
+ flag.StringVar(&cmdlineArgs.KatiSuffix, "kati_suffix", "", "the suffix for kati and ninja files, so that different configurations don't clobber each other")
// Debug flags
flag.StringVar(&delveListen, "delve_listen", "", "Delve port to listen on for debugging")
diff --git a/filesystem/android_device.go b/filesystem/android_device.go
index fd8e915..6a939e8 100644
--- a/filesystem/android_device.go
+++ b/filesystem/android_device.go
@@ -15,6 +15,9 @@
package filesystem
import (
+ "strings"
+ "sync/atomic"
+
"android/soong/android"
"github.com/google/blueprint"
@@ -52,19 +55,33 @@
Odm_dlkm_partition_name *string
}
+type DeviceProperties struct {
+ // Path to the prebuilt bootloader that would be copied to PRODUCT_OUT
+ Bootloader *string `android:"path"`
+ // Path to android-info.txt file containing board specific info.
+ Android_info *string `android:"path"`
+}
+
type androidDevice struct {
android.ModuleBase
partitionProps PartitionNameProperties
+
+ deviceProps DeviceProperties
+
+ // copyToProductOutTimestamp for copying necessary files to PRODUCT_OUT
+ copyToProductOutTimestamp android.WritablePath
}
func AndroidDeviceFactory() android.Module {
module := &androidDevice{}
- module.AddProperties(&module.partitionProps)
+ module.AddProperties(&module.partitionProps, &module.deviceProps)
android.InitAndroidMultiTargetsArchModule(module, android.DeviceSupported, android.MultilibFirst)
return module
}
+var numAutogeneratedAndroidDevicesOnceKey android.OnceKey = android.NewOnceKey("num_auto_generated_anroid_devices")
+
type partitionDepTagType struct {
blueprint.BaseDependencyTag
}
@@ -79,6 +96,8 @@
}
addDependencyIfDefined(a.partitionProps.Boot_partition_name)
+ addDependencyIfDefined(a.partitionProps.Init_boot_partition_name)
+ addDependencyIfDefined(a.partitionProps.Vendor_boot_partition_name)
addDependencyIfDefined(a.partitionProps.System_partition_name)
addDependencyIfDefined(a.partitionProps.System_ext_partition_name)
addDependencyIfDefined(a.partitionProps.Product_partition_name)
@@ -88,13 +107,79 @@
addDependencyIfDefined(a.partitionProps.System_dlkm_partition_name)
addDependencyIfDefined(a.partitionProps.Vendor_dlkm_partition_name)
addDependencyIfDefined(a.partitionProps.Odm_dlkm_partition_name)
+ addDependencyIfDefined(a.partitionProps.Recovery_partition_name)
for _, vbmetaPartition := range a.partitionProps.Vbmeta_partitions {
ctx.AddDependency(ctx.Module(), filesystemDepTag, vbmetaPartition)
}
}
+func (a *androidDevice) copyToProductOut(ctx android.ModuleContext, builder *android.RuleBuilder, src android.Path, dest string) {
+ destPath := android.PathForModuleInPartitionInstall(ctx, "").Join(ctx, dest)
+ builder.Command().Text("rsync").Flag("-a").Flag("--checksum").Input(src).Text(destPath.String())
+}
+
+func (a *androidDevice) copyFilesToProductOut(ctx android.ModuleContext) {
+ a.copyToProductOutTimestamp = android.PathForModuleOut(ctx, "timestamp")
+ builder := android.NewRuleBuilder(pctx, ctx)
+ builder.Command().Text("touch").Output(a.copyToProductOutTimestamp)
+
+ // List all individual files to be copied to PRODUCT_OUT here
+ if a.deviceProps.Bootloader != nil {
+ a.copyToProductOut(ctx, builder, android.PathForModuleSrc(ctx, proptools.String(a.deviceProps.Bootloader)), "bootloader")
+ }
+
+ builder.Build("copy_to_product_out", "Copy files to PRODUCT_OUT")
+}
+
func (a *androidDevice) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.buildTargetFilesZip(ctx)
+ var deps []android.Path
+ ctx.VisitDirectDepsWithTag(filesystemDepTag, func(m android.Module) {
+ imageOutput, ok := android.OtherModuleProvider(ctx, m, android.OutputFilesProvider)
+ if !ok {
+ ctx.ModuleErrorf("Partition module %s doesn't set OutputfilesProvider", m.Name())
+ }
+ if len(imageOutput.DefaultOutputFiles) != 1 {
+ ctx.ModuleErrorf("Partition module %s should provide exact 1 output file", m.Name())
+ }
+ deps = append(deps, imageOutput.DefaultOutputFiles[0])
+ })
+
+ a.copyFilesToProductOut(ctx)
+
+ allImagesStamp := android.PathForModuleOut(ctx, "all_images_stamp")
+ ctx.Build(pctx, android.BuildParams{
+ Rule: android.Touch,
+ Output: allImagesStamp,
+ Implicits: deps,
+ Validation: a.copyToProductOutTimestamp,
+ })
+ ctx.SetOutputFiles(android.Paths{allImagesStamp}, "")
+ ctx.CheckbuildFile(allImagesStamp)
+
+ if ctx.OtherModuleIsAutoGenerated(ctx.Module()) {
+ numAutogeneratedAndroidDevices := ctx.Config().Once(numAutogeneratedAndroidDevicesOnceKey, func() interface{} {
+ return &atomic.Int32{}
+ }).(*atomic.Int32)
+ total := numAutogeneratedAndroidDevices.Add(1)
+ if total > 1 {
+ // There should only be 1 autogenerated android_device module. That one will be
+ // made the default thing to build in soong-only builds.
+ ctx.ModuleErrorf("There cannot be more than 1 autogenerated android_device module")
+ }
+ }
+
+ if !ctx.Config().KatiEnabled() && ctx.OtherModuleIsAutoGenerated(ctx.Module()) {
+ // In soong-only builds, build this module by default.
+ // This is the analogue to this make code:
+ // https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/main.mk;l=1396;drc=6595459cdd8164a6008335f6372c9f97b9094060
+ ctx.Phony("droidcore-unbundled", allImagesStamp)
+ }
+}
+
+type targetFilesZipCopy struct {
+ srcModule *string
+ destSubdir string
}
func (a *androidDevice) buildTargetFilesZip(ctx android.ModuleContext) {
@@ -104,27 +189,88 @@
builder := android.NewRuleBuilder(pctx, ctx)
builder.Command().Textf("rm -rf %s", targetFilesDir.String())
builder.Command().Textf("mkdir -p %s", targetFilesDir.String())
- partitionToSubdir := map[*string]string{
- a.partitionProps.System_partition_name: "SYSTEM",
- a.partitionProps.System_ext_partition_name: "SYSTEM_EXT",
- a.partitionProps.Product_partition_name: "PRODUCT",
- a.partitionProps.Vendor_partition_name: "VENDOR",
- a.partitionProps.Odm_partition_name: "ODM",
- a.partitionProps.System_dlkm_partition_name: "SYSTEM_DLKM",
- a.partitionProps.Vendor_dlkm_partition_name: "VENDOR_DLKM",
- a.partitionProps.Odm_dlkm_partition_name: "ODM_DLKM",
+ toCopy := []targetFilesZipCopy{
+ targetFilesZipCopy{a.partitionProps.System_partition_name, "SYSTEM"},
+ targetFilesZipCopy{a.partitionProps.System_ext_partition_name, "SYSTEM_EXT"},
+ targetFilesZipCopy{a.partitionProps.Product_partition_name, "PRODUCT"},
+ targetFilesZipCopy{a.partitionProps.Vendor_partition_name, "VENDOR"},
+ targetFilesZipCopy{a.partitionProps.Odm_partition_name, "ODM"},
+ targetFilesZipCopy{a.partitionProps.System_dlkm_partition_name, "SYSTEM_DLKM"},
+ targetFilesZipCopy{a.partitionProps.Vendor_dlkm_partition_name, "VENDOR_DLKM"},
+ targetFilesZipCopy{a.partitionProps.Odm_dlkm_partition_name, "ODM_DLKM"},
+ targetFilesZipCopy{a.partitionProps.Init_boot_partition_name, "BOOT/RAMDISK"},
+ targetFilesZipCopy{a.partitionProps.Init_boot_partition_name, "INIT_BOOT/RAMDISK"},
+ targetFilesZipCopy{a.partitionProps.Vendor_boot_partition_name, "VENDOR_BOOT/RAMDISK"},
}
- for partition, subdir := range partitionToSubdir {
- if partition == nil {
+ // TODO: Handle cases where recovery files are copied to BOOT/ or RECOVERY/
+ // https://cs.android.com/android/platform/superproject/main/+/main:build/make/core/Makefile;l=6211-6219?q=core%2FMakefile&ss=android%2Fplatform%2Fsuperproject%2Fmain
+ if ctx.DeviceConfig().BoardMoveRecoveryResourcesToVendorBoot() {
+ toCopy = append(toCopy, targetFilesZipCopy{a.partitionProps.Recovery_partition_name, "VENDOR_BOOT/RAMDISK"})
+ }
+
+ // Create an IMAGES/ subdirectory
+ builder.Command().Textf("mkdir -p %s/IMAGES/", targetFilesDir.String())
+ if a.deviceProps.Bootloader != nil {
+ builder.Command().Textf("cp ").Input(android.PathForModuleSrc(ctx, proptools.String(a.deviceProps.Bootloader))).Textf(" %s/IMAGES/bootloader", targetFilesDir.String())
+ }
+
+ for _, zipCopy := range toCopy {
+ if zipCopy.srcModule == nil {
continue
}
- fsInfo := a.getFilesystemInfo(ctx, *partition)
+ fsInfo := a.getFilesystemInfo(ctx, *zipCopy.srcModule)
+ subdir := zipCopy.destSubdir
+ rootDirString := fsInfo.RootDir.String()
+ if subdir == "SYSTEM" {
+ rootDirString = rootDirString + "/system"
+ }
builder.Command().Textf("mkdir -p %s/%s", targetFilesDir.String(), subdir)
builder.Command().
BuiltTool("acp").
- Textf("-rd %s/. %s/%s", fsInfo.RootDir, targetFilesDir, subdir).
+ Textf("-rd %s/. %s/%s", rootDirString, targetFilesDir, subdir).
Implicit(fsInfo.Output) // so that the staging dir is built
+
+ if subdir == "SYSTEM" {
+ // Create the ROOT partition in target_files.zip
+ builder.Command().Textf("rsync --links --exclude=system/* %s/ -r %s/ROOT", fsInfo.RootDir, targetFilesDir.String())
+ }
+ builder.Command().Textf("cp %s %s/IMAGES/", fsInfo.Output, targetFilesDir.String())
}
+ // Copy cmdline, kernel etc. files of boot images
+ if a.partitionProps.Vendor_boot_partition_name != nil {
+ bootImg := ctx.GetDirectDepWithTag(proptools.String(a.partitionProps.Vendor_boot_partition_name), filesystemDepTag)
+ bootImgInfo, _ := android.OtherModuleProvider(ctx, bootImg, BootimgInfoProvider)
+ builder.Command().Textf("echo %s > %s/VENDOR_BOOT/cmdline", proptools.ShellEscape(strings.Join(bootImgInfo.Cmdline, " ")), targetFilesDir)
+ builder.Command().Textf("echo %s > %s/VENDOR_BOOT/vendor_cmdline", proptools.ShellEscape(strings.Join(bootImgInfo.Cmdline, " ")), targetFilesDir)
+ if bootImgInfo.Dtb != nil {
+ builder.Command().Textf("cp %s %s/VENDOR_BOOT/dtb", bootImgInfo.Dtb, targetFilesDir)
+ }
+ if bootImgInfo.Bootconfig != nil {
+ builder.Command().Textf("cp %s %s/VENDOR_BOOT/vendor_bootconfig", bootImgInfo.Bootconfig, targetFilesDir)
+ }
+ }
+ if a.partitionProps.Boot_partition_name != nil {
+ bootImg := ctx.GetDirectDepWithTag(proptools.String(a.partitionProps.Boot_partition_name), filesystemDepTag)
+ bootImgInfo, _ := android.OtherModuleProvider(ctx, bootImg, BootimgInfoProvider)
+ builder.Command().Textf("echo %s > %s/BOOT/cmdline", proptools.ShellEscape(strings.Join(bootImgInfo.Cmdline, " ")), targetFilesDir)
+ if bootImgInfo.Dtb != nil {
+ builder.Command().Textf("cp %s %s/BOOT/dtb", bootImgInfo.Dtb, targetFilesDir)
+ }
+ if bootImgInfo.Kernel != nil {
+ builder.Command().Textf("cp %s %s/BOOT/kernel", bootImgInfo.Kernel, targetFilesDir)
+ // Even though kernel is not used to build vendor_boot, copy the kernel to VENDOR_BOOT to match the behavior of make packaging.
+ builder.Command().Textf("cp %s %s/VENDOR_BOOT/kernel", bootImgInfo.Kernel, targetFilesDir)
+ }
+ if bootImgInfo.Bootconfig != nil {
+ builder.Command().Textf("cp %s %s/BOOT/bootconfig", bootImgInfo.Bootconfig, targetFilesDir)
+ }
+ }
+
+ if a.deviceProps.Android_info != nil {
+ builder.Command().Textf("mkdir -p %s/OTA", targetFilesDir)
+ builder.Command().Textf("cp %s %s/OTA/android-info.txt", android.PathForModuleSrc(ctx, proptools.String(a.deviceProps.Android_info)), targetFilesDir)
+ }
+
builder.Command().
BuiltTool("soong_zip").
Text("-d").
diff --git a/filesystem/bootimg.go b/filesystem/bootimg.go
index 36b1a18..0a3a177 100644
--- a/filesystem/bootimg.go
+++ b/filesystem/bootimg.go
@@ -197,12 +197,8 @@
ctx.PropertyErrorf("kernel_prebuilt", "boot partition must have kernel")
return
}
- var kernel android.Path
- if kernelProp != "" {
- kernel = android.PathForModuleSrc(ctx, kernelProp)
- }
- unsignedOutput := b.buildBootImage(ctx, kernel)
+ unsignedOutput := b.buildBootImage(ctx, b.getKernelPath(ctx))
output := unsignedOutput
if proptools.Bool(b.properties.Use_avb) {
@@ -213,7 +209,7 @@
case "default":
output = b.signImage(ctx, unsignedOutput)
case "make_legacy":
- output = b.addAvbFooter(ctx, unsignedOutput, kernel)
+ output = b.addAvbFooter(ctx, unsignedOutput, b.getKernelPath(ctx))
default:
ctx.PropertyErrorf("avb_mode", `Unknown value for avb_mode, expected "default" or "make_legacy", got: %q`, *b.properties.Avb_mode)
}
@@ -224,6 +220,58 @@
ctx.SetOutputFiles([]android.Path{output}, "")
b.output = output
+
+ // Set the Filesystem info of the ramdisk dependency.
+ // `android_device` will use this info to package `target_files.zip`
+ if ramdisk := proptools.String(b.properties.Ramdisk_module); ramdisk != "" {
+ ramdiskModule := ctx.GetDirectDepWithTag(ramdisk, bootimgRamdiskDep)
+ fsInfo, _ := android.OtherModuleProvider(ctx, ramdiskModule, FilesystemProvider)
+ android.SetProvider(ctx, FilesystemProvider, fsInfo)
+ }
+
+ // Set BootimgInfo for building target_files.zip
+ android.SetProvider(ctx, BootimgInfoProvider, BootimgInfo{
+ Cmdline: b.properties.Cmdline,
+ Kernel: b.getKernelPath(ctx),
+ Dtb: b.getDtbPath(ctx),
+ Bootconfig: b.getBootconfigPath(ctx),
+ })
+}
+
+var BootimgInfoProvider = blueprint.NewProvider[BootimgInfo]()
+
+type BootimgInfo struct {
+ Cmdline []string
+ Kernel android.Path
+ Dtb android.Path
+ Bootconfig android.Path
+}
+
+func (b *bootimg) getKernelPath(ctx android.ModuleContext) android.Path {
+ var kernelPath android.Path
+ kernelName := proptools.String(b.properties.Kernel_prebuilt)
+ if kernelName != "" {
+ kernelPath = android.PathForModuleSrc(ctx, kernelName)
+ }
+ return kernelPath
+}
+
+func (b *bootimg) getDtbPath(ctx android.ModuleContext) android.Path {
+ var dtbPath android.Path
+ dtbName := proptools.String(b.properties.Dtb_prebuilt)
+ if dtbName != "" {
+ dtbPath = android.PathForModuleSrc(ctx, dtbName)
+ }
+ return dtbPath
+}
+
+func (b *bootimg) getBootconfigPath(ctx android.ModuleContext) android.Path {
+ var bootconfigPath android.Path
+ bootconfigName := proptools.String(b.properties.Bootconfig)
+ if bootconfigName != "" {
+ bootconfigPath = android.PathForModuleSrc(ctx, bootconfigName)
+ }
+ return bootconfigPath
}
func (b *bootimg) buildBootImage(ctx android.ModuleContext, kernel android.Path) android.Path {
@@ -242,10 +290,8 @@
cmd.FlagWithArg("--os_patch_level ", ctx.Config().PlatformSecurityPatch())
}
- dtbName := proptools.String(b.properties.Dtb_prebuilt)
- if dtbName != "" {
- dtb := android.PathForModuleSrc(ctx, dtbName)
- cmd.FlagWithInput("--dtb ", dtb)
+ if b.getDtbPath(ctx) != nil {
+ cmd.FlagWithInput("--dtb ", b.getDtbPath(ctx))
}
cmdline := strings.Join(b.properties.Cmdline, " ")
@@ -372,6 +418,10 @@
cmd.FlagWithArg("--rollback_index ", strconv.FormatInt(*b.properties.Avb_rollback_index, 10))
}
+ if !ctx.Config().KatiEnabled() {
+ copyImageFileToProductOut(ctx, builder, b.bootImageType.String(), output)
+ }
+
builder.Build("add_avb_footer", fmt.Sprintf("Adding avb footer to %s", b.BaseModuleName()))
return output
}
@@ -387,6 +437,10 @@
Implicits(toolDeps).
Output(output)
+ if !ctx.Config().KatiEnabled() {
+ copyImageFileToProductOut(ctx, builder, b.bootImageType.String(), output)
+ }
+
builder.Build("sign_bootimg", fmt.Sprintf("Signing %s", b.BaseModuleName()))
return output
}
diff --git a/filesystem/filesystem.go b/filesystem/filesystem.go
index 9c828e3..993c46e 100644
--- a/filesystem/filesystem.go
+++ b/filesystem/filesystem.go
@@ -215,6 +215,9 @@
// Additional dependencies used for building android products
Android_filesystem_deps AndroidFilesystemDeps
+
+ // Name of the output. Default is $(module_name).img
+ Stem *string
}
type AndroidFilesystemDeps struct {
@@ -392,7 +395,7 @@
}
func (f *filesystem) installFileName() string {
- return f.BaseModuleName() + ".img"
+ return proptools.StringDefault(f.properties.Stem, f.BaseModuleName()+".img")
}
func (f *filesystem) partitionName() string {
@@ -467,6 +470,7 @@
FileListFile: fileListFile,
RootDir: rootDir,
})
+
f.fileListFile = fileListFile
if proptools.Bool(f.properties.Unchecked_module) {
@@ -601,11 +605,16 @@
}
func (f *filesystem) copyFilesToProductOut(ctx android.ModuleContext, builder *android.RuleBuilder, rebasedDir android.OutputPath) {
- if f.Name() != ctx.Config().SoongDefinedSystemImage() {
+ if !(f.Name() == ctx.Config().SoongDefinedSystemImage() || proptools.Bool(f.properties.Is_auto_generated)) {
return
}
installPath := android.PathForModuleInPartitionInstall(ctx, f.partitionName())
- builder.Command().Textf("cp -prf %s/* %s", rebasedDir, installPath)
+ builder.Command().Textf("rsync --checksum %s %s", rebasedDir, installPath)
+}
+
+func copyImageFileToProductOut(ctx android.ModuleContext, builder *android.RuleBuilder, partition string, output android.Path) {
+ copyDir := android.PathForModuleInPartitionInstall(ctx, "").Join(ctx, fmt.Sprintf("%s.img", partition))
+ builder.Command().Textf("rsync -a %s %s", output, copyDir)
}
func (f *filesystem) rootDirString() string {
@@ -659,6 +668,10 @@
Output(output).
Text(rootDir.String()) // directory where to find fs_config_files|dirs
+ if !ctx.Config().KatiEnabled() {
+ copyImageFileToProductOut(ctx, builder, f.partitionName(), output)
+ }
+
// rootDir is not deleted. Might be useful for quick inspection.
builder.Build("build_filesystem_image", fmt.Sprintf("Creating filesystem %s", f.BaseModuleName()))
diff --git a/filesystem/vbmeta.go b/filesystem/vbmeta.go
index 6a47859..c8b4675 100644
--- a/filesystem/vbmeta.go
+++ b/filesystem/vbmeta.go
@@ -281,6 +281,10 @@
FlagWithArg("-s ", strconv.Itoa(vbmetaMaxSize)).
Output(output)
+ if !ctx.Config().KatiEnabled() {
+ copyImageFileToProductOut(ctx, builder, v.partitionName(), output)
+ }
+
builder.Build("vbmeta", fmt.Sprintf("vbmeta %s", ctx.ModuleName()))
v.installDir = android.PathForModuleInstall(ctx, "etc")
diff --git a/fsgen/filesystem_creator.go b/fsgen/filesystem_creator.go
index 41faf94..a070e01 100644
--- a/fsgen/filesystem_creator.go
+++ b/fsgen/filesystem_creator.go
@@ -128,6 +128,8 @@
f.properties.Unsupported_partition_types = append(f.properties.Unsupported_partition_types, partitionType)
}
}
+ // Create android_info.prop
+ f.createAndroidInfo(ctx)
partitionVars := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse
dtbImg := createDtbImgFilegroup(ctx)
@@ -161,7 +163,7 @@
if buildingSuperImage(partitionVars) {
createSuperImage(ctx, finalSoongGeneratedPartitions, partitionVars)
- f.properties.Super_image = ":" + generatedModuleName(ctx.Config(), "super")
+ f.properties.Super_image = ":" + generatedModuleNameForPartition(ctx.Config(), "super")
}
ctx.Config().Get(fsGenStateOnceKey).(*FsGenState).soongGeneratedPartitions = finalSoongGeneratedPartitions
@@ -180,15 +182,37 @@
return generatedModuleName(cfg, fmt.Sprintf("%s_image", partitionType))
}
+func (f *filesystemCreator) createBootloaderFilegroup(ctx android.LoadHookContext) (string, bool) {
+ bootloaderPath := ctx.Config().ProductVariables().PartitionVarsForSoongMigrationOnlyDoNotUse.PrebuiltBootloader
+ if len(bootloaderPath) == 0 {
+ return "", false
+ }
+
+ bootloaderFilegroupName := generatedModuleName(ctx.Config(), "bootloader")
+ filegroupProps := &struct {
+ Name *string
+ Srcs []string
+ Visibility []string
+ }{
+ Name: proptools.StringPtr(bootloaderFilegroupName),
+ Srcs: []string{bootloaderPath},
+ Visibility: []string{"//visibility:public"},
+ }
+ ctx.CreateModuleInDirectory(android.FileGroupFactory, ".", filegroupProps)
+ return bootloaderFilegroupName, true
+}
+
func (f *filesystemCreator) createDeviceModule(
ctx android.LoadHookContext,
generatedPartitionTypes []string,
vbmetaPartitions []string,
) {
baseProps := &struct {
- Name *string
+ Name *string
+ Android_info *string
}{
- Name: proptools.StringPtr(generatedModuleName(ctx.Config(), "device")),
+ Name: proptools.StringPtr(generatedModuleName(ctx.Config(), "device")),
+ Android_info: proptools.StringPtr(":" + generatedModuleName(ctx.Config(), "android_info.prop{.txt}")),
}
// Currently, only the system and system_ext partition module is created.
@@ -234,7 +258,12 @@
}
partitionProps.Vbmeta_partitions = vbmetaPartitions
- ctx.CreateModule(filesystem.AndroidDeviceFactory, baseProps, partitionProps)
+ deviceProps := &filesystem.DeviceProperties{}
+ if bootloader, ok := f.createBootloaderFilegroup(ctx); ok {
+ deviceProps.Bootloader = proptools.StringPtr(":" + bootloader)
+ }
+
+ ctx.CreateModule(filesystem.AndroidDeviceFactory, baseProps, partitionProps, deviceProps)
}
func partitionSpecificFsProps(ctx android.EarlyModuleContext, fsProps *filesystem.FilesystemProperties, partitionVars android.PartitionVariables, partitionType string) {
@@ -292,6 +321,7 @@
if ctx.DeviceConfig().SystemExtPath() == "system_ext" {
fsProps.Import_aconfig_flags_from = []string{generatedModuleNameForPartition(ctx.Config(), "system_ext")}
}
+ fsProps.Stem = proptools.StringPtr("system.img")
case "system_ext":
if partitionVars.ProductFsverityGenerateMetadata {
fsProps.Fsverity.Inputs = []string{
@@ -302,6 +332,7 @@
fsProps.Fsverity.Libs = []string{":framework-res{.export-package.apk}"}
}
fsProps.Security_patch = proptools.StringPtr(ctx.Config().PlatformSecurityPatch())
+ fsProps.Stem = proptools.StringPtr("system_ext.img")
case "product":
fsProps.Gen_aconfig_flags_pb = proptools.BoolPtr(true)
fsProps.Android_filesystem_deps.System = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "system"))
@@ -309,6 +340,7 @@
fsProps.Android_filesystem_deps.System_ext = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "system_ext"))
}
fsProps.Security_patch = proptools.StringPtr(ctx.Config().PlatformSecurityPatch())
+ fsProps.Stem = proptools.StringPtr("product.img")
case "vendor":
fsProps.Gen_aconfig_flags_pb = proptools.BoolPtr(true)
fsProps.Symlinks = []filesystem.SymlinkDefinition{
@@ -326,6 +358,7 @@
fsProps.Android_filesystem_deps.System_ext = proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "system_ext"))
}
fsProps.Security_patch = proptools.StringPtr(partitionVars.VendorSecurityPatch)
+ fsProps.Stem = proptools.StringPtr("vendor.img")
case "odm":
fsProps.Symlinks = []filesystem.SymlinkDefinition{
filesystem.SymlinkDefinition{
@@ -334,8 +367,10 @@
},
}
fsProps.Security_patch = proptools.StringPtr(partitionVars.OdmSecurityPatch)
+ fsProps.Stem = proptools.StringPtr("odm.img")
case "userdata":
fsProps.Base_dir = proptools.StringPtr("data")
+ fsProps.Stem = proptools.StringPtr("userdata.img")
case "ramdisk":
// Following the logic in https://cs.android.com/android/platform/superproject/main/+/c3c5063df32748a8806ce5da5dd0db158eab9ad9:build/make/core/Makefile;l=1307
fsProps.Dirs = android.NewSimpleConfigurable([]string{
@@ -358,6 +393,7 @@
"first_stage_ramdisk/sys",
})
}
+ fsProps.Stem = proptools.StringPtr("ramdisk.img")
case "recovery":
dirs := append(commonPartitionDirs, []string{
"sdcard",
@@ -373,16 +409,21 @@
Target: proptools.StringPtr("prop.default"),
Name: proptools.StringPtr("default.prop"),
}), "root")
+ fsProps.Stem = proptools.StringPtr("recovery.img")
case "system_dlkm":
fsProps.Security_patch = proptools.StringPtr(partitionVars.SystemDlkmSecurityPatch)
+ fsProps.Stem = proptools.StringPtr("system_dlkm.img")
case "vendor_dlkm":
fsProps.Security_patch = proptools.StringPtr(partitionVars.VendorDlkmSecurityPatch)
+ fsProps.Stem = proptools.StringPtr("vendor_dlkm.img")
case "odm_dlkm":
fsProps.Security_patch = proptools.StringPtr(partitionVars.OdmDlkmSecurityPatch)
+ fsProps.Stem = proptools.StringPtr("odm_dlkm.img")
case "vendor_ramdisk":
if android.InList("recovery", generatedPartitions(ctx)) {
fsProps.Include_files_of = []string{generatedModuleNameForPartition(ctx.Config(), "recovery")}
}
+ fsProps.Stem = proptools.StringPtr("vendor_ramdisk.img")
}
}
@@ -575,8 +616,8 @@
(*fsGenState.fsDeps[partitionType])[name] = defaultDepCandidateProps(ctx.Config())
}
-// Create a build_prop and android_info module. This will be used to create /vendor/build.prop
-func (f *filesystemCreator) createVendorBuildProp(ctx android.LoadHookContext) {
+// Create an android_info module. This will be used to create /vendor/build.prop
+func (f *filesystemCreator) createAndroidInfo(ctx android.LoadHookContext) {
// Create a android_info for vendor
// The board info files might be in a directory outside the root soong namespace, so create
// the module in "."
@@ -600,7 +641,9 @@
androidInfoProps,
)
androidInfoProp.HideFromMake()
- // Create a build prop for vendor
+}
+
+func (f *filesystemCreator) createVendorBuildProp(ctx android.LoadHookContext) {
vendorBuildProps := &struct {
Name *string
Vendor *bool
@@ -613,7 +656,7 @@
Vendor: proptools.BoolPtr(true),
Stem: proptools.StringPtr("build.prop"),
Product_config: proptools.StringPtr(":product_config"),
- Android_info: proptools.StringPtr(":" + androidInfoProp.Name()),
+ Android_info: proptools.StringPtr(":" + generatedModuleName(ctx.Config(), "android_info.prop")),
Licenses: []string{"Android-Apache-2.0"},
}
vendorBuildProp := ctx.CreateModule(
diff --git a/fsgen/super_img.go b/fsgen/super_img.go
index 8ee3bf2..a36f614 100644
--- a/fsgen/super_img.go
+++ b/fsgen/super_img.go
@@ -19,6 +19,7 @@
"android/soong/android"
"android/soong/filesystem"
+
"github.com/google/blueprint/proptools"
)
@@ -30,7 +31,7 @@
baseProps := &struct {
Name *string
}{
- Name: proptools.StringPtr(generatedModuleName(ctx.Config(), "super")),
+ Name: proptools.StringPtr(generatedModuleNameForPartition(ctx.Config(), "super")),
}
superImageProps := &filesystem.SuperImageProperties{
diff --git a/java/app.go b/java/app.go
index 801c012..c6fad60 100644
--- a/java/app.go
+++ b/java/app.go
@@ -1690,7 +1690,7 @@
module.appProperties.Use_embedded_native_libs = proptools.BoolPtr(true)
module.appProperties.AlwaysPackageNativeLibs = true
module.Module.dexpreopter.isTest = true
- module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true)
+ module.Module.linter.properties.Lint.Test_module_type = proptools.BoolPtr(true)
module.addHostAndDeviceProperties()
module.AddProperties(
@@ -1748,7 +1748,7 @@
module.appProperties.Use_embedded_native_libs = proptools.BoolPtr(true)
module.appProperties.AlwaysPackageNativeLibs = true
module.Module.dexpreopter.isTest = true
- module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true)
+ module.Module.linter.properties.Lint.Test_module_type = proptools.BoolPtr(true)
module.addHostAndDeviceProperties()
module.AddProperties(
diff --git a/java/app_import.go b/java/app_import.go
index f593c02..b77e31a 100644
--- a/java/app_import.go
+++ b/java/app_import.go
@@ -43,6 +43,12 @@
Description: "Uncompress embedded JNI libs",
})
+ stripEmbeddedJniLibsUnusedArchRule = pctx.AndroidStaticRule("strip-embedded-jni-libs-from-unused-arch", blueprint.RuleParams{
+ Command: `${config.Zip2ZipCmd} -i $in -o $out -x 'lib/**/*.so' $extraArgs`,
+ CommandDeps: []string{"${config.Zip2ZipCmd}"},
+ Description: "Remove all JNI libs from unused architectures",
+ }, "extraArgs")
+
uncompressDexRule = pctx.AndroidStaticRule("uncompress-dex", blueprint.RuleParams{
Command: `if (zipinfo $in '*.dex' 2>/dev/null | grep -v ' stor ' >/dev/null) ; then ` +
`${config.Zip2ZipCmd} -i $in -o $out -0 'classes*.dex'` +
@@ -56,6 +62,11 @@
CommandDeps: []string{"build/soong/scripts/check_prebuilt_presigned_apk.py", "${config.Aapt2Cmd}", "${config.ZipAlign}"},
Description: "Check presigned apk",
}, "extraArgs")
+
+ extractApkRule = pctx.AndroidStaticRule("extract-apk", blueprint.RuleParams{
+ Command: "unzip -p $in $extract_apk > $out",
+ Description: "Extract specific sub apk",
+ }, "extract_apk")
)
func RegisterAppImportBuildComponents(ctx android.RegistrationContext) {
@@ -150,10 +161,16 @@
// the prebuilt is Name() without "prebuilt_" prefix
Source_module_name *string
+ // Whether stripping all libraries from unused architectures.
+ Strip_unused_jni_arch *bool
+
// Path to the .prebuilt_info file of the prebuilt app.
// In case of mainline modules, the .prebuilt_info file contains the build_id that was used
// to generate the prebuilt.
Prebuilt_info *string `android:"path"`
+
+ // Path of extracted apk which is extracted from prebuilt apk. Use this extracted to import.
+ Extract_apk *string
}
func (a *AndroidAppImport) IsInstallable() bool {
@@ -278,6 +295,19 @@
})
}
+func (a *AndroidAppImport) extractSubApk(
+ ctx android.ModuleContext, inputPath android.Path, outputPath android.WritablePath) {
+ extractApkPath := *a.properties.Extract_apk
+ ctx.Build(pctx, android.BuildParams{
+ Rule: extractApkRule,
+ Input: inputPath,
+ Output: outputPath,
+ Args: map[string]string{
+ "extract_apk": extractApkPath,
+ },
+ })
+}
+
// Returns whether this module should have the dex file stored uncompressed in the APK.
func (a *AndroidAppImport) shouldUncompressDex(ctx android.ModuleContext) bool {
if ctx.Config().UnbundledBuild() || proptools.Bool(a.properties.Preprocessed) {
@@ -292,6 +322,26 @@
return shouldUncompressDex(ctx, android.RemoveOptionalPrebuiltPrefix(ctx.ModuleName()), &a.dexpreopter)
}
+func (a *AndroidAppImport) stripEmbeddedJniLibsUnusedArch(
+ ctx android.ModuleContext, inputPath android.Path, outputPath android.WritablePath) {
+ var wantedJniLibSlice []string
+ for _, target := range ctx.MultiTargets() {
+ supported_abis := target.Arch.Abi
+ for _, arch := range supported_abis {
+ wantedJniLibSlice = append(wantedJniLibSlice, " -X lib/"+arch+"/*.so")
+ }
+ }
+ wantedJniLibString := strings.Join(wantedJniLibSlice, " ")
+ ctx.Build(pctx, android.BuildParams{
+ Rule: stripEmbeddedJniLibsUnusedArchRule,
+ Input: inputPath,
+ Output: outputPath,
+ Args: map[string]string{
+ "extraArgs": wantedJniLibString,
+ },
+ })
+}
+
func (a *AndroidAppImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.generateAndroidBuildActions(ctx)
}
@@ -336,10 +386,14 @@
ctx.ModuleErrorf("One and only one of certficate, presigned (implied by preprocessed), and default_dev_cert properties must be set")
}
- // TODO: LOCAL_EXTRACT_APK/LOCAL_EXTRACT_DPI_APK
// TODO: LOCAL_PACKAGE_SPLITS
srcApk := a.prebuilt.SingleSourcePath(ctx)
+ if a.properties.Extract_apk != nil {
+ extract_apk := android.PathForModuleOut(ctx, "extract-apk", ctx.ModuleName()+".apk")
+ a.extractSubApk(ctx, srcApk, extract_apk)
+ srcApk = extract_apk
+ }
// TODO: Install or embed JNI libraries
@@ -347,6 +401,13 @@
jnisUncompressed := android.PathForModuleOut(ctx, "jnis-uncompressed", ctx.ModuleName()+".apk")
a.uncompressEmbeddedJniLibs(ctx, srcApk, jnisUncompressed)
+ // Strip all embedded JNI libs and include only required ones accordingly to the module's compile_multilib
+ if Bool(a.properties.Strip_unused_jni_arch) {
+ jnisStripped := android.PathForModuleOut(ctx, "jnis-stripped", ctx.ModuleName()+".apk")
+ a.stripEmbeddedJniLibsUnusedArch(ctx, jnisUncompressed, jnisStripped)
+ jnisUncompressed = jnisStripped
+ }
+
var pathFragments []string
relInstallPath := String(a.properties.Relative_install_path)
diff --git a/java/app_import_test.go b/java/app_import_test.go
index 70c487c..408d376 100644
--- a/java/app_import_test.go
+++ b/java/app_import_test.go
@@ -685,6 +685,22 @@
}
}
+func TestAndroidAppImport_ExtractApk(t *testing.T) {
+ ctx, _ := testJava(t, `
+ android_app_import {
+ name: "foo",
+ apk: "prebuilts/apk/app.apk",
+ certificate: "platform",
+ extract_apk: "extract_path/sub_app.apk"
+ }
+ `)
+
+ variant := ctx.ModuleForTests("foo", "android_common")
+ extractRuleArgs := variant.Output("extract-apk/foo.apk").BuildParams.Args
+ if extractRuleArgs["extract_apk"] != "extract_path/sub_app.apk" {
+ t.Errorf("Unexpected extract apk args: %s", extractRuleArgs["extract_apk"])
+ }
+}
func TestAndroidTestImport(t *testing.T) {
ctx, _ := testJava(t, `
android_test_import {
diff --git a/java/base.go b/java/base.go
index 49a60f0..1e0d4bf 100644
--- a/java/base.go
+++ b/java/base.go
@@ -90,6 +90,10 @@
// list of module-specific flags that will be used for kotlinc compiles
Kotlincflags []string `android:"arch_variant"`
+ // Kotlin language version to target. Currently only 1.9 and 2 are supported.
+ // See kotlinc's `-language-version` flag.
+ Kotlin_lang_version *string
+
// list of java libraries that will be in the classpath
Libs []string `android:"arch_variant"`
@@ -1332,6 +1336,16 @@
kotlincFlags := j.properties.Kotlincflags
CheckKotlincFlags(ctx, kotlincFlags)
+ kotlin_lang_version := proptools.StringDefault(j.properties.Kotlin_lang_version, "1.9")
+ if kotlin_lang_version == "1.9" {
+ kotlincFlags = append(kotlincFlags, "-language-version 1.9")
+ } else if kotlin_lang_version == "2" {
+ kotlincFlags = append(kotlincFlags, "-Xsuppress-version-warnings", "-Xconsistent-data-class-copy-visibility")
+ } else {
+ ctx.PropertyErrorf("kotlin_lang_version", "Must be one of `1.9` or `2`")
+
+ }
+
// Workaround for KT-46512
kotlincFlags = append(kotlincFlags, "-Xsam-conversions=class")
@@ -2060,7 +2074,9 @@
} else if strings.HasPrefix(flag, "-Xintellij-plugin-root") {
ctx.PropertyErrorf("kotlincflags",
"Bad flag: `%s`, only use internal compiler for consistency.", flag)
- } else if inList(flag, config.KotlincIllegalFlags) {
+ } else if slices.ContainsFunc(config.KotlincIllegalFlags, func(f string) bool {
+ return strings.HasPrefix(flag, f)
+ }) {
ctx.PropertyErrorf("kotlincflags", "Flag `%s` already used by build system", flag)
} else if flag == "-include-runtime" {
ctx.PropertyErrorf("kotlincflags", "Bad flag: `%s`, do not include runtime.", flag)
diff --git a/java/builder.go b/java/builder.go
index 30de61d..f1d5e99 100644
--- a/java/builder.go
+++ b/java/builder.go
@@ -468,6 +468,7 @@
android.WriteFileRule(ctx, srcJarRspFile, strings.Join(srcJars.Strings(), "\n"))
srcJarArgs = "@" + srcJarRspFile.String()
implicits = append(implicits, srcJarRspFile)
+ rspFiles = append(rspFiles, srcJarRspFile)
rbeInputs = append(rbeInputs, srcJarRspFile)
} else {
rbeInputs = append(rbeInputs, srcJars...)
diff --git a/java/config/kotlin.go b/java/config/kotlin.go
index bf4c886..ffb025d 100644
--- a/java/config/kotlin.go
+++ b/java/config/kotlin.go
@@ -21,6 +21,7 @@
KotlincIllegalFlags = []string{
"-no-jdk",
"-no-stdlib",
+ "-language-version",
}
)
@@ -49,12 +50,12 @@
"-J--add-opens=java.base/java.util=ALL-UNNAMED", // https://youtrack.jetbrains.com/issue/KT-43704
}, " "))
- pctx.StaticVariable("KotlincGlobalFlags", strings.Join([]string{"-language-version 1.9"}, " "))
+ pctx.StaticVariable("KotlincGlobalFlags", strings.Join([]string{}, " "))
// Use KotlincKytheGlobalFlags to prevent kotlinc version skew issues between android and
// g3 kythe indexers.
// This is necessary because there might be instances of kotlin code in android
// platform that are not fully compatible with the kotlinc used in g3 kythe indexers.
// e.g. uninitialized variables are a warning in 1.*, but an error in 2.*
// https://github.com/JetBrains/kotlin/blob/master/compiler/fir/checkers/gen/org/jetbrains/kotlin/fir/analysis/diagnostics/FirErrors.kt#L748
- pctx.StaticVariable("KotlincKytheGlobalFlags", strings.Join([]string{"-language-version 1.9"}, " "))
+ pctx.StaticVariable("KotlincKytheGlobalFlags", strings.Join([]string{}, " "))
}
diff --git a/java/fuzz.go b/java/fuzz.go
index 79cd042..5973957 100644
--- a/java/fuzz.go
+++ b/java/fuzz.go
@@ -63,7 +63,7 @@
module.Module.properties.Installable = proptools.BoolPtr(true)
module.Module.dexpreopter.isTest = true
- module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true)
+ module.Module.linter.properties.Lint.Test_module_type = proptools.BoolPtr(true)
module.Module.sourceProperties.Test_only = proptools.BoolPtr(true)
module.Module.sourceProperties.Top_level_test_target = true
diff --git a/java/java.go b/java/java.go
index 1689aee..3a1bc33 100644
--- a/java/java.go
+++ b/java/java.go
@@ -1794,7 +1794,7 @@
module.Module.properties.Installable = proptools.BoolPtr(true)
module.Module.dexpreopter.isTest = true
- module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true)
+ module.Module.linter.properties.Lint.Test_module_type = proptools.BoolPtr(true)
module.Module.sourceProperties.Test_only = proptools.BoolPtr(true)
module.Module.sourceProperties.Top_level_test_target = true
@@ -1811,7 +1811,7 @@
module.Module.properties.Installable = proptools.BoolPtr(true)
module.Module.dexpreopter.isTest = true
- module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true)
+ module.Module.linter.properties.Lint.Test_module_type = proptools.BoolPtr(true)
module.Module.sourceProperties.Test_only = proptools.BoolPtr(true)
InitJavaModule(module, android.HostAndDeviceSupported)
diff --git a/java/lint.go b/java/lint.go
index 9c6b93b..cee25a8 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -69,6 +69,11 @@
// If soong gets support for testonly, this flag should be replaced with that.
Test *bool
+ // Same as the regular Test property, but set by internal soong code based on if the module
+ // type is a test module type. This will act as the default value for the test property,
+ // but can be overridden by the user.
+ Test_module_type *bool `blueprint:"mutated"`
+
// Whether to ignore the exit code of Android lint. This is the --exit_code
// option. Defaults to false.
Suppress_exit_code *bool
@@ -257,7 +262,12 @@
if l.library {
cmd.Flag("--library")
}
- if proptools.BoolDefault(l.properties.Lint.Test, false) {
+
+ test := proptools.BoolDefault(l.properties.Lint.Test_module_type, false)
+ if l.properties.Lint.Test != nil {
+ test = *l.properties.Lint.Test
+ }
+ if test {
cmd.Flag("--test")
}
if l.manifest != nil {
diff --git a/java/lint_test.go b/java/lint_test.go
index afe3914..617dc54 100644
--- a/java/lint_test.go
+++ b/java/lint_test.go
@@ -276,3 +276,50 @@
ExtendWithErrorHandler(android.FixtureExpectsOneErrorPattern("Don't use --disable, --enable, or --check in the flags field, instead use the dedicated disabled_checks, warning_checks, error_checks, or fatal_checks fields")).
RunTestWithBp(t, bp)
}
+
+// b/358643466
+func TestNotTestViaDefault(t *testing.T) {
+ bp := `
+ java_defaults {
+ name: "mydefaults",
+ lint: {
+ test: false,
+ },
+ }
+ android_test {
+ name: "foo",
+ srcs: [
+ "a.java",
+ ],
+ min_sdk_version: "29",
+ sdk_version: "current",
+ defaults: ["mydefaults"],
+ }
+ android_test {
+ name: "foo2",
+ srcs: [
+ "a.java",
+ ],
+ min_sdk_version: "29",
+ sdk_version: "current",
+ }
+ `
+ result := PrepareForTestWithJavaDefaultModules.RunTestWithBp(t, bp)
+ ctx := result.TestContext
+
+ foo := ctx.ModuleForTests("foo", "android_common")
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, ctx, foo.Output("lint.sbox.textproto"))
+ command := *sboxProto.Commands[0].Command
+
+ if strings.Contains(command, "--test") {
+ t.Fatalf("Expected command to not contain --test")
+ }
+
+ foo2 := ctx.ModuleForTests("foo2", "android_common")
+ sboxProto2 := android.RuleBuilderSboxProtoForTests(t, ctx, foo2.Output("lint.sbox.textproto"))
+ command2 := *sboxProto2.Commands[0].Command
+
+ if !strings.Contains(command2, "--test") {
+ t.Fatalf("Expected command to contain --test")
+ }
+}
diff --git a/java/platform_bootclasspath.go b/java/platform_bootclasspath.go
index d09a02e..152eb1e 100644
--- a/java/platform_bootclasspath.go
+++ b/java/platform_bootclasspath.go
@@ -172,7 +172,7 @@
// Do not add implLibModule to allModules as the impl lib is only used to collect the
// transitive source files
var implLibModule []android.Module
- ctx.VisitDirectDepsWithTag(implLibraryTag, func(m android.Module) {
+ ctx.VisitDirectDepsWithTag(platformBootclasspathImplLibDepTag, func(m android.Module) {
implLibModule = append(implLibModule, m)
})
diff --git a/java/platform_bootclasspath_test.go b/java/platform_bootclasspath_test.go
index f2768db..1f691a0 100644
--- a/java/platform_bootclasspath_test.go
+++ b/java/platform_bootclasspath_test.go
@@ -30,18 +30,23 @@
preparer := android.GroupFixturePreparers(
prepareForTestWithPlatformBootclasspath,
FixtureConfigureBootJars("platform:foo", "system_ext:bar"),
+ android.FixtureMergeMockFs(android.MockFS{
+ "api/current.txt": nil,
+ "api/removed.txt": nil,
+ }),
android.FixtureWithRootAndroidBp(`
platform_bootclasspath {
name: "platform-bootclasspath",
}
- java_library {
+ java_sdk_library {
name: "bar",
srcs: ["a.java"],
system_modules: "none",
sdk_version: "none",
compile_dex: true,
system_ext_specific: true,
+ unsafe_ignore_missing_latest_api: true,
}
`),
)
diff --git a/java/platform_compat_config.go b/java/platform_compat_config.go
index 5b145c6..bb98944 100644
--- a/java/platform_compat_config.go
+++ b/java/platform_compat_config.go
@@ -51,6 +51,10 @@
type platformCompatConfigProperties struct {
Src *string `android:"path"`
+
+ // If true, we include it in the "merged" XML (merged_compat_config.xml).
+ // Default is true.
+ Include_in_merged_xml *bool
}
type platformCompatConfig struct {
@@ -60,6 +64,7 @@
installDirPath android.InstallPath
configFile android.OutputPath
metadataFile android.OutputPath
+ doMerge bool
installConfigFile android.InstallPath
}
@@ -68,6 +73,10 @@
return p.metadataFile
}
+func (p *platformCompatConfig) includeInMergedXml() bool {
+ return p.doMerge
+}
+
func (p *platformCompatConfig) CompatConfig() android.OutputPath {
return p.configFile
}
@@ -78,6 +87,9 @@
type platformCompatConfigMetadataProvider interface {
compatConfigMetadata() android.Path
+
+ // Whether to include it in the "merged" XML (merged_compat_config.xml) or not.
+ includeInMergedXml() bool
}
type PlatformCompatConfigIntf interface {
@@ -98,6 +110,7 @@
metadataFileName := p.Name() + "_meta.xml"
p.configFile = android.PathForModuleOut(ctx, configFileName).OutputPath
p.metadataFile = android.PathForModuleOut(ctx, metadataFileName).OutputPath
+ p.doMerge = proptools.BoolDefault(p.properties.Include_in_merged_xml, true)
path := android.PathForModuleSrc(ctx, String(p.properties.Src))
rule.Command().
@@ -201,6 +214,10 @@
return module.metadataFile
}
+func (module *prebuiltCompatConfigModule) includeInMergedXml() bool {
+ return true // Always include in merged.xml
+}
+
func (module *prebuiltCompatConfigModule) BaseModuleName() string {
return proptools.StringDefault(module.properties.Source_module_name, module.ModuleBase.Name())
}
@@ -237,6 +254,9 @@
if !android.IsModulePreferred(module) {
return
}
+ if !c.includeInMergedXml() {
+ return
+ }
metadata := c.compatConfigMetadata()
compatConfigMetadata = append(compatConfigMetadata, metadata)
}
diff --git a/java/platform_compat_config_test.go b/java/platform_compat_config_test.go
index 80d991c..f7529a7 100644
--- a/java/platform_compat_config_test.go
+++ b/java/platform_compat_config_test.go
@@ -26,6 +26,7 @@
android.FixtureWithRootAndroidBp(`
platform_compat_config {
name: "myconfig2",
+ include_in_merged_xml: false,
}
platform_compat_config {
name: "myconfig1",
@@ -38,7 +39,6 @@
CheckMergedCompatConfigInputs(t, result, "myconfig",
"out/soong/.intermediates/myconfig1/myconfig1_meta.xml",
- "out/soong/.intermediates/myconfig2/myconfig2_meta.xml",
"out/soong/.intermediates/myconfig3/myconfig3_meta.xml",
)
}
diff --git a/java/ravenwood.go b/java/ravenwood.go
index 4c43a9f..84d6a9f 100644
--- a/java/ravenwood.go
+++ b/java/ravenwood.go
@@ -110,7 +110,7 @@
module.AddProperties(&module.testProperties, &module.ravenwoodTestProperties)
module.Module.dexpreopter.isTest = true
- module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true)
+ module.Module.linter.properties.Lint.Test_module_type = proptools.BoolPtr(true)
module.testProperties.Test_suites = []string{
"general-tests",
diff --git a/java/robolectric.go b/java/robolectric.go
index 8c76ac7..29aa2f0 100644
--- a/java/robolectric.go
+++ b/java/robolectric.go
@@ -20,6 +20,7 @@
"android/soong/android"
"android/soong/java/config"
"android/soong/tradefed"
+
"github.com/google/blueprint"
"github.com/google/blueprint/proptools"
)
@@ -119,8 +120,6 @@
ctx.AddVariationDependencies(nil, roboRuntimeOnlyDepTag, robolectricCurrentLib)
} else {
ctx.AddVariationDependencies(nil, staticLibTag, robolectricCurrentLib)
- // opting out from strict mode, robolectric_non_strict_mode_permission lib should be added
- ctx.AddVariationDependencies(nil, staticLibTag, "robolectric_non_strict_mode_permission")
}
ctx.AddVariationDependencies(nil, staticLibTag, robolectricDefaultLibs...)
@@ -297,7 +296,7 @@
&module.testProperties)
module.Module.dexpreopter.isTest = true
- module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true)
+ module.Module.linter.properties.Lint.Test_module_type = proptools.BoolPtr(true)
module.testProperties.Test_suites = []string{"robolectric-tests"}
diff --git a/ui/build/build.go b/ui/build/build.go
index 1dc6dbd..26f5969 100644
--- a/ui/build/build.go
+++ b/ui/build/build.go
@@ -107,8 +107,11 @@
{{end -}}
pool highmem_pool
depth = {{.HighmemParallel}}
-{{if and (not .SkipKatiNinja) .HasKatiSuffix}}subninja {{.KatiBuildNinjaFile}}
+{{if and (not .SkipKatiNinja) .HasKatiSuffix}}
+subninja {{.KatiBuildNinjaFile}}
subninja {{.KatiPackageNinjaFile}}
+{{else}}
+subninja {{.KatiSoongOnlyPackageNinjaFile}}
{{end -}}
subninja {{.SoongNinjaFile}}
`))
@@ -346,25 +349,31 @@
return
}
+ // Still generate the kati suffix in soong-only builds because soong-only still uses kati for
+ // the packaging step. Also, the kati suffix is used for the combined ninja file.
+ genKatiSuffix(ctx, config)
+
if what&RunSoong != 0 {
runSoong(ctx, config)
}
if what&RunKati != 0 {
- genKatiSuffix(ctx, config)
runKatiCleanSpec(ctx, config)
runKatiBuild(ctx, config)
- runKatiPackage(ctx, config)
+ runKatiPackage(ctx, config, false)
- ioutil.WriteFile(config.LastKatiSuffixFile(), []byte(config.KatiSuffix()), 0666) // a+rw
} else if what&RunKatiNinja != 0 {
// Load last Kati Suffix if it exists
- if katiSuffix, err := ioutil.ReadFile(config.LastKatiSuffixFile()); err == nil {
+ if katiSuffix, err := os.ReadFile(config.LastKatiSuffixFile()); err == nil {
ctx.Verboseln("Loaded previous kati config:", string(katiSuffix))
config.SetKatiSuffix(string(katiSuffix))
}
+ } else if what&RunSoong != 0 {
+ runKatiPackage(ctx, config, true)
}
+ os.WriteFile(config.LastKatiSuffixFile(), []byte(config.KatiSuffix()), 0666) // a+rw
+
// Write combined ninja file
createCombinedBuildNinjaFile(ctx, config)
diff --git a/ui/build/config.go b/ui/build/config.go
index dc468c2..4f2d213 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -1592,6 +1592,10 @@
return filepath.Join(c.OutDir(), "build"+c.KatiSuffix()+katiPackageSuffix+".ninja")
}
+func (c *configImpl) KatiSoongOnlyPackageNinjaFile() string {
+ return filepath.Join(c.OutDir(), "build"+c.KatiSuffix()+katiSoongOnlyPackageSuffix+".ninja")
+}
+
func (c *configImpl) SoongVarsFile() string {
targetProduct, err := c.TargetProductOrErr()
if err != nil {
@@ -1647,7 +1651,7 @@
}
func (c *configImpl) KatiPackageMkDir() string {
- return filepath.Join(c.ProductOut(), "obj", "CONFIG", "kati_packaging")
+ return filepath.Join(c.SoongOutDir(), "kati_packaging"+c.KatiSuffix())
}
func (c *configImpl) hostOutRoot() string {
diff --git a/ui/build/kati.go b/ui/build/kati.go
index acd5254..6519573 100644
--- a/ui/build/kati.go
+++ b/ui/build/kati.go
@@ -31,6 +31,7 @@
const katiBuildSuffix = ""
const katiCleanspecSuffix = "-cleanspec"
const katiPackageSuffix = "-package"
+const katiSoongOnlyPackageSuffix = "-soong-only-package"
// genKatiSuffix creates a filename suffix for kati-generated files so that we
// can cache them based on their inputs. Such files include the generated Ninja
@@ -40,8 +41,12 @@
// Currently that includes the TARGET_PRODUCT and kati-processed command line
// arguments.
func genKatiSuffix(ctx Context, config Config) {
+ targetProduct := "unknown"
+ if p, err := config.TargetProductOrErr(); err == nil {
+ targetProduct = p
+ }
// Construct the base suffix.
- katiSuffix := "-" + config.TargetProduct() + config.CoverageSuffix()
+ katiSuffix := "-" + targetProduct + config.CoverageSuffix()
// Append kati arguments to the suffix.
if args := config.KatiArgs(); len(args) > 0 {
@@ -68,13 +73,13 @@
func writeValueIfChanged(ctx Context, config Config, dir string, filename string, value string) {
filePath := filepath.Join(dir, filename)
previousValue := ""
- rawPreviousValue, err := ioutil.ReadFile(filePath)
+ rawPreviousValue, err := os.ReadFile(filePath)
if err == nil {
previousValue = string(rawPreviousValue)
}
if previousValue != value {
- if err = ioutil.WriteFile(filePath, []byte(value), 0666); err != nil {
+ if err = os.WriteFile(filePath, []byte(value), 0666); err != nil {
ctx.Fatalf("Failed to write: %v", err)
}
}
@@ -334,10 +339,19 @@
// Generate the Ninja file containing the packaging command lines for the dist
// dir.
-func runKatiPackage(ctx Context, config Config) {
+func runKatiPackage(ctx Context, config Config, soongOnly bool) {
ctx.BeginTrace(metrics.RunKati, "kati package")
defer ctx.EndTrace()
+ entryPoint := "build/make/packaging/main.mk"
+ suffix := katiPackageSuffix
+ ninjaFile := config.KatiPackageNinjaFile()
+ if soongOnly {
+ entryPoint = "build/make/packaging/main_soong_only.mk"
+ suffix = katiSoongOnlyPackageSuffix
+ ninjaFile = config.KatiSoongOnlyPackageNinjaFile()
+ }
+
args := []string{
// Mark the dist dir as writable.
"--writable", config.DistDir() + "/",
@@ -346,14 +360,14 @@
// Fail when redefining / duplicating a target.
"--werror_overriding_commands",
// Entry point.
- "-f", "build/make/packaging/main.mk",
+ "-f", entryPoint,
// Directory containing .mk files for packaging purposes, such as
// the dist.mk file, containing dist-for-goals data.
"KATI_PACKAGE_MK_DIR=" + config.KatiPackageMkDir(),
}
// Run Kati against a restricted set of environment variables.
- runKati(ctx, config, katiPackageSuffix, args, func(env *Environment) {
+ runKati(ctx, config, suffix, args, func(env *Environment) {
env.Allow([]string{
// Some generic basics
"LANG",
@@ -381,7 +395,7 @@
})
// Compress and dist the packaging Ninja file.
- distGzipFile(ctx, config, config.KatiPackageNinjaFile())
+ distGzipFile(ctx, config, ninjaFile)
}
// Run Kati on the cleanspec files to clean the build.
diff --git a/ui/build/soong.go b/ui/build/soong.go
index 82e5c96..58334a9 100644
--- a/ui/build/soong.go
+++ b/ui/build/soong.go
@@ -197,6 +197,8 @@
func (pb PrimaryBuilderFactory) primaryBuilderInvocation(config Config) bootstrap.PrimaryBuilderInvocation {
commonArgs := make([]string, 0, 0)
+ commonArgs = append(commonArgs, "--kati_suffix", config.KatiSuffix())
+
if !pb.config.skipSoongTests {
commonArgs = append(commonArgs, "-t")
}