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

Commit 36ce9584 authored by Colin Cross's avatar Colin Cross Committed by Gerrit Code Review
Browse files

Merge "Use ModuleInfoJSONProvider for cc modules" into main

parents 138d37dd 4a9e6ec9
Loading
Loading
Loading
Loading
+0 −9
Original line number Original line Diff line number Diff line
@@ -101,15 +101,6 @@ func (c *Module) AndroidMkEntries() []android.AndroidMkEntries {
				if len(c.Properties.AndroidMkSharedLibs) > 0 {
				if len(c.Properties.AndroidMkSharedLibs) > 0 {
					entries.AddStrings("LOCAL_SHARED_LIBRARIES", c.Properties.AndroidMkSharedLibs...)
					entries.AddStrings("LOCAL_SHARED_LIBRARIES", c.Properties.AndroidMkSharedLibs...)
				}
				}
				if len(c.Properties.AndroidMkStaticLibs) > 0 {
					entries.AddStrings("LOCAL_STATIC_LIBRARIES", c.Properties.AndroidMkStaticLibs...)
				}
				if len(c.Properties.AndroidMkWholeStaticLibs) > 0 {
					entries.AddStrings("LOCAL_WHOLE_STATIC_LIBRARIES", c.Properties.AndroidMkWholeStaticLibs...)
				}
				if len(c.Properties.AndroidMkHeaderLibs) > 0 {
					entries.AddStrings("LOCAL_HEADER_LIBRARIES", c.Properties.AndroidMkHeaderLibs...)
				}
				if len(c.Properties.AndroidMkRuntimeLibs) > 0 {
				if len(c.Properties.AndroidMkRuntimeLibs) > 0 {
					entries.AddStrings("LOCAL_RUNTIME_LIBRARIES", c.Properties.AndroidMkRuntimeLibs...)
					entries.AddStrings("LOCAL_RUNTIME_LIBRARIES", c.Properties.AndroidMkRuntimeLibs...)
				}
				}
+5 −0
Original line number Original line Diff line number Diff line
@@ -541,6 +541,11 @@ func (binary *binaryDecorator) overriddenModules() []string {
	return binary.Properties.Overrides
	return binary.Properties.Overrides
}
}


func (binary *binaryDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
	moduleInfoJSON.Class = []string{"EXECUTABLES"}
	binary.baseLinker.moduleInfoJSON(ctx, moduleInfoJSON)
}

var _ overridable = (*binaryDecorator)(nil)
var _ overridable = (*binaryDecorator)(nil)


func init() {
func init() {
+40 −0
Original line number Original line Diff line number Diff line
@@ -543,6 +543,7 @@ type ModuleContextIntf interface {
	isPreventInstall() bool
	isPreventInstall() bool
	isCfiAssemblySupportEnabled() bool
	isCfiAssemblySupportEnabled() bool
	getSharedFlags() *SharedFlags
	getSharedFlags() *SharedFlags
	notInPlatform() bool
}
}


type SharedFlags struct {
type SharedFlags struct {
@@ -623,6 +624,8 @@ type linker interface {


	// Get the deps that have been explicitly specified in the properties.
	// Get the deps that have been explicitly specified in the properties.
	linkerSpecifiedDeps(specifiedDeps specifiedDeps) specifiedDeps
	linkerSpecifiedDeps(specifiedDeps specifiedDeps) specifiedDeps

	moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON)
}
}


// specifiedDeps is a tuple struct representing dependencies of a linked binary owned by the linker.
// specifiedDeps is a tuple struct representing dependencies of a linked binary owned by the linker.
@@ -1785,6 +1788,10 @@ func (ctx *moduleContextImpl) isCfiAssemblySupportEnabled() bool {
	return ctx.mod.isCfiAssemblySupportEnabled()
	return ctx.mod.isCfiAssemblySupportEnabled()
}
}


func (ctx *moduleContextImpl) notInPlatform() bool {
	return ctx.mod.NotInPlatform()
}

