Use default fallback when generating cc deps
The current logic enforces a device arch match and omits a module altogether if none is found. To collect a more comprehensive list of cc deps for IDE (ASfP) project setup, we introduce a fallback that defaults to an arbitrary (first-processed) variant. Bug: 322369312 Test: refreshmod Change-Id: Ic5e1fd39e569735ff90b5c71ab1395632cca9af7
This commit is contained in:
39
cc/ccdeps.go
39
cc/ccdeps.go
@@ -85,9 +85,8 @@ func (c *ccdepsGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCon
|
|||||||
moduleDeps := ccDeps{}
|
moduleDeps := ccDeps{}
|
||||||
moduleInfos := map[string]ccIdeInfo{}
|
moduleInfos := map[string]ccIdeInfo{}
|
||||||
|
|
||||||
// Track which projects have already had CMakeLists.txt generated to keep the first
|
// Track if best variant (device arch match) has been found.
|
||||||
// variant for each project.
|
bestVariantFound := map[string]bool{}
|
||||||
seenProjects := map[string]bool{}
|
|
||||||
|
|
||||||
pathToCC, _ := evalVariable(ctx, "${config.ClangBin}/")
|
pathToCC, _ := evalVariable(ctx, "${config.ClangBin}/")
|
||||||
moduleDeps.C_clang = fmt.Sprintf("%s%s", buildCMakePath(pathToCC), cClang)
|
moduleDeps.C_clang = fmt.Sprintf("%s%s", buildCMakePath(pathToCC), cClang)
|
||||||
@@ -96,7 +95,7 @@ func (c *ccdepsGeneratorSingleton) GenerateBuildActions(ctx android.SingletonCon
|
|||||||
ctx.VisitAllModules(func(module android.Module) {
|
ctx.VisitAllModules(func(module android.Module) {
|
||||||
if ccModule, ok := module.(*Module); ok {
|
if ccModule, ok := module.(*Module); ok {
|
||||||
if compiledModule, ok := ccModule.compiler.(CompiledInterface); ok {
|
if compiledModule, ok := ccModule.compiler.(CompiledInterface); ok {
|
||||||
generateCLionProjectData(ctx, compiledModule, ccModule, seenProjects, moduleInfos)
|
generateCLionProjectData(ctx, compiledModule, ccModule, bestVariantFound, moduleInfos)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -180,26 +179,30 @@ func parseCompilerCCParameters(ctx android.SingletonContext, params []string) cc
|
|||||||
}
|
}
|
||||||
|
|
||||||
func generateCLionProjectData(ctx android.SingletonContext, compiledModule CompiledInterface,
|
func generateCLionProjectData(ctx android.SingletonContext, compiledModule CompiledInterface,
|
||||||
ccModule *Module, seenProjects map[string]bool, moduleInfos map[string]ccIdeInfo) {
|
ccModule *Module, bestVariantFound map[string]bool, moduleInfos map[string]ccIdeInfo) {
|
||||||
|
moduleName := ccModule.ModuleBase.Name()
|
||||||
srcs := compiledModule.Srcs()
|
srcs := compiledModule.Srcs()
|
||||||
|
|
||||||
|
// Skip if best variant has already been found.
|
||||||
|
if bestVariantFound[moduleName] {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skip if sources are empty.
|
||||||
if len(srcs) == 0 {
|
if len(srcs) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only keep the DeviceArch variant module.
|
// Check if device arch matches, in which case this is the best variant and takes precedence.
|
||||||
if ctx.DeviceConfig().DeviceArch() != ccModule.ModuleBase.Arch().ArchType.Name {
|
if ccModule.Device() && ccModule.ModuleBase.Arch().ArchType.Name == ctx.DeviceConfig().DeviceArch() {
|
||||||
|
bestVariantFound[moduleName] = true
|
||||||
|
} else if _, ok := moduleInfos[moduleName]; ok {
|
||||||
|
// Skip because this isn't the best variant and a previous one has already been added.
|
||||||
|
// Heuristically, ones that appear first are likely to be more relevant.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
clionProjectLocation := getCMakeListsForModule(ccModule, ctx)
|
dpInfo := ccIdeInfo{}
|
||||||
if seenProjects[clionProjectLocation] {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
seenProjects[clionProjectLocation] = true
|
|
||||||
|
|
||||||
name := ccModule.ModuleBase.Name()
|
|
||||||
dpInfo := moduleInfos[name]
|
|
||||||
|
|
||||||
dpInfo.Path = append(dpInfo.Path, path.Dir(ctx.BlueprintFile(ccModule)))
|
dpInfo.Path = append(dpInfo.Path, path.Dir(ctx.BlueprintFile(ccModule)))
|
||||||
dpInfo.Srcs = append(dpInfo.Srcs, srcs.Strings()...)
|
dpInfo.Srcs = append(dpInfo.Srcs, srcs.Strings()...)
|
||||||
@@ -216,9 +219,9 @@ func generateCLionProjectData(ctx android.SingletonContext, compiledModule Compi
|
|||||||
dpInfo.Local_Cpp_flags = parseCompilerCCParameters(ctx, ccModule.flags.Local.CppFlags)
|
dpInfo.Local_Cpp_flags = parseCompilerCCParameters(ctx, ccModule.flags.Local.CppFlags)
|
||||||
dpInfo.System_include_flags = parseCompilerCCParameters(ctx, ccModule.flags.SystemIncludeFlags)
|
dpInfo.System_include_flags = parseCompilerCCParameters(ctx, ccModule.flags.SystemIncludeFlags)
|
||||||
|
|
||||||
dpInfo.Module_name = name
|
dpInfo.Module_name = moduleName
|
||||||
|
|
||||||
moduleInfos[name] = dpInfo
|
moduleInfos[moduleName] = dpInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
type Deal struct {
|
type Deal struct {
|
||||||
|
Reference in New Issue
Block a user