blob: 2da32c6602928131b412bc16b810367798b744b7 [file] [log] [blame]
Liz Kammer2dd9ca42020-11-25 16:06:39 -08001package bp2build
2
3import (
4 "android/soong/android"
Liz Kammer2dd9ca42020-11-25 16:06:39 -08005)
6
7type nestedProps struct {
8 Nested_prop string
9}
10
11type 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
25type 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.
33func (m *customModule) OutputFiles(tag string) (android.Paths, error) {
34 return android.PathsForTesting("path" + tag), nil
35}
36
37func (m *customModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
38 // nothing for now.
39}
40
41func customModuleFactoryBase() android.Module {
42 module := &customModule{}
43 module.AddProperties(&module.props)
44 return module
45}
46
47func customModuleFactory() android.Module {
48 m := customModuleFactoryBase()
49 android.InitAndroidModule(m)
50 return m
51}
52
53type testProps struct {
54 Test_prop struct {
55 Test_string_prop string
56 }
57}
58
59type customTestModule struct {
60 android.ModuleBase
61
62 props customProps
63 test_props testProps
64}
65
66func (m *customTestModule) GenerateAndroidBuildActions(ctx android.ModuleContext) {
67 // nothing for now.
68}
69
70func customTestModuleFactoryBase() android.Module {
71 m := &customTestModule{}
72 m.AddProperties(&m.props)
73 m.AddProperties(&m.test_props)
74 return m
75}
76
77func customTestModuleFactory() android.Module {
78 m := customTestModuleFactoryBase()
79 android.InitAndroidModule(m)
80 return m
81}
82
83type customDefaultsModule struct {
84 android.ModuleBase
85 android.DefaultsModuleBase
86}
87
88func customDefaultsModuleFactoryBase() android.DefaultsModule {
89 module := &customDefaultsModule{}
90 module.AddProperties(&customProps{})
91 return module
92}
93
94func customDefaultsModuleFactoryBasic() android.Module {
95 return customDefaultsModuleFactoryBase()
96}
97
98func customDefaultsModuleFactory() android.Module {
99 m := customDefaultsModuleFactoryBase()
100 android.InitDefaultsModule(m)
101 return m
102}