Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 1 | // Copyright 2018 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 android |
| 16 | |
| 17 | import ( |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 18 | "testing" |
Paul Duffin | 3578188 | 2019-07-25 15:41:09 +0100 | [diff] [blame] | 19 | |
| 20 | "github.com/google/blueprint" |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 21 | ) |
| 22 | |
| 23 | var neverallowTests = []struct { |
Paul Duffin | 115445b | 2019-08-07 15:31:07 +0100 | [diff] [blame] | 24 | // The name of the test. |
| 25 | name string |
| 26 | |
| 27 | // Optional test specific rules. If specified then they are used instead of the default rules. |
| 28 | rules []Rule |
| 29 | |
| 30 | // Additional contents to add to the virtual filesystem used by the tests. |
Paul Duffin | 3c6a4ea | 2021-03-16 23:41:40 +0000 | [diff] [blame] | 31 | fs MockFS |
Paul Duffin | 115445b | 2019-08-07 15:31:07 +0100 | [diff] [blame] | 32 | |
| 33 | // The expected error patterns. If empty then no errors are expected, otherwise each error |
| 34 | // reported must be matched by at least one of these patterns. A pattern matches if the error |
| 35 | // message contains the pattern. A pattern does not have to match the whole error message. |
Paul Duffin | b5af620 | 2019-08-05 15:07:57 +0100 | [diff] [blame] | 36 | expectedErrors []string |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 37 | }{ |
Paul Duffin | 3578188 | 2019-07-25 15:41:09 +0100 | [diff] [blame] | 38 | // Test General Functionality |
| 39 | |
| 40 | // in direct deps tests |
| 41 | { |
| 42 | name: "not_allowed_in_direct_deps", |
Paul Duffin | 115445b | 2019-08-07 15:31:07 +0100 | [diff] [blame] | 43 | rules: []Rule{ |
| 44 | NeverAllow().InDirectDeps("not_allowed_in_direct_deps"), |
| 45 | }, |
Paul Duffin | 3578188 | 2019-07-25 15:41:09 +0100 | [diff] [blame] | 46 | fs: map[string][]byte{ |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 47 | "top/Android.bp": []byte(` |
Paul Duffin | 3578188 | 2019-07-25 15:41:09 +0100 | [diff] [blame] | 48 | cc_library { |
| 49 | name: "not_allowed_in_direct_deps", |
| 50 | }`), |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 51 | "other/Android.bp": []byte(` |
Paul Duffin | 3578188 | 2019-07-25 15:41:09 +0100 | [diff] [blame] | 52 | cc_library { |
| 53 | name: "libother", |
| 54 | static_libs: ["not_allowed_in_direct_deps"], |
| 55 | }`), |
| 56 | }, |
Paul Duffin | b5af620 | 2019-08-05 15:07:57 +0100 | [diff] [blame] | 57 | expectedErrors: []string{ |
| 58 | `module "libother": violates neverallow deps:not_allowed_in_direct_deps`, |
| 59 | }, |
Paul Duffin | 3578188 | 2019-07-25 15:41:09 +0100 | [diff] [blame] | 60 | }, |
| 61 | |
Paul Duffin | 115445b | 2019-08-07 15:31:07 +0100 | [diff] [blame] | 62 | // Test android specific rules |
Paul Duffin | 3578188 | 2019-07-25 15:41:09 +0100 | [diff] [blame] | 63 | |
Paul Duffin | c811170 | 2019-07-22 12:13:55 +0100 | [diff] [blame] | 64 | // include_dir rule tests |
| 65 | { |
| 66 | name: "include_dir not allowed to reference art", |
| 67 | fs: map[string][]byte{ |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 68 | "other/Android.bp": []byte(` |
Paul Duffin | c811170 | 2019-07-22 12:13:55 +0100 | [diff] [blame] | 69 | cc_library { |
| 70 | name: "libother", |
| 71 | include_dirs: ["art/libdexfile/include"], |
| 72 | }`), |
| 73 | }, |
Paul Duffin | b5af620 | 2019-08-05 15:07:57 +0100 | [diff] [blame] | 74 | expectedErrors: []string{ |
| 75 | "all usages of 'art' have been migrated", |
| 76 | }, |
Paul Duffin | c811170 | 2019-07-22 12:13:55 +0100 | [diff] [blame] | 77 | }, |
| 78 | { |
Steven Moreland | 8fc8dbf | 2021-04-27 02:31:07 +0000 | [diff] [blame] | 79 | name: "include_dir not allowed to reference art", |
| 80 | fs: map[string][]byte{ |
| 81 | "system/libfmq/Android.bp": []byte(` |
| 82 | cc_library { |
| 83 | name: "libother", |
| 84 | include_dirs: ["any/random/file"], |
| 85 | }`), |
| 86 | }, |
| 87 | expectedErrors: []string{ |
| 88 | "all usages of them in 'system/libfmq' have been migrated", |
| 89 | }, |
| 90 | }, |
| 91 | { |
| 92 | name: "include_dir can work", |
Paul Duffin | c811170 | 2019-07-22 12:13:55 +0100 | [diff] [blame] | 93 | fs: map[string][]byte{ |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 94 | "other/Android.bp": []byte(` |
Paul Duffin | c811170 | 2019-07-22 12:13:55 +0100 | [diff] [blame] | 95 | cc_library { |
| 96 | name: "libother", |
| 97 | include_dirs: ["another/include"], |
| 98 | }`), |
| 99 | }, |
| 100 | }, |
| 101 | // Treble rule tests |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 102 | { |
| 103 | name: "no vndk.enabled under vendor directory", |
| 104 | fs: map[string][]byte{ |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 105 | "vendor/Android.bp": []byte(` |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 106 | cc_library { |
| 107 | name: "libvndk", |
| 108 | vendor_available: true, |
| 109 | vndk: { |
| 110 | enabled: true, |
| 111 | }, |
| 112 | }`), |
| 113 | }, |
Paul Duffin | b5af620 | 2019-08-05 15:07:57 +0100 | [diff] [blame] | 114 | expectedErrors: []string{ |
| 115 | "VNDK can never contain a library that is device dependent", |
| 116 | }, |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 117 | }, |
| 118 | { |
| 119 | name: "no vndk.enabled under device directory", |
| 120 | fs: map[string][]byte{ |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 121 | "device/Android.bp": []byte(` |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 122 | cc_library { |
| 123 | name: "libvndk", |
| 124 | vendor_available: true, |
| 125 | vndk: { |
| 126 | enabled: true, |
| 127 | }, |
| 128 | }`), |
| 129 | }, |
Paul Duffin | b5af620 | 2019-08-05 15:07:57 +0100 | [diff] [blame] | 130 | expectedErrors: []string{ |
| 131 | "VNDK can never contain a library that is device dependent", |
| 132 | }, |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 133 | }, |
Logan Chien | af29bad | 2018-03-12 16:35:58 +0800 | [diff] [blame] | 134 | { |
| 135 | name: "vndk-ext under vendor or device directory", |
| 136 | fs: map[string][]byte{ |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 137 | "device/Android.bp": []byte(` |
Logan Chien | af29bad | 2018-03-12 16:35:58 +0800 | [diff] [blame] | 138 | cc_library { |
| 139 | name: "libvndk1_ext", |
| 140 | vendor: true, |
| 141 | vndk: { |
| 142 | enabled: true, |
| 143 | }, |
| 144 | }`), |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 145 | "vendor/Android.bp": []byte(` |
Logan Chien | af29bad | 2018-03-12 16:35:58 +0800 | [diff] [blame] | 146 | cc_library { |
| 147 | name: "libvndk2_ext", |
| 148 | vendor: true, |
| 149 | vndk: { |
| 150 | enabled: true, |
| 151 | }, |
| 152 | }`), |
| 153 | }, |
Logan Chien | af29bad | 2018-03-12 16:35:58 +0800 | [diff] [blame] | 154 | }, |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 155 | |
| 156 | { |
| 157 | name: "no enforce_vintf_manifest.cflags", |
| 158 | fs: map[string][]byte{ |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 159 | "Android.bp": []byte(` |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 160 | cc_library { |
| 161 | name: "libexample", |
| 162 | product_variables: { |
| 163 | enforce_vintf_manifest: { |
| 164 | cflags: ["-DSHOULD_NOT_EXIST"], |
| 165 | }, |
| 166 | }, |
| 167 | }`), |
| 168 | }, |
Paul Duffin | b5af620 | 2019-08-05 15:07:57 +0100 | [diff] [blame] | 169 | expectedErrors: []string{ |
| 170 | "manifest enforcement should be independent", |
| 171 | }, |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 172 | }, |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 173 | |
| 174 | { |
| 175 | name: "no treble_linker_namespaces.cflags", |
| 176 | fs: map[string][]byte{ |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 177 | "Android.bp": []byte(` |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 178 | cc_library { |
| 179 | name: "libexample", |
| 180 | product_variables: { |
| 181 | treble_linker_namespaces: { |
| 182 | cflags: ["-DSHOULD_NOT_EXIST"], |
| 183 | }, |
| 184 | }, |
| 185 | }`), |
| 186 | }, |
Paul Duffin | b5af620 | 2019-08-05 15:07:57 +0100 | [diff] [blame] | 187 | expectedErrors: []string{ |
| 188 | "nothing should care if linker namespaces are enabled or not", |
| 189 | }, |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 190 | }, |
| 191 | { |
| 192 | name: "libc_bionic_ndk treble_linker_namespaces.cflags", |
| 193 | fs: map[string][]byte{ |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 194 | "Android.bp": []byte(` |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 195 | cc_library { |
| 196 | name: "libc_bionic_ndk", |
| 197 | product_variables: { |
| 198 | treble_linker_namespaces: { |
| 199 | cflags: ["-DSHOULD_NOT_EXIST"], |
| 200 | }, |
| 201 | }, |
| 202 | }`), |
| 203 | }, |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 204 | }, |
Neil Fuller | df5f356 | 2018-10-21 17:19:10 +0100 | [diff] [blame] | 205 | { |
Colin Cross | fd4f743 | 2019-03-05 15:06:16 -0800 | [diff] [blame] | 206 | name: "java_device_for_host", |
| 207 | fs: map[string][]byte{ |
Colin Cross | 98be1bb | 2019-12-13 20:41:13 -0800 | [diff] [blame] | 208 | "Android.bp": []byte(` |
Colin Cross | fd4f743 | 2019-03-05 15:06:16 -0800 | [diff] [blame] | 209 | java_device_for_host { |
| 210 | name: "device_for_host", |
| 211 | libs: ["core-libart"], |
| 212 | }`), |
| 213 | }, |
Paul Duffin | b5af620 | 2019-08-05 15:07:57 +0100 | [diff] [blame] | 214 | expectedErrors: []string{ |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 215 | "java_device_for_host can only be used in allowed projects", |
Paul Duffin | b5af620 | 2019-08-05 15:07:57 +0100 | [diff] [blame] | 216 | }, |
Colin Cross | fd4f743 | 2019-03-05 15:06:16 -0800 | [diff] [blame] | 217 | }, |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 218 | // CC sdk rule tests |
| 219 | { |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 220 | name: `"sdk_variant_only" outside allowed list`, |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 221 | fs: map[string][]byte{ |
| 222 | "Android.bp": []byte(` |
| 223 | cc_library { |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 224 | name: "outside_allowed_list", |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 225 | sdk_version: "current", |
| 226 | sdk_variant_only: true, |
| 227 | }`), |
| 228 | }, |
| 229 | expectedErrors: []string{ |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 230 | `module "outside_allowed_list": violates neverallow`, |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 231 | }, |
| 232 | }, |
| 233 | { |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 234 | name: `"sdk_variant_only: false" outside allowed list`, |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 235 | fs: map[string][]byte{ |
| 236 | "Android.bp": []byte(` |
| 237 | cc_library { |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 238 | name: "outside_allowed_list", |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 239 | sdk_version: "current", |
| 240 | sdk_variant_only: false, |
| 241 | }`), |
| 242 | }, |
| 243 | expectedErrors: []string{ |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 244 | `module "outside_allowed_list": violates neverallow`, |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 245 | }, |
| 246 | }, |
| 247 | { |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 248 | name: `"platform" outside allowed list`, |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 249 | fs: map[string][]byte{ |
| 250 | "Android.bp": []byte(` |
| 251 | cc_library { |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 252 | name: "outside_allowed_list", |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 253 | platform: { |
| 254 | shared_libs: ["libfoo"], |
| 255 | }, |
| 256 | }`), |
| 257 | }, |
| 258 | expectedErrors: []string{ |
Colin Cross | 440e0d0 | 2020-06-11 11:32:11 -0700 | [diff] [blame] | 259 | `module "outside_allowed_list": violates neverallow`, |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 260 | }, |
| 261 | }, |
David Srbecky | e033cba | 2020-05-20 22:20:28 +0100 | [diff] [blame] | 262 | { |
| 263 | name: "uncompress_dex inside art", |
| 264 | fs: map[string][]byte{ |
| 265 | "art/Android.bp": []byte(` |
| 266 | java_library { |
| 267 | name: "inside_art_libraries", |
| 268 | uncompress_dex: true, |
| 269 | }`), |
| 270 | }, |
| 271 | }, |
| 272 | { |
| 273 | name: "uncompress_dex outside art", |
| 274 | fs: map[string][]byte{ |
| 275 | "other/Android.bp": []byte(` |
| 276 | java_library { |
| 277 | name: "outside_art_libraries", |
| 278 | uncompress_dex: true, |
| 279 | }`), |
| 280 | }, |
| 281 | expectedErrors: []string{ |
| 282 | "module \"outside_art_libraries\": violates neverallow", |
| 283 | }, |
| 284 | }, |
Yifan Hong | 696ed4d | 2020-07-27 12:59:58 -0700 | [diff] [blame] | 285 | { |
| 286 | name: "disallowed makefile_goal", |
| 287 | fs: map[string][]byte{ |
| 288 | "Android.bp": []byte(` |
| 289 | makefile_goal { |
| 290 | name: "foo", |
| 291 | product_out_path: "boot/trap.img" |
| 292 | } |
| 293 | `), |
| 294 | }, |
| 295 | expectedErrors: []string{ |
| 296 | "Only boot images may be imported as a makefile goal.", |
| 297 | }, |
| 298 | }, |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 299 | } |
| 300 | |
Paul Duffin | 3c6a4ea | 2021-03-16 23:41:40 +0000 | [diff] [blame] | 301 | var prepareForNeverAllowTest = GroupFixturePreparers( |
| 302 | FixtureRegisterWithContext(func(ctx RegistrationContext) { |
| 303 | ctx.RegisterModuleType("cc_library", newMockCcLibraryModule) |
| 304 | ctx.RegisterModuleType("java_library", newMockJavaLibraryModule) |
| 305 | ctx.RegisterModuleType("java_library_host", newMockJavaLibraryModule) |
| 306 | ctx.RegisterModuleType("java_device_for_host", newMockJavaLibraryModule) |
| 307 | ctx.RegisterModuleType("makefile_goal", newMockMakefileGoalModule) |
Paul Duffin | 3c6a4ea | 2021-03-16 23:41:40 +0000 | [diff] [blame] | 308 | }), |
| 309 | ) |
| 310 | |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 311 | func TestNeverallow(t *testing.T) { |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 312 | for _, test := range neverallowTests { |
Paul Duffin | b5af620 | 2019-08-05 15:07:57 +0100 | [diff] [blame] | 313 | t.Run(test.name, func(t *testing.T) { |
Paul Duffin | 30ac3e7 | 2021-03-20 00:36:14 +0000 | [diff] [blame] | 314 | GroupFixturePreparers( |
| 315 | prepareForNeverAllowTest, |
Paul Duffin | 45338f0 | 2021-03-30 23:07:52 +0100 | [diff] [blame] | 316 | PrepareForTestWithNeverallowRules(test.rules), |
Paul Duffin | 30ac3e7 | 2021-03-20 00:36:14 +0000 | [diff] [blame] | 317 | test.fs.AddToFixture(), |
Paul Duffin | 3cb2c06 | 2021-03-22 19:24:26 +0000 | [diff] [blame] | 318 | ). |
| 319 | ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern(test.expectedErrors)). |
Paul Duffin | 30ac3e7 | 2021-03-20 00:36:14 +0000 | [diff] [blame] | 320 | RunTest(t) |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 321 | }) |
| 322 | } |
| 323 | } |
| 324 | |
Neil Fuller | df5f356 | 2018-10-21 17:19:10 +0100 | [diff] [blame] | 325 | type mockCcLibraryProperties struct { |
Paul Duffin | c811170 | 2019-07-22 12:13:55 +0100 | [diff] [blame] | 326 | Include_dirs []string |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 327 | Vendor_available *bool |
Paul Duffin | 3578188 | 2019-07-25 15:41:09 +0100 | [diff] [blame] | 328 | Static_libs []string |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 329 | Sdk_version *string |
| 330 | Sdk_variant_only *bool |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 331 | |
| 332 | Vndk struct { |
| 333 | Enabled *bool |
| 334 | Support_system_process *bool |
| 335 | Extends *string |
| 336 | } |
| 337 | |
| 338 | Product_variables struct { |
| 339 | Enforce_vintf_manifest struct { |
| 340 | Cflags []string |
| 341 | } |
| 342 | |
| 343 | Treble_linker_namespaces struct { |
| 344 | Cflags []string |
| 345 | } |
| 346 | } |
Colin Cross | c511bc5 | 2020-04-07 16:50:32 +0000 | [diff] [blame] | 347 | |
| 348 | Platform struct { |
| 349 | Shared_libs []string |
| 350 | } |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | type mockCcLibraryModule struct { |
| 354 | ModuleBase |
Neil Fuller | df5f356 | 2018-10-21 17:19:10 +0100 | [diff] [blame] | 355 | properties mockCcLibraryProperties |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 356 | } |
| 357 | |
| 358 | func newMockCcLibraryModule() Module { |
| 359 | m := &mockCcLibraryModule{} |
| 360 | m.AddProperties(&m.properties) |
| 361 | InitAndroidModule(m) |
| 362 | return m |
| 363 | } |
| 364 | |
Paul Duffin | 3578188 | 2019-07-25 15:41:09 +0100 | [diff] [blame] | 365 | type neverallowTestDependencyTag struct { |
| 366 | blueprint.BaseDependencyTag |
| 367 | name string |
| 368 | } |
| 369 | |
| 370 | var staticDepTag = neverallowTestDependencyTag{name: "static"} |
| 371 | |
| 372 | func (c *mockCcLibraryModule) DepsMutator(ctx BottomUpMutatorContext) { |
| 373 | for _, lib := range c.properties.Static_libs { |
| 374 | ctx.AddDependency(ctx.Module(), staticDepTag, lib) |
| 375 | } |
| 376 | } |
| 377 | |
Logan Chien | ee97c3e | 2018-03-12 16:34:26 +0800 | [diff] [blame] | 378 | func (p *mockCcLibraryModule) GenerateAndroidBuildActions(ModuleContext) { |
| 379 | } |
Neil Fuller | df5f356 | 2018-10-21 17:19:10 +0100 | [diff] [blame] | 380 | |
| 381 | type mockJavaLibraryProperties struct { |
David Srbecky | e033cba | 2020-05-20 22:20:28 +0100 | [diff] [blame] | 382 | Libs []string |
| 383 | Sdk_version *string |
| 384 | Uncompress_dex *bool |
Neil Fuller | df5f356 | 2018-10-21 17:19:10 +0100 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | type mockJavaLibraryModule struct { |
| 388 | ModuleBase |
| 389 | properties mockJavaLibraryProperties |
| 390 | } |
| 391 | |
| 392 | func newMockJavaLibraryModule() Module { |
| 393 | m := &mockJavaLibraryModule{} |
| 394 | m.AddProperties(&m.properties) |
| 395 | InitAndroidModule(m) |
| 396 | return m |
| 397 | } |
| 398 | |
Neil Fuller | df5f356 | 2018-10-21 17:19:10 +0100 | [diff] [blame] | 399 | func (p *mockJavaLibraryModule) GenerateAndroidBuildActions(ModuleContext) { |
| 400 | } |
Yifan Hong | 696ed4d | 2020-07-27 12:59:58 -0700 | [diff] [blame] | 401 | |
| 402 | type mockMakefileGoalProperties struct { |
| 403 | Product_out_path *string |
| 404 | } |
| 405 | |
| 406 | type mockMakefileGoalModule struct { |
| 407 | ModuleBase |
| 408 | properties mockMakefileGoalProperties |
| 409 | } |
| 410 | |
| 411 | func newMockMakefileGoalModule() Module { |
| 412 | m := &mockMakefileGoalModule{} |
| 413 | m.AddProperties(&m.properties) |
| 414 | InitAndroidModule(m) |
| 415 | return m |
| 416 | } |
| 417 | |
| 418 | func (p *mockMakefileGoalModule) GenerateAndroidBuildActions(ModuleContext) { |
| 419 | } |