Ensure sscp jars get copied to $OUT/soong/system_server_dexjars
(This was missed in aosp/2876756, which copied only the bcp jars) This hardcoded location is used by dex2oat to compile the dexpreopt artifacts. The copy rules are currently generated by java_(sdk)_library for source builds, and their prebuilt counterparts in prebuilt builds. After this change, the copy rule will be bifurcated between source and prebuilt builds 1. For source builds, it will come from java_(sdk)_library 2. For prebuilt builds, it will come from the top-level prebuilt apex. Since there can be multiple prebuilt apexes in trunk stable, HideFromMake will be used to determine which deapexed jar to copy. The bifurfaction is expected to be temporary. It is needed for now since the `apex_contributions` which will be used for source vs prebuilt selection have not been populated completely. Test: Added a unit test Test: Presubmits Test: git_master-art-host: art-gtest (https://android-build.corp.google.com/builds/abtd/run/L40800030001459791) Test: git_main:art_standalone_tests (https://android-build.corp.google.com/builds/abtd/run/L09000030001463855) Bug: 308790457 Change-Id: I3105d3b3a7e5c41cb601d07806f4ea483a61b50a
This commit is contained in:
@@ -229,6 +229,30 @@ func ToOdexPath(path string, arch android.ArchType) string {
|
||||
pathtools.ReplaceExtension(filepath.Base(path), "odex"))
|
||||
}
|
||||
|
||||
// Copy the dex'd system server to a predefined location in out/soong/system_server_dexjars
|
||||
// dex2oat will use this predefined location to generate the dexpreopt artifacts.
|
||||
func CopySystemServerJarsToPredefinedLocations(ctx android.BuilderContext, libName string, libDexPath android.Path) {
|
||||
allSystemServerJars := GetGlobalConfig(ctx).AllSystemServerJars(ctx)
|
||||
if !allSystemServerJars.ContainsJar(libName) {
|
||||
// This is not a system server jar
|
||||
return
|
||||
}
|
||||
if DexpreoptRunningInSoong {
|
||||
// Copy the system server jar to a predefined location where dex2oat will find it.
|
||||
rule := android.NewRuleBuilder(pctx, ctx)
|
||||
dexPathHost := SystemServerDexJarHostPath(ctx, libName)
|
||||
rule.Command().Text("mkdir -p").Flag(filepath.Dir(dexPathHost.String()))
|
||||
rule.Command().Text("cp -f").Input(libDexPath).Output(dexPathHost)
|
||||
rule.Build("copy "+libName+" to soong/system_server_dexjars/", "system_server_dexjars")
|
||||
} else {
|
||||
// For Make modules the copy rule is generated in the makefiles, not in dexpreopt.sh.
|
||||
// This is necessary to expose the rule to Ninja, otherwise it has rules that depend on
|
||||
// the jar (namely, dexpreopt commands for all subsequent system server jars that have
|
||||
// this one in their class loader context), but no rule that creates it (because Ninja
|
||||
// cannot see the rule in the generated dexpreopt.sh script).
|
||||
}
|
||||
}
|
||||
|
||||
func dexpreoptCommand(ctx android.BuilderContext, globalSoong *GlobalSoongConfig,
|
||||
global *GlobalConfig, module *ModuleConfig, rule *android.RuleBuilder, archIdx int,
|
||||
profile android.WritablePath, appImage bool, generateDM bool, productPackages android.Path) {
|
||||
@@ -277,19 +301,6 @@ func dexpreoptCommand(ctx android.BuilderContext, globalSoong *GlobalSoongConfig
|
||||
clcTarget = append(clcTarget, GetSystemServerDexLocation(ctx, global, lib))
|
||||
}
|
||||
|
||||
if DexpreoptRunningInSoong {
|
||||
// Copy the system server jar to a predefined location where dex2oat will find it.
|
||||
dexPathHost := SystemServerDexJarHostPath(ctx, module.Name)
|
||||
rule.Command().Text("mkdir -p").Flag(filepath.Dir(dexPathHost.String()))
|
||||
rule.Command().Text("cp -f").Input(module.DexPath).Output(dexPathHost)
|
||||
} else {
|
||||
// For Make modules the copy rule is generated in the makefiles, not in dexpreopt.sh.
|
||||
// This is necessary to expose the rule to Ninja, otherwise it has rules that depend on
|
||||
// the jar (namely, dexpreopt commands for all subsequent system server jars that have
|
||||
// this one in their class loader context), but no rule that creates it (because Ninja
|
||||
// cannot see the rule in the generated dexpreopt.sh script).
|
||||
}
|
||||
|
||||
clcHostString := "PCL[" + strings.Join(clcHost.Strings(), ":") + "]"
|
||||
clcTargetString := "PCL[" + strings.Join(clcTarget, ":") + "]"
|
||||
|
||||
|
Reference in New Issue
Block a user