SDK snapshot is dist'ed

`m module_sdk dist` produces snapshots of all SDKs in the source tree.
A snapshot is a zip file consists of Android.bp, exported headers,
exported AIDL files, stubs for native libs and jars. The zip file is
expected to be downloaded from the build server and extracted to a
directory (which probably will be
/prebuilts/module_sdks/<module_name>/current).

Bug: 138182343
Test: m (sdk_test.go updated)

Change-Id: Idbe4bc24795fe08f26fc1cf7497028f9d162053a
This commit is contained in:
Jiyong Park
2019-11-04 12:23:40 +09:00
parent b9a80a0716
commit 232e785b98
4 changed files with 167 additions and 139 deletions

View File

@@ -29,6 +29,7 @@ import (
)
func init() {
pctx.Import("android/soong/android")
android.RegisterModuleType("sdk", ModuleFactory)
android.RegisterModuleType("sdk_snapshot", SnapshotModuleFactory)
android.PreDepsMutators(RegisterPreDepsMutators)
@@ -41,8 +42,7 @@ type sdk struct {
properties sdkProperties
updateScript android.OutputPath
freezeScript android.OutputPath
snapshotFile android.OptionalPath
}
type sdkProperties struct {
@@ -104,11 +104,24 @@ func (s *sdk) frozenVersions(ctx android.BaseModuleContext) []string {
}
func (s *sdk) GenerateAndroidBuildActions(ctx android.ModuleContext) {
s.buildSnapshotGenerationScripts(ctx)
if !s.snapshot() {
// We don't need to create a snapshot out of sdk_snapshot.
// That doesn't make sense. We need a snapshot to create sdk_snapshot.
s.snapshotFile = android.OptionalPathForPath(s.buildSnapshot(ctx))
}
}
func (s *sdk) AndroidMkEntries() android.AndroidMkEntries {
return s.androidMkEntriesForScript()
if !s.snapshotFile.Valid() {
return android.AndroidMkEntries{}
}
return android.AndroidMkEntries{
Class: "FAKE",
OutputFile: s.snapshotFile,
DistFile: s.snapshotFile,
Include: "$(BUILD_PHONY_PACKAGE)",
}
}
// RegisterPreDepsMutators registers pre-deps mutators to support modules implementing SdkAware