Merge "Make PrebuiltStubsSources support srcjar properly" am: c24f0855d9
am: d88eb89740
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1879682 Change-Id: Iffe1b469d1c8c91aeddca775825cfbb610d37c47
This commit is contained in:
@@ -16,6 +16,7 @@ package java
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
@@ -805,7 +806,7 @@ type PrebuiltStubsSources struct {
|
|||||||
|
|
||||||
properties PrebuiltStubsSourcesProperties
|
properties PrebuiltStubsSourcesProperties
|
||||||
|
|
||||||
stubsSrcJar android.ModuleOutPath
|
stubsSrcJar android.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PrebuiltStubsSources) OutputFiles(tag string) (android.Paths, error) {
|
func (p *PrebuiltStubsSources) OutputFiles(tag string) (android.Paths, error) {
|
||||||
@@ -822,35 +823,39 @@ func (d *PrebuiltStubsSources) StubsSrcJar() android.Path {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PrebuiltStubsSources) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (p *PrebuiltStubsSources) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
p.stubsSrcJar = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"stubs.srcjar")
|
|
||||||
|
|
||||||
if len(p.properties.Srcs) != 1 {
|
if len(p.properties.Srcs) != 1 {
|
||||||
ctx.PropertyErrorf("srcs", "must only specify one directory path, contains %d paths", len(p.properties.Srcs))
|
ctx.PropertyErrorf("srcs", "must only specify one directory path or srcjar, contains %d paths", len(p.properties.Srcs))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
localSrcDir := p.properties.Srcs[0]
|
src := p.properties.Srcs[0]
|
||||||
// Although PathForModuleSrc can return nil if either the path doesn't exist or
|
if filepath.Ext(src) == ".srcjar" {
|
||||||
// the path components are invalid it won't in this case because no components
|
// This is a srcjar. We can use it directly.
|
||||||
// are specified and the module directory must exist in order to get this far.
|
p.stubsSrcJar = android.PathForModuleSrc(ctx, src)
|
||||||
srcDir := android.PathForModuleSrc(ctx).(android.SourcePath).Join(ctx, localSrcDir)
|
} else {
|
||||||
|
outPath := android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"stubs.srcjar")
|
||||||
|
|
||||||
// Glob the contents of the directory just in case the directory does not exist.
|
// This is a directory. Glob the contents just in case the directory does not exist.
|
||||||
srcGlob := localSrcDir + "/**/*"
|
srcGlob := src + "/**/*"
|
||||||
srcPaths := android.PathsForModuleSrc(ctx, []string{srcGlob})
|
srcPaths := android.PathsForModuleSrc(ctx, []string{srcGlob})
|
||||||
|
|
||||||
rule := android.NewRuleBuilder(pctx, ctx)
|
// Although PathForModuleSrc can return nil if either the path doesn't exist or
|
||||||
rule.Command().
|
// the path components are invalid it won't in this case because no components
|
||||||
BuiltTool("soong_zip").
|
// are specified and the module directory must exist in order to get this far.
|
||||||
Flag("-write_if_changed").
|
srcDir := android.PathForModuleSrc(ctx).(android.SourcePath).Join(ctx, src)
|
||||||
Flag("-jar").
|
|
||||||
FlagWithOutput("-o ", p.stubsSrcJar).
|
|
||||||
FlagWithArg("-C ", srcDir.String()).
|
|
||||||
FlagWithRspFileInputList("-r ", p.stubsSrcJar.ReplaceExtension(ctx, "rsp"), srcPaths)
|
|
||||||
|
|
||||||
rule.Restat()
|
rule := android.NewRuleBuilder(pctx, ctx)
|
||||||
|
rule.Command().
|
||||||
rule.Build("zip src", "Create srcjar from prebuilt source")
|
BuiltTool("soong_zip").
|
||||||
|
Flag("-write_if_changed").
|
||||||
|
Flag("-jar").
|
||||||
|
FlagWithOutput("-o ", outPath).
|
||||||
|
FlagWithArg("-C ", srcDir.String()).
|
||||||
|
FlagWithRspFileInputList("-r ", outPath.ReplaceExtension(ctx, "rsp"), srcPaths)
|
||||||
|
rule.Restat()
|
||||||
|
rule.Build("zip src", "Create srcjar from prebuilt source")
|
||||||
|
p.stubsSrcJar = outPath
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PrebuiltStubsSources) Prebuilt() *android.Prebuilt {
|
func (p *PrebuiltStubsSources) Prebuilt() *android.Prebuilt {
|
||||||
|
Reference in New Issue
Block a user