demake 0.1.1 → 0.2.0
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 +438 -492
- data/lib/data/example/demake/applications +3 -0
- data/lib/data/example/demake/license +19 -0
- data/lib/data/example/demake/settings.rb +62 -0
- data/lib/data/example/demake/test-target.rb +8 -0
- data/lib/data/example/src/goodbye.c +12 -0
- data/lib/data/example/src/hello.c +12 -0
- data/lib/data/example/src/string/string.c +12 -0
- data/lib/data/example/src/string/string.h +7 -0
- data/lib/data/oreo/demake/applications +1 -0
- data/lib/data/oreo/demake/license +19 -0
- data/lib/data/oreo/demake/settings.rb +62 -0
- data/lib/data/oreo/demake/test-target.rb +9 -0
- data/lib/data/oreo/oreo_test.txt +1 -0
- data/lib/data/oreo/src/defines.h +29 -0
- data/lib/data/oreo/src/fast_read_file.h +259 -0
- data/lib/data/oreo/src/oreo.c +102 -0
- data/lib/data/oreo/src/typedefs.h +61 -0
- data/lib/template/build_target.rb +6 -0
- data/lib/template/clean_target.rb +6 -0
- data/lib/template/debug_executable_target.rb +14 -0
- data/lib/template/debug_library_target.rb +14 -0
- data/lib/template/debug_target.rb +4 -0
- data/lib/template/dependency_targets.rb +22 -0
- data/lib/template/executable_debug_target.rb +6 -0
- data/lib/template/executable_target.rb +14 -0
- data/lib/template/generic_dependency_targets.rb +26 -0
- data/lib/template/library_debug_target.rb +6 -0
- data/lib/template/library_target.rb +6 -0
- data/lib/template/license_target.rb +10 -0
- data/lib/template/link_library_target.rb +14 -0
- data/lib/template/strip_build.rb +8 -0
- metadata +37 -5
data/bin/demake
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
#
|
|
3
|
-
# demake -
|
|
3
|
+
# demake - Executeable script which uses Ruby to generate decorated make files
|
|
4
4
|
# for multiple related applications.
|
|
5
5
|
#
|
|
6
|
+
require 'rbconfig' # Needed by older versions of Ruby
|
|
6
7
|
require 'pipetext'
|
|
7
8
|
|
|
8
|
-
demake_version = "0.
|
|
9
|
+
demake_version = "0.2.0"
|
|
9
10
|
|
|
10
11
|
@silent = false
|
|
11
12
|
@compiler = "gcc"
|
|
@@ -13,18 +14,25 @@ demake_version = "0.1.1"
|
|
|
13
14
|
#@compiler = "arm-none-eabi-gcc"
|
|
14
15
|
#@compiler = "arm-linux-gnu-gcc"
|
|
15
16
|
|
|
17
|
+
@strip = true
|
|
18
|
+
@debug_enabled = true
|
|
16
19
|
# Raise if you have more cores and a long compile time
|
|
17
20
|
@num_threads = 8
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
WIDTH = 75
|
|
23
|
+
BOX_WIDTH = WIDTH + "\t@echo".length # To normalize for Makefile format
|
|
24
|
+
SHORT_WIDTH = BOX_WIDTH - 8
|
|
25
|
+
|
|
26
|
+
# Where to install binaries / libraries
|
|
20
27
|
@prefix = "/usr/local/bin/"
|
|
21
|
-
@library_prefix = "/usr/local/
|
|
28
|
+
@library_prefix = "/usr/local/lib/"
|
|
22
29
|
|
|
23
30
|
# Contains code, does not get touched
|
|
24
31
|
@source_directory = "src"
|
|
25
32
|
|
|
26
|
-
#
|
|
33
|
+
# These get completely blown away with make clean
|
|
27
34
|
@binary_directory = "bin"
|
|
35
|
+
@library_directory = "lib"
|
|
28
36
|
@object_directory = "obj"
|
|
29
37
|
|
|
30
38
|
@working_directory = Dir.pwd
|
|
@@ -34,6 +42,8 @@ demake_version = "0.1.1"
|
|
|
34
42
|
@replace_with = "|mo|n"
|
|
35
43
|
# The space at the end helps with some fonts that cut the emoji with the next letter
|
|
36
44
|
@emoji_build = "|Y|[construction]|n "
|
|
45
|
+
@emoji_library = "|Y|[books]|n "
|
|
46
|
+
@emoji_license = "|b|[scroll]|n "
|
|
37
47
|
@emoji_clean = "|r|[fire]|n "
|
|
38
48
|
@emoji_debug = "|n|[bug] "
|
|
39
49
|
@emoji_install = "|s|[nut and bolt]|n "
|
|
@@ -47,18 +57,46 @@ demake_version = "0.1.1"
|
|
|
47
57
|
@pipe = Class.new.extend(PipeText)
|
|
48
58
|
|
|
49
59
|
@flags = String.new
|
|
50
|
-
@
|
|
60
|
+
@optimize_flags = String.new
|
|
61
|
+
@compiler_flags = String.new
|
|
62
|
+
@library_compiler_flags = String.new
|
|
63
|
+
@linker_flags = String.new
|
|
64
|
+
@debug_flags = String.new
|
|
51
65
|
@linux_flags = String.new
|
|
52
66
|
@x86_64_flags = String.new
|
|
53
67
|
@aarch64_flags = String.new
|
|
68
|
+
@riscv_flags = String.new
|
|
54
69
|
@darwin_flags = String.new
|
|
55
70
|
@windows_flags = String.new
|
|
56
71
|
@freebsd_flags = String.new
|
|
72
|
+
@library_linker_flags = String.new
|
|
57
73
|
@libraries = String.new
|
|
74
|
+
@linker_libraries = String.new
|
|
75
|
+
@library_linker_libraries = String.new
|
|
58
76
|
@raw_binary_files = String.new
|
|
77
|
+
@ruby_headers = String.new
|
|
78
|
+
@ruby_library = String.new
|
|
79
|
+
if(RbConfig::CONFIG["rubyhdrdir"] != nil &&
|
|
80
|
+
RbConfig::CONFIG["rubyarchhdrdir"] != nil)
|
|
81
|
+
@ruby_headers = "-I" + RbConfig::CONFIG["rubyhdrdir"] +
|
|
82
|
+
" -I" + RbConfig::CONFIG["rubyarchhdrdir"]
|
|
83
|
+
elsif(RbConfig::CONFIG["rubyhdrdir"] != nil)
|
|
84
|
+
@ruby_headers = "-I" + RbConfig::CONFIG["rubyhdrdir"]
|
|
85
|
+
elsif(RbConfig::CONFIG["rubyarchhdrdir"] != nil)
|
|
86
|
+
@ruby_headers = " -I" + RbConfig::CONFIG["rubyarchhdrdir"]
|
|
87
|
+
else
|
|
88
|
+
@ruby_headers = "-I" + RbConfig::CONFIG["includedir"]
|
|
89
|
+
end
|
|
90
|
+
if(RbConfig::CONFIG["LIBRUBYARG"] != nil)
|
|
91
|
+
@ruby_library = RbConfig::CONFIG["LIBRUBYARG"] +
|
|
92
|
+
" -Wl,-rpath," + RbConfig::CONFIG["LIBRUBYARG"]
|
|
93
|
+
end
|
|
94
|
+
@page_debug = false
|
|
59
95
|
|
|
60
96
|
def strip_emojis!(string)
|
|
61
97
|
string.gsub!(@emoji_build, @replace_with)
|
|
98
|
+
string.gsub!(@emoji_library, @replace_with)
|
|
99
|
+
string.gsub!(@emoji_license, @replace_with)
|
|
62
100
|
string.gsub!(@emoji_clean, @replace_with)
|
|
63
101
|
string.gsub!(@emoji_debug, @replace_with)
|
|
64
102
|
string.gsub!(@emoji_install, @replace_with)
|
|
@@ -79,42 +117,32 @@ def notify(string)
|
|
|
79
117
|
STDERR.puts(@pipe.pipetext(string))
|
|
80
118
|
end
|
|
81
119
|
|
|
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
|
-
"-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
|
|
120
|
+
@lib_data = File.join(File.expand_path("../..", __FILE__), "lib", "data")
|
|
121
|
+
@lib_dir = File.join(File.expand_path("../..", __FILE__), "lib")
|
|
122
|
+
|
|
123
|
+
if(ARGV[0] == "help" || ARGV[0] == "--help" || ARGV[0] == "-h" ||
|
|
124
|
+
ARGV[0] == "?" || ARGV[0] == "-?")
|
|
125
|
+
program = File.basename($0)
|
|
126
|
+
notify("Command syntax:\n\n")
|
|
127
|
+
notify("|y#{program}|n - Create or update Makefile\n")
|
|
128
|
+
notify("|y#{program} example|n - Create an example application\n")
|
|
129
|
+
notify("|y#{program} oreo|n - Create a different sample application\n\n")
|
|
130
|
+
exit!
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def file_open_write_close(filename, data)
|
|
134
|
+
File.open(filename, 'w') do |f|
|
|
135
|
+
f.write(data)
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def file_open_read_close(filename)
|
|
140
|
+
data = String.new
|
|
141
|
+
File.open(filename, 'r') do |f|
|
|
142
|
+
data = f.read
|
|
143
|
+
end
|
|
144
|
+
return(data)
|
|
145
|
+
end
|
|
118
146
|
|
|
119
147
|
@example = false
|
|
120
148
|
if(ARGV[0] =~ /^example$/)
|
|
@@ -124,92 +152,39 @@ if(ARGV[0] =~ /^example$/)
|
|
|
124
152
|
exit!
|
|
125
153
|
end
|
|
126
154
|
@example = true
|
|
127
|
-
#
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
|
155
|
+
# Code files used by the example
|
|
156
|
+
example_settings_rb = file_open_read_close(@lib_data + '/example/demake/settings.rb')
|
|
157
|
+
hello_c = file_open_read_close(@lib_data + '/example/src/hello.c')
|
|
158
|
+
goodbye_c = file_open_read_close(@lib_data + '/example/src/goodbye.c')
|
|
159
|
+
string_h = file_open_read_close(@lib_data + '/example/src/string/string.h')
|
|
160
|
+
string_c = file_open_read_close(@lib_data + '/example/src/string/string.c')
|
|
161
|
+
testtarget_rb = file_open_read_close(@lib_data + '/example/demake/test-target.rb')
|
|
162
|
+
license = file_open_read_close(@lib_data + '/example/demake/license')
|
|
190
163
|
|
|
191
164
|
Dir.mkdir('example')
|
|
192
165
|
notify("#{@emoji_success} Created directory: |gexample|n |[open file folder]\n")
|
|
193
166
|
Dir.mkdir('example/src')
|
|
194
167
|
notify("#{@emoji_success} Created directory: |gexample|n/|gsrc|n |[open file folder]\n")
|
|
195
|
-
|
|
168
|
+
file_open_write_close('example/src/hello.c', hello_c)
|
|
196
169
|
notify("#{@emoji_success} Created file: |gexample|n/|gsrc|n/|yhello.c|n |[page facing up]\n")
|
|
197
|
-
|
|
170
|
+
file_open_write_close('example/src/goodbye.c', goodbye_c)
|
|
198
171
|
notify("#{@emoji_success} Created file: |gexample|n/|gsrc|n/|ygoodbye.c|n |[page facing up]\n")
|
|
199
172
|
Dir.mkdir('example/src/string')
|
|
200
173
|
notify("#{@emoji_success} Created directory: |gexample|n/|gsrc|n/|gstring|n |[open file folder]\n")
|
|
201
|
-
|
|
174
|
+
file_open_write_close('example/src/string/string.h', string_h)
|
|
202
175
|
notify("#{@emoji_success} Created file: |gexample|n/|gsrc|n/|gstring|n/|ystring.h|n |[page facing up]\n")
|
|
203
|
-
|
|
176
|
+
file_open_write_close('example/src/string/string.c', string_c)
|
|
204
177
|
notify("#{@emoji_success} Created file: |gexample|n/|gsrc|n/|gstring|n/|ystring.c|n |[page facing up]\n")
|
|
205
178
|
Dir.mkdir('example/demake')
|
|
206
179
|
notify("#{@emoji_success} Created directory: |gexample|n/|gdemake|n |[open file folder]\n")
|
|
207
|
-
|
|
180
|
+
file_open_write_close('example/demake/applications', "hello string\ngoodbye string\n")
|
|
208
181
|
notify("#{@emoji_success} Created file: |gexample|n/|gdemake|n/|yapplications|n |[page facing up]\n")
|
|
209
|
-
|
|
182
|
+
file_open_write_close('example/demake/settings.rb', example_settings_rb)
|
|
210
183
|
notify("#{@emoji_success} Created file: |gexample|n/|gdemake|n/|ysettings.rb|n |[page facing up]\n")
|
|
211
|
-
|
|
184
|
+
file_open_write_close('example/demake/test-target.rb', testtarget_rb)
|
|
212
185
|
notify("#{@emoji_success} Created file: |gexample|n/|gdemake|n/|ytest-target.rb|n |[page facing up]\n")
|
|
186
|
+
file_open_write_close('example/demake/license', license)
|
|
187
|
+
notify("#{@emoji_success} Created file: |gexample|n/|gdemake|n/|ylicense|n |[page facing up]\n")
|
|
213
188
|
Dir.chdir('example')
|
|
214
189
|
@working_directory = Dir.pwd
|
|
215
190
|
end
|
|
@@ -222,176 +197,78 @@ if(ARGV[0] =~ /^oreo$/)
|
|
|
222
197
|
exit!
|
|
223
198
|
end
|
|
224
199
|
@oreo = true
|
|
225
|
-
#
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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
|
|
200
|
+
# Code file used by oreo
|
|
201
|
+
oreo_settings_rb = file_open_read_close(@lib_data + '/oreo/demake/settings.rb')
|
|
202
|
+
defines_h = file_open_read_close(@lib_data + '/oreo/src/defines.h')
|
|
203
|
+
typedefs_h = file_open_read_close(@lib_data + '/oreo/src/typedefs.h')
|
|
204
|
+
fast_read_file_h = file_open_read_close(@lib_data + '/oreo/src/fast_read_file.h')
|
|
205
|
+
oreo_c = file_open_read_close(@lib_data + '/oreo/src/oreo.c')
|
|
206
|
+
testtarget_rb = file_open_read_close(@lib_data + '/oreo/demake/test-target.rb')
|
|
207
|
+
oreo_test_txt = file_open_read_close(@lib_data + '/oreo/oreo_test.txt')
|
|
208
|
+
license = file_open_read_close(@lib_data + '/oreo/demake/license')
|
|
354
209
|
|
|
355
210
|
Dir.mkdir('oreo')
|
|
356
211
|
notify("#{@emoji_success} Created directory: |goreo|n |[open file folder]\n")
|
|
357
212
|
Dir.mkdir('oreo/src')
|
|
358
213
|
notify("#{@emoji_success} Created directory: |goreo|n/|gsrc|n |[open file folder]\n")
|
|
359
|
-
|
|
214
|
+
file_open_write_close('oreo/src/defines.h', defines_h)
|
|
215
|
+
notify("#{@emoji_success} Created file: |goreo|n/|gsrc|n/|ydefines.h|n |[page facing up]\n")
|
|
216
|
+
file_open_write_close('oreo/src/typedefs.h', typedefs_h)
|
|
217
|
+
notify("#{@emoji_success} Created file: |goreo|n/|gsrc|n/|ytypedefs.h|n |[page facing up]\n")
|
|
218
|
+
file_open_write_close('oreo/src/fast_read_file.h', fast_read_file_h)
|
|
219
|
+
notify("#{@emoji_success} Created file: |goreo|n/|gsrc|n/|yfast_read_file.h|n |[page facing up]\n")
|
|
220
|
+
file_open_write_close('oreo/src/oreo.c', oreo_c)
|
|
360
221
|
notify("#{@emoji_success} Created file: |goreo|n/|gsrc|n/|yoreo.c|n |[page facing up]\n")
|
|
361
222
|
Dir.mkdir('oreo/demake')
|
|
362
223
|
notify("#{@emoji_success} Created directory: |goreo|n/|gdemake|n |[open file folder]\n")
|
|
363
|
-
|
|
224
|
+
file_open_write_close('oreo/demake/applications', "oreo\n")
|
|
364
225
|
notify("#{@emoji_success} Created file: |goreo|n/|gdemake|n/|yapplications|n |[page facing up]\n")
|
|
365
|
-
|
|
226
|
+
file_open_write_close('oreo/demake/settings.rb', oreo_settings_rb)
|
|
366
227
|
notify("#{@emoji_success} Created file: |goreo|n/|gdemake|n/|ysettings.rb|n |[page facing up]\n")
|
|
367
|
-
|
|
228
|
+
file_open_write_close('oreo/demake/test-target.rb', testtarget_rb)
|
|
368
229
|
notify("#{@emoji_success} Created file: |goreo|n/|gdemake|n/|ytest-target.rb|n |[page facing up]\n")
|
|
230
|
+
file_open_write_close('oreo/demake/license', license)
|
|
231
|
+
notify("#{@emoji_success} Created file: |goreo|n/|gdemake|n/|ylicense|n |[page facing up]\n")
|
|
369
232
|
Dir.chdir('oreo')
|
|
233
|
+
file_open_write_close('oreo_test.txt', oreo_test_txt)
|
|
234
|
+
notify("#{@emoji_success} Created file: |goreo|n/|yoreo_text.txt|n |[page facing up]\n")
|
|
370
235
|
@working_directory = Dir.pwd
|
|
371
236
|
end
|
|
372
237
|
|
|
373
238
|
@applications = Hash.new
|
|
374
239
|
@build_libraries = Hash.new
|
|
375
240
|
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
code =
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
241
|
+
# Check for settings / default override
|
|
242
|
+
begin
|
|
243
|
+
if(@example == false && @oreo == false)
|
|
244
|
+
code = file_open_read_close('demake/settings.rb')
|
|
245
|
+
elsif(@example == true)
|
|
246
|
+
code = example_settings_rb
|
|
247
|
+
elsif(@oreo == true)
|
|
248
|
+
code = oreo_settings_rb
|
|
249
|
+
end
|
|
250
|
+
if(@emojis == false)
|
|
251
|
+
strip_emojis!(code)
|
|
387
252
|
end
|
|
253
|
+
eval code
|
|
254
|
+
rescue Errno::ENOENT
|
|
255
|
+
rescue
|
|
256
|
+
notify("\n|YWARNING|n: #{$!}\n\n")
|
|
257
|
+
end
|
|
388
258
|
|
|
259
|
+
if(@library_compiler_flags =~ /-static/)
|
|
260
|
+
@library_extension = '.a'
|
|
261
|
+
else
|
|
262
|
+
@library_extension = '.so'
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
if(@example == false && @oreo == false)
|
|
389
266
|
# Applications to build
|
|
390
267
|
no_applications_file = true
|
|
391
268
|
begin
|
|
392
269
|
# The expected format is the application followed by a list of its dependencies
|
|
393
270
|
# all on the same line separated by space, : or tab and # for comments
|
|
394
|
-
application_and_dependencies =
|
|
271
|
+
application_and_dependencies = file_open_read_close('demake/applications').split(/\n/)
|
|
395
272
|
no_applications_file = false
|
|
396
273
|
application_and_dependencies.each do |app|
|
|
397
274
|
if(app !~ /^#/ && app !~ /^[ \t]*#/)
|
|
@@ -412,7 +289,7 @@ if(@example == false && @oreo == false)
|
|
|
412
289
|
begin
|
|
413
290
|
# The expected format is the application followed by a list of its dependencies
|
|
414
291
|
# all on the same line separated by space, : or tab and # for comments
|
|
415
|
-
libraries_and_dependencies =
|
|
292
|
+
libraries_and_dependencies = file_open_read_close('demake/libraries').split(/\n/)
|
|
416
293
|
no_libraries_file = false
|
|
417
294
|
libraries_and_dependencies.each do |lib|
|
|
418
295
|
if(lib !~ /^#/ && lib !~ /^[ \t]*#/)
|
|
@@ -463,10 +340,11 @@ CC = #{@compiler}
|
|
|
463
340
|
OS := $(shell uname)
|
|
464
341
|
PROCESSOR := $(shell uname -p)
|
|
465
342
|
MACHINE := $(shell uname -m)
|
|
343
|
+
STRIP := strip
|
|
344
|
+
STRIP_ARGS := --strip-unneeded
|
|
466
345
|
PREFIX = #{@prefix}
|
|
467
346
|
LIBRARY_PREFIX = #{@library_prefix}
|
|
468
347
|
END_OF_STRING
|
|
469
|
-
|
|
470
348
|
@output << compiler_settings
|
|
471
349
|
|
|
472
350
|
compiler_flags = "FLAGS = #{@flags}\n"
|
|
@@ -484,6 +362,12 @@ if(@windows_flags != "")
|
|
|
484
362
|
compiler_flags << "ifeq '$(OS)' 'Windows_NT'\n"
|
|
485
363
|
compiler_flags << " FLAGS += #{@windows_flags}\n"
|
|
486
364
|
compiler_flags << "endif\n"
|
|
365
|
+
compiler_flags << "ifneq ($(filter CYGWIN_NT%,$(OS)),)\n"
|
|
366
|
+
compiler_flags << " FLAGS += #{@windows_flags}\n"
|
|
367
|
+
compiler_flags << "endif\n"
|
|
368
|
+
compiler_flags << "ifneq ($(filter MINGW64_NT%,$(OS)),)\n"
|
|
369
|
+
compiler_flags << " FLAGS += #{@windows_flags}\n"
|
|
370
|
+
compiler_flags << "endif\n"
|
|
487
371
|
end
|
|
488
372
|
if(@darwin_flags != "")
|
|
489
373
|
compiler_flags << "ifeq '$(OS)' 'Darwin'\n"
|
|
@@ -495,41 +379,41 @@ if(@aarch64_flags != "")
|
|
|
495
379
|
compiler_flags << " FLAGS += #{@aarch64_flags}\n"
|
|
496
380
|
compiler_flags << "endif\n"
|
|
497
381
|
end
|
|
382
|
+
if(@riscv64_flags != "")
|
|
383
|
+
compiler_flags << "ifeq '$(MACHINE)' 'riscv64'\n"
|
|
384
|
+
compiler_flags << " FLAGS += #{@riscv64_flags}\n"
|
|
385
|
+
compiler_flags << "endif\n"
|
|
386
|
+
end
|
|
498
387
|
if(@x86_64_flags != "")
|
|
499
388
|
compiler_flags << "ifeq '$(MACHINE)' 'x86_64'\n"
|
|
500
389
|
compiler_flags << " FLAGS += #{@x86_64_flags}\n"
|
|
501
390
|
compiler_flags << "endif\n"
|
|
391
|
+
compiler_flags << "ifeq '$(MACHINE)' 'amd64'\n"
|
|
392
|
+
compiler_flags << " FLAGS += #{@x86_64_flags}\n"
|
|
393
|
+
compiler_flags << "endif\n"
|
|
502
394
|
end
|
|
503
395
|
compiler_flags += <<-END_OF_STRING
|
|
504
396
|
DEBUG_FLAGS = #{@debug_flags}
|
|
505
|
-
|
|
506
|
-
CFLAGS = $(FLAGS)
|
|
397
|
+
OFLAGS = #{@optimize_flags}
|
|
398
|
+
CFLAGS = #{@compiler_flags} $(FLAGS)
|
|
399
|
+
LDFLAGS = #{@linker_flags}
|
|
400
|
+
LIB_CFLAGS = #{@library_compiler_flags} $(FLAGS)
|
|
401
|
+
LIB_LDFLAGS = #{@library_linker_flags}
|
|
402
|
+
BUILD_FLAGS = $(CFLAGS)
|
|
507
403
|
END_OF_STRING
|
|
508
|
-
if(defined?($flags_override))
|
|
509
|
-
notify("|ROverriding compiler flags|n:")
|
|
510
|
-
notify("|RFLAGS|n = #{@flags}")
|
|
511
|
-
compiler_flags = "FLAGS = #{@flags}\nCFLAGS = $(FLAGS)\n"
|
|
512
|
-
end
|
|
513
404
|
@output << compiler_flags
|
|
514
405
|
|
|
515
|
-
if(compiler_flags =~ /-static/)
|
|
516
|
-
@library_extension = '.a'
|
|
517
|
-
else
|
|
518
|
-
@library_extension = '.so'
|
|
519
|
-
end
|
|
520
|
-
|
|
521
406
|
compiler_directories = <<-END_OF_STRING
|
|
522
407
|
LIBS = #{@libraries}
|
|
408
|
+
LDLIBS = $(LIBS) #{@linker_libraries}
|
|
409
|
+
LIB_LDLIBS = $(LIBS) #{@library_linker_libraries}
|
|
523
410
|
BINARY = #{@binary_directory}
|
|
411
|
+
LIBRARY = #{@library_directory}
|
|
524
412
|
SOURCE = #{@source_directory}
|
|
525
413
|
OBJECT = #{@object_directory}
|
|
526
414
|
END_OF_STRING
|
|
527
|
-
|
|
528
415
|
@output << compiler_directories
|
|
529
416
|
|
|
530
|
-
#SOURCES = $(wildcard $(SOURCE)/*.c $(SOURCE)/*.h)
|
|
531
|
-
#OBJECTS = $(patsubst $(SOURCE)/%.c, $(OBJECT)/%.o, $(SOURCES))
|
|
532
|
-
|
|
533
417
|
counter = 0
|
|
534
418
|
file_list = String.new
|
|
535
419
|
debug_file_list = String.new
|
|
@@ -639,112 +523,209 @@ debug_file_list = String.new
|
|
|
639
523
|
@output << debug_file_list
|
|
640
524
|
end
|
|
641
525
|
|
|
526
|
+
@output << "\nRUBY := $(shell command -v ruby 2> /dev/null)\n\n"
|
|
527
|
+
|
|
528
|
+
license = file_open_read_close('demake/license')
|
|
529
|
+
if(license != "")
|
|
530
|
+
longest_line = 0
|
|
531
|
+
license.lines.each do |l|
|
|
532
|
+
if(l.length > longest_line)
|
|
533
|
+
longest_line = l.length
|
|
534
|
+
end
|
|
535
|
+
end
|
|
536
|
+
line_length = longest_line + 2
|
|
537
|
+
include_license = "\n\t@echo \"|=!|29 #{@emoji_license} |blicense|n|;!|O\""
|
|
538
|
+
@output << "define LICENSE\n"
|
|
539
|
+
text = license.gsub(/^/, "|-!|O ").gsub(/\n/, "|;|-!|O\n")
|
|
540
|
+
text = text.sub("|-!|O", "|-!|O|b").sub("|;|-!|O\n", "|n|;|-!|O\n")
|
|
541
|
+
@output << @pipe.pipetext("|]#{line_length}\n|-[|#{line_length - 1}-]|O\n" +
|
|
542
|
+
"#{text}|-{|#{line_length - 1}-}|O\n\n")
|
|
543
|
+
@output << "endef\n"
|
|
544
|
+
@output << "export LICENSE\n"
|
|
545
|
+
@output << "define LICENSE_FILE\n"
|
|
546
|
+
@output << license
|
|
547
|
+
@output << "endef\n"
|
|
548
|
+
@output << "export LICENSE_FILE\n"
|
|
549
|
+
else
|
|
550
|
+
include_license = ""
|
|
551
|
+
end
|
|
552
|
+
|
|
553
|
+
if(@build_libraries != {})
|
|
554
|
+
include_libraries = "\n\t@echo \"|=!|29 #{@emoji_library} |mlibrary|n|;!|O\""
|
|
555
|
+
else
|
|
556
|
+
include_libraries = ""
|
|
557
|
+
end
|
|
558
|
+
if(@debug_enabled == true)
|
|
559
|
+
include_debug = "\n\t@echo \"|=!|29 #{@emoji_debug} |Ydebug|n|;!|O\""
|
|
560
|
+
else
|
|
561
|
+
include_debug = ""
|
|
562
|
+
end
|
|
563
|
+
if(include_license != "")
|
|
564
|
+
LICENSE = "LICENSE"
|
|
565
|
+
else
|
|
566
|
+
LICENSE = ""
|
|
567
|
+
end
|
|
642
568
|
menu_target = <<-END_OF_STRING
|
|
643
569
|
.PHONY : menu
|
|
644
|
-
menu :
|
|
645
|
-
\t@echo "|]
|
|
570
|
+
menu : #{LICENSE}
|
|
571
|
+
\t@echo "|]#{BOX_WIDTH}|=[|#{SHORT_WIDTH}-]|O"
|
|
646
572
|
\t@echo "|=!|;!|O"
|
|
647
|
-
\t@echo "|=!|
|
|
573
|
+
\t@echo "|=!|27 Make targets:|;!|O"
|
|
648
574
|
\t@echo "|=!|;!|O"
|
|
649
|
-
\t@echo "|=!|
|
|
650
|
-
\t@echo "|=!|
|
|
651
|
-
\t@echo "|=!|
|
|
652
|
-
\t@echo "|=!|
|
|
653
|
-
\t@echo "|=!|
|
|
654
|
-
\t@echo "|=!|28 #{@emoji_test} |ctest|n|;!|O"
|
|
575
|
+
\t@echo "|=!|29 #{@emoji_build} |ybuild|n|;!|O"#{include_libraries}#{include_license}
|
|
576
|
+
\t@echo "|=!|29 #{@emoji_clean} |rclean|n|;!|O"#{include_debug}
|
|
577
|
+
\t@echo "|=!|29 #{@emoji_install} |cinstall|n|;!|O"
|
|
578
|
+
\t@echo "|=!|29 #{@emoji_uninstall} |cuninstall|n|;!|O"
|
|
579
|
+
\t@echo "|=!|29 #{@emoji_test} |gtest|n|;!|O"
|
|
655
580
|
\t@echo "|=!|;!|O"
|
|
656
|
-
\t@echo "
|
|
581
|
+
\t@echo "|=>|#{SHORT_WIDTH}-<|O"
|
|
657
582
|
END_OF_STRING
|
|
658
583
|
@applications.each do |app|
|
|
659
|
-
menu_target << "\t@echo \"|=!|]
|
|
584
|
+
menu_target << "\t@echo \"|=!|]#{BOX_WIDTH} |O|yBuild|n Executable: #{@binary_directory}/|g#{app[0]}|n|=|;!|O\"\n"
|
|
660
585
|
end
|
|
661
586
|
@build_libraries.each do |lib|
|
|
662
|
-
menu_target << "\t@echo \"|=!|]
|
|
587
|
+
menu_target << "\t@echo \"|=!|]#{BOX_WIDTH} |O|mLibrary|n File: #{@library_directory}/|g#{lib[0]}#{@library_extension}|n|=|;!|O\"\n"
|
|
663
588
|
end
|
|
664
|
-
menu_target << "\t@echo \"
|
|
589
|
+
menu_target << "\t@echo \"|=>|#{SHORT_WIDTH}-<|O\"\n"
|
|
590
|
+
if(@debug_enabled == true)
|
|
591
|
+
@applications.each do |app|
|
|
592
|
+
menu_target << "\t@echo \"|=!|]#{BOX_WIDTH} |O|YDebug|n Executable: #{@binary_directory}/|Y#{app[0]}_debug|n|=|;!|O\"\n"
|
|
593
|
+
end
|
|
594
|
+
@build_libraries.each do |lib|
|
|
595
|
+
menu_target << "\t@echo \"|=!|]#{BOX_WIDTH} |O|YDebug|n |mLibrary|n File: #{@library_directory}/|Y#{lib[0]}_debug#{@library_extension}|n|=|;!|O\"\n"
|
|
596
|
+
end
|
|
597
|
+
menu_target << "\t@echo \"|=>|#{SHORT_WIDTH}-<|O\"\n"
|
|
598
|
+
end
|
|
599
|
+
menu_target << "\t@echo \"|=!|]#{BOX_WIDTH} |O|cInstall|n |yBinary|n Directory: |g#{@prefix}|n|=|;!|O\"\n"
|
|
600
|
+
menu_target << "\t@echo \"|=!|]#{BOX_WIDTH} |O|cInstall|n |mLibrary|n Directory: |g#{@library_prefix}|n|=|;!|O\"\n"
|
|
601
|
+
menu_target << "\t@echo \"|={|#{SHORT_WIDTH}-}|O\"\n"
|
|
665
602
|
@output << "\n"
|
|
666
603
|
if(@emojis == false)
|
|
667
604
|
strip_emojis!(menu_target)
|
|
668
605
|
end
|
|
669
606
|
@output << @pipe.pipetext(menu_target)
|
|
670
607
|
|
|
671
|
-
|
|
608
|
+
if(@build_libraries != {} && @debug_enabled == true)
|
|
609
|
+
all_target = ".PHONY : all\nall : #{LICENSE} build library debug\n\n"
|
|
610
|
+
elsif(@debug_enabled == true)
|
|
611
|
+
all_target = ".PHONY : all\nall : #{LICENSE} build debug\n\n"
|
|
612
|
+
elsif(@build_libraries != {})
|
|
613
|
+
all_target = ".PHONY : all\nall : #{LICENSE} build library\n\n"
|
|
614
|
+
else
|
|
615
|
+
all_target = ".PHONY : all\nall : #{LICENSE} build\n\n"
|
|
616
|
+
end
|
|
617
|
+
@output << all_target
|
|
618
|
+
#
|
|
619
|
+
# Rather than lots of Makefile heredocs in main source, most have been
|
|
620
|
+
# split up into lib/template/*.rb though a few are still inline
|
|
621
|
+
#
|
|
622
|
+
def load_with_template(template)
|
|
623
|
+
begin
|
|
624
|
+
code = file_open_read_close(@lib_dir + '/template/' + template + '.rb')
|
|
625
|
+
if(@emojis == false)
|
|
626
|
+
strip_emojis!(code)
|
|
627
|
+
end
|
|
628
|
+
if(block_given?)
|
|
629
|
+
yield(code)
|
|
630
|
+
else
|
|
631
|
+
eval(code)
|
|
632
|
+
end
|
|
633
|
+
rescue Errno::ENOENT
|
|
634
|
+
rescue
|
|
635
|
+
notify("\n|YWARNING|n: #{$!}\n\n")
|
|
636
|
+
end
|
|
637
|
+
end
|
|
638
|
+
|
|
639
|
+
if(include_license != "")
|
|
640
|
+
load_with_template("license_target") do |code|
|
|
641
|
+
eval(code)
|
|
642
|
+
end
|
|
643
|
+
@output << "\n"
|
|
644
|
+
if(@emojis == false)
|
|
645
|
+
strip_emojis!(@license_target)
|
|
646
|
+
end
|
|
647
|
+
@output << @pipe.pipetext(@license_target)
|
|
648
|
+
end
|
|
649
|
+
|
|
650
|
+
build_targets = <<-END_OF_STRING
|
|
672
651
|
.PHONY : build
|
|
673
|
-
build :
|
|
652
|
+
build : #{LICENSE}
|
|
674
653
|
END_OF_STRING
|
|
675
654
|
|
|
676
655
|
@applications.each do |app|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
\t@echo "|={|70-}|O"
|
|
681
|
-
\t@$(MAKE) $(BINARY)/#{app[0]}
|
|
682
|
-
END_OF_STRING
|
|
656
|
+
load_with_template("build_target") do |code|
|
|
657
|
+
eval(code)
|
|
658
|
+
end
|
|
683
659
|
if(@emojis == false)
|
|
684
|
-
strip_emojis!(
|
|
660
|
+
strip_emojis!(@build_target)
|
|
661
|
+
end
|
|
662
|
+
build_targets << @pipe.pipetext(@build_target)
|
|
663
|
+
if(@strip == true)
|
|
664
|
+
load_with_template("strip_build") do |code|
|
|
665
|
+
eval(code)
|
|
666
|
+
end
|
|
667
|
+
build_targets << @pipe.pipetext(@strip_build)
|
|
685
668
|
end
|
|
686
|
-
build_target << @pipe.pipetext(executable_target)
|
|
687
669
|
end
|
|
688
670
|
|
|
689
|
-
@
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
671
|
+
@output << "\n"
|
|
672
|
+
@output << build_targets
|
|
673
|
+
|
|
674
|
+
library_targets = <<-END_OF_STRING
|
|
675
|
+
.PHONY : library
|
|
676
|
+
library : #{LICENSE}
|
|
695
677
|
END_OF_STRING
|
|
678
|
+
|
|
679
|
+
@build_libraries.each do |lib|
|
|
680
|
+
load_with_template("library_target") do |code|
|
|
681
|
+
eval(code)
|
|
682
|
+
end
|
|
696
683
|
if(@emojis == false)
|
|
697
|
-
strip_emojis!(library_target)
|
|
684
|
+
strip_emojis!(@library_target)
|
|
698
685
|
end
|
|
699
|
-
|
|
686
|
+
library_targets << @pipe.pipetext(@library_target)
|
|
700
687
|
end
|
|
701
688
|
|
|
702
689
|
@output << "\n"
|
|
703
|
-
@output <<
|
|
690
|
+
@output << library_targets
|
|
691
|
+
|
|
692
|
+
def add_dependencies_from_file(dependencies, filename, path)
|
|
693
|
+
File.readlines(filename).each do |line|
|
|
694
|
+
begin
|
|
695
|
+
if(line =~ /#include \"(.*)\"/)
|
|
696
|
+
include = $1
|
|
697
|
+
if(filename !~ /#{include}$/)
|
|
698
|
+
included_filename = @working_directory + '/' + @source_directory + path + include
|
|
699
|
+
begin
|
|
700
|
+
File.open(included_filename)
|
|
701
|
+
add_dependencies_from_file(dependencies, included_filename, path)
|
|
702
|
+
rescue Errno::ENOENT
|
|
703
|
+
notify("|YWARNING|n: included dependency does not exist - Removing #{filename}:#{included_filename}\n")
|
|
704
|
+
next
|
|
705
|
+
rescue
|
|
706
|
+
notify("|YWARNING|n: #{$!} - Removing #{filename}:#{included_filename}\n")
|
|
707
|
+
next
|
|
708
|
+
end
|
|
709
|
+
dependencies << "\t\\\n\t$(SOURCE)#{path}#{include}"
|
|
710
|
+
end
|
|
711
|
+
end
|
|
712
|
+
rescue ArgumentError
|
|
713
|
+
end
|
|
714
|
+
end
|
|
715
|
+
end
|
|
704
716
|
|
|
705
717
|
def add_dependencies(filename, path)
|
|
706
718
|
begin
|
|
707
719
|
dependencies = String.new
|
|
708
|
-
|
|
709
|
-
if(line =~ /^#include \"(.*)\"/)
|
|
710
|
-
file_name = @working_directory + '/' + @source_directory + path + $1
|
|
711
|
-
begin
|
|
712
|
-
File.open(file_name)
|
|
713
|
-
rescue Errno::ENOENT
|
|
714
|
-
notify("|YWARNING|n: included dependency does not exist - Removing #{filename}:#{file_name}\n")
|
|
715
|
-
next
|
|
716
|
-
rescue
|
|
717
|
-
notify("|YWARNING|n: #{$!} - Removing #{filename}:#{file_name}\n")
|
|
718
|
-
next
|
|
719
|
-
end
|
|
720
|
-
dependencies << "\t\\\n\t$(SOURCE)#{path}#{$1}"
|
|
721
|
-
end
|
|
722
|
-
end
|
|
720
|
+
add_dependencies_from_file(dependencies, filename, path)
|
|
723
721
|
if(dependencies != "")
|
|
724
|
-
dependency_targets
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
\t@echo "|=!|O #{@emoji_compile} Compiling... |Y$(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '.o')}|n"
|
|
728
|
-
ifeq '$(OS)' 'Windows_NT'
|
|
729
|
-
\t@test -d $(OBJECT)#{path} |||| mkdir $(OBJECT)#{path}
|
|
730
|
-
else
|
|
731
|
-
\t@mkdir -p $(OBJECT)#{path}
|
|
732
|
-
endif
|
|
733
|
-
\t$(CC) $(LIBS) $(CFLAGS) -c $(SOURCE)#{path}#{filename} -o $(OBJECT)#{path}#{filename.gsub(/\.cp?p?$/, '.o')}
|
|
734
|
-
# Dependencies for debug
|
|
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}
|
|
739
|
-
else
|
|
740
|
-
\t@mkdir -p $(OBJECT)#{path}
|
|
741
|
-
endif
|
|
742
|
-
\t$(CC) $(LIBS) $(DEBUG_FLAGS) -c $(SOURCE)#{path}#{filename} -o $(OBJECT)#{path}#{filename.gsub(/\.cp?p?$/, '_debug.o')}
|
|
743
|
-
END_OF_STRING
|
|
722
|
+
load_with_template("dependency_targets") do |code|
|
|
723
|
+
eval(code)
|
|
724
|
+
end
|
|
744
725
|
if(@emojis == false)
|
|
745
|
-
strip_emojis!(dependency_targets)
|
|
726
|
+
strip_emojis!(@dependency_targets)
|
|
746
727
|
end
|
|
747
|
-
@output << "\n" + @pipe.pipetext(dependency_targets)
|
|
728
|
+
@output << "\n" + @pipe.pipetext(@dependency_targets)
|
|
748
729
|
end
|
|
749
730
|
rescue
|
|
750
731
|
notify("|YWARNING|n: #{$!}")
|
|
@@ -766,7 +747,7 @@ def add_all_dependencies(directory, path)
|
|
|
766
747
|
Dir.entries(directory).each do |e|
|
|
767
748
|
if(e != '.' && e != '..')
|
|
768
749
|
Dir.chdir(directory) do
|
|
769
|
-
if(File.directory?(e) == false)
|
|
750
|
+
if(File.directory?(e) == false && (e =~ /.c$/ || e =~ /.cpp$/))
|
|
770
751
|
add_dependencies(e, path)
|
|
771
752
|
end
|
|
772
753
|
end
|
|
@@ -779,181 +760,122 @@ add_all_dependencies(@source_directory, '/')
|
|
|
779
760
|
counter = 0
|
|
780
761
|
@applications.each do |app|
|
|
781
762
|
counter += 1
|
|
782
|
-
executable_target
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
\t@echo "|]78|=! #{@emoji_link} Linking Files...|O bin/|g#{app[0]}|=|n|;!|O"
|
|
786
|
-
\t@echo "|={|70-}|O"
|
|
787
|
-
ifeq '$(OS)' 'Windows_NT'
|
|
788
|
-
\t@test -d $(BINARY) |||| mkdir $(BINARY)
|
|
789
|
-
else
|
|
790
|
-
\t@mkdir -p $(BINARY)
|
|
791
|
-
endif
|
|
792
|
-
\t$(CC) $(LIBS) $(CFLAGS) -o $(BINARY)/#{app[0]} $(OL#{counter})#{@raw_binary_files}
|
|
793
|
-
END_OF_STRING
|
|
763
|
+
load_with_template("executable_target") do |code|
|
|
764
|
+
eval(code)
|
|
765
|
+
end
|
|
794
766
|
@output << "\n"
|
|
795
767
|
if(@emojis == false)
|
|
796
|
-
strip_emojis!(executable_target)
|
|
768
|
+
strip_emojis!(@executable_target)
|
|
797
769
|
end
|
|
798
|
-
@output << @pipe.pipetext(executable_target)
|
|
799
|
-
end
|
|
800
|
-
|
|
801
|
-
if(@library_extension == ".so")
|
|
802
|
-
shared = " -shared"
|
|
803
|
-
else
|
|
804
|
-
shared = String.new
|
|
770
|
+
@output << @pipe.pipetext(@executable_target)
|
|
805
771
|
end
|
|
806
772
|
|
|
807
773
|
@build_libraries.each do |lib|
|
|
808
774
|
counter += 1
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
\t@echo "|]78|=! #{@emoji_link} Linking Files...|O bin/|g#{lib[0]}#{@library_extension}|=|n|;!|O"
|
|
813
|
-
\t@echo "|={|70-}|O"
|
|
814
|
-
ifeq '$(OS)' 'Windows_NT'
|
|
815
|
-
\t@test -d $(BINARY) |||| mkdir $(BINARY)
|
|
816
|
-
else
|
|
817
|
-
\t@mkdir -p $(BINARY)
|
|
818
|
-
endif
|
|
819
|
-
\t$(CC)#{shared} $(LIBS) $(CFLAGS) -o $(BINARY)/#{lib[0]}#{@library_extension} $(OL#{counter})#{@raw_binary_files}
|
|
820
|
-
END_OF_STRING
|
|
775
|
+
load_with_template("link_library_target") do |code|
|
|
776
|
+
eval(code)
|
|
777
|
+
end
|
|
821
778
|
@output << "\n"
|
|
822
779
|
if(@emojis == false)
|
|
823
|
-
strip_emojis!(
|
|
780
|
+
strip_emojis!(@link_library_target)
|
|
824
781
|
end
|
|
825
|
-
@output << @pipe.pipetext(
|
|
782
|
+
@output << @pipe.pipetext(@link_library_target)
|
|
826
783
|
end
|
|
827
784
|
|
|
828
|
-
|
|
829
|
-
counter = 0
|
|
830
|
-
@applications.each do |app|
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
\t@mkdir -p $(BINARY)
|
|
841
|
-
endif
|
|
842
|
-
\t$(CC) $(LIBS) $(DEBUG_FLAGS) -o $(BINARY)/#{app[0]}_debug $(DOL#{counter})#{@raw_binary_files}
|
|
843
|
-
END_OF_STRING
|
|
844
|
-
@output << "\n"
|
|
845
|
-
if(@emojis == false)
|
|
846
|
-
strip_emojis!(debug_executable_target)
|
|
785
|
+
if(@debug_enabled == true)
|
|
786
|
+
counter = 0
|
|
787
|
+
@applications.each do |app|
|
|
788
|
+
counter += 1
|
|
789
|
+
load_with_template("debug_executable_target") do |code|
|
|
790
|
+
eval(code)
|
|
791
|
+
end
|
|
792
|
+
@output << "\n"
|
|
793
|
+
if(@emojis == false)
|
|
794
|
+
strip_emojis!(@debug_executable_target)
|
|
795
|
+
end
|
|
796
|
+
@output << @pipe.pipetext(@debug_executable_target)
|
|
847
797
|
end
|
|
848
|
-
@output << @pipe.pipetext(debug_executable_target)
|
|
849
|
-
end
|
|
850
798
|
|
|
851
|
-
@build_libraries.each do |lib|
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
\t@mkdir -p $(BINARY)
|
|
862
|
-
endif
|
|
863
|
-
\t$(CC)#{shared} $(LIBS) $(DEBUG_FLAGS) -o $(BINARY)/#{lib[0]}_debug#{@library_extension} $(DOL#{counter})#{@raw_binary_files}
|
|
864
|
-
END_OF_STRING
|
|
865
|
-
@output << "\n"
|
|
866
|
-
if(@emojis == false)
|
|
867
|
-
strip_emojis!(debug_library_target)
|
|
799
|
+
@build_libraries.each do |lib|
|
|
800
|
+
counter += 1
|
|
801
|
+
load_with_template("debug_library_target") do |code|
|
|
802
|
+
eval(code)
|
|
803
|
+
end
|
|
804
|
+
@output << "\n"
|
|
805
|
+
if(@emojis == false)
|
|
806
|
+
strip_emojis!(@debug_library_target)
|
|
807
|
+
end
|
|
808
|
+
@output << @pipe.pipetext(@debug_library_target)
|
|
868
809
|
end
|
|
869
|
-
@output << @pipe.pipetext(debug_library_target)
|
|
870
810
|
end
|
|
871
811
|
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
\t@echo "|=!|O #{@emoji_compile} Compiling... |Y$(@)|n"
|
|
876
|
-
ifeq '$(OS)' 'Windows_NT'
|
|
877
|
-
\t@test -d $(BINARY) |||| mkdir $(BINARY)
|
|
878
|
-
\t@test -d $(OBJECT) |||| mkdir $(OBJECT)
|
|
879
|
-
else
|
|
880
|
-
\t@mkdir -p $(BINARY)
|
|
881
|
-
\t@mkdir -p $(OBJECT)
|
|
882
|
-
endif
|
|
883
|
-
\t$(CC) $(LIBS) $(CFLAGS) -c $< -o $@
|
|
884
|
-
# General Auto-Dependencies for debug
|
|
885
|
-
$(OBJECT)/%_debug.o : $(SOURCE)/%.c
|
|
886
|
-
\t@echo "|=!|O #{@emoji_debug} #{@emoji_compile} Compiling... |Y$(@)|n"
|
|
887
|
-
ifeq '$(OS)' 'Windows_NT'
|
|
888
|
-
\t@test -d $(BINARY) |||| mkdir $(BINARY)
|
|
889
|
-
\t@test -d $(OBJECT) |||| mkdir $(OBJECT)
|
|
890
|
-
else
|
|
891
|
-
\t@mkdir -p $(BINARY)
|
|
892
|
-
\t@mkdir -p $(OBJECT)
|
|
893
|
-
endif
|
|
894
|
-
\t$(CC) $(LIBS) $(DEBUG_FLAGS) -c $< -o $@
|
|
895
|
-
END_OF_STRING
|
|
812
|
+
load_with_template("generic_dependency_targets") do |code|
|
|
813
|
+
eval(code)
|
|
814
|
+
end
|
|
896
815
|
if(@emojis == false)
|
|
897
|
-
strip_emojis!(
|
|
816
|
+
strip_emojis!(@generic_dependency_targets)
|
|
898
817
|
end
|
|
899
|
-
@output << "\n" + @pipe.pipetext(
|
|
818
|
+
@output << "\n" + @pipe.pipetext(@generic_dependency_targets)
|
|
900
819
|
|
|
901
|
-
clean_target
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
\t@echo "#{@emoji_clean} Removed |Yeverything|n from |R$(OBJECT)|n and |R$(BINARY)|n directories"
|
|
905
|
-
\t@rm -rf $(OBJECT) $(BINARY)
|
|
906
|
-
END_OF_STRING
|
|
820
|
+
load_with_template("clean_target") do |code|
|
|
821
|
+
eval(code)
|
|
822
|
+
end
|
|
907
823
|
if(@emojis == false)
|
|
908
|
-
strip_emojis!(clean_target)
|
|
824
|
+
strip_emojis!(@clean_target)
|
|
909
825
|
end
|
|
910
|
-
@output << "\n" + @pipe.pipetext(clean_target)
|
|
826
|
+
@output << "\n" + @pipe.pipetext(@clean_target)
|
|
911
827
|
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
828
|
+
if(@debug_enabled == true)
|
|
829
|
+
load_with_template("debug_target") do |code|
|
|
830
|
+
eval(code)
|
|
831
|
+
end
|
|
916
832
|
|
|
917
|
-
@
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
\t@echo "|={|70-}|O"
|
|
922
|
-
\t@$(MAKE) $(BINARY)/#{app[0]}_debug
|
|
923
|
-
END_OF_STRING
|
|
924
|
-
if(@emojis == false)
|
|
925
|
-
strip_emojis!(executable_debug_target)
|
|
833
|
+
if(@page_debug == true)
|
|
834
|
+
@pager = " 2>&1 | less -F -R -X -e"
|
|
835
|
+
else
|
|
836
|
+
@pager = ""
|
|
926
837
|
end
|
|
927
|
-
debug_target << @pipe.pipetext(executable_debug_target)
|
|
928
|
-
end
|
|
929
838
|
|
|
930
|
-
@
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
strip_emojis!(library_debug_target)
|
|
839
|
+
@applications.each do |app|
|
|
840
|
+
load_with_template("executable_debug_target") do |code|
|
|
841
|
+
eval(code)
|
|
842
|
+
end
|
|
843
|
+
if(@emojis == false)
|
|
844
|
+
strip_emojis!(@executable_debug_target)
|
|
845
|
+
end
|
|
846
|
+
@debug_target << @pipe.pipetext(@executable_debug_target)
|
|
939
847
|
end
|
|
940
|
-
debug_target << @pipe.pipetext(library_debug_target)
|
|
941
|
-
end
|
|
942
848
|
|
|
943
|
-
@
|
|
944
|
-
|
|
849
|
+
@build_libraries.each do |lib|
|
|
850
|
+
load_with_template("library_debug_target") do |code|
|
|
851
|
+
eval(code)
|
|
852
|
+
end
|
|
853
|
+
if(@emojis == false)
|
|
854
|
+
strip_emojis!(@library_debug_target)
|
|
855
|
+
end
|
|
856
|
+
@debug_target << @pipe.pipetext(@library_debug_target)
|
|
857
|
+
end
|
|
858
|
+
@output << "\n"
|
|
859
|
+
@output << @debug_target
|
|
860
|
+
end
|
|
945
861
|
|
|
946
862
|
def default_test_target(test_target)
|
|
947
863
|
test_target << "\t@echo\n"
|
|
948
864
|
test_target << "\t@echo \"#{@emoji_fail} |rWARNING: No tests have been created!|n\""
|
|
949
865
|
end
|
|
950
866
|
|
|
867
|
+
if(@build_libraries != {})
|
|
868
|
+
test_dependencies = "test : #{LICENSE} build library"
|
|
869
|
+
else
|
|
870
|
+
test_dependencies = "test : #{LICENSE} build"
|
|
871
|
+
end
|
|
872
|
+
|
|
951
873
|
test_target = <<-END_OF_STRING
|
|
952
|
-
|
|
953
|
-
\t@echo -n "#{@emoji_test}
|
|
874
|
+
#{test_dependencies}
|
|
875
|
+
\t@echo -n "#{@emoji_test}Running tests:"
|
|
954
876
|
END_OF_STRING
|
|
955
877
|
begin
|
|
956
|
-
code =
|
|
878
|
+
code = file_open_read_close('demake/test-target.rb')
|
|
957
879
|
if(@emojis == false)
|
|
958
880
|
strip_emojis!(code)
|
|
959
881
|
end
|
|
@@ -969,27 +891,31 @@ end
|
|
|
969
891
|
|
|
970
892
|
def default_install_target(install_target)
|
|
971
893
|
if(@applications != {})
|
|
972
|
-
install_target << "\
|
|
894
|
+
install_target << "\t@test -d $(PREFIX) || install -d $(PREFIX)\n"
|
|
973
895
|
end
|
|
974
896
|
@applications.each do |app|
|
|
975
|
-
install_target << "\
|
|
897
|
+
install_target << "\t@test -f #{@binary_directory}/#{app[0]} && install -v -m 755 #{@binary_directory}/#{app[0]} $(PREFIX) |||| \\\n"
|
|
898
|
+
install_target << "\t\t(echo \"Executable file #{@binary_directory}/|g#{app[0]}|n not found.\"; \\\n"
|
|
899
|
+
install_target << "\t\techo \"Please type '|ymake build|n' first, if you wish to install.\")\n"
|
|
976
900
|
end
|
|
977
901
|
if(@build_libraries != {})
|
|
978
|
-
install_target << "\
|
|
902
|
+
install_target << "\t@test -d $(LIBRARY_PREFIX) || install -d $(LIBRARY_PREFIX)\n"
|
|
979
903
|
end
|
|
980
904
|
@build_libraries.each do |lib|
|
|
981
|
-
install_target << "\
|
|
905
|
+
install_target << "\t@test -f #{@library_directory}/#{lib[0]}#{@library_extension} && install -v -m 755 #{@library_directory}/#{lib[0]}#{@library_extension} $(LIBRARY_PREFIX) |||| \\\n"
|
|
906
|
+
install_target << "\t\t(echo \"Library file #{@library_directory}/|g#{lib[0]}#{@library_extension}|n not found.\"; \\\n"
|
|
907
|
+
install_target << "\t\techo \"Please type '|mmake library|n' first, if you wish to install.\")\n"
|
|
982
908
|
end
|
|
983
909
|
install_target << "\t@echo \"#{@emoji_install} #{@emoji_success} |gInstallation Finished|n\"\n"
|
|
984
910
|
end
|
|
985
911
|
|
|
986
912
|
install_target = <<-END_OF_STRING
|
|
987
913
|
.PHONY : install
|
|
988
|
-
install :
|
|
914
|
+
install : #{LICENSE}
|
|
989
915
|
\t@echo "#{@emoji_install} Starting install..."
|
|
990
916
|
END_OF_STRING
|
|
991
917
|
begin
|
|
992
|
-
code =
|
|
918
|
+
code = file_open_read_close('demake/install-target.rb')
|
|
993
919
|
if(@emojis == false)
|
|
994
920
|
strip_emojis!(code)
|
|
995
921
|
end
|
|
@@ -1030,7 +956,7 @@ uninstall :
|
|
|
1030
956
|
\t@echo "#{@emoji_uninstall} Starting uninstall..."
|
|
1031
957
|
END_OF_STRING
|
|
1032
958
|
begin
|
|
1033
|
-
code =
|
|
959
|
+
code = file_open_read_close('demake/uninstall-target.rb')
|
|
1034
960
|
if(@emojis == false)
|
|
1035
961
|
strip_emojis!(code)
|
|
1036
962
|
end
|
|
@@ -1056,5 +982,25 @@ if(@example || @oreo)
|
|
|
1056
982
|
end
|
|
1057
983
|
Dir.chdir('..')
|
|
1058
984
|
else
|
|
1059
|
-
|
|
985
|
+
if(File.exist?('Makefile'))
|
|
986
|
+
lines = file_open_read_close('Makefile').split("\n")
|
|
987
|
+
if(lines[1] =~ /^# Makefile automatically generated by Ruby Gem - demake [0-9]*\.[0-9]*\.[0-9]*$/)
|
|
988
|
+
File.open('Makefile', 'w').write(@output)
|
|
989
|
+
else
|
|
990
|
+
match = lines.find do |e|
|
|
991
|
+
e =~ /^# Makefile automatically generated by Ruby Gem - demake [0-9]*\.[0-9]*\.[0-9]*$/
|
|
992
|
+
end
|
|
993
|
+
if(match != nil)
|
|
994
|
+
print(@pipe.pipetext("|yMakefile|n already exists, |Rbut has been modified|n overwrite anyway (y/n)? "))
|
|
995
|
+
else
|
|
996
|
+
print(@pipe.pipetext("|yMakefile|n already exists, |Rand is unrecognized|n overwrite anyway (y/n)? "))
|
|
997
|
+
end
|
|
998
|
+
if(STDIN.getc == ?y)
|
|
999
|
+
File.open('Makefile', 'w').write(@output)
|
|
1000
|
+
end
|
|
1001
|
+
end
|
|
1002
|
+
else
|
|
1003
|
+
File.open('Makefile', 'w').write(@output)
|
|
1004
|
+
# puts @output
|
|
1005
|
+
end
|
|
1060
1006
|
end
|