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

Commit 812bfff3 authored by Trevor Radcliffe's avatar Trevor Radcliffe Committed by Gerrit Code Review
Browse files

Merge "Add support for privileged apps to androidmk"

parents 10eada74 ecdb9f70
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ package androidmk
import (
	"fmt"
	"sort"
	"strconv"
	"strings"

	mkparser "android/soong/androidmk/parser"
@@ -623,6 +624,16 @@ func makeBlueprintStringAssignment(file *bpFile, prefix string, suffix string, v
	return err
}

// Assigns a given boolean value to a given variable in the result bp file. See
// setVariable documentation for more information about prefix and name.
func makeBlueprintBoolAssignment(ctx variableAssignmentContext, prefix, name string, value bool) error {
	expressionValue, err := stringToBoolValue(strconv.FormatBool(value))
	if err == nil {
		err = setVariable(ctx.file, false, prefix, name, expressionValue, true)
	}
	return err
}

// If variable is a literal variable name, return the name, otherwise return ""
func varLiteralName(variable mkparser.Variable) string {
	if len(variable.Name.Variables) == 0 {
@@ -647,7 +658,11 @@ func prebuiltModulePath(ctx variableAssignmentContext) error {
	varname := ""
	fixed := ""
	val := ctx.mkvalue

	if len(val.Variables) == 1 && varLiteralName(val.Variables[0]) != "" && len(val.Strings) == 2 && val.Strings[0] == "" {
		if varLiteralName(val.Variables[0]) == "PRODUCT_OUT" && val.Strings[1] == "/system/priv-app" {
			return makeBlueprintBoolAssignment(ctx, "", "privileged", true)
		}
		fixed = val.Strings[1]
		varname = val.Variables[0].Name.Strings[0]
		// TARGET_OUT_OPTIONAL_EXECUTABLES puts the artifact in xbin, which is
+18 −0
Original line number Diff line number Diff line
@@ -411,6 +411,24 @@ func makeVariableToBlueprint(file *bpFile, val *mkparser.MakeString,
	return exp, nil
}

// If local is set to true, then the variable will be added as a part of the
// variable at file.bpPos. For example, if file.bpPos references a module,
// then calling this method will set a property on that module if local is set
// to true. Otherwise, the Variable will be created at the root of the file.
//
// prefix should be populated with the top level value to be assigned, and
// name with a sub-value. If prefix is empty, then name is the top level value.
// For example, if prefix is "foo" and name is "bar" with a value of "baz", then
// the following variable will be generated:
//
// foo {
//   bar: "baz"
// }
//
// If prefix is the empty string and name is "foo" with a value of "bar", the
// following variable will be generated (if it is a property):
//
// foo: "bar"
func setVariable(file *bpFile, plusequals bool, prefix, name string, value bpparser.Expression, local bool) error {
	if prefix != "" {
		name = prefix + "." + name
+15 −0
Original line number Diff line number Diff line
@@ -1673,6 +1673,21 @@ android_app {
	name: "foo",
	auto_gen_config: true,
}
`,
	},
	{
		desc: "privileged app",
		in: `
include $(CLEAR_VARS)
LOCAL_MODULE := foo
LOCAL_MODULE_PATH := $(PRODUCT_OUT)/system/priv-app
include $(BUILD_PACKAGE)
		`,
		expected: `
android_app {
	name: "foo",
	privileged: true
}
`,
	},
}
+14 −4
Original line number Diff line number Diff line
@@ -24,14 +24,24 @@ import (
// A MakeString is a string that may contain variable substitutions in it.
// It can be considered as an alternating list of raw Strings and variable
// substitutions, where the first and last entries in the list must be raw
// Strings (possibly empty).  A MakeString that starts with a variable
// will have an empty first raw string, and a MakeString that ends with a
// variable will have an empty last raw string.  Two sequential Variables
// will have an empty raw string between them.
// Strings (possibly empty). The entirety of the text before the first variable,
// between two variables, and after the last variable will be considered a
// single String value. A MakeString that starts with a variable will have an
// empty first raw string, and a MakeString that ends with a  variable will have
// an empty last raw string.  Two sequential Variables will have an empty raw
// string between them.
//
// The MakeString is stored as two lists, a list of raw Strings and a list
// of Variables.  The raw string list is always one longer than the variable
// list.
//
// For example, "$(FOO)/bar/baz" will be represented as the
// following lists:
//
// {
//   Strings: ["", "/bar/baz"],
//   Variables: ["FOO"]
// }
type MakeString struct {
	StringPos Pos
	Strings   []string