Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 364740b4 authored by Inseob Kim's avatar Inseob Kim Committed by Gerrit Code Review
Browse files

Merge "Merge logtags from cc modules too" into main

parents 37d17209 37e0bb0d
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ bootstrap_go_package {
        "license_metadata.go",
        "license_sdk_member.go",
        "licenses.go",
        "logtags.go",
        "makevars.go",
        "metrics.go",
        "module.go",

android/logtags.go

0 → 100644
+56 −0
Original line number Diff line number Diff line
// Copyright 2024 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package android

import "github.com/google/blueprint"

func init() {
	RegisterParallelSingletonType("logtags", LogtagsSingleton)
}

type LogtagsInfo struct {
	Logtags Paths
}

var LogtagsProviderKey = blueprint.NewProvider[*LogtagsInfo]()

func LogtagsSingleton() Singleton {
	return &logtagsSingleton{}
}

type logtagsSingleton struct{}

func MergedLogtagsPath(ctx PathContext) OutputPath {
	return PathForIntermediates(ctx, "all-event-log-tags.txt")
}

func (l *logtagsSingleton) GenerateBuildActions(ctx SingletonContext) {
	var allLogtags Paths
	ctx.VisitAllModules(func(module Module) {
		if !module.ExportedToMake() {
			return
		}
		if logtagsInfo, ok := SingletonModuleProvider(ctx, module, LogtagsProviderKey); ok {
			allLogtags = append(allLogtags, logtagsInfo.Logtags...)
		}
	})

	builder := NewRuleBuilder(pctx, ctx)
	builder.Command().
		BuiltTool("merge-event-log-tags").
		FlagWithOutput("-o ", MergedLogtagsPath(ctx)).
		Inputs(SortedUniquePaths(allLogtags))
	builder.Build("all-event-log-tags.txt", "merge logtags")
}
+1 −1
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@ func init() {
			"LOCAL_CLANG_CFLAGS":                  "clang_cflags",
			"LOCAL_YACCFLAGS":                     "yacc.flags",
			"LOCAL_SANITIZE_RECOVER":              "sanitize.recover",
			"LOCAL_LOGTAGS_FILES":                 "logtags",
			"LOCAL_SOONG_LOGTAGS_FILES":           "logtags",
			"LOCAL_EXPORT_HEADER_LIBRARY_HEADERS": "export_header_lib_headers",
			"LOCAL_EXPORT_SHARED_LIBRARY_HEADERS": "export_shared_lib_headers",
			"LOCAL_EXPORT_STATIC_LIBRARY_HEADERS": "export_static_lib_headers",
+1 −1
Original line number Diff line number Diff line
@@ -88,7 +88,7 @@ func (c *Module) AndroidMkEntries() []android.AndroidMkEntries {
		ExtraEntries: []android.AndroidMkExtraEntriesFunc{
			func(ctx android.AndroidMkExtraEntriesContext, entries *android.AndroidMkEntries) {
				if len(c.Properties.Logtags) > 0 {
					entries.AddStrings("LOCAL_LOGTAGS_FILES", c.Properties.Logtags...)
					entries.AddStrings("LOCAL_SOONG_LOGTAGS_FILES", c.logtagsPaths.Strings()...)
				}
				// Note: Pass the exact value of AndroidMkSystemSharedLibs to the Make
				// world, even if it is an empty list. In the Make world,
+8 −1
Original line number Diff line number Diff line
@@ -320,7 +320,7 @@ type BaseProperties struct {

	// *.logtags files, to combine together in order to generate the /system/etc/event-log-tags
	// file
	Logtags []string
	Logtags []string `android:"path"`

	// Make this module available when building for ramdisk.
	// On device without a dedicated recovery partition, the module is only
@@ -909,6 +909,8 @@ type Module struct {

	// Aconfig files for all transitive deps.  Also exposed via TransitiveDeclarationsInfo
	mergedAconfigFiles map[string]android.Paths

	logtagsPaths android.Paths
}

func (c *Module) AddJSONData(d *map[string]interface{}) {
@@ -1998,6 +2000,11 @@ func (d *Defaults) GenerateAndroidBuildActions(ctx android.ModuleContext) {
func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
	ctx := moduleContextFromAndroidModuleContext(actx, c)

	c.logtagsPaths = android.PathsForModuleSrc(actx, c.Properties.Logtags)
	android.SetProvider(ctx, android.LogtagsProviderKey, &android.LogtagsInfo{
		Logtags: c.logtagsPaths,
	})

	// If Test_only is set on a module in bp file, respect the setting, otherwise
	// see if is a known test module type.
	testOnly := c.testModule || c.testLibrary()
Loading