Merge "Allow module types to generate resources"

am: da2bba1d71

Change-Id: I0ad142dadec08bd50ab8fdaa1f6dada0bf24a069
This commit is contained in:
Colin Cross 2019-05-07 07:36:39 -07:00 committed by android-build-merger
commit 04c69f1c9d
2 changed files with 16 additions and 1 deletions

View file

@ -340,6 +340,9 @@ type Module struct {
// list of additional targets for checkbuild
additionalCheckedModules android.Paths
// Extra files generated by the module type to be added as java resources.
extraResources android.Paths
hiddenAPI
dexpreopter
}
@ -1113,6 +1116,7 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
dirArgs, dirDeps := ResourceDirsToJarArgs(ctx, j.properties.Java_resource_dirs,
j.properties.Exclude_java_resource_dirs, j.properties.Exclude_java_resources)
fileArgs, fileDeps := ResourceFilesToJarArgs(ctx, j.properties.Java_resources, j.properties.Exclude_java_resources)
extraArgs, extraDeps := resourcePathsToJarArgs(j.extraResources), j.extraResources
var resArgs []string
var resDeps android.Paths
@ -1123,6 +1127,9 @@ func (j *Module) compile(ctx android.ModuleContext, extraSrcJars ...android.Path
resArgs = append(resArgs, fileArgs...)
resDeps = append(resDeps, fileDeps...)
resArgs = append(resArgs, extraArgs...)
resDeps = append(resDeps, extraDeps...)
if Bool(j.properties.Include_srcs) {
srcArgs, srcDeps := SourceFilesToJarArgs(ctx, j.properties.Srcs, j.properties.Exclude_srcs)
resArgs = append(resArgs, srcArgs...)

View file

@ -98,6 +98,14 @@ func resourceFilesToJarArgs(ctx android.ModuleContext,
files := android.PathsForModuleSrcExcludes(ctx, res, exclude)
args = resourcePathsToJarArgs(files)
return args, files
}
func resourcePathsToJarArgs(files android.Paths) []string {
var args []string
lastDir := ""
for i, f := range files {
rel := f.Rel()
@ -113,5 +121,5 @@ func resourceFilesToJarArgs(ctx android.ModuleContext,
lastDir = dir
}
return args, files
return args
}