diff options
Diffstat (limited to 'cc/cc.go')
| -rw-r--r-- | cc/cc.go | 96 |
1 files changed, 67 insertions, 29 deletions
@@ -37,6 +37,22 @@ import ( "android/soong/genrule" ) +type CcMakeVarsInfo struct { + WarningsAllowed string + UsingWnoError string + MissingProfile string +} + +var CcMakeVarsInfoProvider = blueprint.NewProvider[*CcMakeVarsInfo]() + +type CcObjectInfo struct { + objFiles android.Paths + tidyFiles android.Paths + kytheFiles android.Paths +} + +var CcObjectInfoProvider = blueprint.NewProvider[CcObjectInfo]() + func init() { RegisterCCBuildComponents(android.InitRegistrationContext) @@ -536,6 +552,7 @@ type ModuleContextIntf interface { getSharedFlags() *SharedFlags notInPlatform() bool optimizeForSize() bool + getOrCreateMakeVarsInfo() *CcMakeVarsInfo } type SharedFlags struct { @@ -644,10 +661,6 @@ type installer interface { installInRoot() bool } -type xref interface { - XrefCcFiles() android.Paths -} - type overridable interface { overriddenModules() []string } @@ -850,9 +863,10 @@ type Module struct { sourceProperties android.SourceProperties // initialize before calling Init - hod android.HostOrDeviceSupported - multilib android.Multilib - testModule bool + hod android.HostOrDeviceSupported + multilib android.Multilib + testModule bool + incremental bool // Allowable SdkMemberTypes of this module type. sdkMemberTypes []android.SdkMemberType @@ -895,12 +909,6 @@ type Module struct { staticAnalogue *StaticLibraryInfo makeLinkType string - // Kythe (source file indexer) paths for this compilation module - kytheFiles android.Paths - // Object .o file output paths for this compilation module - objFiles android.Paths - // Tidy .tidy file output paths for this compilation module - tidyFiles android.Paths // For apex variants, this is set as apex.min_sdk_version apexSdkVersion android.ApiLevel @@ -918,8 +926,16 @@ type Module struct { hasSysprop bool hasWinMsg bool hasYacc bool + + makeVarsInfo *CcMakeVarsInfo } +func (c *Module) IncrementalSupported() bool { + return c.incremental +} + +var _ blueprint.Incremental = (*Module)(nil) + func (c *Module) AddJSONData(d *map[string]interface{}) { c.AndroidModuleBase().AddJSONData(d) (*d)["Cc"] = map[string]interface{}{ @@ -1460,10 +1476,6 @@ func InstallToBootstrap(name string, config android.Config) bool { return isBionic(name) } -func (c *Module) XrefCcFiles() android.Paths { - return c.kytheFiles -} - func (c *Module) isCfiAssemblySupportEnabled() bool { return c.sanitize != nil && Bool(c.sanitize.Properties.Sanitize.Config.Cfi_assembly_support) @@ -1554,12 +1566,11 @@ func (ctx *moduleContextImpl) minSdkVersion() string { } if ctx.ctx.Device() { - config := ctx.ctx.Config() - if ctx.inVendor() { - // If building for vendor with final API, then use the latest _stable_ API as "current". - if config.VendorApiLevelFrozen() && (ver == "" || ver == "current") { - ver = config.PlatformSdkVersion().String() - } + // When building for vendor/product, use the latest _stable_ API as "current". + // This is passed to clang/aidl compilers so that compiled/generated code works + // with the system. + if (ctx.inVendor() || ctx.inProduct()) && (ver == "" || ver == "current") { + ver = ctx.ctx.Config().PlatformSdkVersion().String() } } @@ -1705,6 +1716,13 @@ func (ctx *moduleContextImpl) notInPlatform() bool { return ctx.mod.NotInPlatform() } +func (ctx *moduleContextImpl) getOrCreateMakeVarsInfo() *CcMakeVarsInfo { + if ctx.mod.makeVarsInfo == nil { + ctx.mod.makeVarsInfo = &CcMakeVarsInfo{} + } + return ctx.mod.makeVarsInfo +} + func newBaseModule(hod android.HostOrDeviceSupported, multilib android.Multilib) *Module { return &Module{ hod: hod, @@ -2028,9 +2046,6 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { if ctx.Failed() { return } - c.kytheFiles = objs.kytheFiles - c.objFiles = objs.objFiles - c.tidyFiles = objs.tidyFiles } if c.linker != nil { @@ -2099,7 +2114,28 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) { c.hasYacc = b.hasSrcExt(ctx, ".y") || b.hasSrcExt(ctx, ".yy") } + ccObjectInfo := CcObjectInfo{ + kytheFiles: objs.kytheFiles, + } + if !ctx.Config().KatiEnabled() || !android.ShouldSkipAndroidMkProcessing(ctx, c) { + ccObjectInfo.objFiles = objs.objFiles + ccObjectInfo.tidyFiles = objs.tidyFiles + } + if len(ccObjectInfo.kytheFiles)+len(ccObjectInfo.objFiles)+len(ccObjectInfo.tidyFiles) > 0 { + android.SetProvider(ctx, CcObjectInfoProvider, ccObjectInfo) + } + c.setOutputFiles(ctx) + + if c.makeVarsInfo != nil { + android.SetProvider(ctx, CcMakeVarsInfoProvider, c.makeVarsInfo) + } +} + +func setOutputFilesIfNotEmpty(ctx ModuleContext, files android.Paths, tag string) { + if len(files) > 0 { + ctx.SetOutputFiles(files, tag) + } } func (c *Module) setOutputFiles(ctx ModuleContext) { @@ -2175,6 +2211,7 @@ func (c *Module) maybeInstall(ctx ModuleContext, apexInfo android.ApexInfo) { // modules can be hidden from make as some are needed for resolving make side // dependencies. c.HideFromMake() + c.SkipInstall() } else if !installable(c, apexInfo) { c.SkipInstall() } @@ -3939,9 +3976,10 @@ type kytheExtractAllSingleton struct { func (ks *kytheExtractAllSingleton) GenerateBuildActions(ctx android.SingletonContext) { var xrefTargets android.Paths - ctx.VisitAllModules(func(module android.Module) { - if ccModule, ok := module.(xref); ok { - xrefTargets = append(xrefTargets, ccModule.XrefCcFiles()...) + ctx.VisitAllModuleProxies(func(module android.ModuleProxy) { + files := android.OtherModuleProviderOrDefault(ctx, module, CcObjectInfoProvider).kytheFiles + if len(files) > 0 { + xrefTargets = append(xrefTargets, files...) } }) // TODO(asmundak): Perhaps emit a rule to output a warning if there were no xrefTargets |