Split logtags implementations for cc and java
Logtags files in cc and java are treated fundamentally differently.
In cc, they are not used for compiling at all, but need to be passed
to Make to be combined into the global logtags list, and logtag files
are listed in a logtags property. In java they are listed in srcs
and produce generated code that is compiled in, and so shouldn't
also need to be listed in a logtags property.
Move the logtags property to cc and export it to Make from there,
and have java extract logtags files from srcs to be exported to
Make.
Test: m checkbuild
Change-Id: I31d49289efe72db60d2f33566df771b4a3ebc8a0
diff --git a/android/androidmk.go b/android/androidmk.go
index 12aa5fa..fb3934f 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -224,9 +224,6 @@
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, " "))
}
diff --git a/android/module.go b/android/module.go
index 865764f..6d7bb43 100644
--- a/android/module.go
+++ b/android/module.go
@@ -214,10 +214,6 @@
// 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
diff --git a/androidmk/cmd/androidmk/android.go b/androidmk/cmd/androidmk/android.go
index bb9d140..4022a5e 100644
--- a/androidmk/cmd/androidmk/android.go
+++ b/androidmk/cmd/androidmk/android.go
@@ -49,7 +49,6 @@
"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 @@
})
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 @@
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)
diff --git a/androidmk/cmd/androidmk/androidmk_test.go b/androidmk/cmd/androidmk/androidmk_test.go
index 9986889..22a52d4 100644
--- a/androidmk/cmd/androidmk/androidmk_test.go
+++ b/androidmk/cmd/androidmk/androidmk_test.go
@@ -213,35 +213,6 @@
`,
},
{
- 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"],
-}
-`,
- },
- {
desc: "_<OS> suffixes",
in: `
include $(CLEAR_VARS)
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 7311263..1db5373 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -60,6 +60,9 @@
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, " "))
diff --git a/cc/cc.go b/cc/cc.go
index c31cf04..fa33bc6 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -164,6 +164,10 @@
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 {
diff --git a/java/androidmk.go b/java/androidmk.go
index acf597b..af91a33 100644
--- a/java/androidmk.go
+++ b/java/androidmk.go
@@ -31,6 +31,14 @@
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")
}