Paste Search Dynamic
android RegisterModuleType
  1.  
  2. [android-building] using go for condition in Srcs[] for cc_prebuilt_library_static
  3. A
  4. Aditya Singh Rathore
  5. kam: Android
  6. pirms 19 stundāmInformācija
  7. I have requirement of using different "src" for my prebuilt static library, based on some condition other than Target_arch.
  8.  
  9. I have used go file as below
  10.  
  11. func init() {
  12. android.RegisterModuleType("native_cc_prebuilt_defaults", genNativeDefaultsFactory)
  13. }
  14.  
  15. func genNativeDefaultsFactory() android.Module{
  16.     module := cc.DefaultsFactory()
  17.     android.AddLoadHook(module, loadBuildConfigCCNative)
  18.     return module
  19. }
  20.  
  21. func loadBuildConfigCCNative(ctx android.LoadHookContext){
  22.     type props struct {
  23.         Srcs []string
  24.     }
  25.     p := &props{}
  26.     var srcs  []string
  27.    
  28.     conditinal := getEnv(PRODUCT_CONFIG)
  29.    
  30.     if condition{
  31.         if envIsContains(target_arch, "arm64") {
  32.             srcs = append(srcs ,"path1/arm64/lib.a")
  33.         } else if envIsContains(target_arch, "arm"){
  34.             srcs = append(srcs ,"path1/arm/lib_32.a")
  35.         }
  36.     }else {
  37.         if envIsContains(target_arch, "arm64") {
  38.             srcs = append(srcs ,"path2/arm64/libiqinative.a")
  39.         } else if envIsContains(target_arch, "arm"){
  40.             srcs = append(srcs ,"path2/arm/libiqinative.a")
  41.         }
  42.     }
  43.     p.Srcs = srcs
  44.     ctx.AppendProperties(p)
  45. }
  46.  
  47. func envIsContains(key1 string, key2 string) bool {
  48.  
  49.     contained, _ := regexp.MatchString(key2, key1)
  50.     return contained
  51. }
  52.  
  53.  
  54. Android.bp
  55.  
  56. native_cc_prebuilt_defaults{
  57.     name: "my_lib_defaults",
  58. }
  59.  cc_prebuilt_library_static {
  60.     name : "my_lib",
  61.     compile_multilib: "both",  
  62.     defaults: ["my_lib_defaults"],    
  63.  }
  64.  
  65. But when I use "my_lib"
  66.  
  67. in some other module like below (in some go file for module "libAPVE")
  68.  
  69. staticLibs = append(staticLibs, "my_lib")
  70.  
  71. I am recieving following error "Requesting an invalid path" upon building :
  72.  
  73. internal error: panic in GenerateBuildActions for module "libAPVE" variant "android_arm_armv8-a_cortex-a53_core_shared"
  74. Requesting an invalid path
  75. goroutine 1187053 [running]:
  76. github.com/google/blueprint.newPanicErrorf(0xafad80, 0xcf1780, 0xc02f1b88c0, 0x6e, 0x0, 0x0, 0x0, 0x0, 0x0)
  77.     /workspace/android/build/blueprint/context.go:3566 +0x7b
  78. github.com/google/blueprint.(*Context).generateModuleBuildActions.func2.1.1(0xc051976000, 0xc03d5e9ba0)
  79.     /workspace/android/build/blueprint/context.go:2308 +0x39f
  80. panic(0xafad80, 0xcf1780)
  81.     prebuilts/go/linux-x86/src/runtime/panic.go:522 +0x1b5
  82. android/soong/android.OptionalPath.Path(...)
  83.     /workspace/android/build/soong/android/paths.go:180
  84. android/soong/cc.orderStaticModuleDeps(0xc04f88ad80, 0xc007264ac0, 0x4, 0x4, 0xc0357a1480, 0xb, 0x10, 0x7f7cee6ca118, 0x0, 0x0)
  85.     /workspace/android/build/soong/cc/cc.go:919 +0x63e
  86. android/soong/cc.(*Module).depsToPaths(0xc04f88ad80, 0xd359e0, 0xc0980af710, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
  87.     /workspace/android/build/soong/cc/cc.go:1892 +0x1eb
  88. android/soong/cc.(*Module).GenerateAndroidBuildActions(0xc04f88ad80, 0xd357a0, 0xc037254820)
  89.     /workspace/android/build/soong/cc/cc.go:946 +0xcb
  90. android/soong/android.(*ModuleBase).GenerateBuildActions(0xc04f88ad80, 0xd33700, 0xc03d5e9ba0)
  91.     /workspace/android/build/soong/android/module.go:887 +0x706
  92. github.com/google/blueprint.(*Context).generateModuleBuildActions.func2.1(0xc051976000, 0xc03d5e9ba0)
  93.     /workspace/android/build/blueprint/context.go:2312 +0x80
  94. github.com/google/blueprint.(*Context).generateModuleBuildActions.func2(0xc051976000, 0x0)
  95.     /workspace/android/build/blueprint/context.go:2313 +0x339
  96. github.com/google/blueprint.(*Context).parallelVisit.func1.1(0xc087c32ec0, 0xc051976000, 0xc0007c6480, 0xc0007c6300)
  97.     /workspace/android/build/blueprint/context.go:1718 +0x30
  98. created by github.com/google/blueprint.(*Context).parallelVisit.func1
  99.     / workspace /android/build/blueprint/context.go:1717 +0x124
Parsed in 0.025 seconds