| 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 ( | 
| Dan Willemsen | 1945a4b | 2019-06-04 17:10:41 -0700 | [diff] [blame] | 18 | 	"path/filepath" | 
| Colin Cross | f18e110 | 2017-11-16 14:33:08 -0800 | [diff] [blame] | 19 | 	"testing" | 
 | 20 | ) | 
 | 21 |  | 
 | 22 | func 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 Willemsen | 1945a4b | 2019-06-04 17:10:41 -0700 | [diff] [blame] | 36 | 		if !inList("-I"+filepath.Dir(aidl.Output.String()), libfoo.flags.GlobalFlags) { | 
| Colin Cross | f18e110 | 2017-11-16 14:33:08 -0800 | [diff] [blame] | 37 | 			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 Willemsen | 1945a4b | 2019-06-04 17:10:41 -0700 | [diff] [blame] | 59 | 		if !inList("-I"+filepath.Dir(aidl.Output.String()), libfoo.flags.GlobalFlags) { | 
| Colin Cross | f18e110 | 2017-11-16 14:33:08 -0800 | [diff] [blame] | 60 | 			t.Errorf("missing aidl includes in global flags") | 
 | 61 | 		} | 
 | 62 | 	}) | 
 | 63 |  | 
 | 64 | } |