Merge "Remove unnecessary snake case variables." am: e794b1e302
am: ce131b6fcf
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1533880 MUST ONLY BE SUBMITTED BY AUTOMERGER Change-Id: I26021fd6bd84ccf36b877eec0a35667446e3ebd4
This commit is contained in:
24
apex/apex.go
24
apex/apex.go
@@ -298,12 +298,12 @@ type apexBundle struct {
|
||||
// Inputs
|
||||
|
||||
// Keys for apex_paylaod.img
|
||||
public_key_file android.Path
|
||||
private_key_file android.Path
|
||||
publicKeyFile android.Path
|
||||
privateKeyFile android.Path
|
||||
|
||||
// Cert/priv-key for the zip container
|
||||
container_certificate_file android.Path
|
||||
container_private_key_file android.Path
|
||||
containerCertificateFile android.Path
|
||||
containerPrivateKeyFile android.Path
|
||||
|
||||
// Flags for special variants of APEX
|
||||
testApex bool
|
||||
@@ -1684,16 +1684,16 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
}
|
||||
case keyTag:
|
||||
if key, ok := child.(*apexKey); ok {
|
||||
a.private_key_file = key.private_key_file
|
||||
a.public_key_file = key.public_key_file
|
||||
a.privateKeyFile = key.privateKeyFile
|
||||
a.publicKeyFile = key.publicKeyFile
|
||||
} else {
|
||||
ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
|
||||
}
|
||||
return false
|
||||
case certificateTag:
|
||||
if dep, ok := child.(*java.AndroidAppCertificate); ok {
|
||||
a.container_certificate_file = dep.Certificate.Pem
|
||||
a.container_private_key_file = dep.Certificate.Key
|
||||
a.containerCertificateFile = dep.Certificate.Pem
|
||||
a.containerPrivateKeyFile = dep.Certificate.Key
|
||||
} else {
|
||||
ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName)
|
||||
}
|
||||
@@ -1810,7 +1810,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
}
|
||||
return false
|
||||
})
|
||||
if a.private_key_file == nil {
|
||||
if a.privateKeyFile == nil {
|
||||
ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
|
||||
return
|
||||
}
|
||||
@@ -1950,7 +1950,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
copiedPubkey := android.PathForModuleOut(ctx, "apex_pubkey")
|
||||
ctx.Build(pctx, android.BuildParams{
|
||||
Rule: android.Cp,
|
||||
Input: a.public_key_file,
|
||||
Input: a.publicKeyFile,
|
||||
Output: copiedPubkey,
|
||||
})
|
||||
a.filesInfo = append(a.filesInfo, newApexFile(ctx, copiedPubkey, "apex_pubkey", ".", etc, nil))
|
||||
@@ -2839,14 +2839,14 @@ func init() {
|
||||
func createApexPermittedPackagesRules(modules_packages map[string][]string) []android.Rule {
|
||||
rules := make([]android.Rule, 0, len(modules_packages))
|
||||
for module_name, module_packages := range modules_packages {
|
||||
permitted_packages_rule := android.NeverAllow().
|
||||
permittedPackagesRule := android.NeverAllow().
|
||||
BootclasspathJar().
|
||||
With("apex_available", module_name).
|
||||
WithMatcher("permitted_packages", android.NotInList(module_packages)).
|
||||
Because("jars that are part of the " + module_name +
|
||||
" module may only allow these packages: " + strings.Join(module_packages, ",") +
|
||||
". Please jarjar or move code around.")
|
||||
rules = append(rules, permitted_packages_rule)
|
||||
rules = append(rules, permittedPackagesRule)
|
||||
}
|
||||
return rules
|
||||
}
|
||||
|
@@ -2679,12 +2679,12 @@ func TestKeys(t *testing.T) {
|
||||
// check the APEX keys
|
||||
keys := ctx.ModuleForTests("myapex.key", "android_common").Module().(*apexKey)
|
||||
|
||||
if keys.public_key_file.String() != "vendor/foo/devkeys/testkey.avbpubkey" {
|
||||
t.Errorf("public key %q is not %q", keys.public_key_file.String(),
|
||||
if keys.publicKeyFile.String() != "vendor/foo/devkeys/testkey.avbpubkey" {
|
||||
t.Errorf("public key %q is not %q", keys.publicKeyFile.String(),
|
||||
"vendor/foo/devkeys/testkey.avbpubkey")
|
||||
}
|
||||
if keys.private_key_file.String() != "vendor/foo/devkeys/testkey.pem" {
|
||||
t.Errorf("private key %q is not %q", keys.private_key_file.String(),
|
||||
if keys.privateKeyFile.String() != "vendor/foo/devkeys/testkey.pem" {
|
||||
t.Errorf("private key %q is not %q", keys.privateKeyFile.String(),
|
||||
"vendor/foo/devkeys/testkey.pem")
|
||||
}
|
||||
|
||||
@@ -4143,12 +4143,12 @@ func TestApexKeyFromOtherModule(t *testing.T) {
|
||||
|
||||
apex_key := ctx.ModuleForTests("myapex.key", "android_common").Module().(*apexKey)
|
||||
expected_pubkey := "testkey2.avbpubkey"
|
||||
actual_pubkey := apex_key.public_key_file.String()
|
||||
actual_pubkey := apex_key.publicKeyFile.String()
|
||||
if actual_pubkey != expected_pubkey {
|
||||
t.Errorf("wrong public key path. expected %q. actual %q", expected_pubkey, actual_pubkey)
|
||||
}
|
||||
expected_privkey := "testkey2.pem"
|
||||
actual_privkey := apex_key.private_key_file.String()
|
||||
actual_privkey := apex_key.privateKeyFile.String()
|
||||
if actual_privkey != expected_privkey {
|
||||
t.Errorf("wrong private key path. expected %q. actual %q", expected_privkey, actual_privkey)
|
||||
}
|
||||
|
@@ -577,8 +577,8 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
||||
fileContexts := a.buildFileContexts(ctx)
|
||||
implicitInputs = append(implicitInputs, fileContexts)
|
||||
|
||||
implicitInputs = append(implicitInputs, a.private_key_file, a.public_key_file)
|
||||
optFlags = append(optFlags, "--pubkey "+a.public_key_file.String())
|
||||
implicitInputs = append(implicitInputs, a.privateKeyFile, a.publicKeyFile)
|
||||
optFlags = append(optFlags, "--pubkey "+a.publicKeyFile.String())
|
||||
|
||||
manifestPackageName := a.getOverrideManifestPackageName(ctx)
|
||||
if manifestPackageName != "" {
|
||||
@@ -667,7 +667,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
|
||||
"manifest": a.manifestPbOut.String(),
|
||||
"file_contexts": fileContexts.String(),
|
||||
"canned_fs_config": cannedFsConfig.String(),
|
||||
"key": a.private_key_file.String(),
|
||||
"key": a.privateKeyFile.String(),
|
||||
"opt_flags": strings.Join(optFlags, " "),
|
||||
},
|
||||
})
|
||||
@@ -842,8 +842,8 @@ func (a *apexBundle) buildFlattenedApex(ctx android.ModuleContext) {
|
||||
// the zip container of this APEX. See the description of the 'certificate' property for how
|
||||
// the cert and the private key are found.
|
||||
func (a *apexBundle) getCertificateAndPrivateKey(ctx android.PathContext) (pem, key android.Path) {
|
||||
if a.container_certificate_file != nil {
|
||||
return a.container_certificate_file, a.container_private_key_file
|
||||
if a.containerCertificateFile != nil {
|
||||
return a.containerCertificateFile, a.containerPrivateKeyFile
|
||||
}
|
||||
|
||||
cert := String(a.properties.Certificate)
|
||||
|
56
apex/key.go
56
apex/key.go
@@ -36,8 +36,8 @@ type apexKey struct {
|
||||
|
||||
properties apexKeyProperties
|
||||
|
||||
public_key_file android.Path
|
||||
private_key_file android.Path
|
||||
publicKeyFile android.Path
|
||||
privateKeyFile android.Path
|
||||
|
||||
keyName string
|
||||
}
|
||||
@@ -69,30 +69,30 @@ func (m *apexKey) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
||||
// Otherwise, try to locate the key files in the default cert dir or
|
||||
// in the local module dir
|
||||
if android.SrcIsModule(String(m.properties.Public_key)) != "" {
|
||||
m.public_key_file = android.PathForModuleSrc(ctx, String(m.properties.Public_key))
|
||||
m.publicKeyFile = android.PathForModuleSrc(ctx, String(m.properties.Public_key))
|
||||
} else {
|
||||
m.public_key_file = ctx.Config().ApexKeyDir(ctx).Join(ctx, String(m.properties.Public_key))
|
||||
m.publicKeyFile = ctx.Config().ApexKeyDir(ctx).Join(ctx, String(m.properties.Public_key))
|
||||
// If not found, fall back to the local key pairs
|
||||
if !android.ExistentPathForSource(ctx, m.public_key_file.String()).Valid() {
|
||||
m.public_key_file = android.PathForModuleSrc(ctx, String(m.properties.Public_key))
|
||||
if !android.ExistentPathForSource(ctx, m.publicKeyFile.String()).Valid() {
|
||||
m.publicKeyFile = android.PathForModuleSrc(ctx, String(m.properties.Public_key))
|
||||
}
|
||||
}
|
||||
|
||||
if android.SrcIsModule(String(m.properties.Private_key)) != "" {
|
||||
m.private_key_file = android.PathForModuleSrc(ctx, String(m.properties.Private_key))
|
||||
m.privateKeyFile = android.PathForModuleSrc(ctx, String(m.properties.Private_key))
|
||||
} else {
|
||||
m.private_key_file = ctx.Config().ApexKeyDir(ctx).Join(ctx, String(m.properties.Private_key))
|
||||
if !android.ExistentPathForSource(ctx, m.private_key_file.String()).Valid() {
|
||||
m.private_key_file = android.PathForModuleSrc(ctx, String(m.properties.Private_key))
|
||||
m.privateKeyFile = ctx.Config().ApexKeyDir(ctx).Join(ctx, String(m.properties.Private_key))
|
||||
if !android.ExistentPathForSource(ctx, m.privateKeyFile.String()).Valid() {
|
||||
m.privateKeyFile = android.PathForModuleSrc(ctx, String(m.properties.Private_key))
|
||||
}
|
||||
}
|
||||
|
||||
pubKeyName := m.public_key_file.Base()[0 : len(m.public_key_file.Base())-len(m.public_key_file.Ext())]
|
||||
privKeyName := m.private_key_file.Base()[0 : len(m.private_key_file.Base())-len(m.private_key_file.Ext())]
|
||||
pubKeyName := m.publicKeyFile.Base()[0 : len(m.publicKeyFile.Base())-len(m.publicKeyFile.Ext())]
|
||||
privKeyName := m.privateKeyFile.Base()[0 : len(m.privateKeyFile.Base())-len(m.privateKeyFile.Ext())]
|
||||
|
||||
if m.properties.Public_key != nil && m.properties.Private_key != nil && pubKeyName != privKeyName {
|
||||
ctx.ModuleErrorf("public_key %q (keyname:%q) and private_key %q (keyname:%q) do not have same keyname",
|
||||
m.public_key_file.String(), pubKeyName, m.private_key_file, privKeyName)
|
||||
m.publicKeyFile.String(), pubKeyName, m.privateKeyFile, privKeyName)
|
||||
return
|
||||
}
|
||||
m.keyName = pubKeyName
|
||||
@@ -107,20 +107,20 @@ type apexKeysText struct {
|
||||
func (s *apexKeysText) GenerateBuildActions(ctx android.SingletonContext) {
|
||||
s.output = android.PathForOutput(ctx, "apexkeys.txt")
|
||||
type apexKeyEntry struct {
|
||||
name string
|
||||
presigned bool
|
||||
public_key string
|
||||
private_key string
|
||||
container_certificate string
|
||||
container_private_key string
|
||||
partition string
|
||||
name string
|
||||
presigned bool
|
||||
publicKey string
|
||||
privateKey string
|
||||
containerCertificate string
|
||||
containerPrivateKey string
|
||||
partition string
|
||||
}
|
||||
toString := func(e apexKeyEntry) string {
|
||||
format := "name=%q public_key=%q private_key=%q container_certificate=%q container_private_key=%q partition=%q\n"
|
||||
if e.presigned {
|
||||
return fmt.Sprintf(format, e.name, "PRESIGNED", "PRESIGNED", "PRESIGNED", "PRESIGNED", e.partition)
|
||||
} else {
|
||||
return fmt.Sprintf(format, e.name, e.public_key, e.private_key, e.container_certificate, e.container_private_key, e.partition)
|
||||
return fmt.Sprintf(format, e.name, e.publicKey, e.privateKey, e.containerCertificate, e.containerPrivateKey, e.partition)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,13 +129,13 @@ func (s *apexKeysText) GenerateBuildActions(ctx android.SingletonContext) {
|
||||
if m, ok := module.(*apexBundle); ok && m.Enabled() && m.installable() {
|
||||
pem, key := m.getCertificateAndPrivateKey(ctx)
|
||||
apexKeyMap[m.Name()] = apexKeyEntry{
|
||||
name: m.Name() + ".apex",
|
||||
presigned: false,
|
||||
public_key: m.public_key_file.String(),
|
||||
private_key: m.private_key_file.String(),
|
||||
container_certificate: pem.String(),
|
||||
container_private_key: key.String(),
|
||||
partition: m.PartitionTag(ctx.DeviceConfig()),
|
||||
name: m.Name() + ".apex",
|
||||
presigned: false,
|
||||
publicKey: m.publicKeyFile.String(),
|
||||
privateKey: m.privateKeyFile.String(),
|
||||
containerCertificate: pem.String(),
|
||||
containerPrivateKey: key.String(),
|
||||
partition: m.PartitionTag(ctx.DeviceConfig()),
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user