Add gensrcs module type
gensrcs allows sources to be generated by a specified command.
Change-Id: I725086fcdcd72bfe6c07fb8903e7b520678a247f
diff --git a/cc/cc.go b/cc/cc.go
index d562421..3ffe26f 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1,3 +1,4 @@
+// Copyright 2015 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.
@@ -25,6 +26,7 @@
"strings"
"android/soong/common"
+ "android/soong/genrule"
)
type Config interface {
@@ -284,7 +286,7 @@
props = append(props, &base.properties, &base.unused)
- return common.InitAndroidModule(module, hod, multilib, props...)
+ return common.InitAndroidArchModule(module, hod, multilib, props...)
}
func (c *ccBase) GenerateAndroidBuildActions(ctx common.AndroidModuleContext) {
@@ -313,6 +315,13 @@
return
}
+ generatedObjFiles := c.compileGeneratedObjs(ctx, flags, deps)
+ if ctx.Failed() {
+ return
+ }
+
+ objFiles = append(objFiles, generatedObjFiles...)
+
c.ccModuleType().compileModule(ctx, flags, deps, objFiles)
if ctx.Failed() {
return
@@ -578,6 +587,28 @@
return c.customCompileObjs(ctx, flags, deps, "", c.properties.Srcs)
}
+// Compile generated source files from dependencies
+func (c *ccBase) compileGeneratedObjs(ctx common.AndroidModuleContext, flags ccFlags,
+ deps ccDeps) []string {
+ var srcs []string
+
+ if c.properties.SkipCompileObjs {
+ return nil
+ }
+
+ ctx.VisitDirectDeps(func(module blueprint.Module) {
+ if gen, ok := module.(genrule.SourceFileGenerator); ok {
+ srcs = append(srcs, gen.GeneratedSourceFiles()...)
+ }
+ })
+
+ if len(srcs) == 0 {
+ return nil
+ }
+
+ return TransformSourceToObj(ctx, "", srcs, ccFlagsToBuilderFlags(flags))
+}
+
func (c *ccBase) outputFile() string {
return ""
}