Colin Cross | f18e110 | 2017-11-16 14:33:08 -0800 | [diff] [blame] | 1 | // 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 | |
| 15 | package cc |
| 16 | |
| 17 | import ( |
| 18 | "testing" |
| 19 | ) |
| 20 | |
| 21 | func TestGen(t *testing.T) { |
| 22 | t.Run("simple", func(t *testing.T) { |
| 23 | ctx := testCc(t, ` |
| 24 | cc_library_shared { |
| 25 | name: "libfoo", |
| 26 | srcs: [ |
| 27 | "foo.c", |
| 28 | "b.aidl", |
| 29 | ], |
| 30 | }`) |
| 31 | |
| 32 | aidl := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("aidl") |
| 33 | libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Module().(*Module) |
| 34 | |
| 35 | if !inList("-I"+aidl.Args["outDir"], libfoo.flags.GlobalFlags) { |
| 36 | t.Errorf("missing aidl includes in global flags") |
| 37 | } |
| 38 | }) |
| 39 | |
| 40 | t.Run("filegroup", func(t *testing.T) { |
| 41 | ctx := testCc(t, ` |
| 42 | filegroup { |
| 43 | name: "fg", |
| 44 | srcs: ["b.aidl"], |
| 45 | } |
| 46 | |
| 47 | cc_library_shared { |
| 48 | name: "libfoo", |
| 49 | srcs: [ |
| 50 | "foo.c", |
| 51 | ":fg", |
| 52 | ], |
| 53 | }`) |
| 54 | |
| 55 | aidl := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Rule("aidl") |
| 56 | libfoo := ctx.ModuleForTests("libfoo", "android_arm_armv7-a-neon_core_shared").Module().(*Module) |
| 57 | |
| 58 | if !inList("-I"+aidl.Args["outDir"], libfoo.flags.GlobalFlags) { |
| 59 | t.Errorf("missing aidl includes in global flags") |
| 60 | } |
| 61 | }) |
| 62 | |
| 63 | } |