aboutsummaryrefslogtreecommitdiffstats
path: root/bpfix
diff options
context:
space:
mode:
authorDan Willemsen2018-05-09 15:45:03 -0500
committerDan Willemsen2018-05-14 19:33:11 -0500
commitf923f2b54cd0ad9f7fecb06f7005030886cb64a5 (patch)
tree991b3e4c919868029d51b037ab279dd62bd7a6dc /bpfix
parent5473c9a60a9059667130edb6036b70d24604e276 (diff)
downloadplatform-build-soong-f923f2b54cd0ad9f7fecb06f7005030886cb64a5.tar.gz
platform-build-soong-f923f2b54cd0ad9f7fecb06f7005030886cb64a5.tar.xz
platform-build-soong-f923f2b54cd0ad9f7fecb06f7005030886cb64a5.zip
Remove the unused `tags` property
And fix up androidmk / bpfix to provide warnings about what to do instead. Test: m blueprint_tools (runs the tests, ensures there aren't any tags left) Change-Id: I1a3ad8600211050420041740207d6957f44463c8
Diffstat (limited to 'bpfix')
-rw-r--r--bpfix/bpfix/bpfix.go75
1 files changed, 75 insertions, 0 deletions
diff --git a/bpfix/bpfix/bpfix.go b/bpfix/bpfix/bpfix.go
index 55de9936..ee00907f 100644
--- a/bpfix/bpfix/bpfix.go
+++ b/bpfix/bpfix/bpfix.go
@@ -50,6 +50,7 @@ type FixRequest struct {
50 rewriteIncorrectAndroidmkAndroidLibraries bool 50 rewriteIncorrectAndroidmkAndroidLibraries bool
51 mergeMatchingModuleProperties bool 51 mergeMatchingModuleProperties bool
52 reorderCommonProperties bool 52 reorderCommonProperties bool
53 removeTags bool
53} 54}
54 55
55func NewFixRequest() FixRequest { 56func NewFixRequest() FixRequest {
@@ -63,6 +64,7 @@ func (r FixRequest) AddAll() (result FixRequest) {
63 result.rewriteIncorrectAndroidmkAndroidLibraries = true 64 result.rewriteIncorrectAndroidmkAndroidLibraries = true
64 result.mergeMatchingModuleProperties = true 65 result.mergeMatchingModuleProperties = true
65 result.reorderCommonProperties = true 66 result.reorderCommonProperties = true
67 result.removeTags = true
66 return result 68 return result
67} 69}
68 70
@@ -180,6 +182,13 @@ func (f *Fixer) fixTreeOnce(config FixRequest) error {
180 return err 182 return err
181 } 183 }
182 } 184 }
185
186 if config.removeTags {
187 err := f.runPatchListMod(removeTags)
188 if err != nil {
189 return err
190 }
191 }
183 return nil 192 return nil
184} 193}
185 194
@@ -352,6 +361,72 @@ func reorderCommonProperties(mod *parser.Module, buf []byte, patchlist *parser.P
352 return nil 361 return nil
353} 362}
354 363
364func removeTags(mod *parser.Module, buf []byte, patchlist *parser.PatchList) error {
365 prop, ok := mod.GetProperty("tags")
366 if !ok {
367 return nil
368 }
369 list, ok := prop.Value.(*parser.List)
370 if !ok {
371 return nil
372 }
373
374 replaceStr := ""
375
376 for _, item := range list.Values {
377 str, ok := item.(*parser.String)
378 if !ok {
379 replaceStr += fmt.Sprintf("// ERROR: Unable to parse tag %q\n", item)
380 continue
381 }
382
383 switch str.Value {
384 case "optional":
385 continue
386 case "debug":
387 replaceStr += `// WARNING: Module tags are not supported in Soong.
388 // Add this module to PRODUCT_PACKAGES_DEBUG in your product file if you want to
389 // force installation for -userdebug and -eng builds.
390 `
391 case "eng":
392 replaceStr += `// WARNING: Module tags are not supported in Soong.
393 // Add this module to PRODUCT_PACKAGES_ENG in your product file if you want to
394 // force installation for -eng builds.
395 `
396 case "tests":
397 if strings.Contains(mod.Type, "cc_test") || strings.Contains(mod.Type, "cc_library_static") {
398 continue
399 } else if strings.Contains(mod.Type, "cc_lib") {
400 replaceStr += `// WARNING: Module tags are not supported in Soong.
401 // To make a shared library only for tests, use the "cc_test_library" module
402 // type. If you don't use gtest, set "gtest: false".
403 `
404 } else if strings.Contains(mod.Type, "cc_bin") {
405 replaceStr += `// WARNING: Module tags are not supported in Soong.
406 // For native test binaries, use the "cc_test" module type. Some differences:
407 // - If you don't use gtest, set "gtest: false"
408 // - Binaries will be installed into /data/nativetest[64]/<name>/<name>
409 // - Both 32 & 64 bit versions will be built (as appropriate)
410 `
411 } else if strings.Contains(mod.Type, "java_lib") {
412 replaceStr += `// WARNING: Module tags are not supported in Soong.
413 // For JUnit or similar tests, use the "java_test" module type. A dependency on
414 // Junit will be added by default, if it is using some other runner, set "junit: false".
415 `
416 } else {
417 replaceStr += `// WARNING: Module tags are not supported in Soong.
418 // In most cases, tests are now identified by their module type:
419 // cc_test, java_test, python_test
420 `
421 }
422 default:
423 replaceStr += fmt.Sprintf("// WARNING: Unknown module tag %q\n", str.Value)
424 }
425 }
426
427 return patchlist.Add(prop.Pos().Offset, prop.End().Offset+2, replaceStr)
428}
429
355func mergeMatchingModuleProperties(mod *parser.Module, buf []byte, patchlist *parser.PatchList) error { 430func mergeMatchingModuleProperties(mod *parser.Module, buf []byte, patchlist *parser.PatchList) error {
356 return mergeMatchingProperties(&mod.Properties, buf, patchlist) 431 return mergeMatchingProperties(&mod.Properties, buf, patchlist)
357} 432}