Merge "Add PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES"
This commit is contained in:
commit
10ed054a6b
|
@ -862,6 +862,24 @@ func (c *deviceConfig) PlatPrivateSepolicyDirs() []string {
|
|||
return c.config.productVariables.BoardPlatPrivateSepolicyDirs
|
||||
}
|
||||
|
||||
func (c *deviceConfig) OverrideManifestPackageNameFor(name string) (manifestName string, overridden bool) {
|
||||
overrides := c.config.productVariables.ManifestPackageNameOverrides
|
||||
if overrides == nil || len(overrides) == 0 {
|
||||
return "", false
|
||||
}
|
||||
for _, o := range overrides {
|
||||
split := strings.Split(o, ":")
|
||||
if len(split) != 2 {
|
||||
// This shouldn't happen as this is first checked in make, but just in case.
|
||||
panic(fmt.Errorf("invalid override rule %q in PRODUCT_MANIFEST_PACKAGE_NAME_OVERRIDES should be <module_name>:<manifest_name>", o))
|
||||
}
|
||||
if matchPattern(split[0], name) {
|
||||
return substPattern(split[0], split[1], name), true
|
||||
}
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
func (c *config) SecondArchIsTranslated() bool {
|
||||
deviceTargets := c.Targets[Android]
|
||||
if len(deviceTargets) < 2 {
|
||||
|
|
|
@ -202,3 +202,44 @@ func GetNumericSdkVersion(v string) string {
|
|||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// copied from build/kati/strutil.go
|
||||
func substPattern(pat, repl, str string) string {
|
||||
ps := strings.SplitN(pat, "%", 2)
|
||||
if len(ps) != 2 {
|
||||
if str == pat {
|
||||
return repl
|
||||
}
|
||||
return str
|
||||
}
|
||||
in := str
|
||||
trimed := str
|
||||
if ps[0] != "" {
|
||||
trimed = strings.TrimPrefix(in, ps[0])
|
||||
if trimed == in {
|
||||
return str
|
||||
}
|
||||
}
|
||||
in = trimed
|
||||
if ps[1] != "" {
|
||||
trimed = strings.TrimSuffix(in, ps[1])
|
||||
if trimed == in {
|
||||
return str
|
||||
}
|
||||
}
|
||||
|
||||
rs := strings.SplitN(repl, "%", 2)
|
||||
if len(rs) != 2 {
|
||||
return repl
|
||||
}
|
||||
return rs[0] + trimed + rs[1]
|
||||
}
|
||||
|
||||
// copied from build/kati/strutil.go
|
||||
func matchPattern(pat, str string) bool {
|
||||
i := strings.IndexByte(pat, '%')
|
||||
if i < 0 {
|
||||
return pat == str
|
||||
}
|
||||
return strings.HasPrefix(str, pat[:i]) && strings.HasSuffix(str, pat[i+1:])
|
||||
}
|
||||
|
|
|
@ -261,6 +261,8 @@ type productVariables struct {
|
|||
FlattenApex *bool `json:",omitempty"`
|
||||
|
||||
DexpreoptGlobalConfig *string `json:",omitempty"`
|
||||
|
||||
ManifestPackageNameOverrides []string `json:",omitempty"`
|
||||
}
|
||||
|
||||
func boolPtr(v bool) *bool {
|
||||
|
|
|
@ -757,6 +757,11 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext, keyFile and
|
|||
optFlags = append(optFlags, "--pubkey "+pubKeyFile.String())
|
||||
}
|
||||
|
||||
manifestPackageName, overridden := ctx.DeviceConfig().OverrideManifestPackageNameFor(ctx.ModuleName())
|
||||
if overridden {
|
||||
optFlags = append(optFlags, "--override_apk_package_name "+manifestPackageName)
|
||||
}
|
||||
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: apexRule,
|
||||
Implicits: implicitInputs,
|
||||
|
|
|
@ -184,6 +184,11 @@ func (a *AndroidApp) generateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
// TODO: LOCAL_PACKAGE_OVERRIDES
|
||||
// $(addprefix --rename-manifest-package , $(PRIVATE_MANIFEST_PACKAGE_NAME)) \
|
||||
|
||||
manifestPackageName, overridden := ctx.DeviceConfig().OverrideManifestPackageNameFor(ctx.ModuleName())
|
||||
if overridden {
|
||||
linkFlags = append(linkFlags, "--rename-manifest-package "+manifestPackageName)
|
||||
}
|
||||
|
||||
a.aapt.buildActions(ctx, sdkContext(a), linkFlags...)
|
||||
|
||||
// apps manifests are handled by aapt, don't let Module see them
|
||||
|
|
Loading…
Reference in New Issue