Merge changes I825ec897,I565a5624

* changes:
  Support non-installable java libraries
  Add notice property to all modules
This commit is contained in:
Treehugger Robot
2017-09-05 22:31:33 +00:00
committed by Gerrit Code Review
5 changed files with 44 additions and 17 deletions

View File

@@ -232,6 +232,9 @@ func translateAndroidMkModule(ctx blueprint.SingletonContext, w io.Writer, mod b
if amod.commonProperties.Owner != nil {
fmt.Fprintln(&data.preamble, "LOCAL_MODULE_OWNER :=", *amod.commonProperties.Owner)
}
if amod.commonProperties.Notice != nil {
fmt.Fprintln(&data.preamble, "LOCAL_NOTICE_FILE :=", *amod.commonProperties.Notice)
}
}
if host {

View File

@@ -162,6 +162,9 @@ type commonProperties struct {
// names of other modules to install if this module is installed
Required []string `android:"arch_variant"`
// relative path to a file to include in the list of notices for the device
Notice *string
// Set by TargetMutator
CompileTarget Target `blueprint:"mutated"`
CompilePrimary bool `blueprint:"mutated"`

View File

@@ -37,6 +37,7 @@ var rewriteProperties = map[string](func(variableAssignmentContext) error){
"LOCAL_SANITIZE": sanitize(""),
"LOCAL_SANITIZE_DIAG": sanitize("diag."),
"LOCAL_CFLAGS": cflags,
"LOCAL_UNINSTALLABLE_MODULE": invert("installable"),
// composite functions
"LOCAL_MODULE_TAGS": includeVariableIf(bpVariable{"tags", bpparser.ListType}, not(valueDumpEquals("optional"))),
@@ -74,6 +75,7 @@ func init() {
"LOCAL_PROTOC_OPTIMIZE_TYPE": "proto.type",
"LOCAL_MODULE_OWNER": "owner",
"LOCAL_RENDERSCRIPT_TARGET_API": "renderscript.target_api",
"LOCAL_NOTICE_FILE": "notice",
})
addStandardProperties(bpparser.ListType,
map[string]string{
@@ -128,7 +130,6 @@ func init() {
"LOCAL_TIDY": "tidy",
"LOCAL_PROPRIETARY_MODULE": "proprietary",
"LOCAL_VENDOR_MODULE": "vendor",
"LOCAL_EXPORT_PACKAGE_RESOURCES": "export_package_resources",
})
}
@@ -527,6 +528,19 @@ func cflags(ctx variableAssignmentContext) error {
return includeVariableNow(bpVariable{"cflags", bpparser.ListType}, ctx)
}
func invert(name string) func(ctx variableAssignmentContext) error {
return func(ctx variableAssignmentContext) error {
val, err := makeVariableToBlueprint(ctx.file, ctx.mkvalue, bpparser.BoolType)
if err != nil {
return err
}
val.(*bpparser.Bool).Value = !val.(*bpparser.Bool).Value
return setVariable(ctx.file, ctx.append, ctx.prefix, name, val, true)
}
}
// given a conditional, returns a function that will insert a variable assignment or not, based on the conditional
func includeVariableIf(bpVar bpVariable, conditional func(ctx variableAssignmentContext) bool) func(ctx variableAssignmentContext) error {
return func(ctx variableAssignmentContext) error {

View File

@@ -29,6 +29,9 @@ func (library *Library) AndroidMk() android.AndroidMkData {
Extra: []android.AndroidMkExtraFunc{
func(w io.Writer, outputFile android.Path) {
fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := .jar")
if library.properties.Installable != nil && *library.properties.Installable == false {
fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
}
},
},
}
@@ -41,6 +44,7 @@ func (prebuilt *Import) AndroidMk() android.AndroidMkData {
Extra: []android.AndroidMkExtraFunc{
func(w io.Writer, outputFile android.Path) {
fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := .jar")
fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
},
},
}

View File

@@ -96,6 +96,9 @@ type CompilerProperties struct {
// If not blank, set the java version passed to javac as -source and -target
Java_version *string
// If set to false, don't allow this module to be installed. Defaults to true.
Installable *bool
}
type CompilerDeviceProperties struct {
@@ -473,7 +476,10 @@ type Library struct {
func (j *Library) GenerateAndroidBuildActions(ctx android.ModuleContext) {
j.compile(ctx)
j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"), ctx.ModuleName()+".jar", j.outputFile)
if j.properties.Installable == nil || *j.properties.Installable == true {
j.installFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
ctx.ModuleName()+".jar", j.outputFile)
}
}
func (j *Library) DepsMutator(ctx android.BottomUpMutatorContext) {
@@ -605,9 +611,6 @@ func (j *Import) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}
j.combinedClasspathFile = TransformClassesToJar(ctx, j.classJarSpecs, android.OptionalPath{}, nil)
ctx.InstallFile(android.PathForModuleInstall(ctx, "framework"),
ctx.ModuleName()+".jar", j.combinedClasspathFile)
}
var _ Dependency = (*Import)(nil)