Merge changes from topic "soong_prebuilts_misc_common"
* changes:
Fix finding src directory for aidl
Support multiple outputs in genrules with depfile: true
Support installable prebuilt jars
diff --git a/cc/cc_test.go b/cc/cc_test.go
index b9cdba5..dc04a4e 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -603,5 +603,89 @@
expected,
)
}
+}
+var compilerFlagsTestCases = []struct {
+ in string
+ out bool
+}{
+ {
+ in: "a",
+ out: false,
+ },
+ {
+ in: "-a",
+ out: true,
+ },
+ {
+ in: "-Ipath/to/something",
+ out: false,
+ },
+ {
+ in: "-isystempath/to/something",
+ out: false,
+ },
+ {
+ in: "--coverage",
+ out: false,
+ },
+ {
+ in: "-include a/b",
+ out: true,
+ },
+ {
+ in: "-include a/b c/d",
+ out: false,
+ },
+ {
+ in: "-DMACRO",
+ out: true,
+ },
+ {
+ in: "-DMAC RO",
+ out: false,
+ },
+ {
+ in: "-a -b",
+ out: false,
+ },
+ {
+ in: "-DMACRO=definition",
+ out: true,
+ },
+ {
+ in: "-DMACRO=defi nition",
+ out: true, // TODO(jiyong): this should be false
+ },
+ {
+ in: "-DMACRO(x)=x + 1",
+ out: true,
+ },
+ {
+ in: "-DMACRO=\"defi nition\"",
+ out: true,
+ },
+}
+
+type mockContext struct {
+ BaseModuleContext
+ result bool
+}
+
+func (ctx *mockContext) PropertyErrorf(property, format string, args ...interface{}) {
+ // CheckBadCompilerFlags calls this function when the flag should be rejected
+ ctx.result = false
+}
+
+func TestCompilerFlags(t *testing.T) {
+ for _, testCase := range compilerFlagsTestCases {
+ ctx := &mockContext{result: true}
+ CheckBadCompilerFlags(ctx, "", []string{testCase.in})
+ if ctx.result != testCase.out {
+ t.Errorf("incorrect output:")
+ t.Errorf(" input: %#v", testCase.in)
+ t.Errorf(" expected: %#v", testCase.out)
+ t.Errorf(" got: %#v", ctx.result)
+ }
+ }
}
diff --git a/cc/check.go b/cc/check.go
index d04b145..4e9e160 100644
--- a/cc/check.go
+++ b/cc/check.go
@@ -50,6 +50,11 @@
} else if strings.HasPrefix("../", path) {
ctx.PropertyErrorf(prop, "Path must not start with `../`: `%s`. Use include_dirs to -include from a different directory", flag)
}
+ } else if strings.HasPrefix(flag, "-D") && strings.Contains(flag, "=") {
+ // Do nothing in this case.
+ // For now, we allow space characters in -DNAME=def form to allow use cases
+ // like -DNAME="value with string". Later, this check should be done more
+ // correctly to prevent multi flag cases like -DNAME=value -O2.
} else {
ctx.PropertyErrorf(prop, "Bad flag: `%s` is not an allowed multi-word flag. Should it be split into multiple flags?", flag)
}
diff --git a/cc/test.go b/cc/test.go
index fa75f48..9df3467 100644
--- a/cc/test.go
+++ b/cc/test.go
@@ -175,11 +175,16 @@
}
func (test *testDecorator) linkerInit(ctx BaseModuleContext, linker *baseLinker) {
+ // add ../../lib[64] to rpath so that out/host/linux-x86/nativetest/<test dir>/<test> can
+ // find out/host/linux-x86/lib[64]/library.so
runpath := "../../lib"
if ctx.toolchain().Is64Bit() {
runpath += "64"
}
linker.dynamicProperties.RunPaths = append(linker.dynamicProperties.RunPaths, runpath)
+
+ // add "" to rpath so that test binaries can find libraries in their own test directory
+ linker.dynamicProperties.RunPaths = append(linker.dynamicProperties.RunPaths, "")
}
func (test *testDecorator) linkerProps() []interface{} {