demake 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/demake +520 -167
- metadata +22 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ad64570b38ff8a61ee1a0707c671e207443422c403048971107ecb88a8b397bf
|
|
4
|
+
data.tar.gz: a8ec76e1e656f91b352c5f4207da9727f887d71ad69127f028405153c56789fd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 92df21acfb3f996384d3e6284f4c75ae4a0807b75deba072a4d88473c9f6adb22b8348b1b6c8c2c6d7ccdd56880ebe8b904c88b610e72adf3da41d32496136ad
|
|
7
|
+
data.tar.gz: 433713d18c06f6ce22aa64f819d5acf98d55f6581dafb57affcb3b0e57e76cf8001703ae6499833dfd4ec1ccd01c2bad2b4752c4999681dc1c3f8d17bee50288
|
data/bin/demake
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
#
|
|
6
6
|
require 'pipetext'
|
|
7
7
|
|
|
8
|
-
demake_version = "0.1.
|
|
8
|
+
demake_version = "0.1.1"
|
|
9
9
|
|
|
10
10
|
@silent = false
|
|
11
11
|
@compiler = "gcc"
|
|
@@ -16,6 +16,10 @@ demake_version = "0.1.0"
|
|
|
16
16
|
# Raise if you have more cores and a long compile time
|
|
17
17
|
@num_threads = 8
|
|
18
18
|
|
|
19
|
+
# Where to install binaries
|
|
20
|
+
@prefix = "/usr/local/bin/"
|
|
21
|
+
@library_prefix = "/usr/local/lib64/"
|
|
22
|
+
|
|
19
23
|
# Contains code, does not get touched
|
|
20
24
|
@source_directory = "src"
|
|
21
25
|
|
|
@@ -33,18 +37,23 @@ demake_version = "0.1.0"
|
|
|
33
37
|
@emoji_clean = "|r|[fire]|n "
|
|
34
38
|
@emoji_debug = "|n|[bug] "
|
|
35
39
|
@emoji_install = "|s|[nut and bolt]|n "
|
|
40
|
+
@emoji_uninstall = "|y|[wrench]|n "
|
|
36
41
|
@emoji_test = "|R|[red question mark]|n "
|
|
37
42
|
@emoji_compile = "|s|[hammer and wrench]|n "
|
|
38
43
|
@emoji_link = "|B|[link]|n "
|
|
39
44
|
@emoji_fail = "|R|[cross mark]|n "
|
|
45
|
+
@emoji_success = "|g|[check mark]|n "
|
|
40
46
|
|
|
41
47
|
@pipe = Class.new.extend(PipeText)
|
|
42
48
|
|
|
43
49
|
@flags = String.new
|
|
50
|
+
@debug_flags = "-DDEBUG -g -Wall -Wextra -Wunused-variable -Wundef -Wconversion -Wshadow -Wcast-qual -Wwrite-strings "
|
|
44
51
|
@linux_flags = String.new
|
|
45
52
|
@x86_64_flags = String.new
|
|
46
53
|
@aarch64_flags = String.new
|
|
47
54
|
@darwin_flags = String.new
|
|
55
|
+
@windows_flags = String.new
|
|
56
|
+
@freebsd_flags = String.new
|
|
48
57
|
@libraries = String.new
|
|
49
58
|
@raw_binary_files = String.new
|
|
50
59
|
|
|
@@ -53,10 +62,12 @@ def strip_emojis!(string)
|
|
|
53
62
|
string.gsub!(@emoji_clean, @replace_with)
|
|
54
63
|
string.gsub!(@emoji_debug, @replace_with)
|
|
55
64
|
string.gsub!(@emoji_install, @replace_with)
|
|
65
|
+
string.gsub!(@emoji_uninstall, @replace_with)
|
|
56
66
|
string.gsub!(@emoji_test, @replace_with)
|
|
57
67
|
string.gsub!(@emoji_compile, @replace_with)
|
|
58
68
|
string.gsub!(@emoji_link, @replace_with)
|
|
59
69
|
string.gsub!(@emoji_fail, @replace_with)
|
|
70
|
+
string.gsub!(@emoji_success, @replace_with)
|
|
60
71
|
# Everything else
|
|
61
72
|
string.gsub!(/\|\[.*\]/, @replace_with)
|
|
62
73
|
end
|
|
@@ -68,76 +79,370 @@ def notify(string)
|
|
|
68
79
|
STDERR.puts(@pipe.pipetext(string))
|
|
69
80
|
end
|
|
70
81
|
|
|
82
|
+
# Used by both example and oreo to show options
|
|
83
|
+
settingsrb = <<-END_OF_STRING
|
|
84
|
+
# Uncomment to use / override
|
|
71
85
|
#
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
86
|
+
=begin
|
|
87
|
+
@silent = false
|
|
88
|
+
@compiler = "clang"
|
|
89
|
+
@prefix = "/usr/local/bin/"
|
|
90
|
+
@library_prefix = "/usr/lib64/"
|
|
91
|
+
@emojis = false
|
|
92
|
+
@replace_with = "|b*|n"
|
|
93
|
+
@libraries << "-lc"
|
|
94
|
+
@flags << "-ansi -pedantic -D_DEFAULT_SOURCE"
|
|
95
|
+
@linux_flags << "-static" # clang
|
|
96
|
+
@linux_flags << "-static -static-libgcc"
|
|
97
|
+
@x86_64_flags << "-msse2 -mssse3 -msse4.1 -msha"
|
|
98
|
+
@aarch64_flags << "-march=armv8-a+crypto"
|
|
99
|
+
@windows_flags << ""
|
|
100
|
+
@freebsd_flags << ""
|
|
101
|
+
@darwin_flags << "-bundle"
|
|
102
|
+
@debug_flags << "-Wpedantic -Wdeprecated-declarations -Wdiv-by-zero " +
|
|
103
|
+
"-Wimplicit-function-declaration -Wimplicit-int " +
|
|
104
|
+
"-Wpointer-arith -Wwrite-strings -Wold-style-definition " +
|
|
105
|
+
"-Wmissing-noreturn -Wno-cast-function-type " +
|
|
106
|
+
"-Wno-constant-logical-operand -Wno-long-long " +
|
|
107
|
+
"-Wno-missing-field-initializers -Wno-overlength-strings " +
|
|
108
|
+
"-Wno-packed-bitfield-compat -Wno-parentheses-equality " +
|
|
109
|
+
"-Wno-self-assign -Wno-tautological-compare " +
|
|
110
|
+
"-Wno-unused-parameter -Wno-unused-value " +
|
|
111
|
+
"-Wsuggest-attribute=format -Wsuggest-attribute=noreturn"
|
|
112
|
+
@flags = "-g -Wall"
|
|
113
|
+
# No default flags (use only flags in the line above)
|
|
114
|
+
$flags_override = true
|
|
115
|
+
=end
|
|
116
|
+
notify("#{@emoji_success} |gdemake/settings.rb is present|n")
|
|
117
|
+
END_OF_STRING
|
|
118
|
+
|
|
119
|
+
@example = false
|
|
120
|
+
if(ARGV[0] =~ /^example$/)
|
|
121
|
+
if(File.directory?('example') == true)
|
|
122
|
+
notify("\n#{@emoji_fail}|RError|n: |Ydirectory example |Ralready exists, aborting creation|n\n\n" +
|
|
123
|
+
"Delete the directory and try again if you wish to recreate it.\n\n")
|
|
124
|
+
exit!
|
|
80
125
|
end
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
126
|
+
@example = true
|
|
127
|
+
# C code files used by the example
|
|
128
|
+
helloc = <<-END_OF_STRING
|
|
129
|
+
/*
|
|
130
|
+
The most basic multiple executable example using a shared object/header file.
|
|
131
|
+
|
|
132
|
+
hello.c will generate an executable named hello which that prints hello, world
|
|
133
|
+
*/
|
|
134
|
+
#include "string/string.h"
|
|
135
|
+
|
|
136
|
+
int main(void)
|
|
137
|
+
{
|
|
138
|
+
out("hello, world");
|
|
139
|
+
return 0;
|
|
140
|
+
}
|
|
141
|
+
END_OF_STRING
|
|
142
|
+
|
|
143
|
+
goodbyec = <<-END_OF_STRING
|
|
144
|
+
/*
|
|
145
|
+
The most basic multiple executable example using a shared object/header file.
|
|
146
|
+
|
|
147
|
+
goodbye.c will generate an executable named hello which that prints goodbye, world
|
|
148
|
+
*/
|
|
149
|
+
#include "string/string.h"
|
|
150
|
+
|
|
151
|
+
int main(void)
|
|
152
|
+
{
|
|
153
|
+
out("goodbye, world");
|
|
154
|
+
return 0;
|
|
155
|
+
}
|
|
156
|
+
END_OF_STRING
|
|
157
|
+
|
|
158
|
+
stringh = <<-END_OF_STRING
|
|
159
|
+
/*
|
|
160
|
+
The most basic multiple executable example using a shared object/header file.
|
|
161
|
+
|
|
162
|
+
string.h includes a simple shared function named out which prints output
|
|
163
|
+
*/
|
|
164
|
+
|
|
165
|
+
void out(const char *in);
|
|
166
|
+
END_OF_STRING
|
|
167
|
+
|
|
168
|
+
stringc = <<-END_OF_STRING
|
|
169
|
+
/*
|
|
170
|
+
The most basic multiple executable example using a shared object/header file.
|
|
171
|
+
|
|
172
|
+
string.c creates a simple shared function named out which prints output
|
|
173
|
+
*/
|
|
174
|
+
#include <stdio.h>
|
|
175
|
+
#include "string.h"
|
|
176
|
+
|
|
177
|
+
void out(const char *in)
|
|
178
|
+
{
|
|
179
|
+
printf("%s\\n", in);
|
|
180
|
+
}
|
|
181
|
+
END_OF_STRING
|
|
182
|
+
|
|
183
|
+
testtargetrb = <<-END_OF_STRING
|
|
184
|
+
test_target << "\\t@echo\\n"
|
|
185
|
+
test_target << "\\t@echo \\"|YTesting command hello:|n\\"\\n"
|
|
186
|
+
test_target << "\\tbin/hello\\n"
|
|
187
|
+
test_target << "\\t@echo \\"|YTesting command goodbye:|n\\"\\n"
|
|
188
|
+
test_target << "\\tbin/goodbye\\n"
|
|
189
|
+
END_OF_STRING
|
|
190
|
+
|
|
191
|
+
Dir.mkdir('example')
|
|
192
|
+
notify("#{@emoji_success} Created directory: |gexample|n |[open file folder]\n")
|
|
193
|
+
Dir.mkdir('example/src')
|
|
194
|
+
notify("#{@emoji_success} Created directory: |gexample|n/|gsrc|n |[open file folder]\n")
|
|
195
|
+
File.open('example/src/hello.c', 'w').write(helloc)
|
|
196
|
+
notify("#{@emoji_success} Created file: |gexample|n/|gsrc|n/|yhello.c|n |[page facing up]\n")
|
|
197
|
+
File.open('example/src/goodbye.c', 'w').write(goodbyec)
|
|
198
|
+
notify("#{@emoji_success} Created file: |gexample|n/|gsrc|n/|ygoodbye.c|n |[page facing up]\n")
|
|
199
|
+
Dir.mkdir('example/src/string')
|
|
200
|
+
notify("#{@emoji_success} Created directory: |gexample|n/|gsrc|n/|gstring|n |[open file folder]\n")
|
|
201
|
+
File.open('example/src/string/string.h', 'w').write(stringh)
|
|
202
|
+
notify("#{@emoji_success} Created file: |gexample|n/|gsrc|n/|gstring|n/|ystring.h|n |[page facing up]\n")
|
|
203
|
+
File.open('example/src/string/string.c', 'w').write(stringc)
|
|
204
|
+
notify("#{@emoji_success} Created file: |gexample|n/|gsrc|n/|gstring|n/|ystring.c|n |[page facing up]\n")
|
|
205
|
+
Dir.mkdir('example/demake')
|
|
206
|
+
notify("#{@emoji_success} Created directory: |gexample|n/|gdemake|n |[open file folder]\n")
|
|
207
|
+
File.open('example/demake/applications', 'w').write("hello string\ngoodbye string\n")
|
|
208
|
+
notify("#{@emoji_success} Created file: |gexample|n/|gdemake|n/|yapplications|n |[page facing up]\n")
|
|
209
|
+
File.open('example/demake/settings.rb', 'w').write(settingsrb)
|
|
210
|
+
notify("#{@emoji_success} Created file: |gexample|n/|gdemake|n/|ysettings.rb|n |[page facing up]\n")
|
|
211
|
+
File.open('example/demake/test-target.rb', 'w').write(testtargetrb)
|
|
212
|
+
notify("#{@emoji_success} Created file: |gexample|n/|gdemake|n/|ytest-target.rb|n |[page facing up]\n")
|
|
213
|
+
Dir.chdir('example')
|
|
214
|
+
@working_directory = Dir.pwd
|
|
85
215
|
end
|
|
86
216
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
application_and_dependencies = File.open('demake/applications').read.split(/\n/)
|
|
94
|
-
no_applications_file = false
|
|
95
|
-
application_and_dependencies.each do |app|
|
|
96
|
-
if(app !~ /^#/ && app !~ /^[ \t]*#/)
|
|
97
|
-
if(app =~ /([^ :\t]*)[ :\t]*(.*)[ \t]*#?.*/)
|
|
98
|
-
application = $1
|
|
99
|
-
dependencies = $2.sub(/#.*$/, '').split(/[ :\t]/)
|
|
100
|
-
@applications[application] = dependencies
|
|
101
|
-
else
|
|
102
|
-
@applications[app] = Array.new
|
|
103
|
-
end
|
|
104
|
-
end
|
|
217
|
+
@oreo = false
|
|
218
|
+
if(ARGV[0] =~ /^oreo$/)
|
|
219
|
+
if(File.directory?('oreo') == true)
|
|
220
|
+
notify("\n#{@emoji_fail}|RError|n: |Ydirectory oreo |Ralready exists, aborting creation|n\n\n" +
|
|
221
|
+
"Delete the directory and try again if you wish to recreate it.\n\n")
|
|
222
|
+
exit!
|
|
105
223
|
end
|
|
106
|
-
|
|
224
|
+
@oreo = true
|
|
225
|
+
# C code file used by oreo
|
|
226
|
+
oreoc = <<-END_OF_STRING
|
|
227
|
+
/*
|
|
228
|
+
oreo.c -- A simple c program that reads data piped in, issued as arguments or from a file and echos output
|
|
229
|
+
|
|
230
|
+
Program main entry point: main/_start
|
|
231
|
+
*/
|
|
232
|
+
|
|
233
|
+
#include <stdio.h>
|
|
234
|
+
#include <stdlib.h>
|
|
235
|
+
#include <string.h>
|
|
236
|
+
#ifndef __WIN32__
|
|
237
|
+
#include <sys/ioctl.h>
|
|
238
|
+
#else
|
|
239
|
+
#include <windows.h>
|
|
240
|
+
#endif
|
|
241
|
+
|
|
242
|
+
#define FALSE 0
|
|
243
|
+
#define TRUE 1
|
|
244
|
+
|
|
245
|
+
#define READ_BUFFER_SIZE 4096
|
|
246
|
+
|
|
247
|
+
/* Read all the text from a file and put it into a string */
|
|
248
|
+
char *read_file(FILE *file, unsigned int *total_bytes)
|
|
249
|
+
{
|
|
250
|
+
size_t bytes = 0, count = 0;
|
|
251
|
+
char buffer[READ_BUFFER_SIZE + 1], *text = NULL;
|
|
252
|
+
|
|
253
|
+
*total_bytes = 0;
|
|
254
|
+
|
|
255
|
+
if(file == NULL)
|
|
256
|
+
return NULL;
|
|
257
|
+
|
|
258
|
+
bytes = fread(buffer, sizeof(char), READ_BUFFER_SIZE, file);
|
|
259
|
+
while(bytes) {
|
|
260
|
+
if(text) {
|
|
261
|
+
text = realloc(text, *total_bytes + bytes + 1);
|
|
262
|
+
count = 0;
|
|
263
|
+
while(count < bytes) {
|
|
264
|
+
*(text + *total_bytes + count) = buffer[count];
|
|
265
|
+
count++;
|
|
266
|
+
}
|
|
267
|
+
} else {
|
|
268
|
+
text = calloc(bytes + 1, sizeof(char));
|
|
269
|
+
count = 0;
|
|
270
|
+
while(count < bytes) {
|
|
271
|
+
*(text + *total_bytes + count) = buffer[count];
|
|
272
|
+
count++;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
*total_bytes += (unsigned int)bytes;
|
|
276
|
+
*(text + *total_bytes) = '\\0';
|
|
277
|
+
bytes = fread(buffer, sizeof(char), READ_BUFFER_SIZE, file);
|
|
278
|
+
}
|
|
279
|
+
return text;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
int main(int argc, char **argv)
|
|
283
|
+
{
|
|
284
|
+
FILE *file = NULL;
|
|
285
|
+
unsigned int total_bytes = 0, l = 0;
|
|
286
|
+
int n = 0;
|
|
287
|
+
unsigned char *string = NULL, displayed = FALSE;
|
|
288
|
+
#ifdef __WIN32__
|
|
289
|
+
HANDLE stdin_handle = GetStdHandle(STD_INPUT_HANDLE);
|
|
290
|
+
DWORD bytes;
|
|
291
|
+
|
|
292
|
+
if(PeekNamedPipe(stdin_handle, NULL, 0, NULL, &bytes, NULL) && bytes > 0) {
|
|
293
|
+
#else
|
|
294
|
+
if(ioctl(0, FIONREAD, &n) == 0 && n > 0) {
|
|
295
|
+
#endif
|
|
296
|
+
string = (unsigned char *)read_file(stdin, &total_bytes);
|
|
297
|
+
#ifdef DEBUG
|
|
298
|
+
printf("From stdin:\\r\\n");
|
|
299
|
+
#endif
|
|
300
|
+
printf("oreo: %s\\r\\n", string);
|
|
301
|
+
free(string);
|
|
302
|
+
string = NULL;
|
|
303
|
+
displayed = TRUE;
|
|
304
|
+
}
|
|
305
|
+
if(argv[1] != NULL) {
|
|
306
|
+
file = fopen(argv[1], "r");
|
|
307
|
+
if(file == NULL) {
|
|
308
|
+
/* We need to manually recreate the command input based on arguments with spaces */
|
|
309
|
+
for(n = 1; n < argc; n++) {
|
|
310
|
+
if(string != NULL) {
|
|
311
|
+
l = (unsigned int)strlen(argv[n]);
|
|
312
|
+
total_bytes += l + 1; /* +1 for space */
|
|
313
|
+
string = realloc(string, (size_t)total_bytes + 1); /* +1 for \\0 */
|
|
314
|
+
strncat((char *)string, " ", (size_t)2); /* 2 for space and \\0 */
|
|
315
|
+
strncat((char *)string, argv[n], l);
|
|
316
|
+
} else {
|
|
317
|
+
total_bytes = (unsigned int)strlen(argv[n]);
|
|
318
|
+
string = calloc(total_bytes + 1, sizeof(char)); /* +1 for \\0 */
|
|
319
|
+
strncpy((char *)string, argv[n], total_bytes);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
#ifdef DEBUG
|
|
323
|
+
printf("From argument:\\r\\n");
|
|
324
|
+
#endif
|
|
325
|
+
printf("oreo: %s\\r\\n", string);
|
|
326
|
+
free(string);
|
|
327
|
+
string = NULL;
|
|
328
|
+
} else {
|
|
329
|
+
#ifdef DEBUG
|
|
330
|
+
printf("From file: %s\\r\\n", argv[1]);
|
|
331
|
+
#endif
|
|
332
|
+
string = (unsigned char *)read_file(file, &total_bytes);
|
|
333
|
+
printf("oreo: %s\\r\\n", string);
|
|
334
|
+
free(string);
|
|
335
|
+
string = NULL;
|
|
336
|
+
}
|
|
337
|
+
} else if(!displayed) {
|
|
338
|
+
#ifdef DEBUG
|
|
339
|
+
printf("No input provided.\\r\\n");
|
|
340
|
+
#endif
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return 0;
|
|
344
|
+
}
|
|
345
|
+
END_OF_STRING
|
|
346
|
+
|
|
347
|
+
testtargetrb = <<-END_OF_STRING
|
|
348
|
+
test_target << "\\t@echo\\n"
|
|
349
|
+
test_target << "\\t@echo \\"|YBasic functional testing of command oreo:|n\\"\\n"
|
|
350
|
+
test_target << "\\tbin/oreo Test 1\\n"
|
|
351
|
+
test_target << "\\techo -n \\"Test 2\\" || bin/oreo\\n"
|
|
352
|
+
test_target << "\\techo -n \\"Test 3\\" || bin/oreo Test 4\\n"
|
|
353
|
+
END_OF_STRING
|
|
354
|
+
|
|
355
|
+
Dir.mkdir('oreo')
|
|
356
|
+
notify("#{@emoji_success} Created directory: |goreo|n |[open file folder]\n")
|
|
357
|
+
Dir.mkdir('oreo/src')
|
|
358
|
+
notify("#{@emoji_success} Created directory: |goreo|n/|gsrc|n |[open file folder]\n")
|
|
359
|
+
File.open('oreo/src/oreo.c', 'w').write(oreoc)
|
|
360
|
+
notify("#{@emoji_success} Created file: |goreo|n/|gsrc|n/|yoreo.c|n |[page facing up]\n")
|
|
361
|
+
Dir.mkdir('oreo/demake')
|
|
362
|
+
notify("#{@emoji_success} Created directory: |goreo|n/|gdemake|n |[open file folder]\n")
|
|
363
|
+
File.open('oreo/demake/applications', 'w').write("oreo\n")
|
|
364
|
+
notify("#{@emoji_success} Created file: |goreo|n/|gdemake|n/|yapplications|n |[page facing up]\n")
|
|
365
|
+
File.open('oreo/demake/settings.rb', 'w').write(settingsrb)
|
|
366
|
+
notify("#{@emoji_success} Created file: |goreo|n/|gdemake|n/|ysettings.rb|n |[page facing up]\n")
|
|
367
|
+
File.open('oreo/demake/test-target.rb', 'w').write(testtargetrb)
|
|
368
|
+
notify("#{@emoji_success} Created file: |goreo|n/|gdemake|n/|ytest-target.rb|n |[page facing up]\n")
|
|
369
|
+
Dir.chdir('oreo')
|
|
370
|
+
@working_directory = Dir.pwd
|
|
107
371
|
end
|
|
108
372
|
|
|
109
|
-
|
|
110
|
-
no_libraries_file = true
|
|
373
|
+
@applications = Hash.new
|
|
111
374
|
@build_libraries = Hash.new
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
#
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
375
|
+
|
|
376
|
+
if(@example == false && @oreo == false)
|
|
377
|
+
# Check for settings override
|
|
378
|
+
begin
|
|
379
|
+
code = File.open('demake/settings.rb').read
|
|
380
|
+
if(@emojis == false)
|
|
381
|
+
strip_emojis!(code)
|
|
382
|
+
end
|
|
383
|
+
eval code
|
|
384
|
+
rescue Errno::ENOENT
|
|
385
|
+
rescue
|
|
386
|
+
notify("\n|YWARNING|n: #{$!}\n\n")
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
# Applications to build
|
|
390
|
+
no_applications_file = true
|
|
391
|
+
begin
|
|
392
|
+
# The expected format is the application followed by a list of its dependencies
|
|
393
|
+
# all on the same line separated by space, : or tab and # for comments
|
|
394
|
+
application_and_dependencies = File.open('demake/applications').read.split(/\n/)
|
|
395
|
+
no_applications_file = false
|
|
396
|
+
application_and_dependencies.each do |app|
|
|
397
|
+
if(app !~ /^#/ && app !~ /^[ \t]*#/)
|
|
398
|
+
if(app =~ /([^ :\t]*)[ :\t]*(.*)[ \t]*#?.*/)
|
|
399
|
+
application = $1
|
|
400
|
+
dependencies = $2.sub(/#.*$/, '').split(/[ :\t]/)
|
|
401
|
+
@applications[application] = dependencies
|
|
402
|
+
else
|
|
403
|
+
@applications[app] = Array.new
|
|
404
|
+
end
|
|
125
405
|
end
|
|
126
406
|
end
|
|
407
|
+
rescue
|
|
127
408
|
end
|
|
128
|
-
rescue
|
|
129
|
-
end
|
|
130
409
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
410
|
+
# Libraries to build
|
|
411
|
+
no_libraries_file = true
|
|
412
|
+
begin
|
|
413
|
+
# The expected format is the application followed by a list of its dependencies
|
|
414
|
+
# all on the same line separated by space, : or tab and # for comments
|
|
415
|
+
libraries_and_dependencies = File.open('demake/libraries').read.split(/\n/)
|
|
416
|
+
no_libraries_file = false
|
|
417
|
+
libraries_and_dependencies.each do |lib|
|
|
418
|
+
if(lib !~ /^#/ && lib !~ /^[ \t]*#/)
|
|
419
|
+
if(lib =~ /([^ :\t]*)[ :\t]*(.*)[ \t]*#?.*/)
|
|
420
|
+
library = $1
|
|
421
|
+
dependencies = $2.sub(/#.*$/, '').split(/[ :\t]/)
|
|
422
|
+
@build_libraries[library] = dependencies
|
|
423
|
+
else
|
|
424
|
+
@build_libraries[lib] = Array.new
|
|
425
|
+
end
|
|
426
|
+
end
|
|
427
|
+
end
|
|
428
|
+
rescue
|
|
429
|
+
end
|
|
430
|
+
if(no_applications_file && no_libraries_file)
|
|
431
|
+
notify("\n#{@emoji_fail}|RError|n: |Yapplications file|n |Rdoes not exist|n\n\n" +
|
|
432
|
+
"You must create a file named |Yapplications|n which contains a list of\n" +
|
|
433
|
+
"executeable application names and any dependencies to be compiled.\n\n")
|
|
434
|
+
exit!
|
|
435
|
+
elsif(@applications == {} && @build_libraries == {})
|
|
436
|
+
notify("\n#{@emoji_fail}|RError|n: |Yapplications file|n |Rcannot be empty|n\n\n" +
|
|
437
|
+
"You must create a file named |Yapplications|n which contains a list of\n" +
|
|
438
|
+
"executeable application names and any dependencies to be compiled.\n\n")
|
|
439
|
+
exit!
|
|
440
|
+
end
|
|
441
|
+
elsif(@oreo == true)
|
|
442
|
+
@applications['oreo'] = Array.new
|
|
443
|
+
elsif(@example == true)
|
|
444
|
+
@applications['hello'] = ['string']
|
|
445
|
+
@applications['goodbye'] = ['string']
|
|
141
446
|
end
|
|
142
447
|
|
|
143
448
|
@output = <<-END_OF_STRING
|
|
@@ -158,6 +463,8 @@ CC = #{@compiler}
|
|
|
158
463
|
OS := $(shell uname)
|
|
159
464
|
PROCESSOR := $(shell uname -p)
|
|
160
465
|
MACHINE := $(shell uname -m)
|
|
466
|
+
PREFIX = #{@prefix}
|
|
467
|
+
LIBRARY_PREFIX = #{@library_prefix}
|
|
161
468
|
END_OF_STRING
|
|
162
469
|
|
|
163
470
|
@output << compiler_settings
|
|
@@ -168,6 +475,16 @@ if(@linux_flags != "")
|
|
|
168
475
|
compiler_flags << " FLAGS += #{@linux_flags}\n"
|
|
169
476
|
compiler_flags << "endif\n"
|
|
170
477
|
end
|
|
478
|
+
if(@freebsd_flags != "")
|
|
479
|
+
compiler_flags << "ifeq '$(OS)' 'FreeBSD'\n"
|
|
480
|
+
compiler_flags << " FLAGS += #{@freebsd_flags}\n"
|
|
481
|
+
compiler_flags << "endif\n"
|
|
482
|
+
end
|
|
483
|
+
if(@windows_flags != "")
|
|
484
|
+
compiler_flags << "ifeq '$(OS)' 'Windows_NT'\n"
|
|
485
|
+
compiler_flags << " FLAGS += #{@windows_flags}\n"
|
|
486
|
+
compiler_flags << "endif\n"
|
|
487
|
+
end
|
|
171
488
|
if(@darwin_flags != "")
|
|
172
489
|
compiler_flags << "ifeq '$(OS)' 'Darwin'\n"
|
|
173
490
|
compiler_flags << " FLAGS += #{@darwin_flags}\n"
|
|
@@ -184,11 +501,7 @@ if(@x86_64_flags != "")
|
|
|
184
501
|
compiler_flags << "endif\n"
|
|
185
502
|
end
|
|
186
503
|
compiler_flags += <<-END_OF_STRING
|
|
187
|
-
|
|
188
|
-
DEBUG_FLAGS = $(FLAGS) -g -Wall -Wpedantic -Wextra -Wdeprecated-declarations -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef -Wconversion -Wshadow -Wcast-qual -Wwrite-strings
|
|
189
|
-
else
|
|
190
|
-
DEBUG_FLAGS = $(FLAGS) -g -Wall -Wpedantic -Wextra -Wdeprecated-declarations -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wundef -Wconversion -Wshadow -Wcast-qual -Wwrite-strings
|
|
191
|
-
endif
|
|
504
|
+
DEBUG_FLAGS = #{@debug_flags}
|
|
192
505
|
FLAGS += -O2
|
|
193
506
|
CFLAGS = $(FLAGS)
|
|
194
507
|
END_OF_STRING
|
|
@@ -200,9 +513,9 @@ end
|
|
|
200
513
|
@output << compiler_flags
|
|
201
514
|
|
|
202
515
|
if(compiler_flags =~ /-static/)
|
|
203
|
-
library_extension = '.a'
|
|
516
|
+
@library_extension = '.a'
|
|
204
517
|
else
|
|
205
|
-
library_extension = '.so'
|
|
518
|
+
@library_extension = '.so'
|
|
206
519
|
end
|
|
207
520
|
|
|
208
521
|
compiler_directories = <<-END_OF_STRING
|
|
@@ -223,12 +536,12 @@ debug_file_list = String.new
|
|
|
223
536
|
@applications.each do |app|
|
|
224
537
|
counter += 1
|
|
225
538
|
file_list << "#\n# #{app[0]} - File List (FL#{counter})\n#\n"
|
|
226
|
-
debug_file_list << "#\n# #{app[0]}
|
|
539
|
+
debug_file_list << "#\n# #{app[0]}_debug - Debug File List (DFL#{counter})\n#\n"
|
|
227
540
|
# test to see if there is a app.c and we need app.o
|
|
228
541
|
begin
|
|
229
542
|
File.open(@source_directory + '/' + "#{app[0]}.c")
|
|
230
543
|
file_list << "FL#{counter} = #{app[0]}.o"
|
|
231
|
-
debug_file_list << "DFL#{counter} = #{app[0]}
|
|
544
|
+
debug_file_list << "DFL#{counter} = #{app[0]}_debug.o"
|
|
232
545
|
rescue Errno::ENOENT
|
|
233
546
|
file_list << "FL#{counter} ="
|
|
234
547
|
debug_file_list << "DFL#{counter} ="
|
|
@@ -239,7 +552,7 @@ debug_file_list = String.new
|
|
|
239
552
|
Dir.chdir(@source_directory + '/' + app[0]) do
|
|
240
553
|
if(File.directory?(e) == false)
|
|
241
554
|
file_list << " " + app[0] + '/' + $1 + '.o'
|
|
242
|
-
debug_file_list << " " + app[0] + '/' + $1 + '
|
|
555
|
+
debug_file_list << " " + app[0] + '/' + $1 + '_debug.o'
|
|
243
556
|
end
|
|
244
557
|
end
|
|
245
558
|
end
|
|
@@ -252,14 +565,14 @@ debug_file_list = String.new
|
|
|
252
565
|
Dir.chdir(@source_directory + '/' + dep) do
|
|
253
566
|
if(File.directory?(e) == false)
|
|
254
567
|
file_list << " " + dep + '/' + $1 + '.o'
|
|
255
|
-
debug_file_list << " " + dep + '/' + $1 + '
|
|
568
|
+
debug_file_list << " " + dep + '/' + $1 + '_debug.o'
|
|
256
569
|
end
|
|
257
570
|
end
|
|
258
571
|
end
|
|
259
572
|
end
|
|
260
573
|
else
|
|
261
574
|
file_list << " " + dep.sub(/\.cp?p?$/, '.o')
|
|
262
|
-
debug_file_list << " " + dep.sub(/\.o$/, '
|
|
575
|
+
debug_file_list << " " + dep.sub(/\.o$/, '_debug.o').sub(/\.cp?p?$/, '_debug.o')
|
|
263
576
|
end
|
|
264
577
|
end
|
|
265
578
|
file_list << "\n"
|
|
@@ -267,7 +580,7 @@ debug_file_list = String.new
|
|
|
267
580
|
file_list << "OL#{counter} = $(patsubst %.o, $(OBJECT)/%.o, $(FL#{counter}))\n"
|
|
268
581
|
@output << file_list
|
|
269
582
|
debug_file_list << "\n"
|
|
270
|
-
debug_file_list << "#\n# #{app[0]}
|
|
583
|
+
debug_file_list << "#\n# #{app[0]}_debug - Debug Object List (DOL#{counter})\n#\n"
|
|
271
584
|
debug_file_list << "DOL#{counter} = $(patsubst %.o, $(OBJECT)/%.o, $(DFL#{counter}))\n"
|
|
272
585
|
@output << debug_file_list
|
|
273
586
|
end
|
|
@@ -276,13 +589,13 @@ file_list = String.new
|
|
|
276
589
|
debug_file_list = String.new
|
|
277
590
|
@build_libraries.each do |lib|
|
|
278
591
|
counter += 1
|
|
279
|
-
file_list << "#\n# #{lib[0]}#{library_extension} - File List (FL#{counter})\n#\n"
|
|
280
|
-
debug_file_list << "#\n# #{lib[0]}
|
|
592
|
+
file_list << "#\n# #{lib[0]}#{@library_extension} - File List (FL#{counter})\n#\n"
|
|
593
|
+
debug_file_list << "#\n# #{lib[0]}_debug#{@library_extension} - Debug File List (DFL#{counter})\n#\n"
|
|
281
594
|
# test to see if there is a lib.c and we need lib.o
|
|
282
595
|
begin
|
|
283
596
|
File.open(@source_directory + '/' + "#{lib[0]}.c")
|
|
284
597
|
file_list << "FL#{counter} = #{lib[0]}.o"
|
|
285
|
-
debug_file_list << "DFL#{counter} = #{lib[0]}
|
|
598
|
+
debug_file_list << "DFL#{counter} = #{lib[0]}_debug.o"
|
|
286
599
|
rescue Errno::ENOENT
|
|
287
600
|
file_list << "FL#{counter} ="
|
|
288
601
|
debug_file_list << "DFL#{counter} ="
|
|
@@ -293,7 +606,7 @@ debug_file_list = String.new
|
|
|
293
606
|
Dir.chdir(@source_directory + '/' + lib[0]) do
|
|
294
607
|
if(File.directory?(e) == false)
|
|
295
608
|
file_list << " " + lib[0] + '/' + $1 + '.o'
|
|
296
|
-
debug_file_list << " " + lib[0] + '/' + $1 + '
|
|
609
|
+
debug_file_list << " " + lib[0] + '/' + $1 + '_debug.o'
|
|
297
610
|
end
|
|
298
611
|
end
|
|
299
612
|
end
|
|
@@ -306,22 +619,22 @@ debug_file_list = String.new
|
|
|
306
619
|
Dir.chdir(@source_directory + '/' + dep) do
|
|
307
620
|
if(File.directory?(e) == false)
|
|
308
621
|
file_list << " " + dep + '/' + $1 + '.o'
|
|
309
|
-
debug_file_list << " " + dep + '/' + $1 + '
|
|
622
|
+
debug_file_list << " " + dep + '/' + $1 + '_debug.o'
|
|
310
623
|
end
|
|
311
624
|
end
|
|
312
625
|
end
|
|
313
626
|
end
|
|
314
627
|
else
|
|
315
628
|
file_list << " " + dep.sub(/\.cp?p?$/, '.o')
|
|
316
|
-
debug_file_list << " " + dep.sub(/\.o$/, '
|
|
629
|
+
debug_file_list << " " + dep.sub(/\.o$/, '_debug.o').sub(/\.cp?p?$/, '_debug.o')
|
|
317
630
|
end
|
|
318
631
|
end
|
|
319
632
|
file_list << "\n"
|
|
320
|
-
file_list << "#\n# #{lib[0]}#{library_extension} - Object List (OL#{counter})\n#\n"
|
|
633
|
+
file_list << "#\n# #{lib[0]}#{@library_extension} - Object List (OL#{counter})\n#\n"
|
|
321
634
|
file_list << "OL#{counter} = $(patsubst %.o, $(OBJECT)/%.o, $(FL#{counter}))\n"
|
|
322
635
|
@output << file_list
|
|
323
636
|
debug_file_list << "\n"
|
|
324
|
-
debug_file_list << "#\n# #{lib[0]}
|
|
637
|
+
debug_file_list << "#\n# #{lib[0]}_debug#{@library_extension} - Debug Object List (DOL#{counter})\n#\n"
|
|
325
638
|
debug_file_list << "DOL#{counter} = $(patsubst %.o, $(OBJECT)/%.o, $(DFL#{counter}))\n"
|
|
326
639
|
@output << debug_file_list
|
|
327
640
|
end
|
|
@@ -337,6 +650,7 @@ menu :
|
|
|
337
650
|
\t@echo "|=!|28 #{@emoji_clean} |cclean|n|;!|O"
|
|
338
651
|
\t@echo "|=!|28 #{@emoji_debug} |cdebug|n|;!|O"
|
|
339
652
|
\t@echo "|=!|28 #{@emoji_install} |cinstall|n|;!|O"
|
|
653
|
+
\t@echo "|=!|28 #{@emoji_uninstall} |cuninstall|n|;!|O"
|
|
340
654
|
\t@echo "|=!|28 #{@emoji_test} |ctest|n|;!|O"
|
|
341
655
|
\t@echo "|=!|;!|O"
|
|
342
656
|
\t@echo "|=>|70-<|O"
|
|
@@ -345,7 +659,7 @@ END_OF_STRING
|
|
|
345
659
|
menu_target << "\t@echo \"|=!|]78 Executable: bin/|g#{app[0]}|n|;!|O\"\n"
|
|
346
660
|
end
|
|
347
661
|
@build_libraries.each do |lib|
|
|
348
|
-
menu_target << "\t@echo \"|=!|]78 Library: bin/|g#{lib[0]}#{library_extension}|n|;!|O\"\n"
|
|
662
|
+
menu_target << "\t@echo \"|=!|]78 Library: bin/|g#{lib[0]}#{@library_extension}|n|;!|O\"\n"
|
|
349
663
|
end
|
|
350
664
|
menu_target << "\t@echo \"|={|70-}|O\"\n"
|
|
351
665
|
@output << "\n"
|
|
@@ -377,7 +691,7 @@ end
|
|
|
377
691
|
\t@echo "|=[|70-]|O"
|
|
378
692
|
\t@echo "|]78|=! #{@emoji_build} Building library: bin/|g#{lib[0]}|n|;!|O"
|
|
379
693
|
\t@echo "|={|70-}|O"
|
|
380
|
-
\t@$(MAKE) $(BINARY)/#{lib[0]}#{library_extension}
|
|
694
|
+
\t@$(MAKE) $(BINARY)/#{lib[0]}#{@library_extension}
|
|
381
695
|
END_OF_STRING
|
|
382
696
|
if(@emojis == false)
|
|
383
697
|
strip_emojis!(library_target)
|
|
@@ -411,25 +725,21 @@ def add_dependencies(filename, path)
|
|
|
411
725
|
# Dependencies
|
|
412
726
|
$(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '.o')} : $(SOURCE)#{path}#{filename}#{dependencies}
|
|
413
727
|
\t@echo "|=!|O #{@emoji_compile} Compiling... |Y$(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '.o')}|n"
|
|
414
|
-
ifeq '$(OS)' '
|
|
415
|
-
\t@
|
|
416
|
-
else ifeq '$(OS)' 'FreeBSD'
|
|
417
|
-
\t@mkdir -p $(OBJECT)#{path}
|
|
728
|
+
ifeq '$(OS)' 'Windows_NT'
|
|
729
|
+
\t@test -d $(OBJECT)#{path} |||| mkdir $(OBJECT)#{path}
|
|
418
730
|
else
|
|
419
|
-
\t@
|
|
731
|
+
\t@mkdir -p $(OBJECT)#{path}
|
|
420
732
|
endif
|
|
421
|
-
\t$(CC) $(CFLAGS) -c $(SOURCE)#{path}#{filename} -o $(OBJECT)#{path}#{filename.gsub(/\.cp?p?$/, '.o')}
|
|
733
|
+
\t$(CC) $(LIBS) $(CFLAGS) -c $(SOURCE)#{path}#{filename} -o $(OBJECT)#{path}#{filename.gsub(/\.cp?p?$/, '.o')}
|
|
422
734
|
# Dependencies for debug
|
|
423
|
-
$(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '
|
|
424
|
-
\t@echo "|=!|O #{@emoji_debug} #{@emoji_compile} Compiling... |Y$(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '
|
|
425
|
-
ifeq '$(OS)' '
|
|
426
|
-
\t@
|
|
427
|
-
else ifeq '$(OS)' 'FreeBSD'
|
|
428
|
-
\t@mkdir -p $(OBJECT)#{path}
|
|
735
|
+
$(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '_debug.o')} : $(SOURCE)#{path}#{filename}#{dependencies}
|
|
736
|
+
\t@echo "|=!|O #{@emoji_debug} #{@emoji_compile} Compiling... |Y$(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '_debug.o')}|n"
|
|
737
|
+
ifeq '$(OS)' 'Windows_NT'
|
|
738
|
+
\t@test -d $(OBJECT)#{path} |||| mkdir $(OBJECT)#{path}
|
|
429
739
|
else
|
|
430
|
-
\t@
|
|
740
|
+
\t@mkdir -p $(OBJECT)#{path}
|
|
431
741
|
endif
|
|
432
|
-
\t$(CC) $(DEBUG_FLAGS) -c $(SOURCE)#{path}#{filename} -o $(OBJECT)#{path}#{filename.gsub(/\.cp?p?$/, '
|
|
742
|
+
\t$(CC) $(LIBS) $(DEBUG_FLAGS) -c $(SOURCE)#{path}#{filename} -o $(OBJECT)#{path}#{filename.gsub(/\.cp?p?$/, '_debug.o')}
|
|
433
743
|
END_OF_STRING
|
|
434
744
|
if(@emojis == false)
|
|
435
745
|
strip_emojis!(dependency_targets)
|
|
@@ -474,14 +784,12 @@ $(BINARY)/#{app[0]} : $(OL#{counter})
|
|
|
474
784
|
\t@echo "|=[|70-]|O"
|
|
475
785
|
\t@echo "|]78|=! #{@emoji_link} Linking Files...|O bin/|g#{app[0]}|=|n|;!|O"
|
|
476
786
|
\t@echo "|={|70-}|O"
|
|
477
|
-
ifeq '$(OS)' '
|
|
478
|
-
\t@
|
|
479
|
-
else ifeq '$(OS)' 'FreeBSD'
|
|
480
|
-
\t@mkdir -p $(BINARY)
|
|
787
|
+
ifeq '$(OS)' 'Windows_NT'
|
|
788
|
+
\t@test -d $(BINARY) |||| mkdir $(BINARY)
|
|
481
789
|
else
|
|
482
|
-
\t@
|
|
790
|
+
\t@mkdir -p $(BINARY)
|
|
483
791
|
endif
|
|
484
|
-
\t$(CC) $(
|
|
792
|
+
\t$(CC) $(LIBS) $(CFLAGS) -o $(BINARY)/#{app[0]} $(OL#{counter})#{@raw_binary_files}
|
|
485
793
|
END_OF_STRING
|
|
486
794
|
@output << "\n"
|
|
487
795
|
if(@emojis == false)
|
|
@@ -490,7 +798,7 @@ END_OF_STRING
|
|
|
490
798
|
@output << @pipe.pipetext(executable_target)
|
|
491
799
|
end
|
|
492
800
|
|
|
493
|
-
if(library_extension == ".so")
|
|
801
|
+
if(@library_extension == ".so")
|
|
494
802
|
shared = " -shared"
|
|
495
803
|
else
|
|
496
804
|
shared = String.new
|
|
@@ -499,18 +807,16 @@ end
|
|
|
499
807
|
@build_libraries.each do |lib|
|
|
500
808
|
counter += 1
|
|
501
809
|
library_target = <<-END_OF_STRING
|
|
502
|
-
$(BINARY)/#{lib[0]}#{library_extension} : $(OL#{counter})
|
|
810
|
+
$(BINARY)/#{lib[0]}#{@library_extension} : $(OL#{counter})
|
|
503
811
|
\t@echo "|=[|70-]|O"
|
|
504
|
-
\t@echo "|]78|=! #{@emoji_link} Linking Files...|O bin/|g#{lib[0]}#{library_extension}|=|n|;!|O"
|
|
812
|
+
\t@echo "|]78|=! #{@emoji_link} Linking Files...|O bin/|g#{lib[0]}#{@library_extension}|=|n|;!|O"
|
|
505
813
|
\t@echo "|={|70-}|O"
|
|
506
|
-
ifeq '$(OS)' '
|
|
507
|
-
\t@
|
|
508
|
-
else ifeq '$(OS)' 'FreeBSD'
|
|
509
|
-
\t@mkdir -p $(BINARY)
|
|
814
|
+
ifeq '$(OS)' 'Windows_NT'
|
|
815
|
+
\t@test -d $(BINARY) |||| mkdir $(BINARY)
|
|
510
816
|
else
|
|
511
|
-
\t@
|
|
817
|
+
\t@mkdir -p $(BINARY)
|
|
512
818
|
endif
|
|
513
|
-
\t$(CC)#{shared} $(
|
|
819
|
+
\t$(CC)#{shared} $(LIBS) $(CFLAGS) -o $(BINARY)/#{lib[0]}#{@library_extension} $(OL#{counter})#{@raw_binary_files}
|
|
514
820
|
END_OF_STRING
|
|
515
821
|
@output << "\n"
|
|
516
822
|
if(@emojis == false)
|
|
@@ -524,18 +830,16 @@ counter = 0
|
|
|
524
830
|
@applications.each do |app|
|
|
525
831
|
counter += 1
|
|
526
832
|
debug_executable_target = <<-END_OF_STRING
|
|
527
|
-
$(BINARY)/#{app[0]}
|
|
833
|
+
$(BINARY)/#{app[0]}_debug : $(DOL#{counter})
|
|
528
834
|
\t@echo "|=[|70-]|O"
|
|
529
|
-
\t@echo "|]78|=! #{@emoji_debug} #{@emoji_link} Linking Files...|O bin/|g#{app[0]}
|
|
835
|
+
\t@echo "|]78|=! #{@emoji_debug} #{@emoji_link} Linking Files...|O bin/|g#{app[0]}_debug|=|n|;!|O"
|
|
530
836
|
\t@echo "|={|70-}|O"
|
|
531
|
-
ifeq '$(OS)' '
|
|
532
|
-
\t@
|
|
533
|
-
else ifeq '$(OS)' 'FreeBSD'
|
|
534
|
-
\t@mkdir -p $(BINARY)
|
|
837
|
+
ifeq '$(OS)' 'Windows_NT'
|
|
838
|
+
\t@test -d $(BINARY) |||| mkdir $(BINARY)
|
|
535
839
|
else
|
|
536
|
-
\t@
|
|
840
|
+
\t@mkdir -p $(BINARY)
|
|
537
841
|
endif
|
|
538
|
-
\t$(CC) $(
|
|
842
|
+
\t$(CC) $(LIBS) $(DEBUG_FLAGS) -o $(BINARY)/#{app[0]}_debug $(DOL#{counter})#{@raw_binary_files}
|
|
539
843
|
END_OF_STRING
|
|
540
844
|
@output << "\n"
|
|
541
845
|
if(@emojis == false)
|
|
@@ -547,18 +851,16 @@ end
|
|
|
547
851
|
@build_libraries.each do |lib|
|
|
548
852
|
counter += 1
|
|
549
853
|
debug_library_target = <<-END_OF_STRING
|
|
550
|
-
$(BINARY)/#{lib[0]}
|
|
854
|
+
$(BINARY)/#{lib[0]}_debug#{@library_extension} : $(DOL#{counter})
|
|
551
855
|
\t@echo "|=[|70-]|O"
|
|
552
|
-
\t@echo "|]78|=! #{@emoji_debug} #{@emoji_link} Linking Files...|O bin/|g#{lib[0]}
|
|
856
|
+
\t@echo "|]78|=! #{@emoji_debug} #{@emoji_link} Linking Files...|O bin/|g#{lib[0]}_debug#{@library_extension}|=|n|;!|O"
|
|
553
857
|
\t@echo "|={|70-}|O"
|
|
554
|
-
ifeq '$(OS)' '
|
|
555
|
-
\t@
|
|
556
|
-
else ifeq '$(OS)' 'FreeBSD'
|
|
557
|
-
\t@mkdir -p $(BINARY)
|
|
858
|
+
ifeq '$(OS)' 'Windows_NT'
|
|
859
|
+
\t@test -d $(BINARY) |||| mkdir $(BINARY)
|
|
558
860
|
else
|
|
559
|
-
\t@
|
|
861
|
+
\t@mkdir -p $(BINARY)
|
|
560
862
|
endif
|
|
561
|
-
\t$(CC)#{shared} $(
|
|
863
|
+
\t$(CC)#{shared} $(LIBS) $(DEBUG_FLAGS) -o $(BINARY)/#{lib[0]}_debug#{@library_extension} $(DOL#{counter})#{@raw_binary_files}
|
|
562
864
|
END_OF_STRING
|
|
563
865
|
@output << "\n"
|
|
564
866
|
if(@emojis == false)
|
|
@@ -571,31 +873,25 @@ dependency_targets = <<-END_OF_STRING
|
|
|
571
873
|
# General Auto-Dependencies
|
|
572
874
|
$(OBJECT)/%.o : $(SOURCE)/%.c
|
|
573
875
|
\t@echo "|=!|O #{@emoji_compile} Compiling... |Y$(@)|n"
|
|
574
|
-
ifeq '$(OS)' '
|
|
575
|
-
\t@
|
|
576
|
-
\t@
|
|
577
|
-
else
|
|
876
|
+
ifeq '$(OS)' 'Windows_NT'
|
|
877
|
+
\t@test -d $(BINARY) |||| mkdir $(BINARY)
|
|
878
|
+
\t@test -d $(OBJECT) |||| mkdir $(OBJECT)
|
|
879
|
+
else
|
|
578
880
|
\t@mkdir -p $(BINARY)
|
|
579
881
|
\t@mkdir -p $(OBJECT)
|
|
580
|
-
else
|
|
581
|
-
\t@if not exist $(BINARY) @mkdir $(BINARY)
|
|
582
|
-
\t@if not exist $(OBJECT) @mkdir $(OBJECT)
|
|
583
882
|
endif
|
|
584
|
-
\t$(CC) $(CFLAGS) -c $< -o $@
|
|
883
|
+
\t$(CC) $(LIBS) $(CFLAGS) -c $< -o $@
|
|
585
884
|
# General Auto-Dependencies for debug
|
|
586
|
-
$(OBJECT)
|
|
885
|
+
$(OBJECT)/%_debug.o : $(SOURCE)/%.c
|
|
587
886
|
\t@echo "|=!|O #{@emoji_debug} #{@emoji_compile} Compiling... |Y$(@)|n"
|
|
588
|
-
ifeq '$(OS)' '
|
|
589
|
-
\t@
|
|
590
|
-
\t@
|
|
591
|
-
else
|
|
887
|
+
ifeq '$(OS)' 'Windows_NT'
|
|
888
|
+
\t@test -d $(BINARY) |||| mkdir $(BINARY)
|
|
889
|
+
\t@test -d $(OBJECT) |||| mkdir $(OBJECT)
|
|
890
|
+
else
|
|
592
891
|
\t@mkdir -p $(BINARY)
|
|
593
892
|
\t@mkdir -p $(OBJECT)
|
|
594
|
-
else
|
|
595
|
-
\t@if not exist $(BINARY) @mkdir $(BINARY)
|
|
596
|
-
\t@if not exist $(OBJECT) @mkdir $(OBJECT)
|
|
597
893
|
endif
|
|
598
|
-
\t$(CC) $(DEBUG_FLAGS) -c $< -o $@
|
|
894
|
+
\t$(CC) $(LIBS) $(DEBUG_FLAGS) -c $< -o $@
|
|
599
895
|
END_OF_STRING
|
|
600
896
|
if(@emojis == false)
|
|
601
897
|
strip_emojis!(dependency_targets)
|
|
@@ -606,16 +902,7 @@ clean_target = <<-END_OF_STRING
|
|
|
606
902
|
.PHONY : clean
|
|
607
903
|
clean :
|
|
608
904
|
\t@echo "#{@emoji_clean} Removed |Yeverything|n from |R$(OBJECT)|n and |R$(BINARY)|n directories"
|
|
609
|
-
ifeq '$(OS)' 'Linux'
|
|
610
|
-
\t@rm -rf $(OBJECT) $(BINARY)
|
|
611
|
-
else ifeq '$(OS)' 'FreeBSD'
|
|
612
905
|
\t@rm -rf $(OBJECT) $(BINARY)
|
|
613
|
-
else
|
|
614
|
-
\t@if exist $(OBJECT)\*.* erase /Q $(OBJECT)\*.*
|
|
615
|
-
\t@if exist $(OBJECT) rmdir $(OBJECT)
|
|
616
|
-
\t@if exist $(BINARY)\*.* erase /Q $(BINARY)\*.*
|
|
617
|
-
\t@if exist $(BINARY) rmdir $(BINARY)
|
|
618
|
-
endif
|
|
619
906
|
END_OF_STRING
|
|
620
907
|
if(@emojis == false)
|
|
621
908
|
strip_emojis!(clean_target)
|
|
@@ -630,9 +917,9 @@ END_OF_STRING
|
|
|
630
917
|
@applications.each do |app|
|
|
631
918
|
executable_debug_target = <<-END_OF_STRING
|
|
632
919
|
\t@echo "|=[|70-]|O"
|
|
633
|
-
\t@echo "|]78|=! #{@emoji_debug} #{@emoji_build} |nBuilding executable:|O bin/|g#{app[0]}
|
|
920
|
+
\t@echo "|]78|=! #{@emoji_debug} #{@emoji_build} |nBuilding executable:|O bin/|g#{app[0]}_debug|=|n|;!|O"
|
|
634
921
|
\t@echo "|={|70-}|O"
|
|
635
|
-
\t@$(MAKE) $(BINARY)/#{app[0]}
|
|
922
|
+
\t@$(MAKE) $(BINARY)/#{app[0]}_debug
|
|
636
923
|
END_OF_STRING
|
|
637
924
|
if(@emojis == false)
|
|
638
925
|
strip_emojis!(executable_debug_target)
|
|
@@ -643,9 +930,9 @@ end
|
|
|
643
930
|
@build_libraries.each do |lib|
|
|
644
931
|
library_debug_target = <<-END_OF_STRING
|
|
645
932
|
\t@echo "|=[|70-]|O"
|
|
646
|
-
\t@echo "|]78|=! #{@emoji_debug} #{@emoji_build} Building library:|O bin/|g#{lib[0]}
|
|
933
|
+
\t@echo "|]78|=! #{@emoji_debug} #{@emoji_build} Building library:|O bin/|g#{lib[0]}_debug#{@library_extension}|=|n|;!|O"
|
|
647
934
|
\t@echo "|={|70-}|O"
|
|
648
|
-
\t@$(MAKE) $(BINARY)/#{lib[0]}
|
|
935
|
+
\t@$(MAKE) $(BINARY)/#{lib[0]}_debug#{@library_extension}
|
|
649
936
|
END_OF_STRING
|
|
650
937
|
if(@emojis == false)
|
|
651
938
|
strip_emojis!(library_debug_target)
|
|
@@ -656,6 +943,11 @@ end
|
|
|
656
943
|
@output << "\n"
|
|
657
944
|
@output << debug_target
|
|
658
945
|
|
|
946
|
+
def default_test_target(test_target)
|
|
947
|
+
test_target << "\t@echo\n"
|
|
948
|
+
test_target << "\t@echo \"#{@emoji_fail} |rWARNING: No tests have been created!|n\""
|
|
949
|
+
end
|
|
950
|
+
|
|
659
951
|
test_target = <<-END_OF_STRING
|
|
660
952
|
test :
|
|
661
953
|
\t@echo -n "#{@emoji_test} Running tests"
|
|
@@ -667,11 +959,6 @@ begin
|
|
|
667
959
|
end
|
|
668
960
|
eval code
|
|
669
961
|
rescue Errno::ENOENT
|
|
670
|
-
test_targets = <<-END_OF_STRING
|
|
671
|
-
\t@echo
|
|
672
|
-
\t@echo "#{@emoji_fail} |rWARNING: No tests have been created!|n"
|
|
673
|
-
END_OF_STRING
|
|
674
|
-
test_target << test_targets
|
|
675
962
|
rescue
|
|
676
963
|
notify("\n|YWARNING|n: #{$!}\n\n")
|
|
677
964
|
end
|
|
@@ -680,6 +967,22 @@ if(@emojis == false)
|
|
|
680
967
|
end
|
|
681
968
|
@output << "\n" + @pipe.pipetext(test_target)
|
|
682
969
|
|
|
970
|
+
def default_install_target(install_target)
|
|
971
|
+
if(@applications != {})
|
|
972
|
+
install_target << "\tinstall -d $(PREFIX)\n"
|
|
973
|
+
end
|
|
974
|
+
@applications.each do |app|
|
|
975
|
+
install_target << "\tinstall -m 755 bin/#{app[0]} $(PREFIX)\n"
|
|
976
|
+
end
|
|
977
|
+
if(@build_libraries != {})
|
|
978
|
+
install_target << "\tinstall -d $(LIBRARY_PREFIX)\n"
|
|
979
|
+
end
|
|
980
|
+
@build_libraries.each do |lib|
|
|
981
|
+
install_target << "\tinstall -m 644 bin/#{lib[0]}#{@library_extension} $(LIBRARY_PREFIX)\n"
|
|
982
|
+
end
|
|
983
|
+
install_target << "\t@echo \"#{@emoji_install} #{@emoji_success} |gInstallation Finished|n\"\n"
|
|
984
|
+
end
|
|
985
|
+
|
|
683
986
|
install_target = <<-END_OF_STRING
|
|
684
987
|
.PHONY : install
|
|
685
988
|
install :
|
|
@@ -692,10 +995,7 @@ begin
|
|
|
692
995
|
end
|
|
693
996
|
eval code
|
|
694
997
|
rescue Errno::ENOENT
|
|
695
|
-
|
|
696
|
-
\t@echo "#{@emoji_fail} |rNo install scripts have been executed|n"
|
|
697
|
-
END_OF_STRING
|
|
698
|
-
install_target << install_targets
|
|
998
|
+
default_install_target(install_target)
|
|
699
999
|
rescue
|
|
700
1000
|
notify("\n|YWARNING|n: #{$!}\n\n")
|
|
701
1001
|
end
|
|
@@ -704,4 +1004,57 @@ if(@emojis == false)
|
|
|
704
1004
|
end
|
|
705
1005
|
@output << "\n" + @pipe.pipetext(install_target)
|
|
706
1006
|
|
|
707
|
-
|
|
1007
|
+
def default_uninstall_target(uninstall_target)
|
|
1008
|
+
@applications.each do |app|
|
|
1009
|
+
uninstall_target << "\trm -f $(PREFIX)#{app[0]}\n"
|
|
1010
|
+
end
|
|
1011
|
+
if(@applications != {})
|
|
1012
|
+
uninstall_target << "ifneq '$(OS)' 'FreeBSD'\n"
|
|
1013
|
+
uninstall_target << "\trmdir --ignore-fail-on-non-empty $(PREFIX)\n"
|
|
1014
|
+
uninstall_target << "endif\n"
|
|
1015
|
+
end
|
|
1016
|
+
@build_libraries.each do |lib|
|
|
1017
|
+
uninstall_target << "\trm -f $(LIBRARY_PREFIX)#{lib[0]}#{@library_extension}\n"
|
|
1018
|
+
end
|
|
1019
|
+
if(@build_libraries != {})
|
|
1020
|
+
uninstall_target << "ifneq '$(OS)' 'FreeBSD'\n"
|
|
1021
|
+
uninstall_target << "\trmdir --ignore-fail-on-non-empty $(LIBRARY_PREFIX)\n"
|
|
1022
|
+
uninstall_target << "endif\n"
|
|
1023
|
+
end
|
|
1024
|
+
uninstall_target << "\t@echo \"#{@emoji_uninstall} #{@emoji_success} |gUninstall Finished|n\"\n"
|
|
1025
|
+
end
|
|
1026
|
+
|
|
1027
|
+
uninstall_target = <<-END_OF_STRING
|
|
1028
|
+
.PHONY : uninstall
|
|
1029
|
+
uninstall :
|
|
1030
|
+
\t@echo "#{@emoji_uninstall} Starting uninstall..."
|
|
1031
|
+
END_OF_STRING
|
|
1032
|
+
begin
|
|
1033
|
+
code = File.open('demake/uninstall-target.rb').read
|
|
1034
|
+
if(@emojis == false)
|
|
1035
|
+
strip_emojis!(code)
|
|
1036
|
+
end
|
|
1037
|
+
eval code
|
|
1038
|
+
rescue Errno::ENOENT
|
|
1039
|
+
default_uninstall_target(uninstall_target)
|
|
1040
|
+
rescue
|
|
1041
|
+
notify("\n|YWARNING|n: #{$!}\n\n")
|
|
1042
|
+
end
|
|
1043
|
+
if(@emojis == false)
|
|
1044
|
+
strip_emojis!(uninstall_target)
|
|
1045
|
+
end
|
|
1046
|
+
@output << "\n" + @pipe.pipetext(uninstall_target)
|
|
1047
|
+
|
|
1048
|
+
if(@example || @oreo)
|
|
1049
|
+
File.open('Makefile', 'w').write(@output)
|
|
1050
|
+
if(@example)
|
|
1051
|
+
notify("#{@emoji_success} Created file: |gexample|n/|yMakefile|n |[page facing up]\n\n" +
|
|
1052
|
+
"Suggestion: |Ccd example ; make ; make build ; make test|n\n")
|
|
1053
|
+
elsif(@oreo)
|
|
1054
|
+
notify("#{@emoji_success} Created file: |goreo|n/|yMakefile|n |[page facing up]\n\n" +
|
|
1055
|
+
"Suggestion: |Ccd oreo ; make ; make build ; make test|n\n")
|
|
1056
|
+
end
|
|
1057
|
+
Dir.chdir('..')
|
|
1058
|
+
else
|
|
1059
|
+
puts @output
|
|
1060
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: demake
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Minaswan Nakamoto
|
|
@@ -30,15 +30,27 @@ dependencies:
|
|
|
30
30
|
- !ruby/object:Gem::Version
|
|
31
31
|
version: 0.1.3
|
|
32
32
|
description: |
|
|
33
|
-
== Develop, Decorate and manage Dependencies for C Makefiles easily with a Ruby script.
|
|
33
|
+
== Develop, Decorate and manage Dependencies for C (GNU) Makefiles easily with a Ruby script.
|
|
34
34
|
|
|
35
35
|
Install using the Ruby Gem:
|
|
36
36
|
|
|
37
37
|
> gem install demake
|
|
38
38
|
|
|
39
|
+
To create an example with multiple sample applications:
|
|
40
|
+
|
|
41
|
+
> demake example
|
|
42
|
+
|
|
43
|
+
This will create a directory named example containing the example.
|
|
44
|
+
|
|
45
|
+
To create an example with a single sample application:
|
|
46
|
+
|
|
47
|
+
> demake oreo
|
|
48
|
+
|
|
49
|
+
This will create a directory named oreo containing the example.
|
|
50
|
+
|
|
39
51
|
It requires a demake directory and application file containing the application
|
|
40
52
|
names followed by depencencies separated by spaces and with a new line to indicate
|
|
41
|
-
a different application. Something like:
|
|
53
|
+
a different application. Something like (from the example):
|
|
42
54
|
|
|
43
55
|
> mkdir demake
|
|
44
56
|
> echo "hello string" > demake/applications
|
|
@@ -48,21 +60,17 @@ description: |
|
|
|
48
60
|
For customization, optionally include (see example):
|
|
49
61
|
demake/settings.rb, demake/test-target.rb, demake/install-target.rb
|
|
50
62
|
|
|
51
|
-
The
|
|
63
|
+
The output of the command by itself is a (GNU style) Makefile:
|
|
52
64
|
|
|
53
65
|
> demake > Makefile
|
|
54
66
|
|
|
55
67
|
You can also clone from git for a more complete example:
|
|
56
68
|
|
|
57
69
|
> git clone https://github.com/MinaswanNakamoto/demake.git
|
|
58
|
-
>
|
|
59
|
-
>
|
|
60
|
-
>
|
|
61
|
-
>
|
|
62
|
-
> make
|
|
63
|
-
> make build
|
|
64
|
-
> bin/hello
|
|
65
|
-
> bin/goodbye
|
|
70
|
+
> chmod +x demake/bin/demake
|
|
71
|
+
> cd demake
|
|
72
|
+
> bin/demake example
|
|
73
|
+
> cd example ; make ; make build ; make test
|
|
66
74
|
|
|
67
75
|
If you have an existing C application and you want to generate a Makefile for it,
|
|
68
76
|
you might try the gen_application shell script.
|
|
@@ -95,6 +103,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
95
103
|
requirements: []
|
|
96
104
|
rubygems_version: 3.6.9
|
|
97
105
|
specification_version: 4
|
|
98
|
-
summary: Develop, Decorate and manage Dependencies for C Makefiles easily with
|
|
99
|
-
script.
|
|
106
|
+
summary: Develop, Decorate and manage Dependencies for C (GNU) Makefiles easily with
|
|
107
|
+
a Ruby script.
|
|
100
108
|
test_files: []
|