Add "aidl.flags:" property for cc_/java_ modules
The property can be used to pass additional flags to the AIDL compiler. For example, cc_library { .. srcs: ["Foo.aidl"], aidl: { flags: [ "-Werror", // warnings as error "-Weverything", // turn on all warnings ], }, } Bug: 168028537 Test: soong test Change-Id: I8120eeae7cd7b1acdd34c554af996a29e760a368
This commit is contained in:
@@ -4244,3 +4244,21 @@ func TestStubsLibReexportsHeaders(t *testing.T) {
|
|||||||
t.Errorf("expected %q in cflags, got %q", "-Iinclude/libbar", cFlags)
|
t.Errorf("expected %q in cflags, got %q", "-Iinclude/libbar", cFlags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAidlFlagsPassedToTheAidlCompiler(t *testing.T) {
|
||||||
|
ctx := testCc(t, `
|
||||||
|
cc_library {
|
||||||
|
name: "libfoo",
|
||||||
|
srcs: ["a/Foo.aidl"],
|
||||||
|
aidl: { flags: ["-Werror"], },
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
libfoo := ctx.ModuleForTests("libfoo", "android_arm64_armv8-a_static")
|
||||||
|
manifest := android.RuleBuilderSboxProtoForTests(t, libfoo.Output("aidl.sbox.textproto"))
|
||||||
|
aidlCommand := manifest.Commands[0].GetCommand()
|
||||||
|
expectedAidlFlag := "-Werror"
|
||||||
|
if !strings.Contains(aidlCommand, expectedAidlFlag) {
|
||||||
|
t.Errorf("aidl command %q does not contain %q", aidlCommand, expectedAidlFlag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -123,6 +123,9 @@ type BaseCompilerProperties struct {
|
|||||||
|
|
||||||
// whether to generate traces (for systrace) for this interface
|
// whether to generate traces (for systrace) for this interface
|
||||||
Generate_traces *bool
|
Generate_traces *bool
|
||||||
|
|
||||||
|
// list of flags that will be passed to the AIDL compiler
|
||||||
|
Flags []string
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderscript struct {
|
Renderscript struct {
|
||||||
@@ -521,6 +524,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
|
|||||||
}
|
}
|
||||||
|
|
||||||
if compiler.hasSrcExt(".aidl") {
|
if compiler.hasSrcExt(".aidl") {
|
||||||
|
flags.aidlFlags = append(flags.aidlFlags, compiler.Properties.Aidl.Flags...)
|
||||||
if len(compiler.Properties.Aidl.Local_include_dirs) > 0 {
|
if len(compiler.Properties.Aidl.Local_include_dirs) > 0 {
|
||||||
localAidlIncludeDirs := android.PathsForModuleSrc(ctx, compiler.Properties.Aidl.Local_include_dirs)
|
localAidlIncludeDirs := android.PathsForModuleSrc(ctx, compiler.Properties.Aidl.Local_include_dirs)
|
||||||
flags.aidlFlags = append(flags.aidlFlags, includeDirsToFlags(localAidlIncludeDirs))
|
flags.aidlFlags = append(flags.aidlFlags, includeDirsToFlags(localAidlIncludeDirs))
|
||||||
|
@@ -304,6 +304,9 @@ type CompilerDeviceProperties struct {
|
|||||||
|
|
||||||
// whether to generate Binder#GetTransaction name method.
|
// whether to generate Binder#GetTransaction name method.
|
||||||
Generate_get_transaction_name *bool
|
Generate_get_transaction_name *bool
|
||||||
|
|
||||||
|
// list of flags that will be passed to the AIDL compiler
|
||||||
|
Flags []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// If true, export a copy of the module as a -hostdex module for host testing.
|
// If true, export a copy of the module as a -hostdex module for host testing.
|
||||||
@@ -872,6 +875,8 @@ func (j *Module) aidlFlags(ctx android.ModuleContext, aidlPreprocess android.Opt
|
|||||||
var flags []string
|
var flags []string
|
||||||
var deps android.Paths
|
var deps android.Paths
|
||||||
|
|
||||||
|
flags = append(flags, j.deviceProperties.Aidl.Flags...)
|
||||||
|
|
||||||
if aidlPreprocess.Valid() {
|
if aidlPreprocess.Valid() {
|
||||||
flags = append(flags, "-p"+aidlPreprocess.String())
|
flags = append(flags, "-p"+aidlPreprocess.String())
|
||||||
deps = append(deps, aidlPreprocess.Path())
|
deps = append(deps, aidlPreprocess.Path())
|
||||||
|
@@ -2424,6 +2424,22 @@ func TestAidlExportIncludeDirsFromImports(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAidlFlagsArePassedToTheAidlCompiler(t *testing.T) {
|
||||||
|
ctx, _ := testJava(t, `
|
||||||
|
java_library {
|
||||||
|
name: "foo",
|
||||||
|
srcs: ["aidl/foo/IFoo.aidl"],
|
||||||
|
aidl: { flags: ["-Werror"], },
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
aidlCommand := ctx.ModuleForTests("foo", "android_common").Rule("aidl").RuleParams.Command
|
||||||
|
expectedAidlFlag := "-Werror"
|
||||||
|
if !strings.Contains(aidlCommand, expectedAidlFlag) {
|
||||||
|
t.Errorf("aidl command %q does not contain %q", aidlCommand, expectedAidlFlag)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestDataNativeBinaries(t *testing.T) {
|
func TestDataNativeBinaries(t *testing.T) {
|
||||||
ctx, config := testJava(t, `
|
ctx, config := testJava(t, `
|
||||||
java_test_host {
|
java_test_host {
|
||||||
|
Reference in New Issue
Block a user