Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f43597f authored by Dan Willemsen's avatar Dan Willemsen
Browse files

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
Merged-In: I830b54d419b59f6db1d4617b45e61a78234f57a7
parent a57e56a6
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -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)
}
+0 −1
Original line number Diff line number Diff line
@@ -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"`
+23 −0
Original line number Diff line number Diff line
@@ -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)
}
+58 −0
Original line number Diff line number Diff line
@@ -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))
		})
	}
}
+1 −1
Original line number Diff line number Diff line
@@ -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()
Loading