diff options
-rw-r--r-- | android/config.go | 22 | ||||
-rw-r--r-- | bpf/Android.bp | 4 | ||||
-rw-r--r-- | bpf/bpf.go | 4 | ||||
-rw-r--r-- | bpf/bpf_test.go | 110 | ||||
-rw-r--r-- | cc/cc_test.go | 55 | ||||
-rw-r--r-- | cc/prebuilt_test.go | 2 | ||||
-rw-r--r-- | cc/testing.go | 58 |
7 files changed, 82 insertions, 173 deletions
diff --git a/android/config.go b/android/config.go index a18feb6d..1507c252 100644 --- a/android/config.go +++ b/android/config.go | |||
@@ -235,20 +235,14 @@ func TestConfig(buildDir string, env map[string]string) Config { | |||
235 | } | 235 | } |
236 | 236 | ||
237 | func TestArchConfigNativeBridge(buildDir string, env map[string]string) Config { | 237 | func TestArchConfigNativeBridge(buildDir string, env map[string]string) Config { |
238 | testConfig := TestConfig(buildDir, env) | 238 | testConfig := TestArchConfig(buildDir, env) |
239 | config := testConfig.config | 239 | config := testConfig.config |
240 | 240 | ||
241 | config.Targets = map[OsType][]Target{ | 241 | config.Targets[Android] = []Target{ |
242 | Android: []Target{ | 242 | {Android, Arch{ArchType: X86_64, ArchVariant: "silvermont", Native: true, Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled}, |
243 | {Android, Arch{ArchType: X86_64, ArchVariant: "silvermont", Native: true, Abi: []string{"arm64-v8a"}}, NativeBridgeDisabled}, | 243 | {Android, Arch{ArchType: X86, ArchVariant: "silvermont", Native: true, Abi: []string{"armeabi-v7a"}}, NativeBridgeDisabled}, |
244 | {Android, Arch{ArchType: X86, ArchVariant: "silvermont", Native: true, Abi: []string{"armeabi-v7a"}}, NativeBridgeDisabled}, | 244 | {Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Native: true, Abi: []string{"arm64-v8a"}}, NativeBridgeEnabled}, |
245 | {Android, Arch{ArchType: Arm64, ArchVariant: "armv8-a", Native: true, Abi: []string{"arm64-v8a"}}, NativeBridgeEnabled}, | 245 | {Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Native: true, Abi: []string{"armeabi-v7a"}}, NativeBridgeEnabled}, |
246 | {Android, Arch{ArchType: Arm, ArchVariant: "armv7-a-neon", Native: true, Abi: []string{"armeabi-v7a"}}, NativeBridgeEnabled}, | ||
247 | }, | ||
248 | BuildOs: []Target{ | ||
249 | {BuildOs, Arch{ArchType: X86_64}, NativeBridgeDisabled}, | ||
250 | {BuildOs, Arch{ArchType: X86}, NativeBridgeDisabled}, | ||
251 | }, | ||
252 | } | 246 | } |
253 | 247 | ||
254 | return testConfig | 248 | return testConfig |
@@ -286,6 +280,10 @@ func TestArchConfig(buildDir string, env map[string]string) Config { | |||
286 | }, | 280 | }, |
287 | } | 281 | } |
288 | 282 | ||
283 | if runtime.GOOS == "darwin" { | ||
284 | config.Targets[BuildOs] = config.Targets[BuildOs][:1] | ||
285 | } | ||
286 | |||
289 | config.BuildOsVariant = config.Targets[BuildOs][0].String() | 287 | config.BuildOsVariant = config.Targets[BuildOs][0].String() |
290 | config.BuildOsCommonVariant = getCommonTargets(config.Targets[BuildOs])[0].String() | 288 | config.BuildOsCommonVariant = getCommonTargets(config.Targets[BuildOs])[0].String() |
291 | config.TestProductVariables.DeviceArch = proptools.StringPtr("arm64") | 289 | config.TestProductVariables.DeviceArch = proptools.StringPtr("arm64") |
diff --git a/bpf/Android.bp b/bpf/Android.bp index 7bd4d443..882cd8af 100644 --- a/bpf/Android.bp +++ b/bpf/Android.bp | |||
@@ -21,10 +21,14 @@ bootstrap_go_package { | |||
21 | "blueprint", | 21 | "blueprint", |
22 | "blueprint-proptools", | 22 | "blueprint-proptools", |
23 | "soong-android", | 23 | "soong-android", |
24 | "soong-cc", | ||
24 | "soong-cc-config", | 25 | "soong-cc-config", |
25 | ], | 26 | ], |
26 | srcs: [ | 27 | srcs: [ |
27 | "bpf.go", | 28 | "bpf.go", |
28 | ], | 29 | ], |
30 | testSrcs: [ | ||
31 | "bpf_test.go", | ||
32 | ], | ||
29 | pluginFor: ["soong_build"], | 33 | pluginFor: ["soong_build"], |
30 | } | 34 | } |
@@ -33,7 +33,7 @@ func init() { | |||
33 | var ( | 33 | var ( |
34 | pctx = android.NewPackageContext("android/soong/bpf") | 34 | pctx = android.NewPackageContext("android/soong/bpf") |
35 | 35 | ||
36 | cc = pctx.AndroidGomaStaticRule("cc", | 36 | ccRule = pctx.AndroidGomaStaticRule("ccRule", |
37 | blueprint.RuleParams{ | 37 | blueprint.RuleParams{ |
38 | Depfile: "${out}.d", | 38 | Depfile: "${out}.d", |
39 | Deps: blueprint.DepsGCC, | 39 | Deps: blueprint.DepsGCC, |
@@ -82,7 +82,7 @@ func (bpf *bpf) GenerateAndroidBuildActions(ctx android.ModuleContext) { | |||
82 | obj := android.ObjPathWithExt(ctx, "", src, "o") | 82 | obj := android.ObjPathWithExt(ctx, "", src, "o") |
83 | 83 | ||
84 | ctx.Build(pctx, android.BuildParams{ | 84 | ctx.Build(pctx, android.BuildParams{ |
85 | Rule: cc, | 85 | Rule: ccRule, |
86 | Input: src, | 86 | Input: src, |
87 | Output: obj, | 87 | Output: obj, |
88 | Args: map[string]string{ | 88 | Args: map[string]string{ |
diff --git a/bpf/bpf_test.go b/bpf/bpf_test.go index 1d53e413..cbb251fa 100644 --- a/bpf/bpf_test.go +++ b/bpf/bpf_test.go | |||
@@ -20,7 +20,7 @@ import ( | |||
20 | "testing" | 20 | "testing" |
21 | 21 | ||
22 | "android/soong/android" | 22 | "android/soong/android" |
23 | cc2 "android/soong/cc" | 23 | "android/soong/cc" |
24 | ) | 24 | ) |
25 | 25 | ||
26 | var buildDir string | 26 | var buildDir string |
@@ -49,115 +49,14 @@ func TestMain(m *testing.M) { | |||
49 | } | 49 | } |
50 | 50 | ||
51 | func testContext(bp string) *android.TestContext { | 51 | func testContext(bp string) *android.TestContext { |
52 | ctx := android.NewTestArchContext() | ||
53 | ctx.RegisterModuleType("bpf", android.ModuleFactoryAdaptor(bpfFactory)) | ||
54 | ctx.RegisterModuleType("cc_test", android.ModuleFactoryAdaptor(cc2.TestFactory)) | ||
55 | ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(cc2.LibraryFactory)) | ||
56 | ctx.RegisterModuleType("cc_library_static", android.ModuleFactoryAdaptor(cc2.LibraryStaticFactory)) | ||
57 | ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(cc2.ObjectFactory)) | ||
58 | ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(cc2.ToolchainLibraryFactory)) | ||
59 | ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { | ||
60 | ctx.BottomUp("link", cc2.LinkageMutator).Parallel() | ||
61 | }) | ||
62 | ctx.Register() | ||
63 | |||
64 | // Add some modules that are required by the compiler and/or linker | ||
65 | bp = bp + ` | ||
66 | toolchain_library { | ||
67 | name: "libatomic", | ||
68 | vendor_available: true, | ||
69 | recovery_available: true, | ||
70 | src: "", | ||
71 | } | ||
72 | |||
73 | toolchain_library { | ||
74 | name: "libclang_rt.builtins-arm-android", | ||
75 | vendor_available: true, | ||
76 | recovery_available: true, | ||
77 | src: "", | ||
78 | } | ||
79 | |||
80 | toolchain_library { | ||
81 | name: "libclang_rt.builtins-aarch64-android", | ||
82 | vendor_available: true, | ||
83 | recovery_available: true, | ||
84 | src: "", | ||
85 | } | ||
86 | |||
87 | toolchain_library { | ||
88 | name: "libgcc", | ||
89 | vendor_available: true, | ||
90 | recovery_available: true, | ||
91 | src: "", | ||
92 | } | ||
93 | |||
94 | cc_library { | ||
95 | name: "libc", | ||
96 | no_libgcc: true, | ||
97 | nocrt: true, | ||
98 | system_shared_libs: [], | ||
99 | recovery_available: true, | ||
100 | } | ||
101 | |||
102 | cc_library { | ||
103 | name: "libm", | ||
104 | no_libgcc: true, | ||
105 | nocrt: true, | ||
106 | system_shared_libs: [], | ||
107 | recovery_available: true, | ||
108 | } | ||
109 | |||
110 | cc_library { | ||
111 | name: "libdl", | ||
112 | no_libgcc: true, | ||
113 | nocrt: true, | ||
114 | system_shared_libs: [], | ||
115 | recovery_available: true, | ||
116 | } | ||
117 | |||
118 | cc_library { | ||
119 | name: "libgtest", | ||
120 | host_supported: true, | ||
121 | vendor_available: true, | ||
122 | } | ||
123 | |||
124 | cc_library { | ||
125 | name: "libgtest_main", | ||
126 | host_supported: true, | ||
127 | vendor_available: true, | ||
128 | } | ||
129 | |||
130 | cc_object { | ||
131 | name: "crtbegin_dynamic", | ||
132 | recovery_available: true, | ||
133 | vendor_available: true, | ||
134 | } | ||
135 | |||
136 | cc_object { | ||
137 | name: "crtend_android", | ||
138 | recovery_available: true, | ||
139 | vendor_available: true, | ||
140 | } | ||
141 | |||
142 | cc_object { | ||
143 | name: "crtbegin_so", | ||
144 | recovery_available: true, | ||
145 | vendor_available: true, | ||
146 | } | ||
147 | |||
148 | cc_object { | ||
149 | name: "crtend_so", | ||
150 | recovery_available: true, | ||
151 | vendor_available: true, | ||
152 | } | ||
153 | ` | ||
154 | mockFS := map[string][]byte{ | 52 | mockFS := map[string][]byte{ |
155 | "Android.bp": []byte(bp), | ||
156 | "bpf.c": nil, | 53 | "bpf.c": nil, |
157 | "BpfTest.cpp": nil, | 54 | "BpfTest.cpp": nil, |
158 | } | 55 | } |
159 | 56 | ||
160 | ctx.MockFileSystem(mockFS) | 57 | ctx := cc.CreateTestContext(bp, mockFS, android.Android) |
58 | ctx.RegisterModuleType("bpf", android.ModuleFactoryAdaptor(bpfFactory)) | ||
59 | ctx.Register() | ||
161 | 60 | ||
162 | return ctx | 61 | return ctx |
163 | } | 62 | } |
@@ -174,6 +73,7 @@ func TestBpfDataDependency(t *testing.T) { | |||
174 | name: "vts_test_binary_bpf_module", | 73 | name: "vts_test_binary_bpf_module", |
175 | srcs: ["BpfTest.cpp"], | 74 | srcs: ["BpfTest.cpp"], |
176 | data: [":bpf.o"], | 75 | data: [":bpf.o"], |
76 | gtest: false, | ||
177 | } | 77 | } |
178 | ` | 78 | ` |
179 | 79 | ||
diff --git a/cc/cc_test.go b/cc/cc_test.go index ef6364b5..f5bb12c8 100644 --- a/cc/cc_test.go +++ b/cc/cc_test.go | |||
@@ -52,64 +52,13 @@ func TestMain(m *testing.M) { | |||
52 | os.Exit(run()) | 52 | os.Exit(run()) |
53 | } | 53 | } |
54 | 54 | ||
55 | func createTestContext(t *testing.T, config android.Config, bp string, fs map[string][]byte, | ||
56 | os android.OsType) *android.TestContext { | ||
57 | |||
58 | ctx := android.NewTestArchContext() | ||
59 | ctx.RegisterModuleType("cc_binary", android.ModuleFactoryAdaptor(BinaryFactory)) | ||
60 | ctx.RegisterModuleType("cc_binary_host", android.ModuleFactoryAdaptor(binaryHostFactory)) | ||
61 | ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(LibraryFactory)) | ||
62 | ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(LibrarySharedFactory)) | ||
63 | ctx.RegisterModuleType("cc_library_static", android.ModuleFactoryAdaptor(LibraryStaticFactory)) | ||
64 | ctx.RegisterModuleType("cc_library_headers", android.ModuleFactoryAdaptor(LibraryHeaderFactory)) | ||
65 | ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(ToolchainLibraryFactory)) | ||
66 | ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(LlndkLibraryFactory)) | ||
67 | ctx.RegisterModuleType("llndk_headers", android.ModuleFactoryAdaptor(llndkHeadersFactory)) | ||
68 | ctx.RegisterModuleType("vendor_public_library", android.ModuleFactoryAdaptor(vendorPublicLibraryFactory)) | ||
69 | ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(ObjectFactory)) | ||
70 | ctx.RegisterModuleType("filegroup", android.ModuleFactoryAdaptor(android.FileGroupFactory)) | ||
71 | ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { | ||
72 | ctx.BottomUp("image", ImageMutator).Parallel() | ||
73 | ctx.BottomUp("link", LinkageMutator).Parallel() | ||
74 | ctx.BottomUp("vndk", VndkMutator).Parallel() | ||
75 | ctx.BottomUp("version", VersionMutator).Parallel() | ||
76 | ctx.BottomUp("begin", BeginMutator).Parallel() | ||
77 | }) | ||
78 | ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) { | ||
79 | ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel() | ||
80 | }) | ||
81 | ctx.RegisterSingletonType("vndk-snapshot", android.SingletonFactoryAdaptor(VndkSnapshotSingleton)) | ||
82 | |||
83 | // add some modules that are required by the compiler and/or linker | ||
84 | bp = bp + GatherRequiredDepsForTest(os) | ||
85 | |||
86 | mockFS := map[string][]byte{ | ||
87 | "Android.bp": []byte(bp), | ||
88 | "foo.c": nil, | ||
89 | "bar.c": nil, | ||
90 | "a.proto": nil, | ||
91 | "b.aidl": nil, | ||
92 | "my_include": nil, | ||
93 | "foo.map.txt": nil, | ||
94 | "liba.so": nil, | ||
95 | } | ||
96 | |||
97 | for k, v := range fs { | ||
98 | mockFS[k] = v | ||
99 | } | ||
100 | |||
101 | ctx.MockFileSystem(mockFS) | ||
102 | |||
103 | return ctx | ||
104 | } | ||
105 | |||
106 | func testCcWithConfig(t *testing.T, bp string, config android.Config) *android.TestContext { | 55 | func testCcWithConfig(t *testing.T, bp string, config android.Config) *android.TestContext { |
107 | return testCcWithConfigForOs(t, bp, config, android.Android) | 56 | return testCcWithConfigForOs(t, bp, config, android.Android) |
108 | } | 57 | } |
109 | 58 | ||
110 | func testCcWithConfigForOs(t *testing.T, bp string, config android.Config, os android.OsType) *android.TestContext { | 59 | func testCcWithConfigForOs(t *testing.T, bp string, config android.Config, os android.OsType) *android.TestContext { |
111 | t.Helper() | 60 | t.Helper() |
112 | ctx := createTestContext(t, config, bp, nil, os) | 61 | ctx := CreateTestContext(bp, nil, os) |
113 | ctx.Register() | 62 | ctx.Register() |
114 | 63 | ||
115 | _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) | 64 | _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) |
@@ -143,7 +92,7 @@ func testCcError(t *testing.T, pattern string, bp string) { | |||
143 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") | 92 | config.TestProductVariables.DeviceVndkVersion = StringPtr("current") |
144 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") | 93 | config.TestProductVariables.Platform_vndk_version = StringPtr("VER") |
145 | 94 | ||
146 | ctx := createTestContext(t, config, bp, nil, android.Android) | 95 | ctx := CreateTestContext(bp, nil, android.Android) |
147 | ctx.Register() | 96 | ctx.Register() |
148 | 97 | ||
149 | _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) | 98 | _, errs := ctx.ParseFileList(".", []string{"Android.bp"}) |
diff --git a/cc/prebuilt_test.go b/cc/prebuilt_test.go index 7cc26514..98d78e81 100644 --- a/cc/prebuilt_test.go +++ b/cc/prebuilt_test.go | |||
@@ -70,7 +70,7 @@ func TestPrebuilt(t *testing.T) { | |||
70 | 70 | ||
71 | config := android.TestArchConfig(buildDir, nil) | 71 | config := android.TestArchConfig(buildDir, nil) |
72 | 72 | ||
73 | ctx := createTestContext(t, config, bp, fs, android.Android) | 73 | ctx := CreateTestContext(bp, fs, android.Android) |
74 | 74 | ||
75 | ctx.RegisterModuleType("cc_prebuilt_library_shared", android.ModuleFactoryAdaptor(prebuiltSharedLibraryFactory)) | 75 | ctx.RegisterModuleType("cc_prebuilt_library_shared", android.ModuleFactoryAdaptor(prebuiltSharedLibraryFactory)) |
76 | ctx.RegisterModuleType("cc_prebuilt_library_static", android.ModuleFactoryAdaptor(prebuiltStaticLibraryFactory)) | 76 | ctx.RegisterModuleType("cc_prebuilt_library_static", android.ModuleFactoryAdaptor(prebuiltStaticLibraryFactory)) |
diff --git a/cc/testing.go b/cc/testing.go index 8d76c2f5..259fb19e 100644 --- a/cc/testing.go +++ b/cc/testing.go | |||
@@ -148,6 +148,12 @@ func GatherRequiredDepsForTest(os android.OsType) string { | |||
148 | } | 148 | } |
149 | 149 | ||
150 | cc_object { | 150 | cc_object { |
151 | name: "crtbegin_dynamic", | ||
152 | recovery_available: true, | ||
153 | vendor_available: true, | ||
154 | } | ||
155 | |||
156 | cc_object { | ||
151 | name: "crtbegin_static", | 157 | name: "crtbegin_static", |
152 | recovery_available: true, | 158 | recovery_available: true, |
153 | vendor_available: true, | 159 | vendor_available: true, |
@@ -183,3 +189,55 @@ func GatherRequiredDepsForTest(os android.OsType) string { | |||
183 | } | 189 | } |
184 | return ret | 190 | return ret |
185 | } | 191 | } |
192 | |||
193 | func CreateTestContext(bp string, fs map[string][]byte, | ||
194 | os android.OsType) *android.TestContext { | ||
195 | |||
196 | ctx := android.NewTestArchContext() | ||
197 | ctx.RegisterModuleType("cc_binary", android.ModuleFactoryAdaptor(BinaryFactory)) | ||
198 | ctx.RegisterModuleType("cc_binary_host", android.ModuleFactoryAdaptor(binaryHostFactory)) | ||
199 | ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(LibraryFactory)) | ||
200 | ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(LibrarySharedFactory)) | ||
201 | ctx.RegisterModuleType("cc_library_static", android.ModuleFactoryAdaptor(LibraryStaticFactory)) | ||
202 | ctx.RegisterModuleType("cc_library_headers", android.ModuleFactoryAdaptor(LibraryHeaderFactory)) | ||
203 | ctx.RegisterModuleType("cc_test", android.ModuleFactoryAdaptor(TestFactory)) | ||
204 | ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(ToolchainLibraryFactory)) | ||
205 | ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(LlndkLibraryFactory)) | ||
206 | ctx.RegisterModuleType("llndk_headers", android.ModuleFactoryAdaptor(llndkHeadersFactory)) | ||
207 | ctx.RegisterModuleType("vendor_public_library", android.ModuleFactoryAdaptor(vendorPublicLibraryFactory)) | ||
208 | ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(ObjectFactory)) | ||
209 | ctx.RegisterModuleType("filegroup", android.ModuleFactoryAdaptor(android.FileGroupFactory)) | ||
210 | ctx.PreDepsMutators(func(ctx android.RegisterMutatorsContext) { | ||
211 | ctx.BottomUp("image", ImageMutator).Parallel() | ||
212 | ctx.BottomUp("link", LinkageMutator).Parallel() | ||
213 | ctx.BottomUp("vndk", VndkMutator).Parallel() | ||
214 | ctx.BottomUp("version", VersionMutator).Parallel() | ||
215 | ctx.BottomUp("begin", BeginMutator).Parallel() | ||
216 | }) | ||
217 | ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) { | ||
218 | ctx.TopDown("double_loadable", checkDoubleLoadableLibraries).Parallel() | ||
219 | }) | ||
220 | ctx.RegisterSingletonType("vndk-snapshot", android.SingletonFactoryAdaptor(VndkSnapshotSingleton)) | ||
221 | |||
222 | // add some modules that are required by the compiler and/or linker | ||
223 | bp = bp + GatherRequiredDepsForTest(os) | ||
224 | |||
225 | mockFS := map[string][]byte{ | ||
226 | "Android.bp": []byte(bp), | ||
227 | "foo.c": nil, | ||
228 | "bar.c": nil, | ||
229 | "a.proto": nil, | ||
230 | "b.aidl": nil, | ||
231 | "my_include": nil, | ||
232 | "foo.map.txt": nil, | ||
233 | "liba.so": nil, | ||
234 | } | ||
235 | |||
236 | for k, v := range fs { | ||
237 | mockFS[k] = v | ||
238 | } | ||
239 | |||
240 | ctx.MockFileSystem(mockFS) | ||
241 | |||
242 | return ctx | ||
243 | } | ||