Remove obsolete PDK build functionality

This hasn't worked for a couple years, and continues to bitrot. Just
remove it.

Adds a bpfix rule so that we can eventually remove the
product_variables.pdk definition, which is now always a no-op.

Test: treehugger
Change-Id: I830b54d419b59f6db1d4617b45e61a78234f57a7
This commit is contained in:
Dan Willemsen 2020-05-28 15:28:00 -07:00
parent 04df40305f
commit ba3876a91a
14 changed files with 110 additions and 131 deletions

View File

@ -742,10 +742,6 @@ func (c *config) Fuchsia() bool {
return Bool(c.productVariables.Fuchsia)
}
func (c *config) IsPdkBuild() bool {
return Bool(c.productVariables.Pdk)
}
func (c *config) MinimizeJavaDebugInfo() bool {
return Bool(c.productVariables.MinimizeJavaDebugInfo) && !Bool(c.productVariables.Eng)
}

View File

@ -233,7 +233,6 @@ type productVariables struct {
Eng *bool `json:",omitempty"`
Treble_linker_namespaces *bool `json:",omitempty"`
Enforce_vintf_manifest *bool `json:",omitempty"`
Pdk *bool `json:",omitempty"`
Uml *bool `json:",omitempty"`
Use_lmkd_stats_log *bool `json:",omitempty"`
Arc *bool `json:",omitempty"`

View File

@ -128,6 +128,10 @@ var fixSteps = []FixStep{
Name: "removeSoongConfigBoolVariable",
Fix: removeSoongConfigBoolVariable,
},
{
Name: "removePdkProperty",
Fix: runPatchListMod(removePdkProperty),
},
}
func NewFixRequest() FixRequest {
@ -993,6 +997,25 @@ func removeTags(mod *parser.Module, buf []byte, patchlist *parser.PatchList) err
return patchlist.Add(prop.Pos().Offset, prop.End().Offset+2, replaceStr)
}
func removePdkProperty(mod *parser.Module, buf []byte, patchlist *parser.PatchList) error {
prop, ok := mod.GetProperty("product_variables")
if !ok {
return nil
}
propMap, ok := prop.Value.(*parser.Map)
if !ok {
return nil
}
pdkProp, ok := propMap.GetProperty("pdk")
if !ok {
return nil
}
if len(propMap.Properties) > 1 {
return patchlist.Add(pdkProp.Pos().Offset, pdkProp.End().Offset+2, "")
}
return patchlist.Add(prop.Pos().Offset, prop.End().Offset+2, "")
}
func mergeMatchingModuleProperties(mod *parser.Module, buf []byte, patchlist *parser.PatchList) error {
return mergeMatchingProperties(&mod.Properties, buf, patchlist)
}

View File

@ -998,3 +998,61 @@ func TestRemoveSoongConfigBoolVariable(t *testing.T) {
})
}
}
func TestRemovePdkProperty(t *testing.T) {
tests := []struct {
name string
in string
out string
}{
{
name: "remove property",
in: `
cc_library_shared {
name: "foo",
product_variables: {
other: {
bar: true,
},
pdk: {
enabled: false,
},
},
}
`,
out: `
cc_library_shared {
name: "foo",
product_variables: {
other: {
bar: true,
},
},
}
`,
},
{
name: "remove property and empty product_variables",
in: `
cc_library_shared {
name: "foo",
product_variables: {
pdk: {
enabled: false,
},
},
}
`,
out: `
cc_library_shared {
name: "foo",
}
`,
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
runPass(t, test.in, test.out, runPatchListMod(removePdkProperty))
})
}
}

View File

