Remove unnecessary snake case variables.

Test: m nothing + TreeHugger
Change-Id: I99f7162944daa6c57c6ae4763261e108bb5cb6b1
This commit is contained in:
Jaewoong Jung 2020-12-21 09:11:10 -08:00
parent 1f8c272984
commit 18aefc1977
33 changed files with 204 additions and 204 deletions

View file

@ -627,7 +627,7 @@ func translateAndroidMk(ctx SingletonContext, mkFile string, mods []blueprint.Mo
fmt.Fprintln(buf, "LOCAL_MODULE_MAKEFILE := $(lastword $(MAKEFILE_LIST))") fmt.Fprintln(buf, "LOCAL_MODULE_MAKEFILE := $(lastword $(MAKEFILE_LIST))")
type_stats := make(map[string]int) typeStats := make(map[string]int)
for _, mod := range mods { for _, mod := range mods {
err := translateAndroidMkModule(ctx, buf, mod) err := translateAndroidMkModule(ctx, buf, mod)
if err != nil { if err != nil {
@ -636,19 +636,19 @@ func translateAndroidMk(ctx SingletonContext, mkFile string, mods []blueprint.Mo
} }
if amod, ok := mod.(Module); ok && ctx.PrimaryModule(amod) == amod { if amod, ok := mod.(Module); ok && ctx.PrimaryModule(amod) == amod {
type_stats[ctx.ModuleType(amod)] += 1 typeStats[ctx.ModuleType(amod)] += 1
} }
} }
keys := []string{} keys := []string{}
fmt.Fprintln(buf, "\nSTATS.SOONG_MODULE_TYPE :=") fmt.Fprintln(buf, "\nSTATS.SOONG_MODULE_TYPE :=")
for k := range type_stats { for k := range typeStats {
keys = append(keys, k) keys = append(keys, k)
} }
sort.Strings(keys) sort.Strings(keys)
for _, mod_type := range keys { for _, mod_type := range keys {
fmt.Fprintln(buf, "STATS.SOONG_MODULE_TYPE +=", mod_type) fmt.Fprintln(buf, "STATS.SOONG_MODULE_TYPE +=", mod_type)
fmt.Fprintf(buf, "STATS.SOONG_MODULE_TYPE.%s := %d\n", mod_type, type_stats[mod_type]) fmt.Fprintf(buf, "STATS.SOONG_MODULE_TYPE.%s := %d\n", mod_type, typeStats[mod_type])
} }
// Don't write to the file if it hasn't changed // Don't write to the file if it hasn't changed

View file

@ -387,25 +387,25 @@ func (context *bazelContext) InvokeBazel() error {
if err != nil { if err != nil {
return err return err
} }
cquery_file_relpath := filepath.Join(context.intermediatesDir(), "buildroot.cquery") cqueryFileRelpath := filepath.Join(context.intermediatesDir(), "buildroot.cquery")
err = ioutil.WriteFile( err = ioutil.WriteFile(
absolutePath(cquery_file_relpath), absolutePath(cqueryFileRelpath),
context.cqueryStarlarkFileContents(), 0666) context.cqueryStarlarkFileContents(), 0666)
if err != nil { if err != nil {
return err return err
} }
workspace_file_relpath := filepath.Join(context.intermediatesDir(), "WORKSPACE.bazel") workspaceFileRelpath := filepath.Join(context.intermediatesDir(), "WORKSPACE.bazel")
err = ioutil.WriteFile( err = ioutil.WriteFile(
absolutePath(workspace_file_relpath), absolutePath(workspaceFileRelpath),
context.workspaceFileContents(), 0666) context.workspaceFileContents(), 0666)
if err != nil { if err != nil {
return err return err
} }
buildroot_label := "//:buildroot" buildrootLabel := "//:buildroot"
cqueryOutput, err = context.issueBazelCommand(bazel.CqueryBuildRootRunName, "cquery", cqueryOutput, err = context.issueBazelCommand(bazel.CqueryBuildRootRunName, "cquery",
[]string{fmt.Sprintf("deps(%s)", buildroot_label)}, []string{fmt.Sprintf("deps(%s)", buildrootLabel)},
"--output=starlark", "--output=starlark",
"--starlark:file="+cquery_file_relpath) "--starlark:file="+cqueryFileRelpath)
if err != nil { if err != nil {
return err return err
@ -432,7 +432,7 @@ func (context *bazelContext) InvokeBazel() error {
// TODO(cparsons): Use --target_pattern_file to avoid command line limits. // TODO(cparsons): Use --target_pattern_file to avoid command line limits.
var aqueryOutput string var aqueryOutput string
aqueryOutput, err = context.issueBazelCommand(bazel.AqueryBuildRootRunName, "aquery", aqueryOutput, err = context.issueBazelCommand(bazel.AqueryBuildRootRunName, "aquery",
[]string{fmt.Sprintf("deps(%s)", buildroot_label), []string{fmt.Sprintf("deps(%s)", buildrootLabel),
// Use jsonproto instead of proto; actual proto parsing would require a dependency on Bazel's // Use jsonproto instead of proto; actual proto parsing would require a dependency on Bazel's
// proto sources, which would add a number of unnecessary dependencies. // proto sources, which would add a number of unnecessary dependencies.
"--output=jsonproto"}) "--output=jsonproto"})

View file

@ -24,8 +24,8 @@ import (
) )
const ( const (
clear_vars = "__android_mk_clear_vars" clearVarsPath = "__android_mk_clear_vars"
include_ignored = "__android_mk_include_ignored" includeIgnoredPath = "__android_mk_include_ignored"
) )
type bpVariable struct { type bpVariable struct {
@ -913,7 +913,7 @@ func allSubdirJavaFiles(args []string) []string {
} }
func includeIgnored(args []string) []string { func includeIgnored(args []string) []string {
return []string{include_ignored} return []string{includeIgnoredPath}
} }
var moduleTypes = map[string]string{ var moduleTypes = map[string]string{
@ -959,7 +959,7 @@ var includePathToModule = map[string]string{
} }
func mapIncludePath(path string) (string, bool) { func mapIncludePath(path string) (string, bool) {
if path == clear_vars || path == include_ignored { if path == clearVarsPath || path == includeIgnoredPath {
return path, true return path, true
} }
module, ok := includePathToModule[path] module, ok := includePathToModule[path]
@ -968,7 +968,7 @@ func mapIncludePath(path string) (string, bool) {
func androidScope() mkparser.Scope { func androidScope() mkparser.Scope {
globalScope := mkparser.NewScope(nil) globalScope := mkparser.NewScope(nil)
globalScope.Set("CLEAR_VARS", clear_vars) globalScope.Set("CLEAR_VARS", clearVarsPath)
globalScope.SetFunc("my-dir", mydir) globalScope.SetFunc("my-dir", mydir)
globalScope.SetFunc("all-java-files-under", allFilesUnder("*.java")) globalScope.SetFunc("all-java-files-under", allFilesUnder("*.java"))
globalScope.SetFunc("all-proto-files-under", allFilesUnder("*.proto")) globalScope.SetFunc("all-proto-files-under", allFilesUnder("*.proto"))

View file

@ -156,9 +156,9 @@ func ConvertFile(filename string, buffer *bytes.Buffer) (string, []error) {
continue continue
} }
switch module { switch module {
case clear_vars: case clearVarsPath:
resetModule(file) resetModule(file)
case include_ignored: case includeIgnoredPath:
// subdirs are already automatically included in Soong // subdirs are already automatically included in Soong
continue continue
default: default:

View file

@ -298,12 +298,12 @@ type apexBundle struct {
// Inputs // Inputs
// Keys for apex_paylaod.img // Keys for apex_paylaod.img
public_key_file android.Path publicKeyFile android.Path
private_key_file android.Path privateKeyFile android.Path
// Cert/priv-key for the zip container // Cert/priv-key for the zip container
container_certificate_file android.Path containerCertificateFile android.Path
container_private_key_file android.Path containerPrivateKeyFile android.Path
// Flags for special variants of APEX // Flags for special variants of APEX
testApex bool testApex bool
@ -1684,16 +1684,16 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
} }
case keyTag: case keyTag:
if key, ok := child.(*apexKey); ok { if key, ok := child.(*apexKey); ok {
a.private_key_file = key.private_key_file a.privateKeyFile = key.privateKeyFile
a.public_key_file = key.public_key_file a.publicKeyFile = key.publicKeyFile
} else { } else {
ctx.PropertyErrorf("key", "%q is not an apex_key module", depName) ctx.PropertyErrorf("key", "%q is not an apex_key module", depName)
} }
return false return false
case certificateTag: case certificateTag:
if dep, ok := child.(*java.AndroidAppCertificate); ok { if dep, ok := child.(*java.AndroidAppCertificate); ok {
a.container_certificate_file = dep.Certificate.Pem a.containerCertificateFile = dep.Certificate.Pem
a.container_private_key_file = dep.Certificate.Key a.containerPrivateKeyFile = dep.Certificate.Key
} else { } else {
ctx.ModuleErrorf("certificate dependency %q must be an android_app_certificate module", depName) 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 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)) ctx.PropertyErrorf("key", "private_key for %q could not be found", String(a.properties.Key))
return return
} }
@ -1950,7 +1950,7 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
copiedPubkey := android.PathForModuleOut(ctx, "apex_pubkey") copiedPubkey := android.PathForModuleOut(ctx, "apex_pubkey")
ctx.Build(pctx, android.BuildParams{ ctx.Build(pctx, android.BuildParams{
Rule: android.Cp, Rule: android.Cp,
Input: a.public_key_file, Input: a.publicKeyFile,
Output: copiedPubkey, Output: copiedPubkey,
}) })
a.filesInfo = append(a.filesInfo, newApexFile(ctx, copiedPubkey, "apex_pubkey", ".", etc, nil)) 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 { func createApexPermittedPackagesRules(modules_packages map[string][]string) []android.Rule {
rules := make([]android.Rule, 0, len(modules_packages)) rules := make([]android.Rule, 0, len(modules_packages))
for module_name, module_packages := range modules_packages { for module_name, module_packages := range modules_packages {
permitted_packages_rule := android.NeverAllow(). permittedPackagesRule := android.NeverAllow().
BootclasspathJar(). BootclasspathJar().
With("apex_available", module_name). With("apex_available", module_name).
WithMatcher("permitted_packages", android.NotInList(module_packages)). WithMatcher("permitted_packages", android.NotInList(module_packages)).
Because("jars that are part of the " + module_name + Because("jars that are part of the " + module_name +
" module may only allow these packages: " + strings.Join(module_packages, ",") + " module may only allow these packages: " + strings.Join(module_packages, ",") +
". Please jarjar or move code around.") ". Please jarjar or move code around.")
rules = append(rules, permitted_packages_rule) rules = append(rules, permittedPackagesRule)
} }
return rules return rules
} }

View file

@ -2679,12 +2679,12 @@ func TestKeys(t *testing.T) {
// check the APEX keys // check the APEX keys
keys := ctx.ModuleForTests("myapex.key", "android_common").Module().(*apexKey) keys := ctx.ModuleForTests("myapex.key", "android_common").Module().(*apexKey)
if keys.public_key_file.String() != "vendor/foo/devkeys/testkey.avbpubkey" { if keys.publicKeyFile.String() != "vendor/foo/devkeys/testkey.avbpubkey" {
t.Errorf("public key %q is not %q", keys.public_key_file.String(), t.Errorf("public key %q is not %q", keys.publicKeyFile.String(),
"vendor/foo/devkeys/testkey.avbpubkey") "vendor/foo/devkeys/testkey.avbpubkey")
} }
if keys.private_key_file.String() != "vendor/foo/devkeys/testkey.pem" { if keys.privateKeyFile.String() != "vendor/foo/devkeys/testkey.pem" {
t.Errorf("private key %q is not %q", keys.private_key_file.String(), t.Errorf("private key %q is not %q", keys.privateKeyFile.String(),
"vendor/foo/devkeys/testkey.pem") "vendor/foo/devkeys/testkey.pem")
} }
@ -4143,12 +4143,12 @@ func TestApexKeyFromOtherModule(t *testing.T) {
apex_key := ctx.ModuleForTests("myapex.key", "android_common").Module().(*apexKey) apex_key := ctx.ModuleForTests("myapex.key", "android_common").Module().(*apexKey)
expected_pubkey := "testkey2.avbpubkey" expected_pubkey := "testkey2.avbpubkey"
actual_pubkey := apex_key.public_key_file.String() actual_pubkey := apex_key.publicKeyFile.String()
if actual_pubkey != expected_pubkey { if actual_pubkey != expected_pubkey {
t.Errorf("wrong public key path. expected %q. actual %q", expected_pubkey, actual_pubkey) t.Errorf("wrong public key path. expected %q. actual %q", expected_pubkey, actual_pubkey)
} }
expected_privkey := "testkey2.pem" expected_privkey := "testkey2.pem"
actual_privkey := apex_key.private_key_file.String() actual_privkey := apex_key.privateKeyFile.String()
if actual_privkey != expected_privkey { if actual_privkey != expected_privkey {
t.Errorf("wrong private key path. expected %q. actual %q", expected_privkey, actual_privkey) t.Errorf("wrong private key path. expected %q. actual %q", expected_privkey, actual_privkey)
} }

View file

@ -577,8 +577,8 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
fileContexts := a.buildFileContexts(ctx) fileContexts := a.buildFileContexts(ctx)
implicitInputs = append(implicitInputs, fileContexts) implicitInputs = append(implicitInputs, fileContexts)
implicitInputs = append(implicitInputs, a.private_key_file, a.public_key_file) implicitInputs = append(implicitInputs, a.privateKeyFile, a.publicKeyFile)
optFlags = append(optFlags, "--pubkey "+a.public_key_file.String()) optFlags = append(optFlags, "--pubkey "+a.publicKeyFile.String())
manifestPackageName := a.getOverrideManifestPackageName(ctx) manifestPackageName := a.getOverrideManifestPackageName(ctx)
if manifestPackageName != "" { if manifestPackageName != "" {
@ -667,7 +667,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
"manifest": a.manifestPbOut.String(), "manifest": a.manifestPbOut.String(),
"file_contexts": fileContexts.String(), "file_contexts": fileContexts.String(),
"canned_fs_config": cannedFsConfig.String(), "canned_fs_config": cannedFsConfig.String(),
"key": a.private_key_file.String(), "key": a.privateKeyFile.String(),
"opt_flags": strings.Join(optFlags, " "), "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 zip container of this APEX. See the description of the 'certificate' property for how
// the cert and the private key are found. // the cert and the private key are found.
func (a *apexBundle) getCertificateAndPrivateKey(ctx android.PathContext) (pem, key android.Path) { func (a *apexBundle) getCertificateAndPrivateKey(ctx android.PathContext) (pem, key android.Path) {
if a.container_certificate_file != nil { if a.containerCertificateFile != nil {
return a.container_certificate_file, a.container_private_key_file return a.containerCertificateFile, a.containerPrivateKeyFile
} }
cert := String(a.properties.Certificate) cert := String(a.properties.Certificate)

View file

@ -36,8 +36,8 @@ type apexKey struct {
properties apexKeyProperties properties apexKeyProperties
public_key_file android.Path publicKeyFile android.Path
private_key_file android.Path privateKeyFile android.Path
keyName string 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 // Otherwise, try to locate the key files in the default cert dir or
// in the local module dir // in the local module dir
if android.SrcIsModule(String(m.properties.Public_key)) != "" { 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 { } 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 not found, fall back to the local key pairs
if !android.ExistentPathForSource(ctx, m.public_key_file.String()).Valid() { if !android.ExistentPathForSource(ctx, m.publicKeyFile.String()).Valid() {
m.public_key_file = android.PathForModuleSrc(ctx, String(m.properties.Public_key)) m.publicKeyFile = android.PathForModuleSrc(ctx, String(m.properties.Public_key))
} }
} }
if android.SrcIsModule(String(m.properties.Private_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 { } else {
m.private_key_file = ctx.Config().ApexKeyDir(ctx).Join(ctx, String(m.properties.Private_key)) m.privateKeyFile = ctx.Config().ApexKeyDir(ctx).Join(ctx, String(m.properties.Private_key))
if !android.ExistentPathForSource(ctx, m.private_key_file.String()).Valid() { if !android.ExistentPathForSource(ctx, m.privateKeyFile.String()).Valid() {
m.private_key_file = android.PathForModuleSrc(ctx, String(m.properties.Private_key)) 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())] pubKeyName := m.publicKeyFile.Base()[0 : len(m.publicKeyFile.Base())-len(m.publicKeyFile.Ext())]
privKeyName := m.private_key_file.Base()[0 : len(m.private_key_file.Base())-len(m.private_key_file.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 { 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", 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 return
} }
m.keyName = pubKeyName m.keyName = pubKeyName
@ -107,20 +107,20 @@ type apexKeysText struct {
func (s *apexKeysText) GenerateBuildActions(ctx android.SingletonContext) { func (s *apexKeysText) GenerateBuildActions(ctx android.SingletonContext) {
s.output = android.PathForOutput(ctx, "apexkeys.txt") s.output = android.PathForOutput(ctx, "apexkeys.txt")
type apexKeyEntry struct { type apexKeyEntry struct {
name string name string
presigned bool presigned bool
public_key string publicKey string
private_key string privateKey string
container_certificate string containerCertificate string
container_private_key string containerPrivateKey string
partition string partition string
} }
toString := func(e apexKeyEntry) 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" format := "name=%q public_key=%q private_key=%q container_certificate=%q container_private_key=%q partition=%q\n"
if e.presigned { if e.presigned {
return fmt.Sprintf(format, e.name, "PRESIGNED", "PRESIGNED", "PRESIGNED", "PRESIGNED", e.partition) return fmt.Sprintf(format, e.name, "PRESIGNED", "PRESIGNED", "PRESIGNED", "PRESIGNED", e.partition)
} else { } 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() { if m, ok := module.(*apexBundle); ok && m.Enabled() && m.installable() {
pem, key := m.getCertificateAndPrivateKey(ctx) pem, key := m.getCertificateAndPrivateKey(ctx)
apexKeyMap[m.Name()] = apexKeyEntry{ apexKeyMap[m.Name()] = apexKeyEntry{
name: m.Name() + ".apex", name: m.Name() + ".apex",
presigned: false, presigned: false,
public_key: m.public_key_file.String(), publicKey: m.publicKeyFile.String(),
private_key: m.private_key_file.String(), privateKey: m.privateKeyFile.String(),
container_certificate: pem.String(), containerCertificate: pem.String(),
container_private_key: key.String(), containerPrivateKey: key.String(),
partition: m.PartitionTag(ctx.DeviceConfig()), partition: m.PartitionTag(ctx.DeviceConfig()),
} }
} }
}) })

View file

@ -784,9 +784,9 @@ func removeSoongConfigBoolVariable(f *Fixer) error {
return nil return nil
} }
bool_variables, ok := getLiteralListProperty(mod, "bool_variables") boolVariables, ok := getLiteralListProperty(mod, "bool_variables")
if ok { if ok {
patchList.Add(bool_variables.RBracePos.Offset, bool_variables.RBracePos.Offset, ","+boolValues.String()) patchList.Add(boolVariables.RBracePos.Offset, boolVariables.RBracePos.Offset, ","+boolValues.String())
} else { } else {
patchList.Add(variables.RBracePos.Offset+2, variables.RBracePos.Offset+2, patchList.Add(variables.RBracePos.Offset+2, variables.RBracePos.Offset+2,
fmt.Sprintf(`bool_variables: [%s],`, boolValues.String())) fmt.Sprintf(`bool_variables: [%s],`, boolValues.String()))

View file

@ -232,8 +232,8 @@ func (library *libraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries
if len(library.Properties.Overrides) > 0 { if len(library.Properties.Overrides) > 0 {
entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, library.Properties.Overrides), " ")) entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, library.Properties.Overrides), " "))
} }
if len(library.post_install_cmds) > 0 { if len(library.postInstallCmds) > 0 {
entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(library.post_install_cmds, "&& ")) entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(library.postInstallCmds, "&& "))
} }
}) })
} else if library.header() { } else if library.header() {
@ -328,8 +328,8 @@ func (binary *binaryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *a
if len(binary.Properties.Overrides) > 0 { if len(binary.Properties.Overrides) > 0 {
entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, binary.Properties.Overrides), " ")) entries.SetString("LOCAL_OVERRIDES_MODULES", strings.Join(makeOverrideModuleNames(ctx, binary.Properties.Overrides), " "))
} }
if len(binary.post_install_cmds) > 0 { if len(binary.postInstallCmds) > 0 {
entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(binary.post_install_cmds, "&& ")) entries.SetString("LOCAL_POST_INSTALL_CMD", strings.Join(binary.postInstallCmds, "&& "))
} }
}) })
} }

View file

@ -109,7 +109,7 @@ type binaryDecorator struct {
// Action command lines to run directly after the binary is installed. For example, // Action command lines to run directly after the binary is installed. For example,
// may be used to symlink runtime dependencies (such as bionic) alongside installation. // may be used to symlink runtime dependencies (such as bionic) alongside installation.
post_install_cmds []string postInstallCmds []string
} }
var _ linker = (*binaryDecorator)(nil) var _ linker = (*binaryDecorator)(nil)
@ -481,11 +481,11 @@ func (binary *binaryDecorator) installSymlinkToRuntimeApex(ctx ModuleContext, fi
target := "/" + filepath.Join("apex", "com.android.runtime", dir.Base(), file.Base()) target := "/" + filepath.Join("apex", "com.android.runtime", dir.Base(), file.Base())
ctx.InstallAbsoluteSymlink(dir, file.Base(), target) ctx.InstallAbsoluteSymlink(dir, file.Base(), target)
binary.post_install_cmds = append(binary.post_install_cmds, makeSymlinkCmd(dirOnDevice, file.Base(), target)) binary.postInstallCmds = append(binary.postInstallCmds, makeSymlinkCmd(dirOnDevice, file.Base(), target))
for _, symlink := range binary.symlinks { for _, symlink := range binary.symlinks {
ctx.InstallAbsoluteSymlink(dir, symlink, target) ctx.InstallAbsoluteSymlink(dir, symlink, target)
binary.post_install_cmds = append(binary.post_install_cmds, makeSymlinkCmd(dirOnDevice, symlink, target)) binary.postInstallCmds = append(binary.postInstallCmds, makeSymlinkCmd(dirOnDevice, symlink, target))
} }
} }

