Merge "Fix the git_master_bazel mixed build breakage."
diff --git a/android/allowlists/allowlists.go b/android/allowlists/allowlists.go
index e981ad5..16f144e 100644
--- a/android/allowlists/allowlists.go
+++ b/android/allowlists/allowlists.go
@@ -69,6 +69,9 @@
"build/soong/scripts": Bp2BuildDefaultTrueRecursively,
"cts/common/device-side/nativetesthelper/jni": Bp2BuildDefaultTrueRecursively,
+
+ "dalvik/tools/dexdeps": Bp2BuildDefaultTrueRecursively,
+
"development/apps/DevelopmentSettings": Bp2BuildDefaultTrue,
"development/apps/Fallback": Bp2BuildDefaultTrue,
"development/apps/WidgetPreview": Bp2BuildDefaultTrue,
@@ -176,7 +179,7 @@
"external/zopfli": Bp2BuildDefaultTrueRecursively,
"external/zstd": Bp2BuildDefaultTrueRecursively,
- "frameworks/av": Bp2BuildDefaultTrue,
+ "frameworks/av": Bp2BuildDefaultTrue,
"frameworks/av/media/codec2/components/aom": Bp2BuildDefaultTrueRecursively,
"frameworks/av/media/codecs": Bp2BuildDefaultTrueRecursively,
"frameworks/av/media/liberror": Bp2BuildDefaultTrueRecursively,
@@ -1346,5 +1349,5 @@
// Staging-mode allowlist. Modules in this list are only built
// by Bazel with --bazel-mode-staging. This list should contain modules
// which will soon be added to the prod allowlist.
- StagingMixedBuildsEnabledList = []string{}
+ StagingMixedBuildsEnabledList = []string{"com.android.tzdata"}
)
diff --git a/android/bazel_handler.go b/android/bazel_handler.go
index f289c56..eec78d2 100644
--- a/android/bazel_handler.go
+++ b/android/bazel_handler.go
@@ -317,7 +317,7 @@
func (bazelCtx *bazelContext) GetApexInfo(label string, cfgKey configKey) (cquery.ApexInfo, error) {
key := makeCqueryKey(label, cquery.GetApexInfo, cfgKey)
if rawString, ok := bazelCtx.results[key]; ok {
- return cquery.GetApexInfo.ParseResult(strings.TrimSpace(rawString)), nil
+ return cquery.GetApexInfo.ParseResult(strings.TrimSpace(rawString))
}
return cquery.ApexInfo{}, fmt.Errorf("no bazel response found for %v", key)
}
@@ -325,7 +325,7 @@
func (bazelCtx *bazelContext) GetCcUnstrippedInfo(label string, cfgKey configKey) (cquery.CcUnstrippedInfo, error) {
key := makeCqueryKey(label, cquery.GetCcUnstrippedInfo, cfgKey)
if rawString, ok := bazelCtx.results[key]; ok {
- return cquery.GetCcUnstrippedInfo.ParseResult(strings.TrimSpace(rawString)), nil
+ return cquery.GetCcUnstrippedInfo.ParseResult(strings.TrimSpace(rawString))
}
return cquery.CcUnstrippedInfo{}, fmt.Errorf("no bazel response for %s", key)
}
@@ -571,7 +571,9 @@
// Suppress noise
"--ui_event_filters=-INFO",
- "--noshow_progress"}
+ "--noshow_progress",
+ "--norun_validations",
+ }
cmdFlags = append(cmdFlags, extraFlags...)
bazelCmd := exec.Command(paths.bazelPath, cmdFlags...)
diff --git a/apex/androidmk.go b/apex/androidmk.go
index ea42c3c..3373211 100644
--- a/apex/androidmk.go
+++ b/apex/androidmk.go
@@ -339,14 +339,14 @@
func (a *apexBundle) androidMkForType() android.AndroidMkData {
return android.AndroidMkData{
Custom: func(w io.Writer, name, prefix, moduleDir string, data android.AndroidMkData) {
+ moduleNames := []string{}
apexType := a.properties.ApexType
+ if a.installable() {
+ apexName := proptools.StringDefault(a.properties.Apex_name, name)
+ moduleNames = a.androidMkForFiles(w, name, apexName, moduleDir, data)
+ }
if apexType == flattenedApex {
- var moduleNames []string = nil
- if a.installable() {
- apexName := proptools.StringDefault(a.properties.Apex_name, name)
- moduleNames = a.androidMkForFiles(w, name, apexName, moduleDir, data)
- }
// Only image APEXes can be flattened.
fmt.Fprintln(w, "\ninclude $(CLEAR_VARS)")
fmt.Fprintln(w, "LOCAL_PATH :=", moduleDir)
@@ -390,7 +390,7 @@
if len(a.overridableProperties.Overrides) > 0 {
fmt.Fprintln(w, "LOCAL_OVERRIDES_MODULES :=", strings.Join(a.overridableProperties.Overrides, " "))
}
- a.writeRequiredModules(w, nil)
+ a.writeRequiredModules(w, moduleNames)
fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
diff --git a/apex/apex.go b/apex/apex.go
index 3676607..72403f9 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -1903,14 +1903,14 @@
apexType := a.properties.ApexType
switch apexType {
case imageApex:
+
// TODO(b/190817312): Generate the notice file from the apex rule.
a.htmlGzNotice = android.PathForBazelOut(ctx, "NOTICE.html.gz")
- // TODO(b/239081457): Generate the bazel bundle module file from the apex rule.
- a.bundleModuleFile = android.PathForBazelOut(ctx, a.Name()+apexType.suffix()+"-base.zip")
+ a.bundleModuleFile = android.PathForBazelOut(ctx, outputs.BundleFile)
a.nativeApisUsedByModuleFile = android.ModuleOutPath(android.PathForBazelOut(ctx, outputs.SymbolsUsedByApex))
a.nativeApisBackedByModuleFile = android.ModuleOutPath(android.PathForBazelOut(ctx, outputs.BackingLibs))
// TODO(b/239084755): Generate the java api using.xml file from Bazel.
- a.javaApisUsedByModuleFile = android.ModuleOutPath(android.PathForBazelOut(ctx, a.Name()+"_using.xml"))
+ a.javaApisUsedByModuleFile = android.ModuleOutPath(android.PathForBazelOut(ctx, outputs.JavaSymbolsUsedByApex))
installSuffix := imageApexSuffix
if a.isCompressed {
installSuffix = imageCapexSuffix
diff --git a/apex/apex_test.go b/apex/apex_test.go
index d8debef..985ad59 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -527,6 +527,7 @@
data.Custom(&builder, ab.BaseModuleName(), "TARGET_", "", data)
androidMk := builder.String()
+ ensureContains(t, androidMk, "LOCAL_MODULE := mylib.myapex\n")
ensureNotContains(t, androidMk, "LOCAL_MODULE := mylib.com.android.myapex\n")
optFlags := apexRule.Args["opt_flags"]
@@ -4125,6 +4126,7 @@
var builder strings.Builder
data.Custom(&builder, name, prefix, "", data)
androidMk := builder.String()
+ ensureContains(t, androidMk, "LOCAL_MODULE := mylib.myapex\n")
ensureNotContains(t, androidMk, "LOCAL_MODULE := mylib.com.android.myapex\n")
}
@@ -5623,6 +5625,12 @@
var builder strings.Builder
data.Custom(&builder, name, prefix, "", data)
androidMk := builder.String()
+ ensureContains(t, androidMk, "LOCAL_MODULE := mytest.myapex\n")
+ ensureContains(t, androidMk, "LOCAL_MODULE := mytest1.myapex\n")
+ ensureContains(t, androidMk, "LOCAL_MODULE := mytest2.myapex\n")
+ ensureContains(t, androidMk, "LOCAL_MODULE := mytest3.myapex\n")
+ ensureContains(t, androidMk, "LOCAL_MODULE := apex_manifest.pb.myapex\n")
+ ensureContains(t, androidMk, "LOCAL_MODULE := apex_pubkey.myapex\n")
ensureContains(t, androidMk, "LOCAL_MODULE := myapex\n")
flatBundle := ctx.ModuleForTests("myapex", "android_common_myapex_flattened").Module().(*apexBundle)
@@ -6449,6 +6457,12 @@
var builder strings.Builder
data.Custom(&builder, name, "TARGET_", "", data)
androidMk := builder.String()
+ ensureContains(t, androidMk, "LOCAL_MODULE := override_app.override_myapex")
+ ensureContains(t, androidMk, "LOCAL_MODULE := overrideBpf.o.override_myapex")
+ ensureContains(t, androidMk, "LOCAL_MODULE := apex_manifest.pb.override_myapex")
+ ensureContains(t, androidMk, "LOCAL_MODULE := override_bcplib.override_myapex")
+ ensureContains(t, androidMk, "LOCAL_MODULE := override_systemserverlib.override_myapex")
+ ensureContains(t, androidMk, "LOCAL_MODULE := override_java_library.override_myapex")
ensureContains(t, androidMk, "LOCAL_MODULE_STEM := override_myapex.apex")
ensureContains(t, androidMk, "LOCAL_OVERRIDES_MODULES := unknownapex myapex")
ensureNotContains(t, androidMk, "LOCAL_MODULE := app.myapex")
@@ -7178,17 +7192,17 @@
}
`)
- apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_flattened").Module().(*apexBundle)
+ apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
data := android.AndroidMkDataForTest(t, ctx, apexBundle)
var builder strings.Builder
data.Custom(&builder, apexBundle.BaseModuleName(), "TARGET_", "", data)
androidMk := builder.String()
// `myotherlib` is added to `myapex` as symlink
- ensureContains(t, androidMk, "LOCAL_MODULE := mylib.myapex.flattened\n")
+ ensureContains(t, androidMk, "LOCAL_MODULE := mylib.myapex\n")
ensureNotContains(t, androidMk, "LOCAL_MODULE := prebuilt_myotherlib.myapex\n")
ensureNotContains(t, androidMk, "LOCAL_MODULE := myotherlib.myapex\n")
// `myapex` should have `myotherlib` in its required line, not `prebuilt_myotherlib`
- ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += mylib.myapex.flattened:64 myotherlib:64 apex_manifest.pb.myapex.flattened apex_pubkey.myapex.flattened\n")
+ ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += mylib.myapex:64 myotherlib:64 apex_manifest.pb.myapex apex_pubkey.myapex\n")
}
func TestApexWithJniLibs(t *testing.T) {
@@ -9754,11 +9768,13 @@
OutputBaseDir: outputBaseDir,
LabelToApexInfo: map[string]cquery.ApexInfo{
"//:foo": cquery.ApexInfo{
- SignedOutput: "signed_out.apex",
- UnsignedOutput: "unsigned_out.apex",
- BundleKeyInfo: []string{"public_key", "private_key"},
- ContainerKeyInfo: []string{"container_cert", "container_private"},
- SymbolsUsedByApex: "foo_using.txt",
+ SignedOutput: "signed_out.apex",
+ UnsignedOutput: "unsigned_out.apex",
+ BundleKeyInfo: []string{"public_key", "private_key"},
+ ContainerKeyInfo: []string{"container_cert", "container_private"},
+ SymbolsUsedByApex: "foo_using.txt",
+ JavaSymbolsUsedByApex: "foo_using.xml",
+ BundleFile: "apex_bundle.zip",
// unused
PackageName: "pkg_name",
@@ -9799,4 +9815,17 @@
if w, g := "out/bazel/execroot/__main__/foo_using.txt", ab.nativeApisUsedByModuleFile.String(); w != g {
t.Errorf("Expected output file %q, got %q", w, g)
}
+
+ if w, g := "out/bazel/execroot/__main__/foo_using.xml", ab.javaApisUsedByModuleFile.String(); w != g {
+ t.Errorf("Expected output file %q, got %q", w, g)
+ }
+
+ mkData := android.AndroidMkDataForTest(t, result.TestContext, m)
+ var builder strings.Builder
+ mkData.Custom(&builder, "foo", "BAZEL_TARGET_", "", mkData)
+
+ data := builder.String()
+ if w := "ALL_MODULES.$(my_register_name).BUNDLE := out/bazel/execroot/__main__/apex_bundle.zip"; !strings.Contains(data, w) {
+ t.Errorf("Expected %q in androidmk data, but did not find %q", w, data)
+ }
}
diff --git a/bazel/cquery/request_type.go b/bazel/cquery/request_type.go
index e47e85f..eb44dd1 100644
--- a/bazel/cquery/request_type.go
+++ b/bazel/cquery/request_type.go
@@ -30,6 +30,7 @@
// be a subset of OutputFiles. (or shared libraries, this will be equal to OutputFiles,
// but general cc_library will also have dynamic libraries in output files).
RootDynamicLibraries []string
+ TidyFiles []string
TocFile string
UnstrippedOutput string
}
@@ -165,6 +166,12 @@
# NOTE: It's OK if there's no ToC, as Soong just uses it for optimization
pass
+tidy_files = []
+p = providers(target)
+clang_tidy_info = p.get("//build/bazel/rules/cc:clang_tidy.bzl%ClangTidyInfo")
+if clang_tidy_info:
+ tidy_files = [v.path for v in clang_tidy_info.tidy_files.to_list()]
+
return json_encode({
"OutputFiles": outputFiles,
"CcObjectFiles": ccObjectFiles,
@@ -175,6 +182,7 @@
"Headers": headers,
"RootStaticArchives": rootStaticArchives,
"RootDynamicLibraries": rootSharedLibraries,
+ "TidyFiles": tidy_files,
"TocFile": toc_file,
"UnstrippedOutput": unstripped,
})`
@@ -186,7 +194,9 @@
// Starlark given in StarlarkFunctionBody.
func (g getCcInfoType) ParseResult(rawString string) (CcInfo, error) {
var ccInfo CcInfo
- parseJson(rawString, &ccInfo)
+ if err := parseJson(rawString, &ccInfo); err != nil {
+ return ccInfo, err
+ }
return ccInfo, nil
}
@@ -219,29 +229,33 @@
"container_key_info": [container_key_info.pem.path, container_key_info.pk8.path, container_key_info.key_name],
"package_name": info.package_name,
"symbols_used_by_apex": info.symbols_used_by_apex.path,
+ "java_symbols_used_by_apex": info.java_symbols_used_by_apex.path,
"backing_libs": info.backing_libs.path,
+ "bundle_file": info.base_with_config_zip.path,
})`
}
type ApexInfo struct {
- SignedOutput string `json:"signed_output"`
- UnsignedOutput string `json:"unsigned_output"`
- ProvidesLibs []string `json:"provides_native_libs"`
- RequiresLibs []string `json:"requires_native_libs"`
- BundleKeyInfo []string `json:"bundle_key_info"`
- ContainerKeyInfo []string `json:"container_key_info"`
- PackageName string `json:"package_name"`
- SymbolsUsedByApex string `json:"symbols_used_by_apex"`
- BackingLibs string `json:"backing_libs"`
+ SignedOutput string `json:"signed_output"`
+ UnsignedOutput string `json:"unsigned_output"`
+ ProvidesLibs []string `json:"provides_native_libs"`
+ RequiresLibs []string `json:"requires_native_libs"`
+ BundleKeyInfo []string `json:"bundle_key_info"`
+ ContainerKeyInfo []string `json:"container_key_info"`
+ PackageName string `json:"package_name"`
+ SymbolsUsedByApex string `json:"symbols_used_by_apex"`
+ JavaSymbolsUsedByApex string `json:"java_symbols_used_by_apex"`
+ BackingLibs string `json:"backing_libs"`
+ BundleFile string `json:"bundle_file"`
}
// ParseResult returns a value obtained by parsing the result of the request's Starlark function.
// The given rawString must correspond to the string output which was created by evaluating the
// Starlark given in StarlarkFunctionBody.
-func (g getApexInfoType) ParseResult(rawString string) ApexInfo {
+func (g getApexInfoType) ParseResult(rawString string) (ApexInfo, error) {
var info ApexInfo
- parseJson(rawString, &info)
- return info
+ err := parseJson(rawString, &info)
+ return info, err
}
// getCcUnstrippedInfoType implements cqueryRequest interface. It handles the
@@ -270,10 +284,10 @@
// ParseResult returns a value obtained by parsing the result of the request's Starlark function.
// The given rawString must correspond to the string output which was created by evaluating the
// Starlark given in StarlarkFunctionBody.
-func (g getCcUnstippedInfoType) ParseResult(rawString string) CcUnstrippedInfo {
+func (g getCcUnstippedInfoType) ParseResult(rawString string) (CcUnstrippedInfo, error) {
var info CcUnstrippedInfo
- parseJson(rawString, &info)
- return info
+ err := parseJson(rawString, &info)
+ return info, err
}
type CcUnstrippedInfo struct {
@@ -293,10 +307,12 @@
// parseJson decodes json string into the fields of the receiver.
// Unknown attribute name causes panic.
-func parseJson(jsonString string, info interface{}) {
+func parseJson(jsonString string, info interface{}) error {
decoder := json.NewDecoder(strings.NewReader(jsonString))
decoder.DisallowUnknownFields() //useful to detect typos, e.g. in unit tests
- if err := decoder.Decode(info); err != nil {
- panic(fmt.Errorf("cannot parse cquery result '%s': %s", jsonString, err))
+ err := decoder.Decode(info)
+ if err != nil {
+ return fmt.Errorf("cannot parse cquery result '%s': %s", jsonString, err)
}
+ return nil
}
diff --git a/bazel/cquery/request_type_test.go b/bazel/cquery/request_type_test.go
index 2c35489..a0a993f 100644
--- a/bazel/cquery/request_type_test.go
+++ b/bazel/cquery/request_type_test.go
@@ -3,10 +3,12 @@
import (
"encoding/json"
"reflect"
+ "strings"
"testing"
)
func TestGetOutputFilesParseResults(t *testing.T) {
+ t.Parallel()
testCases := []struct {
description string
input string
@@ -29,14 +31,17 @@
},
}
for _, tc := range testCases {
- actualOutput := GetOutputFiles.ParseResult(tc.input)
- if !reflect.DeepEqual(tc.expectedOutput, actualOutput) {
- t.Errorf("%q: expected %#v != actual %#v", tc.description, tc.expectedOutput, actualOutput)
- }
+ t.Run(tc.description, func(t *testing.T) {
+ actualOutput := GetOutputFiles.ParseResult(tc.input)
+ if !reflect.DeepEqual(tc.expectedOutput, actualOutput) {
+ t.Errorf("expected %#v != actual %#v", tc.expectedOutput, actualOutput)
+ }
+ })
}
}
func TestGetPythonBinaryParseResults(t *testing.T) {
+ t.Parallel()
testCases := []struct {
description string
input string
@@ -54,14 +59,17 @@
},
}
for _, tc := range testCases {
- actualOutput := GetPythonBinary.ParseResult(tc.input)
- if !reflect.DeepEqual(tc.expectedOutput, actualOutput) {
- t.Errorf("%q: expected %#v != actual %#v", tc.description, tc.expectedOutput, actualOutput)
- }
+ t.Run(tc.description, func(t *testing.T) {
+ actualOutput := GetPythonBinary.ParseResult(tc.input)
+ if !reflect.DeepEqual(tc.expectedOutput, actualOutput) {
+ t.Errorf("expected %#v != actual %#v", tc.expectedOutput, actualOutput)
+ }
+ })
}
}
func TestGetCcInfoParseResults(t *testing.T) {
+ t.Parallel()
testCases := []struct {
description string
inputCcInfo CcInfo
@@ -73,24 +81,6 @@
expectedOutput: CcInfo{},
},
{
- description: "only output",
- inputCcInfo: CcInfo{
- OutputFiles: []string{"test", "test3"},
- },
- expectedOutput: CcInfo{
- OutputFiles: []string{"test", "test3"},
- },
- },
- {
- description: "only ToC",
- inputCcInfo: CcInfo{
- TocFile: "test",
- },
- expectedOutput: CcInfo{
- TocFile: "test",
- },
- },
- {
description: "all items set",
inputCcInfo: CcInfo{
OutputFiles: []string{"out1", "out2"},
@@ -119,17 +109,51 @@
},
}
for _, tc := range testCases {
- jsonInput, _ := json.Marshal(tc.inputCcInfo)
- actualOutput, err := GetCcInfo.ParseResult(string(jsonInput))
- if err != nil {
- t.Errorf("%q:\n test case get error: %q", tc.description, err)
- } else if err == nil && !reflect.DeepEqual(tc.expectedOutput, actualOutput) {
- t.Errorf("%q:\n expected %#v\n!= actual %#v", tc.description, tc.expectedOutput, actualOutput)
- }
+ t.Run(tc.description, func(t *testing.T) {
+ jsonInput, _ := json.Marshal(tc.inputCcInfo)
+ actualOutput, err := GetCcInfo.ParseResult(string(jsonInput))
+ if err != nil {
+ t.Errorf("error parsing result: %q", err)
+ } else if err == nil && !reflect.DeepEqual(tc.expectedOutput, actualOutput) {
+ t.Errorf("expected %#v\n!= actual %#v", tc.expectedOutput, actualOutput)
+ }
+ })
+ }
+}
+
+func TestGetCcInfoParseResultsError(t *testing.T) {
+ t.Parallel()
+ testCases := []struct {
+ description string
+ input string
+ expectedError string
+ }{
+ {
+ description: "not json",
+ input: ``,
+ expectedError: `cannot parse cquery result '': EOF`,
+ },
+ {
+ description: "invalid field",
+ input: `{
+ "toc_file": "dir/file.so.toc"
+}`,
+ expectedError: `json: unknown field "toc_file"`,
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.description, func(t *testing.T) {
+ _, err := GetCcInfo.ParseResult(tc.input)
+ if !strings.Contains(err.Error(), tc.expectedError) {
+ t.Errorf("expected string %q in error message, got %q", tc.expectedError, err)
+ }
+ })
}
}
func TestGetApexInfoParseResults(t *testing.T) {
+ t.Parallel()
testCases := []struct {
description string
input string
@@ -142,15 +166,18 @@
},
{
description: "one result",
- input: `{"signed_output":"my.apex",` +
- `"unsigned_output":"my.apex.unsigned",` +
- `"requires_native_libs":["//bionic/libc:libc","//bionic/libdl:libdl"],` +
- `"bundle_key_info":["foo.pem", "foo.privkey"],` +
- `"container_key_info":["foo.x509.pem", "foo.pk8", "foo"],` +
- `"package_name":"package.name",` +
- `"symbols_used_by_apex": "path/to/my.apex_using.txt",` +
- `"backing_libs":"path/to/backing.txt",` +
- `"provides_native_libs":[]}`,
+ input: `{
+ "signed_output":"my.apex",
+ "unsigned_output":"my.apex.unsigned",
+ "requires_native_libs":["//bionic/libc:libc","//bionic/libdl:libdl"],
+ "bundle_key_info":["foo.pem", "foo.privkey"],
+ "container_key_info":["foo.x509.pem", "foo.pk8", "foo"],
+ "package_name":"package.name",
+ "symbols_used_by_apex": "path/to/my.apex_using.txt",
+ "backing_libs":"path/to/backing.txt",
+ "bundle_file": "dir/bundlefile.zip",
+ "provides_native_libs":[]
+}`,
expectedOutput: ApexInfo{
SignedOutput: "my.apex",
UnsignedOutput: "my.apex.unsigned",
@@ -161,18 +188,56 @@
PackageName: "package.name",
SymbolsUsedByApex: "path/to/my.apex_using.txt",
BackingLibs: "path/to/backing.txt",
+ BundleFile: "dir/bundlefile.zip",
},
},
}
for _, tc := range testCases {
- actualOutput := GetApexInfo.ParseResult(tc.input)
- if !reflect.DeepEqual(tc.expectedOutput, actualOutput) {
- t.Errorf("%q: expected %#v != actual %#v", tc.description, tc.expectedOutput, actualOutput)
- }
+ t.Run(tc.description, func(t *testing.T) {
+ actualOutput, err := GetApexInfo.ParseResult(tc.input)
+ if err != nil {
+ t.Errorf("Unexpected error %q", err)
+ }
+ if !reflect.DeepEqual(tc.expectedOutput, actualOutput) {
+ t.Errorf("expected %#v != actual %#v", tc.expectedOutput, actualOutput)
+ }
+ })
+ }
+}
+
+func TestGetApexInfoParseResultsError(t *testing.T) {
+ t.Parallel()
+ testCases := []struct {
+ description string
+ input string
+ expectedError string
+ }{
+ {
+ description: "not json",
+ input: ``,
+ expectedError: `cannot parse cquery result '': EOF`,
+ },
+ {
+ description: "invalid field",
+ input: `{
+ "fake_field": "path/to/file"
+}`,
+ expectedError: `json: unknown field "fake_field"`,
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.description, func(t *testing.T) {
+ _, err := GetApexInfo.ParseResult(tc.input)
+ if !strings.Contains(err.Error(), tc.expectedError) {
+ t.Errorf("expected string %q in error message, got %q", tc.expectedError, err)
+ }
+ })
}
}
func TestGetCcUnstrippedParseResults(t *testing.T) {
+ t.Parallel()
testCases := []struct {
description string
input string
@@ -193,9 +258,45 @@
},
}
for _, tc := range testCases {
- actualOutput := GetCcUnstrippedInfo.ParseResult(tc.input)
- if !reflect.DeepEqual(tc.expectedOutput, actualOutput) {
- t.Errorf("%q: expected %#v != actual %#v", tc.description, tc.expectedOutput, actualOutput)
- }
+ t.Run(tc.description, func(t *testing.T) {
+ actualOutput, err := GetCcUnstrippedInfo.ParseResult(tc.input)
+ if err != nil {
+ t.Errorf("Unexpected error %q", err)
+ }
+ if !reflect.DeepEqual(tc.expectedOutput, actualOutput) {
+ t.Errorf("expected %#v != actual %#v", tc.expectedOutput, actualOutput)
+ }
+ })
+ }
+}
+
+func TestGetCcUnstrippedParseResultsErrors(t *testing.T) {
+ t.Parallel()
+ testCases := []struct {
+ description string
+ input string
+ expectedError string
+ }{
+ {
+ description: "not json",
+ input: ``,
+ expectedError: `cannot parse cquery result '': EOF`,
+ },
+ {
+ description: "invalid field",
+ input: `{
+ "fake_field": "path/to/file"
+}`,
+ expectedError: `json: unknown field "fake_field"`,
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.description, func(t *testing.T) {
+ _, err := GetCcUnstrippedInfo.ParseResult(tc.input)
+ if !strings.Contains(err.Error(), tc.expectedError) {
+ t.Errorf("expected string %q in error message, got %q", tc.expectedError, err)
+ }
+ })
}
}
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go
index 0d6d5b8..4c86374 100644
--- a/bp2build/cc_library_conversion_test.go
+++ b/bp2build/cc_library_conversion_test.go
@@ -3508,3 +3508,38 @@
},
})
}
+
+func TestCcLibraryWithTidy(t *testing.T) {
+ runCcLibraryTestCase(t, Bp2buildTestCase{
+ Description: "cc_library uses tidy properties",
+ ModuleTypeUnderTest: "cc_library",
+ ModuleTypeUnderTestFactory: cc.LibraryFactory,
+ Blueprint: `
+cc_library_static {
+ name: "foo",
+ srcs: ["foo.cpp"],
+ tidy: true,
+ tidy_checks: ["check1", "check2"],
+ tidy_checks_as_errors: ["check1error", "check2error"],
+ tidy_disabled_srcs: ["bar.cpp"],
+ tidy_timeout_srcs: ["baz.cpp"],
+}`,
+ ExpectedBazelTargets: []string{
+ MakeBazelTarget("cc_library_static", "foo", AttrNameToString{
+ "local_includes": `["."]`,
+ "srcs": `["foo.cpp"]`,
+ "tidy": `True`,
+ "tidy_checks": `[
+ "check1",
+ "check2",
+ ]`,
+ "tidy_checks_as_errors": `[
+ "check1error",
+ "check2error",
+ ]`,
+ "tidy_disabled_srcs": `["bar.cpp"]`,
+ "tidy_timeout_srcs": `["baz.cpp"]`,
+ }),
+ },
+ })
+}
diff --git a/bpf/bpf.go b/bpf/bpf.go
index 60a410d..7376750 100644
--- a/bpf/bpf.go
+++ b/bpf/bpf.go
@@ -18,6 +18,7 @@
"fmt"
"io"
"path/filepath"
+ "runtime"
"strings"
"android/soong/android"
@@ -31,6 +32,9 @@
func init() {
registerBpfBuildComponents(android.InitRegistrationContext)
pctx.Import("android/soong/cc/config")
+ if runtime.GOOS != "darwin" {
+ pctx.StaticVariable("relPwd", "PWD=/proc/self/cwd")
+ }
}
var (
@@ -40,7 +44,7 @@
blueprint.RuleParams{
Depfile: "${out}.d",
Deps: blueprint.DepsGCC,
- Command: "$ccCmd --target=bpf -c $cFlags -MD -MF ${out}.d -o $out $in",
+ Command: "$relPwd $ccCmd --target=bpf -c $cFlags -MD -MF ${out}.d -o $out $in",
CommandDeps: []string{"$ccCmd"},
},
"ccCmd", "cFlags")
@@ -164,6 +168,9 @@
if proptools.Bool(bpf.properties.Btf) {
cflags = append(cflags, "-g")
+ if runtime.GOOS != "darwin" {
+ cflags = append(cflags, "-fdebug-prefix-map=/proc/self/cwd=")
+ }
}
srcs := android.PathsForModuleSrc(ctx, bpf.properties.Srcs)
diff --git a/cc/binary.go b/cc/binary.go
index d09e744..c2868e7 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -646,7 +646,7 @@
sdkAttributes: bp2BuildParseSdkAttributes(m),
}
- m.convertTidyAttributes(&attrs.tidyAttributes)
+ m.convertTidyAttributes(ctx, &attrs.tidyAttributes)
return attrs
}
diff --git a/cc/bp2build.go b/cc/bp2build.go
index 2f79cae..6caa854 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -75,9 +75,11 @@
Tidy_flags []string
Tidy_checks []string
Tidy_checks_as_errors []string
+ Tidy_disabled_srcs bazel.LabelListAttribute
+ Tidy_timeout_srcs bazel.LabelListAttribute
}
-func (m *Module) convertTidyAttributes(moduleAttrs *tidyAttributes) {
+func (m *Module) convertTidyAttributes(ctx android.BaseMutatorContext, moduleAttrs *tidyAttributes) {
for _, f := range m.features {
if tidy, ok := f.(*tidyFeature); ok {
moduleAttrs.Tidy = tidy.Properties.Tidy
@@ -85,6 +87,18 @@
moduleAttrs.Tidy_checks = tidy.Properties.Tidy_checks
moduleAttrs.Tidy_checks_as_errors = tidy.Properties.Tidy_checks_as_errors
}
+
+ }
+ archVariantProps := m.GetArchVariantProperties(ctx, &BaseCompilerProperties{})
+ for axis, configToProps := range archVariantProps {
+ for config, _props := range configToProps {
+ if archProps, ok := _props.(*BaseCompilerProperties); ok {
+ archDisabledSrcs := android.BazelLabelForModuleSrc(ctx, archProps.Tidy_disabled_srcs)
+ moduleAttrs.Tidy_disabled_srcs.SetSelectValue(axis, config, archDisabledSrcs)
+ archTimeoutSrcs := android.BazelLabelForModuleSrc(ctx, archProps.Tidy_timeout_srcs)
+ moduleAttrs.Tidy_timeout_srcs.SetSelectValue(axis, config, archTimeoutSrcs)
+ }
+ }
}
}
diff --git a/cc/cc.go b/cc/cc.go
index 8840631..306e483 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -1853,6 +1853,11 @@
func (c *Module) ProcessBazelQueryResponse(ctx android.ModuleContext) {
bazelModuleLabel := c.getBazelModuleLabel(ctx)
+ bazelCtx := ctx.Config().BazelContext
+ if ccInfo, err := bazelCtx.GetCcInfo(bazelModuleLabel, android.GetConfigKey(ctx)); err == nil {
+ c.tidyFiles = android.PathsForBazelOut(ctx, ccInfo.TidyFiles)
+ }
+
c.bazelHandler.ProcessBazelQueryResponse(ctx, bazelModuleLabel)
c.Properties.SubName = GetSubnameProperty(ctx, c)
diff --git a/cc/library.go b/cc/library.go
index aefb804..03a5575 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -956,7 +956,7 @@
for _, path := range paths {
dir := path.String()
// Skip if dir is for generated headers
- if strings.HasPrefix(dir, android.PathForOutput(ctx).String()) {
+ if strings.HasPrefix(dir, ctx.Config().OutDir()) {
continue
}
@@ -2792,7 +2792,7 @@
Runtime_deps: linkerAttrs.runtimeDeps,
}
- module.convertTidyAttributes(&commonAttrs.tidyAttributes)
+ module.convertTidyAttributes(ctx, &commonAttrs.tidyAttributes)
var attrs interface{}
if isStatic {
diff --git a/cc/test.go b/cc/test.go
index 92055fa..536210b 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -678,7 +678,7 @@
}
}
- m.convertTidyAttributes(&testBinaryAttrs.tidyAttributes)
+ m.convertTidyAttributes(ctx, &testBinaryAttrs.tidyAttributes)
for _, propIntf := range m.GetProperties() {
if testLinkerProps, ok := propIntf.(*TestLinkerProperties); ok {