Merge "Allow java_sdk_library to specify doctags_files" am: 41b0876c10
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1432649 Change-Id: Icd447f255f276a2510cf9bc0c491cfb062f55784
This commit is contained in:
@@ -589,6 +589,9 @@ type commonToSdkLibraryAndImportProperties struct {
|
|||||||
// An Android shared library is one that can be referenced in a <uses-library> element
|
// An Android shared library is one that can be referenced in a <uses-library> element
|
||||||
// in an AndroidManifest.xml.
|
// in an AndroidManifest.xml.
|
||||||
Shared_library *bool
|
Shared_library *bool
|
||||||
|
|
||||||
|
// Files containing information about supported java doc tags.
|
||||||
|
Doctag_files []string `android:"path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Common code between sdk library and sdk library import
|
// Common code between sdk library and sdk library import
|
||||||
@@ -601,6 +604,9 @@ type commonToSdkLibraryAndImport struct {
|
|||||||
|
|
||||||
commonSdkLibraryProperties commonToSdkLibraryAndImportProperties
|
commonSdkLibraryProperties commonToSdkLibraryAndImportProperties
|
||||||
|
|
||||||
|
// Paths to commonSdkLibraryProperties.Doctag_files
|
||||||
|
doctagPaths android.Paths
|
||||||
|
|
||||||
// Functionality related to this being used as a component of a java_sdk_library.
|
// Functionality related to this being used as a component of a java_sdk_library.
|
||||||
EmbeddableSdkLibraryComponent
|
EmbeddableSdkLibraryComponent
|
||||||
}
|
}
|
||||||
@@ -633,6 +639,10 @@ func (c *commonToSdkLibraryAndImport) initCommonAfterDefaultsApplied(ctx android
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *commonToSdkLibraryAndImport) generateCommonBuildActions(ctx android.ModuleContext) {
|
||||||
|
c.doctagPaths = android.PathsForModuleSrc(ctx, c.commonSdkLibraryProperties.Doctag_files)
|
||||||
|
}
|
||||||
|
|
||||||
// Module name of the runtime implementation library
|
// Module name of the runtime implementation library
|
||||||
func (c *commonToSdkLibraryAndImport) implLibraryModuleName() string {
|
func (c *commonToSdkLibraryAndImport) implLibraryModuleName() string {
|
||||||
return c.moduleBase.BaseModuleName() + ".impl"
|
return c.moduleBase.BaseModuleName() + ".impl"
|
||||||
@@ -732,6 +742,14 @@ func (c *commonToSdkLibraryAndImport) commonOutputFiles(tag string) (android.Pat
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
switch tag {
|
||||||
|
case ".doctags":
|
||||||
|
if c.doctagPaths != nil {
|
||||||
|
return c.doctagPaths, nil
|
||||||
|
} else {
|
||||||
|
return nil, fmt.Errorf("no doctag_files specified on %s", c.moduleBase.BaseModuleName())
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1014,6 +1032,8 @@ func (module *SdkLibrary) OutputFiles(tag string) (android.Paths, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
|
module.generateCommonBuildActions(ctx)
|
||||||
|
|
||||||
// Only build an implementation library if required.
|
// Only build an implementation library if required.
|
||||||
if module.requiresRuntimeImplementationLibrary() {
|
if module.requiresRuntimeImplementationLibrary() {
|
||||||
module.Library.GenerateAndroidBuildActions(ctx)
|
module.Library.GenerateAndroidBuildActions(ctx)
|
||||||
@@ -1895,6 +1915,8 @@ func (module *SdkLibraryImport) OutputFiles(tag string) (android.Paths, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
func (module *SdkLibraryImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||||
|
module.generateCommonBuildActions(ctx)
|
||||||
|
|
||||||
// Record the paths to the prebuilt stubs library and stubs source.
|
// Record the paths to the prebuilt stubs library and stubs source.
|
||||||
ctx.VisitDirectDeps(func(to android.Module) {
|
ctx.VisitDirectDeps(func(to android.Module) {
|
||||||
tag := ctx.OtherModuleDependencyTag(to)
|
tag := ctx.OtherModuleDependencyTag(to)
|
||||||
@@ -2187,6 +2209,9 @@ type sdkLibrarySdkMemberProperties struct {
|
|||||||
// True if the java_sdk_library_import is for a shared library, false
|
// True if the java_sdk_library_import is for a shared library, false
|
||||||
// otherwise.
|
// otherwise.
|
||||||
Shared_library *bool
|
Shared_library *bool
|
||||||
|
|
||||||
|
// The paths to the doctag files to add to the prebuilt.
|
||||||
|
Doctag_paths android.Paths
|
||||||
}
|
}
|
||||||
|
|
||||||
type scopeProperties struct {
|
type scopeProperties struct {
|
||||||
@@ -2226,6 +2251,7 @@ func (s *sdkLibrarySdkMemberProperties) PopulateFromVariant(ctx android.SdkMembe
|
|||||||
s.Libs = sdk.properties.Libs
|
s.Libs = sdk.properties.Libs
|
||||||
s.Naming_scheme = sdk.commonSdkLibraryProperties.Naming_scheme
|
s.Naming_scheme = sdk.commonSdkLibraryProperties.Naming_scheme
|
||||||
s.Shared_library = proptools.BoolPtr(sdk.sharedLibrary())
|
s.Shared_library = proptools.BoolPtr(sdk.sharedLibrary())
|
||||||
|
s.Doctag_paths = sdk.doctagPaths
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *sdkLibrarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
|
func (s *sdkLibrarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberContext, propertySet android.BpPropertySet) {
|
||||||
@@ -2274,6 +2300,16 @@ func (s *sdkLibrarySdkMemberProperties) AddToPropertySet(ctx android.SdkMemberCo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(s.Doctag_paths) > 0 {
|
||||||
|
dests := []string{}
|
||||||
|
for _, p := range s.Doctag_paths {
|
||||||
|
dest := filepath.Join("doctags", p.Rel())
|
||||||
|
ctx.SnapshotBuilder().CopyToSnapshot(p, dest)
|
||||||
|
dests = append(dests, dest)
|
||||||
|
}
|
||||||
|
propertySet.AddProperty("doctag_files", dests)
|
||||||
|
}
|
||||||
|
|
||||||
if len(s.Libs) > 0 {
|
if len(s.Libs) > 0 {
|
||||||
propertySet.AddPropertyWithTag("libs", s.Libs, ctx.SnapshotBuilder().SdkMemberReferencePropertyTag(false))
|
propertySet.AddPropertyWithTag("libs", s.Libs, ctx.SnapshotBuilder().SdkMemberReferencePropertyTag(false))
|
||||||
}
|
}
|
||||||
|
@@ -43,6 +43,7 @@ func testSdkWithJava(t *testing.T, bp string) *testSdkResult {
|
|||||||
"api/system-server-current.txt": nil,
|
"api/system-server-current.txt": nil,
|
||||||
"api/system-server-removed.txt": nil,
|
"api/system-server-removed.txt": nil,
|
||||||
"build/soong/scripts/gen-java-current-api-files.sh": nil,
|
"build/soong/scripts/gen-java-current-api-files.sh": nil,
|
||||||
|
"docs/known_doctags": nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
// for java_sdk_library tests
|
// for java_sdk_library tests
|
||||||
@@ -1590,3 +1591,72 @@ sdk_snapshot {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSnapshotWithJavaSdkLibrary_DoctagFiles(t *testing.T) {
|
||||||
|
result := testSdkWithJava(t, `
|
||||||
|
sdk {
|
||||||
|
name: "mysdk",
|
||||||
|
java_sdk_libs: ["myjavalib"],
|
||||||
|
}
|
||||||
|
|
||||||
|
java_sdk_library {
|
||||||
|
name: "myjavalib",
|
||||||
|
srcs: ["Test.java"],
|
||||||
|
sdk_version: "current",
|
||||||
|
public: {
|
||||||
|
enabled: true,
|
||||||
|
},
|
||||||
|
doctag_files: ["docs/known_doctags"],
|
||||||
|
}
|
||||||
|
|
||||||
|
filegroup {
|
||||||
|
name: "mygroup",
|
||||||
|
srcs: [":myjavalib{.doctags}"],
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
result.CheckSnapshot("mysdk", "",
|
||||||
|
checkAndroidBpContents(`
|
||||||
|
// This is auto-generated. DO NOT EDIT.
|
||||||
|
|
||||||
|
java_sdk_library_import {
|
||||||
|
name: "mysdk_myjavalib@current",
|
||||||
|
sdk_member_name: "myjavalib",
|
||||||
|
shared_library: true,
|
||||||
|
doctag_files: ["doctags/docs/known_doctags"],
|
||||||
|
public: {
|
||||||
|
jars: ["sdk_library/public/myjavalib-stubs.jar"],
|
||||||
|
stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
|
||||||
|
current_api: "sdk_library/public/myjavalib.txt",
|
||||||
|
removed_api: "sdk_library/public/myjavalib-removed.txt",
|
||||||
|
sdk_version: "current",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
java_sdk_library_import {
|
||||||
|
name: "myjavalib",
|
||||||
|
prefer: false,
|
||||||
|
shared_library: true,
|
||||||
|
doctag_files: ["doctags/docs/known_doctags"],
|
||||||
|
public: {
|
||||||
|
jars: ["sdk_library/public/myjavalib-stubs.jar"],
|
||||||
|
stub_srcs: ["sdk_library/public/myjavalib_stub_sources"],
|
||||||
|
current_api: "sdk_library/public/myjavalib.txt",
|
||||||
|
removed_api: "sdk_library/public/myjavalib-removed.txt",
|
||||||
|
sdk_version: "current",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
sdk_snapshot {
|
||||||
|
name: "mysdk@current",
|
||||||
|
java_sdk_libs: ["mysdk_myjavalib@current"],
|
||||||
|
}
|
||||||
|
`),
|
||||||
|
checkAllCopyRules(`
|
||||||
|
.intermediates/myjavalib.stubs/android_common/javac/myjavalib.stubs.jar -> sdk_library/public/myjavalib-stubs.jar
|
||||||
|
.intermediates/myjavalib.stubs.source/android_common/myjavalib.stubs.source_api.txt -> sdk_library/public/myjavalib.txt
|
||||||
|
.intermediates/myjavalib.stubs.source/android_common/myjavalib.stubs.source_removed.txt -> sdk_library/public/myjavalib-removed.txt
|
||||||
|
docs/known_doctags -> doctags/docs/known_doctags
|
||||||
|
`),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
@@ -94,6 +94,7 @@ func testSdkContext(bp string, fs map[string][]byte, extraOsTypes []android.OsTy
|
|||||||
|
|
||||||
// from android package
|
// from android package
|
||||||
android.RegisterPackageBuildComponents(ctx)
|
android.RegisterPackageBuildComponents(ctx)
|
||||||
|
ctx.RegisterModuleType("filegroup", android.FileGroupFactory)
|
||||||
ctx.PreArchMutators(android.RegisterVisibilityRuleChecker)
|
ctx.PreArchMutators(android.RegisterVisibilityRuleChecker)
|
||||||
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
ctx.PreArchMutators(android.RegisterDefaultsPreArchMutators)
|
||||||
ctx.PreArchMutators(android.RegisterComponentsMutator)
|
ctx.PreArchMutators(android.RegisterComponentsMutator)
|
||||||
|
Reference in New Issue
Block a user