Only write CMakeLists.txt for normal variants
Modules may have multiple variants for each architecture, and SOONG_GEN_CMAKEFILES=1 was generating CMakeLists.txt for all of them, overwriting the first normal variant with the last (and likely least normal) variant. Keep a map of generated CMakeLists.txt files, and only generate each one once. Bug: 72283227 Test: m SOONG_GEN_CMAKEFILES=1 Change-Id: If31087264d2809088fe36965b9a0ff0f44089852
This commit is contained in:
parent
38462a6881
commit
dfe4752181
1 changed files with 15 additions and 3 deletions
|
@ -62,10 +62,14 @@ func (c *cmakelistsGeneratorSingleton) GenerateBuildActions(ctx android.Singleto
|
|||
|
||||
outputDebugInfo = (getEnvVariable(envVariableGenerateDebugInfo, ctx) == envVariableTrue)
|
||||
|
||||
// Track which projects have already had CMakeLists.txt generated to keep the first
|
||||
// variant for each project.
|
||||
seenProjects := map[string]bool{}
|
||||
|
||||
ctx.VisitAllModules(func(module android.Module) {
|
||||
if ccModule, ok := module.(*Module); ok {
|
||||
if compiledModule, ok := ccModule.compiler.(CompiledInterface); ok {
|
||||
generateCLionProject(compiledModule, ctx, ccModule)
|
||||
generateCLionProject(compiledModule, ctx, ccModule, seenProjects)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -114,14 +118,22 @@ func linkAggregateCMakeListsFiles(path string, info os.FileInfo, err error) erro
|
|||
return nil
|
||||
}
|
||||
|
||||
func generateCLionProject(compiledModule CompiledInterface, ctx android.SingletonContext, ccModule *Module) {
|
||||
func generateCLionProject(compiledModule CompiledInterface, ctx android.SingletonContext, ccModule *Module,
|
||||
seenProjects map[string]bool) {
|
||||
srcs := compiledModule.Srcs()
|
||||
if len(srcs) == 0 {
|
||||
return
|
||||
}
|
||||
|
||||
// Ensure the directory hosting the cmakelists.txt exists
|
||||
// Only write CMakeLists.txt for the first variant of each architecture of each module
|
||||
clionproject_location := getCMakeListsForModule(ccModule, ctx)
|
||||
if seenProjects[clionproject_location] {
|
||||
return
|
||||
}
|
||||
|
||||
seenProjects[clionproject_location] = true
|
||||
|
||||
// Ensure the directory hosting the cmakelists.txt exists
|
||||
projectDir := path.Dir(clionproject_location)
|
||||
os.MkdirAll(projectDir, os.ModePerm)
|
||||
|
||||
|
|
Loading…
Reference in a new issue