func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module {
	return &Module{
	return &Module{
		hod:      hod,
		hod:      hod,
@@ -2139,6 +2146,39 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
	android.CollectDependencyAconfigFiles(ctx, &c.mergedAconfigFiles)
	android.CollectDependencyAconfigFiles(ctx, &c.mergedAconfigFiles)


	c.maybeInstall(ctx, apexInfo)
	c.maybeInstall(ctx, apexInfo)

	if c.linker != nil {
		moduleInfoJSON := ctx.ModuleInfoJSON()
		c.linker.moduleInfoJSON(ctx, moduleInfoJSON)
		moduleInfoJSON.SharedLibs = c.Properties.AndroidMkSharedLibs
		moduleInfoJSON.StaticLibs = c.Properties.AndroidMkStaticLibs
		moduleInfoJSON.SystemSharedLibs = c.Properties.AndroidMkSystemSharedLibs
		moduleInfoJSON.RuntimeDependencies = c.Properties.AndroidMkRuntimeLibs

		moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, c.Properties.AndroidMkSharedLibs...)
		moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, c.Properties.AndroidMkStaticLibs...)
		moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, c.Properties.AndroidMkHeaderLibs...)
		moduleInfoJSON.Dependencies = append(moduleInfoJSON.Dependencies, c.Properties.AndroidMkWholeStaticLibs...)

		if c.sanitize != nil && len(moduleInfoJSON.Class) > 0 &&
			(moduleInfoJSON.Class[0] == "STATIC_LIBRARIES" || moduleInfoJSON.Class[0] == "HEADER_LIBRARIES") {
			if Bool(c.sanitize.Properties.SanitizeMutated.Cfi) {
				moduleInfoJSON.SubName += ".cfi"
			}
			if Bool(c.sanitize.Properties.SanitizeMutated.Hwaddress) {
				moduleInfoJSON.SubName += ".hwasan"
			}
			if Bool(c.sanitize.Properties.SanitizeMutated.Scs) {
				moduleInfoJSON.SubName += ".scs"
			}
		}
		moduleInfoJSON.SubName += c.Properties.SubName

		if c.Properties.IsSdkVariant && c.Properties.SdkAndPlatformVariantVisibleToMake {
			moduleInfoJSON.Uninstallable = true
		}

	}
}
}


func (c *Module) maybeUnhideFromMake() {
func (c *Module) maybeUnhideFromMake() {
+5 −0
Original line number Original line Diff line number Diff line
@@ -163,6 +163,11 @@ func (fuzz *fuzzBinary) linkerFlags(ctx ModuleContext, flags Flags) Flags {
	return flags
	return flags
}
}


func (fuzz *fuzzBinary) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
	fuzz.binaryDecorator.moduleInfoJSON(ctx, moduleInfoJSON)
	moduleInfoJSON.Class = []string{"EXECUTABLES"}
}

// IsValidSharedDependency takes a module and determines if it is a unique shared library
// IsValidSharedDependency takes a module and determines if it is a unique shared library
// that should be installed in the fuzz target output directories. This function
// that should be installed in the fuzz target output directories. This function
// returns true, unless:
// returns true, unless:
+34 −0
Original line number Original line Diff line number Diff line
@@ -1041,6 +1041,40 @@ func (library *libraryDecorator) linkerSpecifiedDeps(specifiedDeps specifiedDeps
	return specifiedDeps
	return specifiedDeps
}
}


func (library *libraryDecorator) moduleInfoJSON(ctx ModuleContext, moduleInfoJSON *android.ModuleInfoJSON) {
	if library.static() {
		moduleInfoJSON.Class = []string{"STATIC_LIBRARIES"}
		moduleInfoJSON.Uninstallable = true
	} else if library.shared() {
		moduleInfoJSON.Class = []string{"SHARED_LIBRARIES"}
	} else if library.header() {
		moduleInfoJSON.Class = []string{"HEADER_LIBRARIES"}
		moduleInfoJSON.Uninstallable = true
	}

	if library.buildStubs() && library.stubsVersion() != "" {
		moduleInfoJSON.SubName += "." + library.stubsVersion()
	}

	// If a library providing a stub is included in an APEX, the private APIs of the library
	// is accessible only inside the APEX. From outside of the APEX, clients can only use the
	// public APIs via the stub. To enforce this, the (latest version of the) stub gets the
	// name of the library. The impl library instead gets the `.bootstrap` suffix to so that
	// they can be exceptionally used directly when APEXes are not available (e.g. during the
	// very early stage in the boot process).
	if len(library.Properties.Stubs.Versions) > 0 && !ctx.Host() && ctx.notInPlatform() &&
		!ctx.inRamdisk() && !ctx.inVendorRamdisk() && !ctx.inRecovery() && !ctx.useVndk() && !ctx.static() {
		if library.buildStubs() && library.isLatestStubVersion() {
			moduleInfoJSON.SubName = ""
		}
		if !library.buildStubs() {
			moduleInfoJSON.SubName = ".bootstrap"
		}
	}

	library.baseLinker.moduleInfoJSON(ctx, moduleInfoJSON)
}

func (library *libraryDecorator) linkStatic(ctx ModuleContext,
func (library *libraryDecorator) linkStatic(ctx ModuleContext,
	flags Flags, deps PathDeps, objs Objects) android.Path {
	flags Flags, deps PathDeps, objs Objects) android.Path {


Loading