forked from MDE4CPP/MDE4CPP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
292 lines (248 loc) · 8.53 KB
/
Copy pathbuild.gradle
File metadata and controls
292 lines (248 loc) · 8.53 KB
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
description 'MDE4CPP root project'
import org.gradle.internal.os.OperatingSystem;
task buildAll() {
group 'MDE4CPP'
description 'build generators and all models'
dependsOn 'generator:createAllGenerators'
dependsOn 'src:buildEcoreModels'
dependsOn 'src:buildReflectionModels'
dependsOn 'src:buildUMLProfiles'
dependsOn 'src:common:pluginFramework:compilePluginFramework'
dependsOn 'src:common:persistence:compilePersistence'
dependsOn 'src:deliverBasicInterfaces'
}
task compileAll() {
group 'MDE4CPP'
description 'compile all models without generating the models'
dependsOn 'src:compileEcoreModels'
dependsOn 'src:compileReflectionModels'
dependsOn 'src:compileUMLProfiles'
dependsOn 'src:common:pluginFramework:compilePluginFramework'
dependsOn 'src:common:persistence:compilePersistence'
dependsOn 'src:deliverBasicInterfaces'
}
task generateAll() {
group 'MDE4CPP'
description 'compile all models without generating the models'
dependsOn 'src:generateEcoreModels'
dependsOn 'src:generateReflectionModels'
dependsOn 'src:generateUMLProfiles'
}
task installationInstruction() {
group 'MDE4CPP'
description 'installation instruction'
def instructionMessage = '' +
'##############################################################################\n' +
'# Installation instruction for MDE4CPP #\n' +
'##############################################################################\n' +
'\n' +
'Welcome to MDE4CPP framework!\n' +
'To start the work with MDE4CPP, you have to configure the environment settings.\n' +
'A pattern is prepared for it:\n' +
'- for Windows systems: setenv.bat.default\n' +
'- for Unix systems: setenv.default.\n' +
'Copy the file and remove the extension \'default\' first.\n' +
'Open this file and configure the variables afterwards.\n' +
'Run the file in a console. Note, that the environment is set inside the console\n' +
'and has to be redone at each season start\n' +
'More information see https://github.com/MDE4CPP/MDE4CPP\n' +
'\n'
/*def files = file('$projectDir').listFiles(new FileFilter() {
public boolean accept(File pathname) {
def extension = '.sh'
if (System.properties['os.name'].toLowerCase().contains('windows')) {
extension = '.bat'
}
return pathname.getName().endsWith(extension);
}
})*/
/*if (files.length == 0) {
println instructionMessage
} else {*/
doFirst {
println instructionMessage
}
//}
}
task setEnvironment(type:Exec){
workingDir System.getenv('MDE4CPP_HOME')
if (OperatingSystem.current().isWindows()) {
// MS Windows
commandLine 'cmd', '/c', 'setenv.bat'
} else if (OperatingSystem.current().isLinux()) {
// GNU/Linux
commandLine 'sh', '-c', '. ./setenv'
} else if (OperatingSystem.current().isMacOsX()){
// Apple macOS
commandLine "bash", "-c", "source setenv"
} else {
// OS not supported yet
throw new GradleException('OS ' + System.getProperty('os.name') + ' is not supported yet')
}
doLast {
println 'Environment variable have been set.'
}
}
task startEclipseModeling(type:Exec){
group 'Utilities'
description 'sets and checks the environment variables and starts the Eclipse instance (EMF) specified in the setenv file'
dependsOn 'checkEnvironment'
workingDir System.getenv('MDE4CPP_ECLIPSE_HOME') //No need to check it here, if it does not exist checkEnvironment will fail with an exception
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows')) {
//on windows:
commandLine 'cmd', '/c', 'start eclipse.exe'
} else {
//on linux
commandLine './eclipse'
}
}
task startCPPIDE(type:Exec){
group 'Utilities'
description 'sets and checks the environment variables and starts the C++ IDE specified in the setenv file'
dependsOn 'checkEnvironment'
doFirst{
if(System.getenv('CPP_IDE_EXECUTABLE') == null)
{
throw new GradleException("The required variable CPP_IDE_EXECUTABLE has not been set in your setEnv file.")
}
if (System.getProperty('os.name').toLowerCase(Locale.ROOT).contains('windows'))
{
//on windows:
commandLine 'cmd', '/c', ('start "" "' + System.getenv('CPP_IDE_EXECUTABLE') + '"')
}
else
{
//on linux
commandLine 'bash' , System.getenv('CPP_IDE_EXECUTABLE')
}
}
}
task checkEnvironment(){
dependsOn 'setEnvironment'
group 'Utilities'
description 'Check that all required variables defined in the setenv file are set and can be found'
ext.checkPath = { path ->
if(path == null || ! new File(path).exists()){
return false;
}
return true;
}
ext.checkVariableExists = { variable_name, should_fail ->
println ''
def my_var = System.getenv(variable_name);
if(my_var == null)
{
if(should_fail){
throw new GradleException(variable_name + ' variable has not been set')
}
else
{
println printColor('Warning:', 'yellow') + ' variable not set: ' + variable_name;
return false;
}
}
print variable_name + ': ' + my_var
return true;
}
ext.printColor = { text, color ->
def fg;
def finalString;
def bg = 49;
switch(color) {
case "red":
fg = 31;
break
case "green":
fg = 32;
break
case "yellow":
fg = 33;
break
default:
throw new GradleException('color "'+color+'" not defined')
break
}
def style = "${(char)27}[$fg;$bg"+"m"
finalString = style + text
//Restore the original color:
finalString += "${(char)27}[39;49m"
return finalString;
}
ext.checkAndPrintPath = { path ->
println ''
path = path.replace('\\', '/')
if(! checkPath(path)){
println path + printColor(' <- Warning! Path element not found!', 'yellow');
return
}
println path + printColor(' (exists)', 'green');
}
ext.checkCompilerIncludes = {
println '\n\n---------------------------'
println 'YOUR COMPILER INCLUDE PATHS'
println '---------------------------'
println 'you can ignore these if you are not using Eclipse as your C++ IDE'
checkVariableExists('COMPILER_DELIVERY_NAME', false);
checkVariableExists('COMPILER_VERSION', false);
def home = System.getenv('COMPILER_HOME');
def delivery = System.getenv('COMPILER_DELIVERY_NAME');
def version = System.getenv('COMPILER_VERSION');
println ''
checkAndPrintPath(home + "/include")
checkAndPrintPath(home + "/lib/gcc/" + delivery + "/" + version + "/include/c++")
checkAndPrintPath(home + "/lib/gcc/" + delivery + "/" + version + "/include/c++/backward")
checkAndPrintPath(home + "/lib/gcc/" + delivery + "/" + version + "/include/c++/" + delivery)
checkAndPrintPath(home + "/lib/gcc/" + delivery + "/" + version + "/include-fixed")
checkAndPrintPath(home + "/lib/gcc/" + delivery + "/" + version + "/include")
checkAndPrintPath(System.getenv('MDE4CPP_HOME') + "/application/include")
}
ext.checkMyVariablePath = { variable_name, should_fail ->
checkVariableExists(variable_name, should_fail)
if(! checkPath(System.getenv(variable_name))){
if(should_fail){
throw new GradleException('Path for variable ' + variable_name + ' cannot be found.' + System.getenv(variable_name))
}
return;
}
println printColor(' (exists)', 'green');
}
doFirst{
println '------------------'
println 'YOUR PATH VARIABLE'
println '------------------'
println 'PATH: ' + System.getenv('PATH')
def os_separator = OperatingSystem.current().isWindows() ? ';' : ':'
def path_elements = System.getenv('PATH').split(os_separator)
println '\nAnalyzing all path elements...'
path_elements.each{el ->
if(! checkPath(el))
{
println 'PATH contains an invalid element: ' + el;
}
else{
println '\t' + el + printColor(' (exists)', 'green');
}
}
println '\n------------------------------'
println 'YOUR ENV VARIABLES WITH A PATH'
println '------------------------------'
checkMyVariablePath('MDE4CPP_HOME', true)
checkMyVariablePath('MDE4CPP_ECLIPSE_HOME', true)
checkMyVariablePath('COMPILER_HOME', false)
checkMyVariablePath('CMAKE_HOME', false)
checkMyVariablePath('JAVA_HOME', false)
checkMyVariablePath('CPP_IDE_EXECUTABLE', false)
println '\n---------------------------------------'
println 'YOUR ENV VARIABLES WITH A CONFIGURATION'
println '---------------------------------------'
checkVariableExists('GRADLE_OPTS', false);
checkVariableExists('ORG_GRADLE_PROJECT_WORKER', false);
checkVariableExists('ORG_GRADLE_PROJECT_RELEASE', false);
checkVariableExists('ORG_GRADLE_PROJECT_DEBUG', false);
checkVariableExists('ORG_GRADLE_PROJECT_DEBUG_MESSAGE_FUML', false);
checkVariableExists('ORG_GRADLE_PROJECT_ACTIVITY_DEBUG_ON', false);
checkVariableExists('COMPILER_DELIVERY_NAME', false);
checkVariableExists('COMPILER_VERSION', false);
checkCompilerIncludes();
}
}