View file

@ -104,7 +104,7 @@ func CheckBadLinkerFlags(ctx BaseModuleContext, prop string, flags []string) {
// Check for bad host_ldlibs // Check for bad host_ldlibs
func CheckBadHostLdlibs(ctx ModuleContext, prop string, flags []string) { func CheckBadHostLdlibs(ctx ModuleContext, prop string, flags []string) {
allowed_ldlibs := ctx.toolchain().AvailableLibraries() allowedLdlibs := ctx.toolchain().AvailableLibraries()
if !ctx.Host() { if !ctx.Host() {
panic("Invalid call to CheckBadHostLdlibs") panic("Invalid call to CheckBadHostLdlibs")
@ -116,7 +116,7 @@ func CheckBadHostLdlibs(ctx ModuleContext, prop string, flags []string) {
// TODO: Probably should just redo this property to prefix -l in Soong // TODO: Probably should just redo this property to prefix -l in Soong
if !strings.HasPrefix(flag, "-l") && !strings.HasPrefix(flag, "-framework") { if !strings.HasPrefix(flag, "-l") && !strings.HasPrefix(flag, "-framework") {
ctx.PropertyErrorf(prop, "Invalid flag: `%s`, must start with `-l` or `-framework`", flag) ctx.PropertyErrorf(prop, "Invalid flag: `%s`, must start with `-l` or `-framework`", flag)
} else if !inList(flag, allowed_ldlibs) { } else if !inList(flag, allowedLdlibs) {
ctx.PropertyErrorf(prop, "Host library `%s` not available", flag) ctx.PropertyErrorf(prop, "Host library `%s` not available", flag)
} }
} }

View file

@ -125,15 +125,15 @@ func generateCLionProject(compiledModule CompiledInterface, ctx android.Singleto
} }
// Only write CMakeLists.txt for the first variant of each architecture of each module // Only write CMakeLists.txt for the first variant of each architecture of each module
clionproject_location := getCMakeListsForModule(ccModule, ctx) clionprojectLocation := getCMakeListsForModule(ccModule, ctx)
if seenProjects[clionproject_location] { if seenProjects[clionprojectLocation] {
return return
} }
seenProjects[clionproject_location] = true seenProjects[clionprojectLocation] = true
// Ensure the directory hosting the cmakelists.txt exists // Ensure the directory hosting the cmakelists.txt exists
projectDir := path.Dir(clionproject_location) projectDir := path.Dir(clionprojectLocation)
os.MkdirAll(projectDir, os.ModePerm) os.MkdirAll(projectDir, os.ModePerm)
// Create cmakelists.txt // Create cmakelists.txt

View file

@ -387,7 +387,7 @@ type libraryDecorator struct {
versionScriptPath android.OptionalPath versionScriptPath android.OptionalPath
post_install_cmds []string postInstallCmds []string
// If useCoreVariant is true, the vendor variant of a VNDK library is // If useCoreVariant is true, the vendor variant of a VNDK library is
// not installed. // not installed.
@ -658,9 +658,9 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
SourceAbiFlags = append(SourceAbiFlags, "-I"+reexportedInclude) SourceAbiFlags = append(SourceAbiFlags, "-I"+reexportedInclude)
} }
flags.SAbiFlags = SourceAbiFlags flags.SAbiFlags = SourceAbiFlags
total_length := len(library.baseCompiler.Properties.Srcs) + len(deps.GeneratedSources) + totalLength := len(library.baseCompiler.Properties.Srcs) + len(deps.GeneratedSources) +
len(library.SharedProperties.Shared.Srcs) + len(library.StaticProperties.Static.Srcs) len(library.SharedProperties.Shared.Srcs) + len(library.StaticProperties.Static.Srcs)
if total_length > 0 { if totalLength > 0 {
flags.SAbiDump = true flags.SAbiDump = true
} }
} }
@ -1377,7 +1377,7 @@ func (library *libraryDecorator) installSymlinkToRuntimeApex(ctx ModuleContext,
dirOnDevice := android.InstallPathToOnDevicePath(ctx, dir) dirOnDevice := android.InstallPathToOnDevicePath(ctx, dir)
target := "/" + filepath.Join("apex", "com.android.runtime", dir.Base(), "bionic", file.Base()) target := "/" + filepath.Join("apex", "com.android.runtime", dir.Base(), "bionic", file.Base())
ctx.InstallAbsoluteSymlink(dir, file.Base(), target) ctx.InstallAbsoluteSymlink(dir, file.Base(), target)
library.post_install_cmds = append(library.post_install_cmds, makeSymlinkCmd(dirOnDevice, file.Base(), target)) library.postInstallCmds = append(library.postInstallCmds, makeSymlinkCmd(dirOnDevice, file.Base(), target))
} }
func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) { func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {
@ -1682,11 +1682,11 @@ func reuseStaticLibrary(mctx android.BottomUpMutatorContext, static, shared *Mod
// LinkageMutator adds "static" or "shared" variants for modules depending // LinkageMutator adds "static" or "shared" variants for modules depending
// on whether the module can be built as a static library or a shared library. // on whether the module can be built as a static library or a shared library.
func LinkageMutator(mctx android.BottomUpMutatorContext) { func LinkageMutator(mctx android.BottomUpMutatorContext) {
cc_prebuilt := false ccPrebuilt := false
if m, ok := mctx.Module().(*Module); ok && m.linker != nil { if m, ok := mctx.Module().(*Module); ok && m.linker != nil {
_, cc_prebuilt = m.linker.(prebuiltLibraryInterface) _, ccPrebuilt = m.linker.(prebuiltLibraryInterface)
} }
if cc_prebuilt { if ccPrebuilt {
library := mctx.Module().(*Module).linker.(prebuiltLibraryInterface) library := mctx.Module().(*Module).linker.(prebuiltLibraryInterface)
// Differentiate between header only and building an actual static/shared library // Differentiate between header only and building an actual static/shared library

View file

@ -469,14 +469,14 @@ func (linker *baseLinker) linkerFlags(ctx ModuleContext, flags Flags) Flags {
flags.Local.LdFlags = append(flags.Local.LdFlags, proptools.NinjaAndShellEscapeList(linker.Properties.Ldflags)...) flags.Local.LdFlags = append(flags.Local.LdFlags, proptools.NinjaAndShellEscapeList(linker.Properties.Ldflags)...)
if ctx.Host() && !ctx.Windows() { if ctx.Host() && !ctx.Windows() {
rpath_prefix := `\$$ORIGIN/` rpathPrefix := `\$$ORIGIN/`
if ctx.Darwin() { if ctx.Darwin() {
rpath_prefix = "@loader_path/" rpathPrefix = "@loader_path/"
} }
if !ctx.static() { if !ctx.static() {
for _, rpath := range linker.dynamicProperties.RunPaths { for _, rpath := range linker.dynamicProperties.RunPaths {
flags.Global.LdFlags = append(flags.Global.LdFlags, "-Wl,-rpath,"+rpath_prefix+rpath) flags.Global.LdFlags = append(flags.Global.LdFlags, "-Wl,-rpath,"+rpathPrefix+rpath)
} }
} }
} }
@ -580,8 +580,8 @@ func (linker *baseLinker) injectVersionSymbol(ctx ModuleContext, in android.Path
// Rule to generate .bss symbol ordering file. // Rule to generate .bss symbol ordering file.
var ( var (
_ = pctx.SourcePathVariable("genSortedBssSymbolsPath", "build/soong/scripts/gen_sorted_bss_symbols.sh") _ = pctx.SourcePathVariable("genSortedBssSymbolsPath", "build/soong/scripts/gen_sorted_bss_symbols.sh")
gen_sorted_bss_symbols = pctx.AndroidStaticRule("gen_sorted_bss_symbols", genSortedBssSymbols = pctx.AndroidStaticRule("gen_sorted_bss_symbols",
blueprint.RuleParams{ blueprint.RuleParams{
Command: "CROSS_COMPILE=$crossCompile $genSortedBssSymbolsPath ${in} ${out}", Command: "CROSS_COMPILE=$crossCompile $genSortedBssSymbolsPath ${in} ${out}",
CommandDeps: []string{"$genSortedBssSymbolsPath", "${crossCompile}nm"}, CommandDeps: []string{"$genSortedBssSymbolsPath", "${crossCompile}nm"},
@ -592,7 +592,7 @@ var (
func (linker *baseLinker) sortBssSymbolsBySize(ctx ModuleContext, in android.Path, symbolOrderingFile android.ModuleOutPath, flags builderFlags) string { func (linker *baseLinker) sortBssSymbolsBySize(ctx ModuleContext, in android.Path, symbolOrderingFile android.ModuleOutPath, flags builderFlags) string {
crossCompile := gccCmd(flags.toolchain, "") crossCompile := gccCmd(flags.toolchain, "")
ctx.Build(pctx, android.BuildParams{ ctx.Build(pctx, android.BuildParams{
Rule: gen_sorted_bss_symbols, Rule: genSortedBssSymbols,
Description: "generate bss symbol order " + symbolOrderingFile.Base(), Description: "generate bss symbol order " + symbolOrderingFile.Base(),
Output: symbolOrderingFile, Output: symbolOrderingFile,
Input: in, Input: in,

View file

@ -103,7 +103,7 @@ func (props *PgoProperties) addSamplingProfileGatherFlags(ctx ModuleContext, fla
} }
func (props *PgoProperties) getPgoProfileFile(ctx BaseModuleContext) android.OptionalPath { func (props *PgoProperties) getPgoProfileFile(ctx BaseModuleContext) android.OptionalPath {
profile_file := *props.Pgo.Profile_file profileFile := *props.Pgo.Profile_file
// Test if the profile_file is present in any of the PGO profile projects // Test if the profile_file is present in any of the PGO profile projects
for _, profileProject := range getPgoProfileProjects(ctx.DeviceConfig()) { for _, profileProject := range getPgoProfileProjects(ctx.DeviceConfig()) {
@ -112,24 +112,24 @@ func (props *PgoProperties) getPgoProfileFile(ctx BaseModuleContext) android.Opt
// <profile_file>.<arbitrary-version> when available. This // <profile_file>.<arbitrary-version> when available. This
// works around an issue where ccache serves stale cache // works around an issue where ccache serves stale cache
// entries when the profile file has changed. // entries when the profile file has changed.
globPattern := filepath.Join(profileProject, profile_file+".*") globPattern := filepath.Join(profileProject, profileFile+".*")
versioned_profiles, err := ctx.GlobWithDeps(globPattern, nil) versionedProfiles, err := ctx.GlobWithDeps(globPattern, nil)
if err != nil { if err != nil {
ctx.ModuleErrorf("glob: %s", err.Error()) ctx.ModuleErrorf("glob: %s", err.Error())
} }
path := android.ExistentPathForSource(ctx, profileProject, profile_file) path := android.ExistentPathForSource(ctx, profileProject, profileFile)
if path.Valid() { if path.Valid() {
if len(versioned_profiles) != 0 { if len(versionedProfiles) != 0 {
ctx.PropertyErrorf("pgo.profile_file", "Profile_file has multiple versions: "+filepath.Join(profileProject, profile_file)+", "+strings.Join(versioned_profiles, ", ")) ctx.PropertyErrorf("pgo.profile_file", "Profile_file has multiple versions: "+filepath.Join(profileProject, profileFile)+", "+strings.Join(versionedProfiles, ", "))
} }
return path return path
} }
if len(versioned_profiles) > 1 { if len(versionedProfiles) > 1 {
ctx.PropertyErrorf("pgo.profile_file", "Profile_file has multiple versions: "+strings.Join(versioned_profiles, ", ")) ctx.PropertyErrorf("pgo.profile_file", "Profile_file has multiple versions: "+strings.Join(versionedProfiles, ", "))
} else if len(versioned_profiles) == 1 { } else if len(versionedProfiles) == 1 {
return android.OptionalPathForPath(android.PathForSource(ctx, versioned_profiles[0])) return android.OptionalPathForPath(android.PathForSource(ctx, versionedProfiles[0]))
} }
} }

View file

@ -787,11 +787,11 @@ func VendorSnapshotSourceMutator(ctx android.BottomUpMutatorContext) {
if !module.SocSpecific() { if !module.SocSpecific() {
// But we can't just check SocSpecific() since we already passed the image mutator. // But we can't just check SocSpecific() since we already passed the image mutator.
// Check ramdisk and recovery to see if we are real "vendor: true" module. // Check ramdisk and recovery to see if we are real "vendor: true" module.
ramdisk_available := module.InRamdisk() && !module.OnlyInRamdisk() ramdiskAvailable := module.InRamdisk() && !module.OnlyInRamdisk()
vendor_ramdisk_available := module.InVendorRamdisk() && !module.OnlyInVendorRamdisk() vendorRamdiskAvailable := module.InVendorRamdisk() && !module.OnlyInVendorRamdisk()
recovery_available := module.InRecovery() && !module.OnlyInRecovery() recoveryAvailable := module.InRecovery() && !module.OnlyInRecovery()
if !ramdisk_available && !recovery_available && !vendor_ramdisk_available { if !ramdiskAvailable && !recoveryAvailable && !vendorRamdiskAvailable {
vendorSnapshotsLock.Lock() vendorSnapshotsLock.Lock()
defer vendorSnapshotsLock.Unlock() defer vendorSnapshotsLock.Unlock()

View file

@ -211,15 +211,15 @@ func TestPerSrcMutator(mctx android.BottomUpMutatorContext) {
// name or even their number. // name or even their number.
testNames = append(testNames, "") testNames = append(testNames, "")
tests := mctx.CreateLocalVariations(testNames...) tests := mctx.CreateLocalVariations(testNames...)
all_tests := tests[numTests] allTests := tests[numTests]
all_tests.(*Module).linker.(testPerSrc).unsetSrc() allTests.(*Module).linker.(testPerSrc).unsetSrc()
// Prevent the "all tests" variation from being installable nor // Prevent the "all tests" variation from being installable nor
// exporting to Make, as it won't create any output file. // exporting to Make, as it won't create any output file.
all_tests.(*Module).Properties.PreventInstall = true allTests.(*Module).Properties.PreventInstall = true
all_tests.(*Module).Properties.HideFromMake = true allTests.(*Module).Properties.HideFromMake = true
for i, src := range test.srcs() { for i, src := range test.srcs() {
tests[i].(*Module).linker.(testPerSrc).setSrc(testNames[i], src) tests[i].(*Module).linker.(testPerSrc).setSrc(testNames[i], src)
mctx.AddInterVariantDependency(testPerSrcDepTag, all_tests, tests[i]) mctx.AddInterVariantDependency(testPerSrcDepTag, allTests, tests[i])
} }
mctx.AliasVariation("") mctx.AliasVariation("")
} }
@ -369,9 +369,9 @@ func (test *testBinary) install(ctx ModuleContext, file android.Path) {
} }
}) })
var api_level_prop string var apiLevelProp string
var configs []tradefed.Config var configs []tradefed.Config
var min_level string var minLevel string
for _, module := range test.Properties.Test_mainline_modules { for _, module := range test.Properties.Test_mainline_modules {
configs = append(configs, tradefed.Option{Name: "config-descriptor:metadata", Key: "mainline-param", Value: module}) configs = append(configs, tradefed.Option{Name: "config-descriptor:metadata", Key: "mainline-param", Value: module})
} }
@ -398,16 +398,16 @@ func (test *testBinary) install(ctx ModuleContext, file android.Path) {
if test.Properties.Test_min_api_level != nil && test.Properties.Test_min_sdk_version != nil { if test.Properties.Test_min_api_level != nil && test.Properties.Test_min_sdk_version != nil {
ctx.PropertyErrorf("test_min_api_level", "'test_min_api_level' and 'test_min_sdk_version' should not be set at the same time.") ctx.PropertyErrorf("test_min_api_level", "'test_min_api_level' and 'test_min_sdk_version' should not be set at the same time.")
} else if test.Properties.Test_min_api_level != nil { } else if test.Properties.Test_min_api_level != nil {
api_level_prop = "ro.product.first_api_level" apiLevelProp = "ro.product.first_api_level"
min_level = strconv.FormatInt(int64(*test.Properties.Test_min_api_level), 10) minLevel = strconv.FormatInt(int64(*test.Properties.Test_min_api_level), 10)
} else if test.Properties.Test_min_sdk_version != nil { } else if test.Properties.Test_min_sdk_version != nil {
api_level_prop = "ro.build.version.sdk" apiLevelProp = "ro.build.version.sdk"
min_level = strconv.FormatInt(int64(*test.Properties.Test_min_sdk_version), 10) minLevel = strconv.FormatInt(int64(*test.Properties.Test_min_sdk_version), 10)
} }
if api_level_prop != "" { if apiLevelProp != "" {
var options []tradefed.Option var options []tradefed.Option
options = append(options, tradefed.Option{Name: "min-api-level", Value: min_level}) options = append(options, tradefed.Option{Name: "min-api-level", Value: minLevel})
options = append(options, tradefed.Option{Name: "api-level-prop", Value: api_level_prop}) options = append(options, tradefed.Option{Name: "api-level-prop", Value: apiLevelProp})
configs = append(configs, tradefed.Object{"module_controller", "com.android.tradefed.testtype.suite.module.MinApiLevelModuleController", options}) configs = append(configs, tradefed.Object{"module_controller", "com.android.tradefed.testtype.suite.module.MinApiLevelModuleController", options})
} }

View file

@ -417,19 +417,19 @@ func VndkMutator(mctx android.BottomUpMutatorContext) {
} }
} }
lib, is_lib := m.linker.(*libraryDecorator) lib, isLib := m.linker.(*libraryDecorator)
prebuilt_lib, is_prebuilt_lib := m.linker.(*prebuiltLibraryLinker) prebuiltLib, isPrebuiltLib := m.linker.(*prebuiltLibraryLinker)
if m.UseVndk() && is_lib && lib.hasLLNDKStubs() { if m.UseVndk() && isLib && lib.hasLLNDKStubs() {
llndk := mctx.AddVariationDependencies(nil, llndkStubDepTag, String(lib.Properties.Llndk_stubs)) llndk := mctx.AddVariationDependencies(nil, llndkStubDepTag, String(lib.Properties.Llndk_stubs))
mergeLLNDKToLib(llndk[0].(*Module), &lib.Properties.Llndk, &lib.flagExporter) mergeLLNDKToLib(llndk[0].(*Module), &lib.Properties.Llndk, &lib.flagExporter)
} }
if m.UseVndk() && is_prebuilt_lib && prebuilt_lib.hasLLNDKStubs() { if m.UseVndk() && isPrebuiltLib && prebuiltLib.hasLLNDKStubs() {
llndk := mctx.AddVariationDependencies(nil, llndkStubDepTag, String(prebuilt_lib.Properties.Llndk_stubs)) llndk := mctx.AddVariationDependencies(nil, llndkStubDepTag, String(prebuiltLib.Properties.Llndk_stubs))
mergeLLNDKToLib(llndk[0].(*Module), &prebuilt_lib.Properties.Llndk, &prebuilt_lib.flagExporter) mergeLLNDKToLib(llndk[0].(*Module), &prebuiltLib.Properties.Llndk, &prebuiltLib.flagExporter)
} }
if (is_lib && lib.buildShared()) || (is_prebuilt_lib && prebuilt_lib.buildShared()) { if (isLib && lib.buildShared()) || (isPrebuiltLib && prebuiltLib.buildShared()) {
if m.vndkdep != nil && m.vndkdep.isVndk() && !m.vndkdep.isVndkExt() { if m.vndkdep != nil && m.vndkdep.isVndk() && !m.vndkdep.isVndkExt() {
processVndkLibrary(mctx, m) processVndkLibrary(mctx, m)
return return

View file

@ -58,7 +58,7 @@ func main() {
os.Exit(4) os.Exit(4)
} }
start_addr, err := parseElf(r, linker) startAddr, err := parseElf(r, linker)
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, err.Error()) fmt.Fprintln(os.Stderr, err.Error())
os.Exit(5) os.Exit(5)
@ -71,7 +71,7 @@ func main() {
} }
defer w.Close() defer w.Close()
err = symbol_inject.InjectUint64Symbol(file, w, "__dlwrap_original_start", start_addr) err = symbol_inject.InjectUint64Symbol(file, w, "__dlwrap_original_start", startAddr)
if err != nil { if err != nil {
fmt.Fprintln(os.Stderr, err.Error()) fmt.Fprintln(os.Stderr, err.Error())
os.Exit(7) os.Exit(7)
@ -128,7 +128,7 @@ func findSymbol(symbols []elf.Symbol, name string) (elf.Symbol, error) {
// Check that all of the PT_LOAD segments have been embedded properly // Check that all of the PT_LOAD segments have been embedded properly
func checkLinker(file, linker *elf.File, fileSyms []elf.Symbol) error { func checkLinker(file, linker *elf.File, fileSyms []elf.Symbol) error {
dlwrap_linker_offset, err := findSymbol(fileSyms, "__dlwrap_linker_offset") dlwrapLinkerOffset, err := findSymbol(fileSyms, "__dlwrap_linker_offset")
if err != nil { if err != nil {
return err return err
} }
@ -138,7 +138,7 @@ func checkLinker(file, linker *elf.File, fileSyms []elf.Symbol) error {
continue continue
} }
laddr := lprog.Vaddr + dlwrap_linker_offset.Value laddr := lprog.Vaddr + dlwrapLinkerOffset.Value
found := false found := false
for _, prog := range file.Progs { for _, prog := range file.Progs {
@ -163,7 +163,7 @@ func checkLinker(file, linker *elf.File, fileSyms []elf.Symbol) error {
} }
if !found { if !found {
return fmt.Errorf("Linker prog %d (0x%x) not found at offset 0x%x", return fmt.Errorf("Linker prog %d (0x%x) not found at offset 0x%x",
i, lprog.Vaddr, dlwrap_linker_offset.Value) i, lprog.Vaddr, dlwrapLinkerOffset.Value)
} }
} }

View file

@ -305,17 +305,17 @@ func apiCheckEnabled(ctx android.ModuleContext, apiToCheck ApiToCheck, apiVersio
} }
func ignoreMissingModules(ctx android.BottomUpMutatorContext, apiToCheck *ApiToCheck) { func ignoreMissingModules(ctx android.BottomUpMutatorContext, apiToCheck *ApiToCheck) {
api_file := String(apiToCheck.Api_file) apiFile := String(apiToCheck.Api_file)
removed_api_file := String(apiToCheck.Removed_api_file) removedApiFile := String(apiToCheck.Removed_api_file)
api_module := android.SrcIsModule(api_file) apiModule := android.SrcIsModule(apiFile)
removed_api_module := android.SrcIsModule(removed_api_file) removedApiModule := android.SrcIsModule(removedApiFile)
if api_module == "" || removed_api_module == "" { if apiModule == "" || removedApiModule == "" {
return return
} }
if ctx.OtherModuleExists(api_module) || ctx.OtherModuleExists(removed_api_module) { if ctx.OtherModuleExists(apiModule) || ctx.OtherModuleExists(removedApiModule) {
return return
} }

View file

@ -1505,11 +1505,11 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
j.compiledJavaSrcs = uniqueSrcFiles j.compiledJavaSrcs = uniqueSrcFiles
j.compiledSrcJars = srcJars j.compiledSrcJars = srcJars
enable_sharding := false enableSharding := false
var headerJarFileWithoutJarjar android.Path var headerJarFileWithoutJarjar android.Path
if ctx.Device() && !ctx.Config().IsEnvFalse("TURBINE_ENABLED") && !deps.disableTurbine { if ctx.Device() && !ctx.Config().IsEnvFalse("TURBINE_ENABLED") && !deps.disableTurbine {
if j.properties.Javac_shard_size != nil && *(j.properties.Javac_shard_size) > 0 { if j.properties.Javac_shard_size != nil && *(j.properties.Javac_shard_size) > 0 {
enable_sharding = true enableSharding = true
// Formerly, there was a check here that prevented annotation processors // Formerly, there was a check here that prevented annotation processors
// from being used when sharding was enabled, as some annotation processors // from being used when sharding was enabled, as some annotation processors
// do not function correctly in sharded environments. It was removed to // do not function correctly in sharded environments. It was removed to
@ -1535,7 +1535,7 @@ func (j *Module) compile(ctx android.ModuleContext, aaptSrcJar android.Path) {
extraJarDeps = append(extraJarDeps, errorprone) extraJarDeps = append(extraJarDeps, errorprone)
} }
if enable_sharding { if enableSharding {
flags.classpath = append(flags.classpath, headerJarFileWithoutJarjar) flags.classpath = append(flags.classpath, headerJarFileWithoutJarjar)
shardSize := int(*(j.properties.Javac_shard_size)) shardSize := int(*(j.properties.Javac_shard_size))
var shardSrcs []android.Paths var shardSrcs []android.Paths

View file

@ -371,8 +371,8 @@ func decodeSdkDep(ctx android.EarlyModuleContext, sdkContext sdkContext) sdkDep
jar := filepath.Join(dir, "android.jar") jar := filepath.Join(dir, "android.jar")
// There's no aidl for other SDKs yet. // There's no aidl for other SDKs yet.
// TODO(77525052): Add aidl files for other SDKs too. // TODO(77525052): Add aidl files for other SDKs too.
public_dir := filepath.Join("prebuilts", "sdk", sdkVersion.version.String(), "public") publicDir := filepath.Join("prebuilts", "sdk", sdkVersion.version.String(), "public")
aidl := filepath.Join(public_dir, "framework.aidl") aidl := filepath.Join(publicDir, "framework.aidl")
jarPath := android.ExistentPathForSource(ctx, jar) jarPath := android.ExistentPathForSource(ctx, jar)
aidlPath := android.ExistentPathForSource(ctx, aidl) aidlPath := android.ExistentPathForSource(ctx, aidl)
lambdaStubsPath := android.PathForSource(ctx, config.SdkLambdaStubsPath) lambdaStubsPath := android.PathForSource(ctx, config.SdkLambdaStubsPath)

View file

@ -1534,7 +1534,7 @@ func (module *SdkLibrary) CreateInternalModules(mctx android.DefaultableHookCont
hasSystemAndTestApis := sdkDep.hasStandardLibs() hasSystemAndTestApis := sdkDep.hasStandardLibs()
module.sdkLibraryProperties.Generate_system_and_test_apis = hasSystemAndTestApis module.sdkLibraryProperties.Generate_system_and_test_apis = hasSystemAndTestApis
missing_current_api := false missingCurrentApi := false
generatedScopes := module.getGeneratedApiScopes(mctx) generatedScopes := module.getGeneratedApiScopes(mctx)
@ -1545,12 +1545,12 @@ func (module *SdkLibrary) CreateInternalModules(mctx android.DefaultableHookCont
p := android.ExistentPathForSource(mctx, path) p := android.ExistentPathForSource(mctx, path)
if !p.Valid() { if !p.Valid() {
mctx.ModuleErrorf("Current api file %#v doesn't exist", path) mctx.ModuleErrorf("Current api file %#v doesn't exist", path)
missing_current_api = true missingCurrentApi = true
} }
} }
} }
if missing_current_api { if missingCurrentApi {
script := "build/soong/scripts/gen-java-current-api-files.sh" script := "build/soong/scripts/gen-java-current-api-files.sh"
p := android.ExistentPathForSource(mctx, script) p := android.ExistentPathForSource(mctx, script)

View file

@ -137,13 +137,13 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl
var implicitOutputs android.WritablePaths var implicitOutputs android.WritablePaths
output.outputFile = outputFile output.outputFile = outputFile
crate_name := ctx.RustModule().CrateName() crateName := ctx.RustModule().CrateName()
targetTriple := ctx.toolchain().RustTriple() targetTriple := ctx.toolchain().RustTriple()
// libstd requires a specific environment variable to be set. This is // libstd requires a specific environment variable to be set. This is
// not officially documented and may be removed in the future. See // not officially documented and may be removed in the future. See
// https://github.com/rust-lang/rust/blob/master/library/std/src/env.rs#L866. // https://github.com/rust-lang/rust/blob/master/library/std/src/env.rs#L866.
if crate_name == "std" { if crateName == "std" {
envVars = append(envVars, "STD_ENV_ARCH="+config.StdEnvArch[ctx.RustModule().Arch().ArchType]) envVars = append(envVars, "STD_ENV_ARCH="+config.StdEnvArch[ctx.RustModule().Arch().ArchType])
} }
@ -153,8 +153,8 @@ func transformSrctoCrate(ctx ModuleContext, main android.Path, deps PathDeps, fl
rustcFlags = append(rustcFlags, flags.GlobalRustFlags...) rustcFlags = append(rustcFlags, flags.GlobalRustFlags...)
rustcFlags = append(rustcFlags, flags.RustFlags...) rustcFlags = append(rustcFlags, flags.RustFlags...)
rustcFlags = append(rustcFlags, "--crate-type="+crate_type) rustcFlags = append(rustcFlags, "--crate-type="+crate_type)
if crate_name != "" { if crateName != "" {
rustcFlags = append(rustcFlags, "--crate-name="+crate_name) rustcFlags = append(rustcFlags, "--crate-name="+crateName)
} }
if targetTriple != "" { if targetTriple != "" {
rustcFlags = append(rustcFlags, "--target="+targetTriple) rustcFlags = append(rustcFlags, "--target="+targetTriple)

View file

@ -214,9 +214,9 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
flags.GlobalLinkFlags = append(flags.GlobalLinkFlags, ctx.toolchain().ToolchainLinkFlags()) flags.GlobalLinkFlags = append(flags.GlobalLinkFlags, ctx.toolchain().ToolchainLinkFlags())
if ctx.Host() && !ctx.Windows() { if ctx.Host() && !ctx.Windows() {
rpath_prefix := `\$$ORIGIN/` rpathPrefix := `\$$ORIGIN/`
if ctx.Darwin() { if ctx.Darwin() {
rpath_prefix = "@loader_path/" rpathPrefix = "@loader_path/"
} }
var rpath string var rpath string
@ -225,8 +225,8 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags) Flag
} else { } else {
rpath = "lib" rpath = "lib"
} }
flags.LinkFlags = append(flags.LinkFlags, "-Wl,-rpath,"+rpath_prefix+rpath) flags.LinkFlags = append(flags.LinkFlags, "-Wl,-rpath,"+rpathPrefix+rpath)
flags.LinkFlags = append(flags.LinkFlags, "-Wl,-rpath,"+rpath_prefix+"../"+rpath) flags.LinkFlags = append(flags.LinkFlags, "-Wl,-rpath,"+rpathPrefix+"../"+rpath)
} }
return flags return flags

View file

@ -686,15 +686,15 @@ func (mod *Module) deps(ctx DepsContext) Deps {
type dependencyTag struct { type dependencyTag struct {
blueprint.BaseDependencyTag blueprint.BaseDependencyTag
name string name string
library bool library bool
proc_macro bool procMacro bool
} }
// InstallDepNeeded returns true for rlibs, dylibs, and proc macros so that they or their transitive // InstallDepNeeded returns true for rlibs, dylibs, and proc macros so that they or their transitive
// dependencies (especially C/C++ shared libs) are installed as dependencies of a rust binary. // dependencies (especially C/C++ shared libs) are installed as dependencies of a rust binary.
func (d dependencyTag) InstallDepNeeded() bool { func (d dependencyTag) InstallDepNeeded() bool {
return d.library || d.proc_macro return d.library || d.procMacro
} }
var _ android.InstallNeededDependencyTag = dependencyTag{} var _ android.InstallNeededDependencyTag = dependencyTag{}
@ -703,7 +703,7 @@ var (
customBindgenDepTag = dependencyTag{name: "customBindgenTag"} customBindgenDepTag = dependencyTag{name: "customBindgenTag"}
rlibDepTag = dependencyTag{name: "rlibTag", library: true} rlibDepTag = dependencyTag{name: "rlibTag", library: true}
dylibDepTag = dependencyTag{name: "dylib", library: true} dylibDepTag = dependencyTag{name: "dylib", library: true}
procMacroDepTag = dependencyTag{name: "procMacro", proc_macro: true} procMacroDepTag = dependencyTag{name: "procMacro", procMacro: true}
testPerSrcDepTag = dependencyTag{name: "rust_unit_tests"} testPerSrcDepTag = dependencyTag{name: "rust_unit_tests"}
sourceDepTag = dependencyTag{name: "source"} sourceDepTag = dependencyTag{name: "source"}
) )

View file

@ -205,14 +205,14 @@ func (s *ShBinary) SetImageVariation(ctx android.BaseModuleContext, variation st
func (s *ShBinary) generateAndroidBuildActions(ctx android.ModuleContext) { func (s *ShBinary) generateAndroidBuildActions(ctx android.ModuleContext) {
s.sourceFilePath = android.PathForModuleSrc(ctx, proptools.String(s.properties.Src)) s.sourceFilePath = android.PathForModuleSrc(ctx, proptools.String(s.properties.Src))
filename := proptools.String(s.properties.Filename) filename := proptools.String(s.properties.Filename)
filename_from_src := proptools.Bool(s.properties.Filename_from_src) filenameFromSrc := proptools.Bool(s.properties.Filename_from_src)
if filename == "" { if filename == "" {
if filename_from_src { if filenameFromSrc {
filename = s.sourceFilePath.Base() filename = s.sourceFilePath.Base()
} else { } else {
filename = ctx.ModuleName() filename = ctx.ModuleName()
} }
} else if filename_from_src { } else if filenameFromSrc {
ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true") ctx.PropertyErrorf("filename_from_src", "filename is set. filename_from_src can't be true")
return return
} }

View file

@ -392,18 +392,18 @@ func syspropLibraryHook(ctx android.LoadHookContext, m *syspropLibrary) {
ctx.PropertyErrorf("srcs", "sysprop_library must specify srcs") ctx.PropertyErrorf("srcs", "sysprop_library must specify srcs")
} }
missing_api := false missingApi := false
for _, txt := range []string{"-current.txt", "-latest.txt"} { for _, txt := range []string{"-current.txt", "-latest.txt"} {
path := path.Join(ctx.ModuleDir(), "api", m.BaseModuleName()+txt) path := path.Join(ctx.ModuleDir(), "api", m.BaseModuleName()+txt)
file := android.ExistentPathForSource(ctx, path) file := android.ExistentPathForSource(ctx, path)
if !file.Valid() { if !file.Valid() {
ctx.ModuleErrorf("API file %#v doesn't exist", path) ctx.ModuleErrorf("API file %#v doesn't exist", path)
missing_api = true missingApi = true
} }
} }
if missing_api { if missingApi {
script := "build/soong/scripts/gen-sysprop-api-files.sh" script := "build/soong/scripts/gen-sysprop-api-files.sh"
p := android.ExistentPathForSource(ctx, script) p := android.ExistentPathForSource(ctx, script)

View file

@ -617,19 +617,19 @@ func (c *configImpl) configureLocale(ctx Context) {
// For LANG and LC_*, only preserve the evaluated version of // For LANG and LC_*, only preserve the evaluated version of
// LC_MESSAGES // LC_MESSAGES
user_lang := "" userLang := ""
if lc_all, ok := c.environ.Get("LC_ALL"); ok { if lc_all, ok := c.environ.Get("LC_ALL"); ok {
user_lang = lc_all userLang = lc_all
} else if lc_messages, ok := c.environ.Get("LC_MESSAGES"); ok { } else if lc_messages, ok := c.environ.Get("LC_MESSAGES"); ok {
user_lang = lc_messages userLang = lc_messages
} else if lang, ok := c.environ.Get("LANG"); ok { } else if lang, ok := c.environ.Get("LANG"); ok {
user_lang = lang userLang = lang
} }
c.environ.UnsetWithPrefix("LC_") c.environ.UnsetWithPrefix("LC_")
if user_lang != "" { if userLang != "" {
c.environ.Set("LC_MESSAGES", user_lang) c.environ.Set("LC_MESSAGES", userLang)
} }
// The for LANG, use C.UTF-8 if it exists (Debian currently, proposed // The for LANG, use C.UTF-8 if it exists (Debian currently, proposed

View file

@ -254,7 +254,7 @@ func runMakeProductConfig(ctx Context, config Config) {
"BUILD_BROKEN_USES_BUILD_STATIC_LIBRARY", "BUILD_BROKEN_USES_BUILD_STATIC_LIBRARY",
}, exportEnvVars...), BannerVars...) }, exportEnvVars...), BannerVars...)
make_vars, err := dumpMakeVars(ctx, config, config.Arguments(), allVars, true, "") makeVars, err := dumpMakeVars(ctx, config, config.Arguments(), allVars, true, "")
if err != nil { if err != nil {
ctx.Fatalln("Error dumping make vars:", err) ctx.Fatalln("Error dumping make vars:", err)
} }
@ -262,24 +262,24 @@ func runMakeProductConfig(ctx Context, config Config) {
env := config.Environment() env := config.Environment()
// Print the banner like make does // Print the banner like make does
if !env.IsEnvTrue("ANDROID_QUIET_BUILD") { if !env.IsEnvTrue("ANDROID_QUIET_BUILD") {
fmt.Fprintln(ctx.Writer, Banner(make_vars)) fmt.Fprintln(ctx.Writer, Banner(makeVars))
} }
// Populate the environment // Populate the environment
for _, name := range exportEnvVars { for _, name := range exportEnvVars {
if make_vars[name] == "" { if makeVars[name] == "" {
env.Unset(name) env.Unset(name)
} else { } else {
env.Set(name, make_vars[name]) env.Set(name, makeVars[name])
} }
} }
config.SetKatiArgs(strings.Fields(make_vars["KATI_GOALS"])) config.SetKatiArgs(strings.Fields(makeVars["KATI_GOALS"]))
config.SetNinjaArgs(strings.Fields(make_vars["NINJA_GOALS"])) config.SetNinjaArgs(strings.Fields(makeVars["NINJA_GOALS"]))
config.SetTargetDevice(make_vars["TARGET_DEVICE"]) config.SetTargetDevice(makeVars["TARGET_DEVICE"])
config.SetTargetDeviceDir(make_vars["TARGET_DEVICE_DIR"]) config.SetTargetDeviceDir(makeVars["TARGET_DEVICE_DIR"])
config.SetBuildBrokenDupRules(make_vars["BUILD_BROKEN_DUP_RULES"] == "true") config.SetBuildBrokenDupRules(makeVars["BUILD_BROKEN_DUP_RULES"] == "true")
config.SetBuildBrokenUsesNetwork(make_vars["BUILD_BROKEN_USES_NETWORK"] == "true") config.SetBuildBrokenUsesNetwork(makeVars["BUILD_BROKEN_USES_NETWORK"] == "true")
config.SetBuildBrokenNinjaUsesEnvVars(strings.Fields(make_vars["BUILD_BROKEN_NINJA_USES_ENV_VARS"])) config.SetBuildBrokenNinjaUsesEnvVars(strings.Fields(makeVars["BUILD_BROKEN_NINJA_USES_ENV_VARS"]))
} }

View file

@ -50,10 +50,10 @@ func testForDanglingRules(ctx Context, config Config) {
// Get a list of leaf nodes in the dependency graph from ninja // Get a list of leaf nodes in the dependency graph from ninja
executable := config.PrebuiltBuildTool("ninja") executable := config.PrebuiltBuildTool("ninja")
common_args := []string{} commonArgs := []string{}
common_args = append(common_args, config.NinjaArgs()...) commonArgs = append(commonArgs, config.NinjaArgs()...)
common_args = append(common_args, "-f", config.CombinedNinjaFile()) commonArgs = append(commonArgs, "-f", config.CombinedNinjaFile())
args := append(common_args, "-t", "targets", "rule") args := append(commonArgs, "-t", "targets", "rule")
cmd := Command(ctx, config, "ninja", executable, args...) cmd := Command(ctx, config, "ninja", executable, args...)
stdout, err := cmd.StdoutPipe() stdout, err := cmd.StdoutPipe()
@ -114,28 +114,28 @@ func testForDanglingRules(ctx Context, config Config) {
title := "Dependencies in out found with no rule to create them:" title := "Dependencies in out found with no rule to create them:"
fmt.Fprintln(sb, title) fmt.Fprintln(sb, title)
report_lines := 1 reportLines := 1
for i, dep := range danglingRulesList { for i, dep := range danglingRulesList {
if report_lines > 20 { if reportLines > 20 {
fmt.Fprintf(sb, " ... and %d more\n", len(danglingRulesList)-i) fmt.Fprintf(sb, " ... and %d more\n", len(danglingRulesList)-i)
break break
} }
// It's helpful to see the reverse dependencies. ninja -t query is the // It's helpful to see the reverse dependencies. ninja -t query is the
// best tool we got for that. Its output starts with the dependency // best tool we got for that. Its output starts with the dependency
// itself. // itself.
query_cmd := Command(ctx, config, "ninja", executable, queryCmd := Command(ctx, config, "ninja", executable,
append(common_args, "-t", "query", dep)...) append(commonArgs, "-t", "query", dep)...)
query_stdout, err := query_cmd.StdoutPipe() queryStdout, err := queryCmd.StdoutPipe()
if err != nil { if err != nil {
ctx.Fatal(err) ctx.Fatal(err)
} }
query_cmd.StartOrFatal() queryCmd.StartOrFatal()
scanner := bufio.NewScanner(query_stdout) scanner := bufio.NewScanner(queryStdout)
for scanner.Scan() { for scanner.Scan() {
report_lines++ reportLines++
fmt.Fprintln(sb, " ", scanner.Text()) fmt.Fprintln(sb, " ", scanner.Text())
} }
query_cmd.WaitOrFatal() queryCmd.WaitOrFatal()
} }
ts.FinishAction(status.ActionResult{ ts.FinishAction(status.ActionResult{

View file

@ -41,13 +41,13 @@ func isSmartTerminal(w io.Writer) bool {
func termSize(w io.Writer) (width int, height int, ok bool) { func termSize(w io.Writer) (width int, height int, ok bool) {
if f, ok := w.(*os.File); ok { if f, ok := w.(*os.File); ok {
var winsize struct { var winsize struct {
ws_row, ws_column uint16 wsRow, wsColumn uint16
ws_xpixel, ws_ypixel uint16 wsXpixel, wsYpixel uint16
} }
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, f.Fd(), _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, f.Fd(),
syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(&winsize)), syscall.TIOCGWINSZ, uintptr(unsafe.Pointer(&winsize)),
0, 0, 0) 0, 0, 0)
return int(winsize.ws_column), int(winsize.ws_row), err == 0 return int(winsize.wsColumn), int(winsize.wsRow), err == 0
} else if f, ok := w.(*fakeSmartTerminal); ok { } else if f, ok := w.(*fakeSmartTerminal); ok {
return f.termWidth, f.termHeight, true return f.termWidth, f.termHeight, true
} }