-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.lip
412 lines (357 loc) · 9.53 KB
/
make.lip
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
//
// file LIP : LIsaac Path directory and make LIsaac Project system.
//
Section Private
//
// Compiler variables.
//
// File information (auto-loading variables).
+ lisaac :STRING; // is environment variable value (auto-loading).
+ input_file :STRING; // is input file name value without extension.
+ output_file :STRING; // is output file name value without extension.
+ output_extension:STRING; // is extension of `output_file'
+ is_speed_push:BOOLEAN := TRUE; // See `old_push' function.
// Debug information.
+ debug_level:INTEGER := 15;
+ debug_with_code:BOOLEAN := TRUE;
+ is_all_warning:BOOLEAN;
// Optimization.
+ is_optimization:BOOLEAN;
+ inline_level:INTEGER := 5;
// Generate code.
+ is_cop:BOOLEAN := FALSE;
+ is_library:BOOLEAN; // For build a lisaac library C
+ execute_back_end:BOOLEAN := TRUE;
+ execute_status_code:INTEGER := 0;
// Other.
+ is_statistic:BOOLEAN;
+ is_quiet:BOOLEAN;
+ is_o3:BOOLEAN;
+ is_tcc:BOOLEAN;
//
// Other variables.
//
+ option_gcc:STRING;
+ lib_gcc:STRING;
+ execute_file:STRING;
+ target:STRING := "unix";
+ is_apple:BOOLEAN := TRUE;
+ cc:STRING := "gcc";
//
// Service
//
+ exit_success_code:INTEGER := 0;
+ exit_failure_code:INTEGER := 1;
+ message:STRING := "";
- message_install msg:STRING <-
(
message := msg;
);
- add_lib lib:STRING <-
(
(target = "windows").if {
run "echo int main(){ return(1); } > __tmp__.c";
(run (cc + " __tmp__.c -o __tmp__ " + lib + " > NUL") = 0).if {
lib_gcc := lib_gcc + " " + lib;
run "del __tmp__.c __tmp__.exe";
} else {
"\nERROR: `" + lib + "' library for `"+cc+"' not found.\n".print;
run "del __tmp__.c";
message.print;
die_with_code exit_failure_code;
};
} else {
run "echo \"int main(){ return(1); }\" > __tmp__.c";
(run (cc + " __tmp__.c -o __tmp__ " + lib + " 2> /dev/null") = 0).if {
lib_gcc := lib_gcc + " " + lib;
run "rm __tmp__.c __tmp__";
} else {
("\nERROR: `" + lib + "' library for `"+cc+"' not found.\n").print;
run "rm __tmp__.c";
message.print;
die_with_code exit_failure_code;
};
};
);
- execute cmd:STRING <-
(
(! is_quiet).if {
"run `".print;
cmd.print;
"'\n".print;
};
execute_status_code := run cmd;
(execute_status_code != 0).if {
(is_quiet).if {
"FAILURE run `".print;
cmd.print;
"' (".print;
} else {
"FAILURE (".print;
};
execute_status_code.print;
")\n".print;
};
);
- execute_fail cmd:STRING <-
(
execute cmd;
(execute_status_code > 255).if {
die_with_code exit_failure_code;
};
(execute_status_code != 0).if {
die_with_code execute_status_code;
};
);
//
// Execute function.
//
- general_front_end <-
(
path "lib/*";
old_push; // BSBS: Pour l'instant...
);
- general_back_end <-
(
((execute_back_end) & (target != "android")).if {
(is_cop).if {
lib_gcc := lib_gcc + " -lpthread";
};
(target = "windows").if {
execute_file := output_file + ".exe";
} else {
execute_file := output_file;
};
(option_gcc != " -g").if {
(is_o3).if {
option_gcc := option_gcc + " -O3";
} else {
option_gcc := option_gcc + " -O2";
};
};
option_gcc := option_gcc + " -Wall -U_FORTIFY_SOURCE -Wno-parentheses-equality -Wstrict-overflow=0 "; // -fomit-frame-pointer
(is_tcc).if {
(is_library).if {
execute_fail ("tcc " + output_file + output_extension + " -c ");
} else {
execute_fail ("tcc " + output_file + output_extension + " -o " + output_file + lib_gcc);
};
} else {
//execute_fail ("sed -i 's/ = \\*((\\*COLOR__/ = ((\\*COLOR__/' "+
//output_file + output_extension);
//execute_fail ("sed -i 's/ = \\*((\\*VERTEX__/ = ((\\*VERTEX__/' "+
//output_file + output_extension);
/*
execute_fail ("sed -i 's/ = \\*((\\*PATH_LOW__/ = ((\\*PATH_LOW__/' "+
output_file + output_extension);
execute_fail ("sed -i 's/ = \\*((\\*SHADER__/ = ((\\*SHADER__/' "+
output_file + output_extension);
execute_fail ("sed -i 's/ = \\*((\\*FRAG__/ = ((\\*FRAG__/' "+
output_file + output_extension);
execute_fail ("sed -i 's/)((\\*FRAG__/)((FRAG__/' "+
output_file + output_extension);
execute_fail ("sed -i 's/\\*)(\\*FRAG__/\\*)(FRAG__/' "+
output_file + output_extension);
execute_fail ("sed -i 's/,((\\*FRAG__/,((FRAG__/' "+
output_file + output_extension);
*/
(is_library).if {
execute_fail (cc+" " + output_file + output_extension + " -c " + option_gcc);
} else {
((is_speed_push) & (debug_level > 0)).if {
execute_fail (cc+" " + output_file + output_extension + " -S " + option_gcc + lib_gcc);
build_label (output_file + ".s");
execute_fail (cc+" " + input_file + "_label.s -o "+ output_file + option_gcc + lib_gcc);
} else {
execute_fail (cc+" " + output_file + output_extension + " -o " + output_file + option_gcc + lib_gcc);
};
};
};
} else {
//execute_fail ("sed -i 's/ = \\*((\\*COLOR__/ = ((\\*COLOR__/' "+
//output_file + output_extension);
/*
execute_fail ("sed -i 's/ = \\*((\\*VERTEX__/ = ((\\*VERTEX__/' "+
output_file + output_extension);
execute_fail ("sed -i 's/ = \\*((\\*PATH_LOW__/ = ((\\*PATH_LOW__/' "+
output_file + output_extension);
execute_fail ("sed -i 's/ = \\*((\\*SHADER__/ = ((\\*SHADER__/' "+
output_file + output_extension);
execute_fail ("sed -i 's/ = \\*((\\*FRAG__/ = ((\\*FRAG__/' "+
output_file + output_extension);
execute_fail ("sed -i 's/)((\\*FRAG__/)((FRAG__/' "+
output_file + output_extension);
execute_fail ("sed -i 's/\\*)(\\*FRAG__/\\*)(FRAG__/' "+
output_file + output_extension);
execute_fail ("sed -i 's/,((\\*FRAG__/,((FRAG__/' "+
output_file + output_extension);
*/
("Written: " + output_file + output_extension + "\n").print;
(target = "android").if {
execute_fail (lisaac+"lia/run.sh " + output_file);
};
};
);
- front_end <-
// Executed by compiler, before compilation step.
(
general_front_end;
);
- back_end <-
// Executed by compiler, after compilation step.
(
general_back_end;
);
Section Public
//
// Debug information:
//
- no_debug <-
// No debug information.
(
debug_level := 0;
debug_with_code := FALSE;
);
- debug level:INTEGER <-
// Fix debug level (default: 15)
(
((level < 1) | (level > 20)).if {
"Incorrect debug level.\n".print;
die_with_code exit_failure_code;
};
debug_level := level;
);
- without_source <-
// Debug mode without source code.
(
debug_with_code := FALSE;
);
- all_warning <-
// All warning (deferred detect, ...).
(
is_all_warning := TRUE;
);
- old_push <-
// Use old stack saving for debug mode.
(
is_speed_push := FALSE;
);
//
// Optimization:
//
- optim <-
// Full Lisaac optimization.
(
no_debug;
is_optimization := TRUE;
);
- boost <-
// Full optimization (lisaac and gcc).
(
optim;
);
- hyper_boost <-
// Simple boost, with `-O3' option for GCC
(
boost;
is_o3 := TRUE;
);
- i level:INTEGER <-
// Inlining level [1..5000] (default: 15)
(
((level < 1) | (level > 5000)).if {
"Incorrect inlining level.\n".print;
exit;
};
inline_level := level;
);
//
// Generate code:
//
- compiler cmd:STRING <-
// Used `cmd' as C compiler.
(
cc := cmd;
);
- cop <-
// Active Concurrence Object Prototype.
(
is_cop := TRUE;
);
- tcc <-
// Used TCC (Tiny C Compiler) for `back_end' operation.
(
(run "command -v tcc > /dev/null 2> /dev/null" != 0).if {
"Error: Tiny C Compiler not found.\n\
\(Debian: sudo apt-get install tcc)\n".print;
die_with_code exit_failure_code;
};
is_speed_push := FALSE;
is_tcc := TRUE;
);
- o outputfile:STRING <-
// Change output file (default: `input_file').
(
output_file := outputfile;
);
- target idf:STRING <-
// Target for backend (unix,windows,dos)
(
target := idf;
);
- gcc option:STRING <-
// Add option for GCC.
(
option_gcc := option_gcc + " " + option;
);
- partial <-
// Only generate C code and don't compile it with GCC
(
execute_back_end := FALSE;
);
//
// Other:
//
- add_path str:STRING <-
// Add the `str' path in the current list of path.
(
path str;
);
- q <-
// Quiet operation.
(
is_quiet := TRUE;
);
- build_library <-
// For to build library (`main' => `init')
(
is_library := TRUE;
);
//
// Information:
//
- s <-
// Statistic information.
(
is_statistic := TRUE;
);
- help <-
// Help
(
help_command;
die_with_code exit_success_code;
);
- version <-
// Version
(
compiler_version;
die_with_code exit_success_code;
);
- go <-
// Search the `main' prototype in current directory
(
"List:\n\
\=====\n".print;
run "grep -l \"\\- main\" *.li";
die_with_code exit_success_code;
);