diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2017-09-19 20:17:50 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2017-09-19 20:17:50 +0000 |
commit | 944d6b4c01e9881f03e84541f63e1d69de710666 (patch) | |
tree | e120eb3f0918873057620ef18bc536498223f5e7 /genrule | |
parent | 3e5bdf29ba6af25e7b82cf877db8e13b70d81512 (diff) | |
parent | d91d7aca7abcfca381ce05746fc179bd24823763 (diff) | |
download | build_soong-944d6b4c01e9881f03e84541f63e1d69de710666.tar.gz build_soong-944d6b4c01e9881f03e84541f63e1d69de710666.tar.bz2 build_soong-944d6b4c01e9881f03e84541f63e1d69de710666.zip |
Merge "Allow exporting filegroups to make"
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(), " "), + }) + } + }, + } +} |