Merge "Split logtags implementations for cc and java"

This commit is contained in:
Colin Cross 2017-12-08 16:14:06 +00:00 committed by Gerrit Code Review
commit e304cc4575
7 changed files with 16 additions and 81 deletions

View file

@ -224,9 +224,6 @@ func translateAndroidMkModule(ctx SingletonContext, w io.Writer, mod blueprint.M
fmt.Fprintln(&data.preamble, "LOCAL_MODULE_TARGET_ARCH :=", archStr)
}
if len(amod.commonProperties.Logtags) > 0 {
fmt.Fprintln(&data.preamble, "LOCAL_LOGTAGS_FILES := ", strings.Join(amod.commonProperties.Logtags, " "))
}
if len(amod.commonProperties.Init_rc) > 0 {
fmt.Fprintln(&data.preamble, "LOCAL_INIT_RC := ", strings.Join(amod.commonProperties.Init_rc, " "))
}

View file

@ -214,10 +214,6 @@ type commonProperties struct {
// whether this module is device specific and should be installed into /vendor
Vendor *bool
// *.logtags files, to combine together in order to generate the /system/etc/event-log-tags
// file
Logtags []string
// init.rc files to be installed if this module is installed
Init_rc []string

View file

@ -49,7 +49,6 @@ var rewriteProperties = map[string](func(variableAssignmentContext) error){
"LOCAL_MODULE_CLASS": prebuiltClass,
"LOCAL_MODULE_STEM": stem,
"LOCAL_MODULE_HOST_OS": hostOs,
"LOCAL_SRC_FILES": srcFiles,
"LOCAL_SANITIZE": sanitize(""),
"LOCAL_SANITIZE_DIAG": sanitize("diag."),
"LOCAL_CFLAGS": cflags,
@ -99,6 +98,7 @@ func init() {
})
addStandardProperties(bpparser.ListType,
map[string]string{
"LOCAL_SRC_FILES": "srcs",
"LOCAL_SRC_FILES_EXCLUDE": "exclude_srcs",
"LOCAL_HEADER_LIBRARIES": "header_libs",
"LOCAL_SHARED_LIBRARIES": "shared_libs",
@ -389,50 +389,6 @@ func hostOs(ctx variableAssignmentContext) error {
return err
}
func splitSrcsLogtags(value bpparser.Expression) (string, bpparser.Expression, error) {
switch v := value.(type) {
case *bpparser.Variable:
// TODO: attempt to split variables?
return "srcs", value, nil
case *bpparser.Operator:
// TODO: attempt to handle expressions?
return "srcs", value, nil
case *bpparser.String:
if strings.HasSuffix(v.Value, ".logtags") {
return "logtags", value, nil
}
return "srcs", value, nil
default:
return "", nil, fmt.Errorf("splitSrcsLogtags expected a string, got %s", value.Type())
}
}
func srcFiles(ctx variableAssignmentContext) error {
val, err := makeVariableToBlueprint(ctx.file, ctx.mkvalue, bpparser.ListType)
if err != nil {
return err
}
lists, err := splitBpList(val, splitSrcsLogtags)
if srcs, ok := lists["srcs"]; ok && !emptyList(srcs) {
err = setVariable(ctx.file, ctx.append, ctx.prefix, "srcs", srcs, true)
if err != nil {
return err
}
}
if logtags, ok := lists["logtags"]; ok && !emptyList(logtags) {
err = setVariable(ctx.file, true, ctx.prefix, "logtags", logtags, true)
if err != nil {
return err
}
}
return nil
}
func sanitize(sub string) func(ctx variableAssignmentContext) error {
return func(ctx variableAssignmentContext) error {
val, err := makeVariableToBlueprint(ctx.file, ctx.mkvalue, bpparser.ListType)

View file

@ -210,35 +210,6 @@ cc_library_shared {
},
},
}
`,
},
{
desc: "*.logtags in LOCAL_SRC_FILES",
in: `
include $(CLEAR_VARS)
LOCAL_SRC_FILES := events.logtags
LOCAL_SRC_FILES += a.c events2.logtags
include $(BUILD_SHARED_LIBRARY)
`,
expected: `
cc_library_shared {
logtags: ["events.logtags"] + ["events2.logtags"],
srcs: ["a.c"],
}
`,
},
{
desc: "LOCAL_LOGTAGS_FILES and *.logtags in LOCAL_SRC_FILES",
in: `
include $(CLEAR_VARS)
LOCAL_LOGTAGS_FILES := events.logtags
LOCAL_SRC_FILES := events2.logtags
include $(BUILD_SHARED_LIBRARY)
`,
expected: `
cc_library_shared {
logtags: ["events.logtags"] + ["events2.logtags"],
}
`,
},
{

View file

@ -60,6 +60,9 @@ func (c *Module) AndroidMk() android.AndroidMkData {
OutputFile: c.outputFile,
Extra: []android.AndroidMkExtraFunc{
func(w io.Writer, outputFile android.Path) {
if len(c.Properties.Logtags) > 0 {
fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES :=", strings.Join(c.Properties.Logtags, " "))
}
fmt.Fprintln(w, "LOCAL_SANITIZE := never")
if len(c.Properties.AndroidMkSharedLibs) > 0 {
fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " "))

View file

@ -164,6 +164,10 @@ type BaseProperties struct {
PreventInstall bool `blueprint:"mutated"`
UseVndk bool `blueprint:"mutated"`
// *.logtags files, to combine together in order to generate the /system/etc/event-log-tags
// file
Logtags []string
}
type VendorProperties struct {

View file

@ -31,6 +31,14 @@ func (library *Library) AndroidMk() android.AndroidMkData {
Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
Extra: []android.AndroidMkExtraFunc{
func(w io.Writer, outputFile android.Path) {
if len(library.logtagsSrcs) > 0 {
var logtags []string
for _, l := range library.logtagsSrcs {
logtags = append(logtags, l.Rel())
}
fmt.Fprintln(w, "LOCAL_LOGTAGS_FILES :=", strings.Join(logtags, " "))
}
if library.properties.Installable != nil && *library.properties.Installable == false {
fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
}