blob: e4219d999d946fb3e6d778104b5a6f88398749b2 [file] [log] [blame]
Colin Crossf18e1102017-11-16 14:33:08 -08001// Copyright 2017 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package cc
16
17import (
Dan Willemsen1945a4b2019-06-04 17:10:41 -070018 "path/filepath"
Colin Crossf18e1102017-11-16 14:33:08 -080019 "testing"
20)
21
22func TestGen(t *testing.T) {
23 t.Run("simple", func(t *testing.T) {
24 ctx := testCc(t, `
25 cc_library_shared {
26 name: "libfoo",
27 srcs: [
28 "foo.c",
29 "b.aidl",
30 ],
31 }`)
32
33 aidl := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("aidl")
34 libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Module().(*Module)
35
Dan Willemsen1945a4b2019-06-04 17:10:41 -070036 if !inList("-I"+filepath.Dir(aidl.Output.String()), libfoo.flags.GlobalFlags) {
Colin Crossf18e1102017-11-16 14:33:08 -080037 t.Errorf("missing aidl includes in global flags")
38 }
39 })
40
41 t.Run("filegroup", func(t *testing.T) {
42 ctx := testCc(t, `
43 filegroup {
44 name: "fg",
45 srcs: ["b.aidl"],
46 }
47
48 cc_library_shared {
49 name: "libfoo",
50 srcs: [
51 "foo.c",
52 ":fg",
53 ],
54 }`)
55
56 aidl := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("aidl")
57 libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Module().(*Module)
58
Dan Willemsen1945a4b2019-06-04 17:10:41 -070059 if !inList("-I"+filepath.Dir(aidl.Output.String()), libfoo.flags.GlobalFlags) {
Colin Crossf18e1102017-11-16 14:33:08 -080060 t.Errorf("missing aidl includes in global flags")
61 }
62 })
63
64}