diff options
author | Colin Cross <ccross@android.com> | 2017-09-12 22:52:12 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2017-09-18 13:54:56 -0700 |
commit | d91d7aca7abcfca381ce05746fc179bd24823763 (patch) | |
tree | bae7a713885cb9032643075bc7fd7706859ae0c2 /genrule | |
parent | 8eded0ac865bbe3df12a62afcbce0091320cddf3 (diff) | |
download | build_soong-d91d7aca7abcfca381ce05746fc179bd24823763.tar.gz build_soong-d91d7aca7abcfca381ce05746fc179bd24823763.tar.bz2 build_soong-d91d7aca7abcfca381ce05746fc179bd24823763.zip |
Allow exporting filegroups to make
Allow sharing lists of files between make and soong by allowing
filegroups to export them as a make variable.
Test: m -j checkbuild
Change-Id: I27ae2f6d180bf01d69a628dbe59edcdba93da015
Diffstat (limited to 'genrule')
-rw-r--r-- | genrule/filegroup.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/genrule/filegroup.go b/genrule/filegroup.go index 40291347..ed206b03 100644 --- a/genrule/filegroup.go +++ b/genrule/filegroup.go @@ -16,6 +16,9 @@ package genrule import ( "android/soong/android" + "io" + "strings" + "text/template" ) func init() { @@ -33,6 +36,10 @@ type fileGroupProperties struct { // the base path is stripped off the path and the remaining path is used as the // installation directory. Path string + + // Create a make variable with the specified name that contains the list of files in the + // filegroup, relative to the root of the source tree. + Export_to_make_var string } type fileGroup struct { @@ -64,3 +71,24 @@ func (fg *fileGroup) GenerateAndroidBuildActions(ctx android.ModuleContext) { func (fg *fileGroup) Srcs() android.Paths { return fg.srcs } + +var androidMkTemplate = template.Must(template.New("filegroup").Parse(` +ifdef {{.makeVar}} + $(error variable {{.makeVar}} set by soong module is already set in make) +endif +{{.makeVar}} := {{.value}} +.KATI_READONLY := {{.makeVar}} +`)) + +func (fg *fileGroup) AndroidMk() android.AndroidMkData { + return android.AndroidMkData{ + Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) { + if makeVar := fg.properties.Export_to_make_var; makeVar != "" { + androidMkTemplate.Execute(w, map[string]string{ + "makeVar": makeVar, + "value": strings.Join(fg.srcs.Strings(), " "), + }) + } + }, + } +} |