-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
197 lines (187 loc) · 7.38 KB
/
build.gradle
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
plugins {
id 'cpp'
id 'edu.wpi.first.NativeUtils' version '1.7.0'
id 'edu.wpi.first.wpilib.versioning.WPILibVersioningPlugin' version '2.1'
}
apply from: 'config.gradle'
ext.sharedConfigsFirmwareSimHeaders = [CTRE_PhoenixPlatform_sim: []]
//To make platform creation easier in gradle, a class is used to store the common info
class PlatformParams {
String supportedOS
String supportedArch
String libName
PlatformParams(supportedOS, supportedArch, libName) {
this.supportedOS = supportedOS
this.supportedArch = supportedArch
this.libName = libName
}
}
PlatformParams platform_stub = ['all', 'all', 'CTRE_PhoenixPlatform']
PlatformParams platform_sim = ['all', 'all', 'CTRE_PhoenixPlatform_sim']
PlatformParams platform_socketcan = ['linux', 'all', 'CTRE_PhoenixPlatform_socketcan']
PlatformParams platform_ics = ['windows', 'all', 'CTRE_PhoenixPlatform_ics']
PlatformParams platform_somethingb = ['osx', 'all', 'CTRE_PhoenixPlatform_somethingb']
//These dictionary keys are also used part of the artifact name (like platform-sim)
ext.platforms = ["stub" : platform_stub,
"sim" : platform_sim,
"socketcan" : platform_socketcan,
"ics" : platform_ics,
"somethingb" : platform_somethingb]
//Everything depends on core
ext.sharedConfigsCore = [CTRE_PhoenixPlatform : [], CTRE_PhoenixPlatform_sim : [], CTRE_PhoenixPlatform_socketcan : [], CTRE_PhoenixPlatform_ics : [], CTRE_PhoenixPlatform_somethingb : []]
ext.sharedConfigsSim = [CTRE_PhoenixPlatform_sim : []]
apply from: 'dependencies.gradle'
def generalx86ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure',
'_CT??_R0?AVbad_cast',
'_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure',
'_TI5?AVfailure']
def generalx64ExcludeSymbols = ['_CT??_R0?AV_System_error', '_CT??_R0?AVexception', '_CT??_R0?AVfailure',
'_CT??_R0?AVbad_cast',
'_CT??_R0?AVruntime_error', '_CT??_R0?AVsystem_error', '_CTA5?AVfailure',
'_TI5?AVfailure']
//To add a new platform, just add a class to the dictionary above and copy each intance of someother platform
//(like stub) and find and replace stub with the new platforms name. This will need to be done in here and in
//publish.gradle
model {
exportsConfigs {
CTRE_PhoenixPlatform(ExportsConfig) {
x86ExcludeSymbols = generalx86ExcludeSymbols
x64ExcludeSymbols = generalx64ExcludeSymbols
}
CTRE_PhoenixPlatform_sim(ExportsConfig) {
x86ExcludeSymbols = generalx86ExcludeSymbols
x64ExcludeSymbols = generalx64ExcludeSymbols
}
CTRE_PhoenixPlatform_socketcan(ExportsConfig) {
x86ExcludeSymbols = generalx86ExcludeSymbols
x64ExcludeSymbols = generalx64ExcludeSymbols
}
CTRE_PhoenixPlatform_ics(ExportsConfig) {
x86ExcludeSymbols = generalx86ExcludeSymbols
x64ExcludeSymbols = generalx64ExcludeSymbols
}
CTRE_PhoenixPlatform_somethingb(ExportsConfig) {
x86ExcludeSymbols = generalx86ExcludeSymbols
x64ExcludeSymbols = generalx64ExcludeSymbols
}
}
//Directory structure is infered from supported os and the name/key
components {
CTRE_PhoenixPlatform(NativeLibrarySpec) {
sources {
cpp {
source {
srcDirs "src/main/${platforms['stub'].supportedOS}/stub/cpp"
include '**/*.cpp'
}
exportedHeaders {
srcDirs = ["src/main/${platforms['stub'].supportedOS}/stub/include", "src/include"]
}
}
}
ext.supportedOS = platforms['stub'].supportedOS
ext.supportedArch = platforms['stub'].supportedArch
}
CTRE_PhoenixPlatform_sim(NativeLibrarySpec) {
sources {
cpp {
source {
srcDirs "src/main/${platforms['sim'].supportedOS}/sim/cpp"
include '**/*.cpp'
}
exportedHeaders {
srcDirs = ["src/main/${platforms['sim'].supportedOS}/sim/include", "src/include"]
}
}
}
ext.supportedOS = platforms['sim'].supportedOS
ext.supportedArch = platforms['sim'].supportedArch
binaries.all {
if(it.targetPlatform.operatingSystem.name == 'windows'){
cppCompiler.define "_CRT_SECURE_NO_WARNINGS"
}
}
}
CTRE_PhoenixPlatform_socketcan(NativeLibrarySpec) {
sources {
cpp {
source {
srcDirs "src/main/${platforms['socketcan'].supportedOS}/socketcan/cpp"
include '**/*.cpp'
}
exportedHeaders {
srcDirs = ["src/main/${platforms['socketcan'].supportedOS}/socketcan/include", "src/include"]
}
}
}
ext.supportedOS = platforms['socketcan'].supportedOS
ext.supportedArch = platforms['socketcan'].supportedArch
}
CTRE_PhoenixPlatform_ics(NativeLibrarySpec) {
sources {
cpp {
source {
srcDirs "src/main/${platforms['ics'].supportedOS}/ics/cpp"
include '**/*.cpp'
}
exportedHeaders {
srcDirs = ["src/main/${platforms['ics'].supportedOS}/ics/include", "src/include"]
}
}
}
ext.supportedOS = platforms['ics'].supportedOS
ext.supportedArch = platforms['ics'].supportedArch
}
CTRE_PhoenixPlatform_somethingb(NativeLibrarySpec) {
sources {
cpp {
source {
srcDirs "src/main/${platforms['somethingb'].supportedOS}/somethingb/cpp"
include '**/*.cpp'
}
exportedHeaders {
srcDirs = ["src/main/${platforms['somethingb'].supportedOS}/somethingb/include", "src/include"]
}
}
}
ext.supportedOS = platforms['somethingb'].supportedOS
ext.supportedArch = platforms['somethingb'].supportedArch
}
}
binaries {
withType(SharedLibraryBinarySpec) {
//Loop through the platform class dictionary. If the this library matches the libName, make sure the os and
//arch are supported. If not, don't build
platforms.each{
key, value ->
if(value.libName == it.component.name) {
if((it.targetPlatform.operatingSystem.name != value.supportedOS && value.supportedOS != 'all')
|| (it.targetPlatform.architecture.name != value.supportedArch && value.supportedArch != 'all')) {
it.buildable = false
}
else {
it.buildable = !project.hasProperty("skip${key}")
}
}
}
}
withType(StaticLibraryBinarySpec) {
platforms.each{
key, value ->
if(value.libName == it.component.name) {
if((it.targetPlatform.operatingSystem.name != value.supportedOS && value.supportedOS != 'all')
|| (it.targetPlatform.architecture.name != value.supportedArch && value.supportedArch != 'all')) {
it.buildable = false
}
else {
it.buildable = !project.hasProperty("skip${key}")
}
}
}
}
}
}
apply from: 'publish.gradle'
wrapper {
gradleVersion = '4.9'
}