Map prebuilt_apis labels to Bazel's manually generated ones.
Change-Id: I5bec807da9b39e2b166af1bd83da43df91f997ef Bug: 237810289 Test: check that android-non-updatable.stubs.module_lib uses manual bazel target for its sdk_system_current_android dependency Change-Id: I6f5fb348e1dcaad10eb756382359f34de792b6e0
This commit is contained in:
@@ -104,20 +104,51 @@ func prebuiltApiModuleName(mctx android.LoadHookContext, module, scope, version
|
||||
return fmt.Sprintf("%s_%s_%s_%s", mctx.ModuleName(), scope, version, module)
|
||||
}
|
||||
|
||||
func hasBazelPrebuilt(module string) bool {
|
||||
return module == "android" || module == "core-for-system-modules"
|
||||
}
|
||||
|
||||
func bazelPrebuiltApiModuleName(module, scope, version string) string {
|
||||
bazelModule := module
|
||||
switch module {
|
||||
case "android":
|
||||
bazelModule = "android_jar"
|
||||
case "core-for-system-modules":
|
||||
bazelModule = "core_jar"
|
||||
}
|
||||
bazelVersion := version
|
||||
if version == "current" {
|
||||
bazelVersion = strconv.Itoa(android.FutureApiLevelInt)
|
||||
}
|
||||
bazelScope := scope
|
||||
switch scope {
|
||||
case "module-lib":
|
||||
bazelScope = "module"
|
||||
case "system-server":
|
||||
bazelScope = "system_server"
|
||||
}
|
||||
return fmt.Sprintf("//prebuilts/sdk:%s_%s_%s", bazelScope, bazelVersion, bazelModule)
|
||||
}
|
||||
|
||||
func createImport(mctx android.LoadHookContext, module, scope, version, path, sdkVersion string, compileDex bool) {
|
||||
props := struct {
|
||||
Name *string
|
||||
Jars []string
|
||||
Sdk_version *string
|
||||
Installable *bool
|
||||
Compile_dex *bool
|
||||
}{}
|
||||
props.Name = proptools.StringPtr(prebuiltApiModuleName(mctx, module, scope, version))
|
||||
props.Jars = append(props.Jars, path)
|
||||
props.Sdk_version = proptools.StringPtr(sdkVersion)
|
||||
props.Installable = proptools.BoolPtr(false)
|
||||
props.Compile_dex = proptools.BoolPtr(compileDex)
|
||||
|
||||
Name *string
|
||||
Jars []string
|
||||
Sdk_version *string
|
||||
Installable *bool
|
||||
Compile_dex *bool
|
||||
Bazel_module android.BazelModuleProperties
|
||||
}{
|
||||
Name: proptools.StringPtr(prebuiltApiModuleName(mctx, module, scope, version)),
|
||||
Jars: []string{path},
|
||||
Sdk_version: proptools.StringPtr(sdkVersion),
|
||||
Installable: proptools.BoolPtr(false),
|
||||
Compile_dex: proptools.BoolPtr(compileDex),
|
||||
}
|
||||
if hasBazelPrebuilt(module) {
|
||||
props.Bazel_module = android.BazelModuleProperties{
|
||||
Label: proptools.StringPtr(bazelPrebuiltApiModuleName(module, scope, version))}
|
||||
}
|
||||
mctx.CreateModule(ImportFactory, &props)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user