filegroup.path is used to specify the include path for aidl files
filegroup { name: "foo", srcs: ["srcs/aidl/com/android/**/*.aidl"], path: "srcs/aidl", } cc_library { // or java_library, etc. name: "bar", srcs: [":foo"], } automatically adds "-Ipath/to/foo/srcs/aidl" when compiling the aidl files from foo for bar. This allows us to omit aidl include path when using sources in other places via file group. Bug: 135922046 Test: m (unit tests added) Change-Id: I9b42f316f2858fb6da72c2f58a314f391416e809
This commit is contained in:
@@ -2277,6 +2277,9 @@ func TestFuzzTarget(t *testing.T) {
|
|||||||
ctx.ModuleForTests("fuzz_smoke_test", variant).Rule("cc")
|
ctx.ModuleForTests("fuzz_smoke_test", variant).Rule("cc")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAidl(t *testing.T) {
|
||||||
|
}
|
||||||
|
|
||||||
func assertString(t *testing.T, got, expected string) {
|
func assertString(t *testing.T, got, expected string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
if got != expected {
|
if got != expected {
|
||||||
|
@@ -120,6 +120,11 @@ func genAidl(ctx android.ModuleContext, rule *android.RuleBuilder, aidlFile andr
|
|||||||
headerBn := outDir.Join(ctx, aidlPackage, "Bn"+shortName+".h")
|
headerBn := outDir.Join(ctx, aidlPackage, "Bn"+shortName+".h")
|
||||||
headerBp := outDir.Join(ctx, aidlPackage, "Bp"+shortName+".h")
|
headerBp := outDir.Join(ctx, aidlPackage, "Bp"+shortName+".h")
|
||||||
|
|
||||||
|
baseDir := strings.TrimSuffix(aidlFile.String(), aidlFile.Rel())
|
||||||
|
if baseDir != "" {
|
||||||
|
aidlFlags += " -I" + baseDir
|
||||||
|
}
|
||||||
|
|
||||||
cmd := rule.Command()
|
cmd := rule.Command()
|
||||||
cmd.BuiltTool(ctx, "aidl-cpp").
|
cmd.BuiltTool(ctx, "aidl-cpp").
|
||||||
FlagWithDepFile("-d", depFile).
|
FlagWithDepFile("-d", depFile).
|
||||||
|
@@ -16,6 +16,7 @@ package cc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -42,7 +43,8 @@ func TestGen(t *testing.T) {
|
|||||||
ctx := testCc(t, `
|
ctx := testCc(t, `
|
||||||
filegroup {
|
filegroup {
|
||||||
name: "fg",
|
name: "fg",
|
||||||
srcs: ["b.aidl"],
|
srcs: ["sub/c.aidl"],
|
||||||
|
path: "sub",
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_library_shared {
|
cc_library_shared {
|
||||||
@@ -59,6 +61,12 @@ func TestGen(t *testing.T) {
|
|||||||
if !inList("-I"+filepath.Dir(aidl.Output.String()), libfoo.flags.GlobalFlags) {
|
if !inList("-I"+filepath.Dir(aidl.Output.String()), libfoo.flags.GlobalFlags) {
|
||||||
t.Errorf("missing aidl includes in global flags")
|
t.Errorf("missing aidl includes in global flags")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
aidlCommand := aidl.RuleParams.Command
|
||||||
|
if !strings.Contains(aidlCommand, "-Isub") {
|
||||||
|
t.Errorf("aidl command for c.aidl should contain \"-Isub\", but was %q", aidlCommand)
|
||||||
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -265,6 +265,7 @@ func CreateTestContext(bp string, fs map[string][]byte,
|
|||||||
"bar.c": nil,
|
"bar.c": nil,
|
||||||
"a.proto": nil,
|
"a.proto": nil,
|
||||||
"b.aidl": nil,
|
"b.aidl": nil,
|
||||||
|
"sub/c.aidl": nil,
|
||||||
"my_include": nil,
|
"my_include": nil,
|
||||||
"foo.map.txt": nil,
|
"foo.map.txt": nil,
|
||||||
"liba.so": nil,
|
"liba.so": nil,
|
||||||
|
@@ -15,6 +15,8 @@
|
|||||||
package java
|
package java
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
"github.com/google/blueprint"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
@@ -63,6 +65,10 @@ var (
|
|||||||
func genAidl(ctx android.ModuleContext, aidlFile android.Path, aidlFlags string, deps android.Paths) android.Path {
|
func genAidl(ctx android.ModuleContext, aidlFile android.Path, aidlFlags string, deps android.Paths) android.Path {
|
||||||
javaFile := android.GenPathWithExt(ctx, "aidl", aidlFile, "java")
|
javaFile := android.GenPathWithExt(ctx, "aidl", aidlFile, "java")
|
||||||
depFile := javaFile.String() + ".d"
|
depFile := javaFile.String() + ".d"
|
||||||
|
baseDir := strings.TrimSuffix(aidlFile.String(), aidlFile.Rel())
|
||||||
|
if baseDir != "" {
|
||||||
|
aidlFlags += " -I" + baseDir
|
||||||
|
}
|
||||||
|
|
||||||
ctx.Build(pctx, android.BuildParams{
|
ctx.Build(pctx, android.BuildParams{
|
||||||
Rule: aidl,
|
Rule: aidl,
|
||||||
|
@@ -192,6 +192,7 @@ func testContext(bp string, fs map[string][]byte) *android.TestContext {
|
|||||||
"bar-doc/a.java": nil,
|
"bar-doc/a.java": nil,
|
||||||
"bar-doc/b.java": nil,
|
"bar-doc/b.java": nil,
|
||||||
"bar-doc/IFoo.aidl": nil,
|
"bar-doc/IFoo.aidl": nil,
|
||||||
|
"bar-doc/IBar.aidl": nil,
|
||||||
"bar-doc/known_oj_tags.txt": nil,
|
"bar-doc/known_oj_tags.txt": nil,
|
||||||
"external/doclava/templates-sdk": nil,
|
"external/doclava/templates-sdk": nil,
|
||||||
|
|
||||||
@@ -754,11 +755,17 @@ func TestDroiddoc(t *testing.T) {
|
|||||||
name: "droiddoc-templates-sdk",
|
name: "droiddoc-templates-sdk",
|
||||||
path: ".",
|
path: ".",
|
||||||
}
|
}
|
||||||
|
filegroup {
|
||||||
|
name: "bar-doc-aidl-srcs",
|
||||||
|
srcs: ["bar-doc/IBar.aidl"],
|
||||||
|
path: "bar-doc",
|
||||||
|
}
|
||||||
droiddoc {
|
droiddoc {
|
||||||
name: "bar-doc",
|
name: "bar-doc",
|
||||||
srcs: [
|
srcs: [
|
||||||
"bar-doc/*.java",
|
"bar-doc/*.java",
|
||||||
"bar-doc/IFoo.aidl",
|
"bar-doc/IFoo.aidl",
|
||||||
|
":bar-doc-aidl-srcs",
|
||||||
],
|
],
|
||||||
exclude_srcs: [
|
exclude_srcs: [
|
||||||
"bar-doc/b.java"
|
"bar-doc/b.java"
|
||||||
@@ -786,8 +793,14 @@ func TestDroiddoc(t *testing.T) {
|
|||||||
for _, i := range inputs {
|
for _, i := range inputs {
|
||||||
javaSrcs = append(javaSrcs, i.Base())
|
javaSrcs = append(javaSrcs, i.Base())
|
||||||
}
|
}
|
||||||
if len(javaSrcs) != 2 || javaSrcs[0] != "a.java" || javaSrcs[1] != "IFoo.java" {
|
if len(javaSrcs) != 3 || javaSrcs[0] != "a.java" || javaSrcs[1] != "IFoo.java" || javaSrcs[2] != "IBar.java" {
|
||||||
t.Errorf("inputs of bar-doc must be []string{\"a.java\", \"IFoo.java\", but was %#v.", javaSrcs)
|
t.Errorf("inputs of bar-doc must be []string{\"a.java\", \"IFoo.java\", \"IBar.java\", but was %#v.", javaSrcs)
|
||||||
|
}
|
||||||
|
|
||||||
|
aidlRule := ctx.ModuleForTests("bar-doc", "android_common").Output(inputs[2].String())
|
||||||
|
aidlFlags := aidlRule.Args["aidlFlags"]
|
||||||
|
if !strings.Contains(aidlFlags, "-Ibar-doc") {
|
||||||
|
t.Errorf("aidl flags for IBar.aidl should contain \"-Ibar-doc\", but was %q", aidlFlags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user