Allow other module types in androidx
1. Update pom2bp to support "host_support" device module.
2. Allow other module type in support library
(The intention is to support the room annotation processor)
Test: m
Bug: 137918883
Change-Id: I9a8fbcff903cc395d5dc38430774202ce389d6bc
Merged-In: I9a8fbcff903cc395d5dc38430774202ce389d6bc
(cherry picked from commit bd7c2f9a1d
)
This commit is contained in:
parent
216e315a34
commit
817850063b
|
@ -124,6 +124,25 @@ func (n HostModuleNames) Set(v string) error {
|
||||||
|
|
||||||
var hostModuleNames = HostModuleNames{}
|
var hostModuleNames = HostModuleNames{}
|
||||||
|
|
||||||
|
type HostAndDeviceModuleNames map[string]bool
|
||||||
|
|
||||||
|
func (n HostAndDeviceModuleNames) IsHostAndDeviceModule(groupId string, artifactId string) bool {
|
||||||
|
_, found := n[groupId+":"+artifactId]
|
||||||
|
|
||||||
|
return found
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n HostAndDeviceModuleNames) String() string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n HostAndDeviceModuleNames) Set(v string) error {
|
||||||
|
n[v] = true
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var hostAndDeviceModuleNames = HostAndDeviceModuleNames{}
|
||||||
|
|
||||||
var sdkVersion string
|
var sdkVersion string
|
||||||
var useVersion string
|
var useVersion string
|
||||||
var staticDeps bool
|
var staticDeps bool
|
||||||
|
@ -190,10 +209,14 @@ func (p Pom) IsDeviceModule() bool {
|
||||||
return !p.IsHostModule()
|
return !p.IsHostModule()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p Pom) IsHostAndDeviceModule() bool {
|
||||||
|
return hostAndDeviceModuleNames.IsHostAndDeviceModule(p.GroupId, p.ArtifactId)
|
||||||
|
}
|
||||||
|
|
||||||
func (p Pom) ModuleType() string {
|
func (p Pom) ModuleType() string {
|
||||||
if p.IsAar() {
|
if p.IsAar() {
|
||||||
return "android_library"
|
return "android_library"
|
||||||
} else if p.IsHostModule() {
|
} else if p.IsHostModule() && !p.IsHostAndDeviceModule() {
|
||||||
return "java_library_host"
|
return "java_library_host"
|
||||||
} else {
|
} else {
|
||||||
return "java_library_static"
|
return "java_library_static"
|
||||||
|
@ -203,7 +226,7 @@ func (p Pom) ModuleType() string {
|
||||||
func (p Pom) ImportModuleType() string {
|
func (p Pom) ImportModuleType() string {
|
||||||
if p.IsAar() {
|
if p.IsAar() {
|
||||||
return "android_library_import"
|
return "android_library_import"
|
||||||
} else if p.IsHostModule() {
|
} else if p.IsHostModule() && !p.IsHostAndDeviceModule() {
|
||||||
return "java_import_host"
|
return "java_import_host"
|
||||||
} else {
|
} else {
|
||||||
return "java_import"
|
return "java_import"
|
||||||
|
@ -340,6 +363,9 @@ var bpTemplate = template.Must(template.New("bp").Parse(`
|
||||||
{{- if .Jetifier}}
|
{{- if .Jetifier}}
|
||||||
jetifier: true,
|
jetifier: true,
|
||||||
{{- end}}
|
{{- end}}
|
||||||
|
{{- if .IsHostAndDeviceModule}}
|
||||||
|
host_supported: true,
|
||||||
|
{{- end}}
|
||||||
{{- if .IsAar}}
|
{{- if .IsAar}}
|
||||||
min_sdk_version: "{{.MinSdkVersion}}",
|
min_sdk_version: "{{.MinSdkVersion}}",
|
||||||
static_libs: [
|
static_libs: [
|
||||||
|
@ -372,6 +398,9 @@ var bpDepsTemplate = template.Must(template.New("bp").Parse(`
|
||||||
{{- if .Jetifier}}
|
{{- if .Jetifier}}
|
||||||
jetifier: true,
|
jetifier: true,
|
||||||
{{- end}}
|
{{- end}}
|
||||||
|
{{- if .IsHostAndDeviceModule}}
|
||||||
|
host_supported: true,
|
||||||
|
{{- end}}
|
||||||
{{- if .IsAar}}
|
{{- if .IsAar}}
|
||||||
min_sdk_version: "{{.MinSdkVersion}}",
|
min_sdk_version: "{{.MinSdkVersion}}",
|
||||||
static_libs: [
|
static_libs: [
|
||||||
|
@ -399,6 +428,9 @@ var bpDepsTemplate = template.Must(template.New("bp").Parse(`
|
||||||
name: "{{.BpName}}",
|
name: "{{.BpName}}",
|
||||||
{{- if .IsDeviceModule}}
|
{{- if .IsDeviceModule}}
|
||||||
sdk_version: "{{.SdkVersion}}",
|
sdk_version: "{{.SdkVersion}}",
|
||||||
|
{{- if .IsHostAndDeviceModule}}
|
||||||
|
host_supported: true,
|
||||||
|
{{- end}}
|
||||||
{{- if .IsAar}}
|
{{- if .IsAar}}
|
||||||
min_sdk_version: "{{.MinSdkVersion}}",
|
min_sdk_version: "{{.MinSdkVersion}}",
|
||||||
manifest: "manifests/{{.BpName}}/AndroidManifest.xml",
|
manifest: "manifests/{{.BpName}}/AndroidManifest.xml",
|
||||||
|
@ -564,6 +596,7 @@ Usage: %s [--rewrite <regex>=<replace>] [-exclude <module>] [--extra-static-libs
|
||||||
flag.Var(&extraLibs, "extra-libs", "Extra runtime dependencies needed when depending on a module")
|
flag.Var(&extraLibs, "extra-libs", "Extra runtime dependencies needed when depending on a module")
|
||||||
flag.Var(&rewriteNames, "rewrite", "Regex(es) to rewrite artifact names")
|
flag.Var(&rewriteNames, "rewrite", "Regex(es) to rewrite artifact names")
|
||||||
flag.Var(&hostModuleNames, "host", "Specifies that the corresponding module (specified in the form 'module.group:module.artifact') is a host module")
|
flag.Var(&hostModuleNames, "host", "Specifies that the corresponding module (specified in the form 'module.group:module.artifact') is a host module")
|
||||||
|
flag.Var(&hostAndDeviceModuleNames, "host-and-device", "Specifies that the corresponding module (specified in the form 'module.group:module.artifact') is both a host and device module.")
|
||||||
flag.StringVar(&sdkVersion, "sdk-version", "", "What to write to sdk_version")
|
flag.StringVar(&sdkVersion, "sdk-version", "", "What to write to sdk_version")
|
||||||
flag.StringVar(&useVersion, "use-version", "", "Only read artifacts of a specific version")
|
flag.StringVar(&useVersion, "use-version", "", "Only read artifacts of a specific version")
|
||||||
flag.BoolVar(&staticDeps, "static-deps", false, "Statically include direct dependencies")
|
flag.BoolVar(&staticDeps, "static-deps", false, "Statically include direct dependencies")
|
||||||
|
|
|
@ -52,8 +52,6 @@ func supportLibrariesMakeVarsProvider(ctx android.MakeVarsContext) {
|
||||||
supportAars = append(supportAars, name)
|
supportAars = append(supportAars, name)
|
||||||
case *Library, *Import:
|
case *Library, *Import:
|
||||||
supportJars = append(supportJars, name)
|
supportJars = append(supportJars, name)
|
||||||
default:
|
|
||||||
ctx.ModuleErrorf(module, "unknown module type %t", module)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue