Liz Kammer | 2dd9ca4 | 2020-11-25 16:06:39 -0800 | [diff] [blame] | 1 | package bp2build |
| 2 | |
| 3 | import ( |
| 4 | "android/soong/android" |
Liz Kammer | 2dd9ca4 | 2020-11-25 16:06:39 -0800 | [diff] [blame] | 5 | ) |
| 6 | |
| 7 | type nestedProps struct { |
| 8 | Nested_prop string |
| 9 | } |
| 10 | |
| 11 | type customProps struct { |
| 12 | Bool_prop bool |
| 13 | Bool_ptr_prop *bool |
| 14 | // Ensure that properties tagged `blueprint:mutated` are omitted |
| 15 | Int_prop int `blueprint:"mutated"` |
| 16 | Int64_ptr_prop *int64 |
| 17 | String_prop string |
| 18 | String_ptr_prop *string |
| 19 | String_list_prop []string |
| 20 | |
| 21 | Nested_props nestedProps |
| 22 | Nested_props_ptr *nestedProps |
| 23 | } |
| 24 | |
| 25 | type customModule struct { |
| 26 | android.ModuleBase |
| 27 | |
| 28 | props customProps |
| 29 | } |
| 30 | |
| 31 | // OutputFiles is needed because some instances of this module use dist with a |
| 32 | // tag property which requires the module implements OutputFileProducer. |
| 33 | func (m *customModule) OutputFiles(tag string) (android.Paths, error) { |
| 34 | return android.PathsForTesting("path" + tag), nil |
| 35 | } |
| 36 | |
| 37 | func (m *customModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 38 | // nothing for now. |
| 39 | } |
| 40 | |
| 41 | func customModuleFactoryBase() android.Module { |
| 42 | module := &customModule{} |
| 43 | module.AddProperties(&module.props) |
| 44 | return module |
| 45 | } |
| 46 | |
| 47 | func customModuleFactory() android.Module { |
| 48 | m := customModuleFactoryBase() |
| 49 | android.InitAndroidModule(m) |
| 50 | return m |
| 51 | } |
| 52 | |
| 53 | type testProps struct { |
| 54 | Test_prop struct { |
| 55 | Test_string_prop string |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | type customTestModule struct { |
| 60 | android.ModuleBase |
| 61 | |
| 62 | props customProps |
| 63 | test_props testProps |
| 64 | } |
| 65 | |
| 66 | func (m *customTestModule) GenerateAndroidBuildActions(ctx android.ModuleContext) { |
| 67 | // nothing for now. |
| 68 | } |
| 69 | |
| 70 | func customTestModuleFactoryBase() android.Module { |
| 71 | m := &customTestModule{} |
| 72 | m.AddProperties(&m.props) |
| 73 | m.AddProperties(&m.test_props) |
| 74 | return m |
| 75 | } |
| 76 | |
| 77 | func customTestModuleFactory() android.Module { |
| 78 | m := customTestModuleFactoryBase() |
| 79 | android.InitAndroidModule(m) |
| 80 | return m |
| 81 | } |
| 82 | |
| 83 | type customDefaultsModule struct { |
| 84 | android.ModuleBase |
| 85 | android.DefaultsModuleBase |
| 86 | } |
| 87 | |
| 88 | func customDefaultsModuleFactoryBase() android.DefaultsModule { |
| 89 | module := &customDefaultsModule{} |
| 90 | module.AddProperties(&customProps{}) |
| 91 | return module |
| 92 | } |
| 93 | |
| 94 | func customDefaultsModuleFactoryBasic() android.Module { |
| 95 | return customDefaultsModuleFactoryBase() |
| 96 | } |
| 97 | |
| 98 | func customDefaultsModuleFactory() android.Module { |
| 99 | m := customDefaultsModuleFactoryBase() |
| 100 | android.InitDefaultsModule(m) |
| 101 | return m |
| 102 | } |