@ -26,7 +26,7 @@ import (
func init() {
pctx.VariableFunc("rsCmd", func(ctx android.PackageVarContext) string {
if ctx.Config().AlwaysUsePrebuiltSdks() {
// Use RenderScript prebuilts for unbundled builds but not PDK builds
// Use RenderScript prebuilts for unbundled builds
return filepath.Join("prebuilts/sdk/tools", runtime.GOOS, "bin/llvm-rs-cc")
} else {
return ctx.Config().HostToolPath(ctx, "llvm-rs-cc").String()

View File

@ -180,7 +180,7 @@ func init() {
func hostBinToolVariableWithSdkToolsPrebuilt(name, tool string) {
pctx.VariableFunc(name, func(ctx android.PackageVarContext) string {
if ctx.Config().AlwaysUsePrebuiltSdks() || ctx.Config().IsPdkBuild() {
if ctx.Config().AlwaysUsePrebuiltSdks() {
return filepath.Join("prebuilts/sdk/tools", runtime.GOOS, "bin", tool)
} else {
return ctx.Config().HostToolPath(ctx, tool).String()
@ -190,7 +190,7 @@ func hostBinToolVariableWithSdkToolsPrebuilt(name, tool string) {
func hostJavaToolVariableWithSdkToolsPrebuilt(name, tool string) {
pctx.VariableFunc(name, func(ctx android.PackageVarContext) string {
if ctx.Config().AlwaysUsePrebuiltSdks() || ctx.Config().IsPdkBuild() {
if ctx.Config().AlwaysUsePrebuiltSdks() {
return filepath.Join("prebuilts/sdk/tools/lib", tool+".jar")
} else {
return ctx.Config().HostJavaToolPath(ctx, tool+".jar").String()
@ -200,7 +200,7 @@ func hostJavaToolVariableWithSdkToolsPrebuilt(name, tool string) {
func hostJNIToolVariableWithSdkToolsPrebuilt(name, tool string) {
pctx.VariableFunc(name, func(ctx android.PackageVarContext) string {
if ctx.Config().AlwaysUsePrebuiltSdks() || ctx.Config().IsPdkBuild() {
if ctx.Config().AlwaysUsePrebuiltSdks() {
ext := ".so"
if runtime.GOOS == "darwin" {
ext = ".dylib"
@ -214,7 +214,7 @@ func hostJNIToolVariableWithSdkToolsPrebuilt(name, tool string) {
func hostBinToolVariableWithBuildToolsPrebuilt(name, tool string) {
pctx.VariableFunc(name, func(ctx android.PackageVarContext) string {
if ctx.Config().AlwaysUsePrebuiltSdks() || ctx.Config().IsPdkBuild() {
if ctx.Config().AlwaysUsePrebuiltSdks() {
return filepath.Join("prebuilts/build-tools", ctx.Config().PrebuiltOS(), "bin", tool)
} else {
return ctx.Config().HostToolPath(ctx, tool).String()

View File

@ -505,7 +505,7 @@ func bootImageProfileRule(ctx android.SingletonContext, image *bootImageConfig,
globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx)
global := dexpreopt.GetGlobalConfig(ctx)
if global.DisableGenerateProfile || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
if global.DisableGenerateProfile || ctx.Config().UnbundledBuild() {
return nil
}
profile := ctx.Config().Once(bootImageProfileRuleKey, func() interface{} {
@ -560,7 +560,7 @@ func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImageConf
globalSoong := dexpreopt.GetCachedGlobalSoongConfig(ctx)
global := dexpreopt.GetGlobalConfig(ctx)
if global.DisableGenerateProfile || ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
if global.DisableGenerateProfile || ctx.Config().UnbundledBuild() {
return nil
}
return ctx.Config().Once(bootFrameworkProfileRuleKey, func() interface{} {
@ -602,7 +602,7 @@ func bootFrameworkProfileRule(ctx android.SingletonContext, image *bootImageConf
var bootFrameworkProfileRuleKey = android.NewOnceKey("bootFrameworkProfileRule")
func updatableBcpPackagesRule(ctx android.SingletonContext, image *bootImageConfig, missingDeps []string) android.WritablePath {
if ctx.Config().IsPdkBuild() || ctx.Config().UnbundledBuild() {
if ctx.Config().UnbundledBuild() {
return nil
}

View File

@ -1081,9 +1081,7 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
rule.Build(pctx, ctx, "javadoc", desc)
if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") &&
!ctx.Config().IsPdkBuild() {
if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") {
apiFile := android.PathForModuleSrc(ctx, String(d.properties.Check_api.Current.Api_file))
removedApiFile := android.PathForModuleSrc(ctx, String(d.properties.Check_api.Current.Removed_api_file))
@ -1150,9 +1148,7 @@ func (d *Droiddoc) GenerateAndroidBuildActions(ctx android.ModuleContext) {
rule.Build(pctx, ctx, "doclavaCurrentApiUpdate", "update current API")
}
if apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") &&
!ctx.Config().IsPdkBuild() {
if apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") {
apiFile := android.PathForModuleSrc(ctx, String(d.properties.Check_api.Last_released.Api_file))
removedApiFile := android.PathForModuleSrc(ctx, String(d.properties.Check_api.Last_released.Removed_api_file))
@ -1444,7 +1440,7 @@ func (d *Droidstubs) apiLevelsAnnotationsFlags(ctx android.ModuleContext, cmd *a
}
func (d *Droidstubs) apiToXmlFlags(ctx android.ModuleContext, cmd *android.RuleBuilderCommand) {
if Bool(d.properties.Jdiff_enabled) && !ctx.Config().IsPdkBuild() && d.apiFile != nil {
if Bool(d.properties.Jdiff_enabled) && d.apiFile != nil {
if d.apiFile.String() == "" {
ctx.ModuleErrorf("API signature file has to be specified in Metalava when jdiff is enabled.")
}
@ -1592,7 +1588,7 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Add API lint options.
if BoolDefault(d.properties.Check_api.Api_lint.Enabled, false) && !ctx.Config().IsPdkBuild() {
if BoolDefault(d.properties.Check_api.Api_lint.Enabled, false) {
doApiLint = true
newSince := android.OptionalPathForModuleSrc(ctx, d.properties.Check_api.Api_lint.New_since)
@ -1659,8 +1655,7 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// Add "check released" options. (Detect incompatible API changes from the last public release)
if apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") &&
!ctx.Config().IsPdkBuild() {
if apiCheckEnabled(ctx, d.properties.Check_api.Last_released, "last_released") {
doCheckReleased = true
if len(d.Javadoc.properties.Out) > 0 {
@ -1737,8 +1732,7 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
rule.Build(pctx, ctx, "metalava", "metalava merged")
if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") &&
!ctx.Config().IsPdkBuild() {
if apiCheckEnabled(ctx, d.properties.Check_api.Current, "current") {
if len(d.Javadoc.properties.Out) > 0 {
ctx.PropertyErrorf("out", "out property may not be combined with check_api")
@ -1852,7 +1846,7 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
rule.Build(pctx, ctx, "nullabilityWarningsCheck", "nullability warnings check")
}
if Bool(d.properties.Jdiff_enabled) && !ctx.Config().IsPdkBuild() {
if Bool(d.properties.Jdiff_enabled) {
if len(d.Javadoc.properties.Out) > 0 {
ctx.PropertyErrorf("out", "out property may not be combined with jdiff")
}

View File

@ -191,23 +191,6 @@ func (s sdkSpec) prebuiltSdkAvailableForUnbundledBuild() bool {
return s.kind != sdkPrivate && s.kind != sdkNone && s.kind != sdkCorePlatform
}
// forPdkBuild converts this sdkSpec into another sdkSpec that is for the PDK builds.
func (s sdkSpec) forPdkBuild(ctx android.EarlyModuleContext) sdkSpec {
// For PDK builds, use the latest SDK version instead of "current" or ""
if s.kind == sdkPrivate || s.kind == sdkPublic {
kind := s.kind
if kind == sdkPrivate {
// We don't have prebuilt SDK for private APIs, so use the public SDK
// instead. This looks odd, but that's how it has been done.
// TODO(b/148271073): investigate the need for this.
kind = sdkPublic
}
version := sdkVersion(LatestSdkVersionInt(ctx))
return sdkSpec{kind, version, s.raw}
}
return s
}
// usePrebuilt determines whether prebuilt SDK should be used for this sdkSpec with the given context.
func (s sdkSpec) usePrebuilt(ctx android.EarlyModuleContext) bool {
if s.version.isCurrent() {
@ -233,9 +216,6 @@ func (s sdkSpec) effectiveVersion(ctx android.EarlyModuleContext) (sdkVersion, e
if !s.valid() {
return s.version, fmt.Errorf("invalid sdk version %q", s.raw)
}
if ctx.Config().IsPdkBuild() {
s = s.forPdkBuild(ctx)
}
if s.version.isNumbered() {
return s.version, nil
}
@ -350,9 +330,6 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep
return sdkDep{}
}
if ctx.Config().IsPdkBuild() {
sdkVersion = sdkVersion.forPdkBuild(ctx)
}
if !sdkVersion.validateSystemSdk(ctx) {
return sdkDep{}
}
@ -511,7 +488,7 @@ func sdkSingletonFactory() android.Singleton {
type sdkSingleton struct{}
func (sdkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
if ctx.Config().AlwaysUsePrebuiltSdks() || ctx.Config().IsPdkBuild() {
if ctx.Config().AlwaysUsePrebuiltSdks() {
return
}
@ -631,9 +608,6 @@ func createAPIFingerprint(ctx android.SingletonContext) {
if ctx.Config().PlatformSdkCodename() == "REL" {
cmd.Text("echo REL >").Output(out)
} else if ctx.Config().IsPdkBuild() {
// TODO: get this from the PDK artifacts?
cmd.Text("echo PDK >").Output(out)
} else if !ctx.Config().AlwaysUsePrebuiltSdks() {
in, err := ctx.GlobWithDeps("frameworks/base/api/*current.txt", nil)
if err != nil {
@ -663,7 +637,7 @@ func ApiFingerprintPath(ctx android.PathContext) android.OutputPath {
}
func sdkMakeVars(ctx android.MakeVarsContext) {
if ctx.Config().AlwaysUsePrebuiltSdks() || ctx.Config().IsPdkBuild() {
if ctx.Config().AlwaysUsePrebuiltSdks() {
return
}

View File

@ -1137,11 +1137,6 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.DefaultableHookContext
Libs []string
Compile_dex *bool
Java_version *string
Product_variables struct {
Pdk struct {
Enabled *bool
}
}
Openjdk9 struct {
Srcs []string
Javacflags []string
@ -1174,7 +1169,6 @@ func (module *SdkLibrary) createStubsLibrary(mctx android.DefaultableHookContext
if proptools.Bool(module.sdkLibraryProperties.Annotations_enabled) {
props.Libs = append(props.Libs, "stub-annotations")
}
props.Product_variables.Pdk.Enabled = proptools.BoolPtr(false)
props.Openjdk9.Srcs = module.properties.Openjdk9.Srcs
props.Openjdk9.Javacflags = module.properties.Openjdk9.Javacflags
// We compile the stubs for 1.8 in line with the main android.jar stubs, and potential

View File

@ -30,7 +30,6 @@ func TestClasspath(t *testing.T) {
var classpathTestcases = []struct {
name string
unbundled bool
pdk bool
moduleType string
host android.OsClass
properties string
@ -216,35 +215,6 @@ func TestClasspath(t *testing.T) {
aidl: "-pprebuilts/sdk/current/public/framework.aidl",
},
{
name: "pdk default",
pdk: true,
bootclasspath: []string{`""`},
system: "sdk_public_30_system_modules",
java8classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
java9classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
aidl: "-pprebuilts/sdk/30/public/framework.aidl",
},
{
name: "pdk current",
pdk: true,
properties: `sdk_version: "current",`,
bootclasspath: []string{`""`},
system: "sdk_public_30_system_modules",
java8classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
java9classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
aidl: "-pprebuilts/sdk/30/public/framework.aidl",
},
{
name: "pdk 29",
pdk: true,
properties: `sdk_version: "29",`,
bootclasspath: []string{`""`},
system: "sdk_public_30_system_modules",
java8classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
java9classpath: []string{"prebuilts/sdk/30/public/android.jar", "prebuilts/sdk/tools/core-lambda-stubs.jar"},
aidl: "-pprebuilts/sdk/30/public/framework.aidl",
},
{
name: "module_current",
properties: `sdk_version: "module_current",`,
@ -386,9 +356,6 @@ func TestClasspath(t *testing.T) {
config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
config.TestProductVariables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
}
if testcase.pdk {
config.TestProductVariables.Pdk = proptools.BoolPtr(true)
}
ctx := testContext()
run(t, ctx, config)
@ -410,9 +377,6 @@ func TestClasspath(t *testing.T) {
config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
config.TestProductVariables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
}
if testcase.pdk {
config.TestProductVariables.Pdk = proptools.BoolPtr(true)
}
ctx := testContext()
run(t, ctx, config)
@ -437,9 +401,6 @@ func TestClasspath(t *testing.T) {
config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
config.TestProductVariables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
}
if testcase.pdk {
config.TestProductVariables.Pdk = proptools.BoolPtr(true)
}
ctx := testContext()
run(t, ctx, config)
@ -456,9 +417,6 @@ func TestClasspath(t *testing.T) {
config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
config.TestProductVariables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
}
if testcase.pdk {
config.TestProductVariables.Pdk = proptools.BoolPtr(true)
}
ctx := testContext()
run(t, ctx, config)

View File

@ -53,8 +53,6 @@ type configImpl struct {
// Autodetected
totalRAM uint64
pdkBuild bool
brokenDupRules bool
brokenUsesNetwork bool
brokenNinjaEnvVars []string
@ -968,14 +966,6 @@ func (c *configImpl) TargetDeviceDir() string {
return c.targetDeviceDir
}
func (c *configImpl) SetPdkBuild(pdk bool) {
c.pdkBuild = pdk
}
func (c *configImpl) IsPdkBuild() bool {
return c.pdkBuild
}
func (c *configImpl) BuildDateTime() string {
return c.buildDateTime
}

View File

@ -161,8 +161,6 @@ var BannerVars = []string{
"BUILD_ID",
"OUT_DIR",
"AUX_OS_VARIANT_LIST",
"TARGET_BUILD_PDK",
"PDK_FUSION_PLATFORM_ZIP",
"PRODUCT_SOONG_NAMESPACES",
}
@ -281,7 +279,6 @@ func runMakeProductConfig(ctx Context, config Config) {
config.SetTargetDevice(make_vars["TARGET_DEVICE"])
config.SetTargetDeviceDir(make_vars["TARGET_DEVICE_DIR"])
config.SetPdkBuild(make_vars["TARGET_BUILD_PDK"] == "true")
config.SetBuildBrokenDupRules(make_vars["BUILD_BROKEN_DUP_RULES"] == "true")
config.SetBuildBrokenUsesNetwork(make_vars["BUILD_BROKEN_USES_NETWORK"] == "true")
config.SetBuildBrokenNinjaUsesEnvVars(strings.Fields(make_vars["BUILD_BROKEN_NINJA_USES_ENV_VARS"]))

View File

@ -134,14 +134,10 @@ func runKatiBuild(ctx Context, config Config) {
args := []string{
"--writable", config.OutDir() + "/",
"--werror_implicit_rules",
"-f", "build/make/core/main.mk",
}
// PDK builds still uses a few implicit rules
if !config.IsPdkBuild() {
args = append(args, "--werror_implicit_rules")
}
if !config.BuildBrokenDupRules() {
args = append(args, "--werror_overriding_commands")
}