Merge "Add support for privileged apps to androidmk"
This commit is contained in:
@@ -17,6 +17,7 @@ package androidmk
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
mkparser "android/soong/androidmk/parser"
|
mkparser "android/soong/androidmk/parser"
|
||||||
@@ -623,6 +624,16 @@ func makeBlueprintStringAssignment(file *bpFile, prefix string, suffix string, v
|
|||||||
return err
|
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 ""
|
// If variable is a literal variable name, return the name, otherwise return ""
|
||||||
func varLiteralName(variable mkparser.Variable) string {
|
func varLiteralName(variable mkparser.Variable) string {
|
||||||
if len(variable.Name.Variables) == 0 {
|
if len(variable.Name.Variables) == 0 {
|
||||||
@@ -647,7 +658,11 @@ func prebuiltModulePath(ctx variableAssignmentContext) error {
|
|||||||
varname := ""
|
varname := ""
|
||||||
fixed := ""
|
fixed := ""
|
||||||
val := ctx.mkvalue
|
val := ctx.mkvalue
|
||||||
|
|
||||||
if len(val.Variables) == 1 && varLiteralName(val.Variables[0]) != "" && len(val.Strings) == 2 && val.Strings[0] == "" {
|
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]
|
fixed = val.Strings[1]
|
||||||
varname = val.Variables[0].Name.Strings[0]
|
varname = val.Variables[0].Name.Strings[0]
|
||||||
// TARGET_OUT_OPTIONAL_EXECUTABLES puts the artifact in xbin, which is
|
// TARGET_OUT_OPTIONAL_EXECUTABLES puts the artifact in xbin, which is
|
||||||
|
@@ -411,6 +411,24 @@ func makeVariableToBlueprint(file *bpFile, val *mkparser.MakeString,
|
|||||||
return exp, nil
|
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 {
|
func setVariable(file *bpFile, plusequals bool, prefix, name string, value bpparser.Expression, local bool) error {
|
||||||
if prefix != "" {
|
if prefix != "" {
|
||||||
name = prefix + "." + name
|
name = prefix + "." + name
|
||||||
|
@@ -1673,6 +1673,21 @@ android_app {
|
|||||||
name: "foo",
|
name: "foo",
|
||||||
auto_gen_config: true,
|
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
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@@ -24,14 +24,24 @@ import (
|
|||||||
// A MakeString is a string that may contain variable substitutions in it.
|
// 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
|
// 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
|
// substitutions, where the first and last entries in the list must be raw
|
||||||
// Strings (possibly empty). A MakeString that starts with a variable
|
// Strings (possibly empty). The entirety of the text before the first variable,
|
||||||
// will have an empty first raw string, and a MakeString that ends with a
|
// between two variables, and after the last variable will be considered a
|
||||||
// variable will have an empty last raw string. Two sequential Variables
|
// single String value. A MakeString that starts with a variable will have an
|
||||||
// will have an empty raw string between them.
|
// 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
|
// 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
|
// of Variables. The raw string list is always one longer than the variable
|
||||||
// list.
|
// list.
|
||||||
|
//
|
||||||
|
// For example, "$(FOO)/bar/baz" will be represented as the
|
||||||
|
// following lists:
|
||||||
|
//
|
||||||
|
// {
|
||||||
|
// Strings: ["", "/bar/baz"],
|
||||||
|
// Variables: ["FOO"]
|
||||||
|
// }
|
||||||
type MakeString struct {
|
type MakeString struct {
|
||||||
StringPos Pos
|
StringPos Pos
|
||||||
Strings []string
|
Strings []string
|
||||||
|
Reference in New Issue
Block a user