From 5beccee92cfa5e13fbebb3d670f0dc65b7ba802c Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 7 Dec 2017 15:28:59 -0800 Subject: [PATCH] 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 --- android/androidmk.go | 3 -- android/module.go | 4 -- androidmk/cmd/androidmk/android.go | 46 +---------------------- androidmk/cmd/androidmk/androidmk_test.go | 29 -------------- cc/androidmk.go | 3 ++ cc/cc.go | 4 ++ java/androidmk.go | 8 ++++ 7 files changed, 16 insertions(+), 81 deletions(-) diff --git a/android/androidmk.go b/android/androidmk.go index 12aa5fa8a..fb3934f8a 100644 --- a/android/androidmk.go +++ b/android/androidmk.go @@ -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, " ")) } diff --git a/android/module.go b/android/module.go index 865764f58..6d7bb4383 100644 --- a/android/module.go +++ b/android/module.go @@ -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 diff --git a/androidmk/cmd/androidmk/android.go b/androidmk/cmd/androidmk/android.go index bb9d140ff..4022a5e33 100644 --- a/androidmk/cmd/androidmk/android.go +++ b/androidmk/cmd/androidmk/android.go @@ -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) diff --git a/androidmk/cmd/androidmk/androidmk_test.go b/androidmk/cmd/androidmk/androidmk_test.go index 9986889cc..22a52d46a 100644 --- a/androidmk/cmd/androidmk/androidmk_test.go +++ b/androidmk/cmd/androidmk/androidmk_test.go @@ -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"], -} `, }, { diff --git a/cc/androidmk.go b/cc/androidmk.go index 73112637e..1db537371 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -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, " ")) diff --git a/cc/cc.go b/cc/cc.go index c31cf0426..fa33bc639 100644 --- a/cc/cc.go +++ b/cc/cc.go @@ -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 { diff --git a/java/androidmk.go b/java/androidmk.go index acf597bb2..af91a33d0 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -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") }