Generate .srcjar for prebuilt_stubs_sources
Changes prebuilt_stubs_sources to generate a .srcjar from its input instead of just exposing the srcs it is given. This ensures that it can be used as a drop in replacement for a droidstubs module. Updates the test for prebuilt_stubs_sources to be more representative of the actual use made of it by sdk snapshot which outputs a directory not a glob pattern. Added some documentation of the prebuilts_stubs_sources srcs property to make it clear that it is supposed to be a set of directories. Extracts common code from sdk/testing.go for normalizing path/paths for testing. Bug: 143678475 Test: m conscrypt-module-sdk conscrypt-module-host-sdk conscrypt-module-test-sdk unzip those in place of external/conscrypt build core-current-stubs-source which expects it to provide a .srcjar. Change-Id: I8204a022557a9b0b45e19eac79ecba98ff95213d
This commit is contained in:
@@ -1948,12 +1948,42 @@ type PrebuiltStubsSources struct {
|
||||
|
||||
properties PrebuiltStubsSourcesProperties
|
||||
|
||||
srcs android.Paths
|
||||
// The source directories containing stubs source files.
|
||||
srcDirs android.Paths
|
||||
stubsSrcJar android.ModuleOutPath
|
||||
}
|
||||
|
||||
func (p *PrebuiltStubsSources) OutputFiles(tag string) (android.Paths, error) {
|
||||
switch tag {
|
||||
case "":
|
||||
return android.Paths{p.stubsSrcJar}, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported module reference tag %q", tag)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PrebuiltStubsSources) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
p.srcs = android.PathsForModuleSrc(ctx, p.properties.Srcs)
|
||||
p.stubsSrcJar = android.PathForModuleOut(ctx, ctx.ModuleName()+"-"+"stubs.srcjar")
|
||||
|
||||
p.srcDirs = android.PathsForModuleSrc(ctx, p.properties.Srcs)
|
||||
|
||||
rule := android.NewRuleBuilder()
|
||||
command := rule.Command().
|
||||
BuiltTool(ctx, "soong_zip").
|
||||
Flag("-write_if_changed").
|
||||
Flag("-jar").
|
||||
FlagWithOutput("-o ", p.stubsSrcJar)
|
||||
|
||||
for _, d := range p.srcDirs {
|
||||
dir := d.String()
|
||||
command.
|
||||
FlagWithArg("-C ", dir).
|
||||
FlagWithInput("-D ", d)
|
||||
}
|
||||
|
||||
rule.Restat()
|
||||
|
||||
rule.Build(pctx, ctx, "zip src", "Create srcjar from prebuilt source")
|
||||
}
|
||||
|
||||
func (p *PrebuiltStubsSources) Prebuilt() *android.Prebuilt {
|
||||
@@ -1964,10 +1994,6 @@ func (p *PrebuiltStubsSources) Name() string {
|
||||
return p.prebuilt.Name(p.ModuleBase.Name())
|
||||
}
|
||||
|
||||
func (p *PrebuiltStubsSources) Srcs() android.Paths {
|
||||
return append(android.Paths{}, p.srcs...)
|
||||
}
|
||||
|
||||
// prebuilt_stubs_sources imports a set of java source files as if they were
|
||||
// generated by droidstubs.
|
||||
//
|
||||
|
Reference in New Issue
Block a user