-
Notifications
You must be signed in to change notification settings - Fork 65
/
CMakeAndroidPluginGenerator.class.st
172 lines (118 loc) · 4.04 KB
/
CMakeAndroidPluginGenerator.class.st
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
Class {
#name : #CMakeAndroidPluginGenerator,
#superclass : #CMakePluginGenerator,
#category : #'CMakeVMMaker-Android'
}
{ #category : #'sources management' }
CMakeAndroidPluginGenerator >> addCrossSources: sources [
^ self addSources: sources prefixed: '$(pluginCross)/'
]
{ #category : #'gmake commands' }
CMakeAndroidPluginGenerator >> addDefinitions: aString [
output
nextPutAll: ('COG_CFLAGS += ', aString);
cr
]
{ #category : #'sources management' }
CMakeAndroidPluginGenerator >> addSources: aFileNames prefixed: aPrefix [
| names |
names := aFileNames inject: '' into: [:res :each | res , aPrefix, each, ' ' ].
self append: #LOCAL_SRC_FILES with: names.
]
{ #category : #'gmake commands' }
CMakeAndroidPluginGenerator >> addSubdirectory: aDir [
^ self include: ('$(buildDir)/', aDir, '/', self outputFileName).
]
{ #category : #'gmake commands' }
CMakeAndroidPluginGenerator >> append: variableName with: aValueString [
output
nextPutAll: (variableName, ' += ', aValueString);
cr
]
{ #category : #'gmake commands' }
CMakeAndroidPluginGenerator >> generate [
| name |
output := String new writeStream.
name := plugin moduleName.
self printHeader.
self
set: #pluginName to: name;
set: #pluginSrc to: '$(srcPluginsDir)/', name;
set: #pluginCross to: '$(crossDir)/plugins/', name;
set: #pluginPlatform to: '$(targetPlatform)/plugins/', name.
self addDefinitions: '-DSQUEAK_BUILTIN_PLUGIN'.
self addSources: { name , '.c' } prefixed: '$(pluginSrc)/'.
self includeDirectories: '-I$(pluginSrc) -I$(pluginCross) -I$(targetPlatform)/plugins/$(pluginName)'.
self addDefinitions: vmGen config compilerFlags.
" perform config's configureXYZ: message to apply per-plugin custom rules, if any "
vmGen config configurePlugin: plugin with: self.
extraRules ifNotNil: [ extraRules value: self ].
vmGen config extraPluginSettings: self.
self saveFile.
]
{ #category : #plugins }
CMakeAndroidPluginGenerator >> generatePlugin: aPlugin internal: aBoolean extraRules: aBlock [
doNotGenerate := false.
internal := aBoolean.
plugin := aPlugin.
vmGen := CMakeAndroidGenerator.
extraRules := aBlock.
^ self generate
]
{ #category : #'gmake commands' }
CMakeAndroidPluginGenerator >> include: aFileName [
output
nextPutAll: ('include ', aFileName);
cr
]
{ #category : #'gmake commands' }
CMakeAndroidPluginGenerator >> includeDirectories: aString [
output
nextPutAll: ('COG_INCLUDE_DIRS += ', aString);
cr
]
{ #category : #'sources management' }
CMakeAndroidPluginGenerator >> includeDirs [
^ '-I$(crossDir)/vm -I$(srcVMDir) -I$(targetPlatform)/vm -I$(buildDir)'.
]
{ #category : #accessing }
CMakeAndroidPluginGenerator >> outputFileName [
"override this to set the file name to create"
^ 'cogsources.mk'
]
{ #category : #'submakefile creation' }
CMakeAndroidPluginGenerator >> printHeader [
self puts: '# This is automatically generated file using ', self configurationName, ' on ',
Date current asString, ' ' , Time current asString.
]
{ #category : #plugins }
CMakeAndroidPluginGenerator >> processInternalPlugins [
| libs |
libs := OrderedCollection new.
config internalPlugins collect: [:each | | plugin gen |
plugin := Smalltalk at: each.
gen := plugin generateFor: self internal: true.
gen doNotGenerate ifFalse: [
libs add: plugin moduleName.
self addSubdirectory: plugin moduleName.
].
].
self generateExportsH: libs.
]
{ #category : #'gmake commands' }
CMakeAndroidPluginGenerator >> set: variableName to: aValueString [
output
nextPutAll: (variableName, ' := ', aValueString);
cr
]
{ #category : #accessing }
CMakeAndroidPluginGenerator >> sources [
self set: #coreSources to:
(self append: '$(srcVMDir)/' toAll: config coreSources).
self set: #platformVMSources to:
(self append: '$(targetPlatform)/vm/' toAll: config platformSources).
self set: #crossVMSources to:
(self append: '$(crossDir)/vm/' toAll: config crossSources).
self set: #extraSources to: config extraSources.
^ '$(coreSources) $(crossVMSources) $(platformVMSources) $(extraSources)'
]