demake 0.0.3 → 0.1.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/demake +471 -134
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3e635ec0a30c148dc71c4aa8bb14e12cd0f45e62346fca6918e9164eef07b153
4
- data.tar.gz: ca1693da772c3417751021bf9a436119af069a18becbb6882ad438fdb1e5fcaa
3
+ metadata.gz: b4eb15f543506fbb9bee17fa5f368f7ec5af0909ca9332417596bd964b682c8f
4
+ data.tar.gz: b2209882106107e8e0597147b003882b671071576402019f01b47e46eceaaba9
5
5
  SHA512:
6
- metadata.gz: 354c414bfae2e7e9138dfd7bf7facc0b09f4b3aa71e420a305c2dda6330e9e7846de943f3ba9296014f1658d6638d2586442aa9d32a26c725e841619444ffb33
7
- data.tar.gz: ccab035b4f0477e8b2d2b9676936bf28bcfe400a7997e88b11bd1ff623214d7a19734466850f1af3175bf57803982224cbeb0b3f0239392c730e9869e0a113de
6
+ metadata.gz: 4f23fe45f09af7fcdbd78b1b952a2f32dddba4a1181b9cc1ca647836e5027d8646fbf73896b4360ee3074a4a7ed742e31dd8dc57f896c89356b47769f4961673
7
+ data.tar.gz: 49d5e3ade0a5c73c1bbf89b2142c5852368e230ab6b056b54b7fe80ee2e43b4fb5bcd32d47f6ebf7e24bbe08227fa45074dd544f55293dca88c7d9b408e2030c
data/bin/demake CHANGED
@@ -1,34 +1,73 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  #
4
3
  # demake - Single self-contained executeable script which uses Ruby to generate decorated make files
5
4
  # for multiple related applications.
6
-
5
+ #
7
6
  require 'pipetext'
8
7
 
9
- demake_version = "0.0.3"
10
-
11
- debug = true
12
- quiet = false
13
- compiler = "gcc"
14
- #compiler = "clang"
15
- #compiler = "arm-none-eabi-gcc"
16
- #compiler = "arm-linux-gnu-gcc"
17
-
18
- flags = String.new
19
- linux_flags = String.new
20
- x86_64_flags = String.new
21
- aarch64_flags = String.new
22
- darwin_flags = String.new
23
- libraries = String.new
24
- @raw_binary_files = String.new
8
+ demake_version = "0.1.0"
9
+
10
+ @silent = false
11
+ @compiler = "gcc"
12
+ #@compiler = "clang"
13
+ #@compiler = "arm-none-eabi-gcc"
14
+ #@compiler = "arm-linux-gnu-gcc"
25
15
 
26
- binary_directory = "bin"
27
- source_directory = "src"
28
- object_directory = "obj"
16
+ # Raise if you have more cores and a long compile time
17
+ @num_threads = 8
18
+
19
+ # Contains code, does not get touched
20
+ @source_directory = "src"
21
+
22
+ # Both of these get completely blown away with make clean
23
+ @binary_directory = "bin"
24
+ @object_directory = "obj"
25
+
26
+ @working_directory = Dir.pwd
27
+
28
+ # If you change this to false, emojis are replaced using @replace_with
29
+ @emojis = true
30
+ @replace_with = "|mo|n"
31
+ # The space at the end helps with some fonts that cut the emoji with the next letter
32
+ @emoji_build = "|Y|[construction]|n "
33
+ @emoji_clean = "|r|[fire]|n "
34
+ @emoji_debug = "|n|[bug] "
35
+ @emoji_install = "|s|[nut and bolt]|n "
36
+ @emoji_test = "|R|[red question mark]|n "
37
+ @emoji_compile = "|s|[hammer and wrench]|n "
38
+ @emoji_link = "|B|[link]|n "
39
+ @emoji_fail = "|R|[cross mark]|n "
29
40
 
30
41
  @pipe = Class.new.extend(PipeText)
31
42
 
43
+ @flags = String.new
44
+ @linux_flags = String.new
45
+ @x86_64_flags = String.new
46
+ @aarch64_flags = String.new
47
+ @darwin_flags = String.new
48
+ @libraries = String.new
49
+ @raw_binary_files = String.new
50
+
51
+ def strip_emojis!(string)
52
+ string.gsub!(@emoji_build, @replace_with)
53
+ string.gsub!(@emoji_clean, @replace_with)
54
+ string.gsub!(@emoji_debug, @replace_with)
55
+ string.gsub!(@emoji_install, @replace_with)
56
+ string.gsub!(@emoji_test, @replace_with)
57
+ string.gsub!(@emoji_compile, @replace_with)
58
+ string.gsub!(@emoji_link, @replace_with)
59
+ string.gsub!(@emoji_fail, @replace_with)
60
+ # Everything else
61
+ string.gsub!(/\|\[.*\]/, @replace_with)
62
+ end
63
+
64
+ def notify(string)
65
+ if(@emojis == false)
66
+ strip_emojis!(string)
67
+ end
68
+ STDERR.puts(@pipe.pipetext(string))
69
+ end
70
+
32
71
  #
33
72
  # !!! If there is a demake/settings.rb file that gets executed NOW as raw code !!!
34
73
  #
@@ -36,58 +75,86 @@ object_directory = "obj"
36
75
  #
37
76
  begin
38
77
  code = File.open('demake/settings.rb').read
78
+ if(@emojis == false)
79
+ strip_emojis!(code)
80
+ end
39
81
  eval code
40
82
  rescue Errno::ENOENT
41
83
  rescue
42
- STDERR.puts(@pipe.pipetext("\n|YWARNING|n: #{$!}\n\n"))
84
+ notify("\n|YWARNING|n: #{$!}\n\n")
43
85
  end
44
86
 
87
+ # Applications to build
88
+ no_applications_file = true
89
+ @applications = Hash.new
45
90
  begin
46
91
  # The expected format is the application followed by a list of its dependencies
47
- # all on the same line separated by space, : or tab.
92
+ # all on the same line separated by space, : or tab and # for comments
48
93
  application_and_dependencies = File.open('demake/applications').read.split(/\n/)
49
- @applications = Hash.new
94
+ no_applications_file = false
50
95
  application_and_dependencies.each do |app|
51
- if(app =~ /([^ :\t]*)[ :\t]*(.*)/)
52
- @applications[$1] = Hash.new
53
- @applications[$1]['dependencies'] = $2.split(/[ :\t]/)
54
- else
55
- @applications[app] = Hash.new
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
105
+ end
106
+ rescue
107
+ end
108
+
109
+ # Libraries to build
110
+ no_libraries_file = true
111
+ @build_libraries = Hash.new
112
+ begin
113
+ # The expected format is the application followed by a list of its dependencies
114
+ # all on the same line separated by space, : or tab and # for comments
115
+ libraries_and_dependencies = File.open('demake/libraries').read.split(/\n/)
116
+ no_libraries_file = false
117
+ libraries_and_dependencies.each do |lib|
118
+ if(lib !~ /^#/ && lib !~ /^[ \t]*#/)
119
+ if(lib =~ /([^ :\t]*)[ :\t]*(.*)[ \t]*#?.*/)
120
+ library = $1
121
+ dependencies = $2.sub(/#.*$/, '').split(/[ :\t]/)
122
+ @build_libraries[library] = dependencies
123
+ else
124
+ @build_libraries[lib] = Array.new
125
+ end
56
126
  end
57
127
  end
58
- rescue Errno::ENOENT
59
- STDERR.puts(@pipe.pipetext("\n|RError|n: |Yapplications file|n |Rdoes not exist|n\n\n" +
60
- "You must create a file named |Yapplications|n which contains a list of\n" +
61
- "executeable application names and any dependencies to be compiled.\n\n"))
62
- exit!
63
128
  rescue
64
- puts $!.inspect
65
129
  end
66
130
 
67
- if(@applications == {})
68
- STDERR.puts(@pipe.pipetext("\n|RError|n: |Yapplications file|n |Rcannot be empty|n\n\n" +
69
- "You must create a file named |Yapplications|n which contains a list of\n" +
70
- "executeable application names and any dependencies to be compiled.\n\n"))
131
+ if(no_applications_file && no_libraries_file)
132
+ notify("\n|RError|n: |Yapplications file|n |Rdoes not exist|n\n\n" +
133
+ "You must create a file named |Yapplications|n which contains a list of\n" +
134
+ "executeable application names and any dependencies to be compiled.\n\n")
135
+ exit!
136
+ elsif(@applications == {} && @build_libraries == {})
137
+ notify("\n|RError|n: |Yapplications file|n |Rcannot be empty|n\n\n" +
138
+ "You must create a file named |Yapplications|n which contains a list of\n" +
139
+ "executeable application names and any dependencies to be compiled.\n\n")
71
140
  exit!
72
141
  end
73
142
 
74
143
  @output = <<-END_OF_STRING
75
144
  #
76
- # Makefile automatically generated by demake #{demake_version}
145
+ # Makefile automatically generated by Ruby Gem - demake #{demake_version}
77
146
  #
78
147
  END_OF_STRING
79
148
 
80
- if(debug)
81
- @output << "DEBUG = true\n"
82
- else
83
- @output << "DEBUG = false\n"
84
- end
85
- if(quiet)
149
+ if(@silent == true)
86
150
  @output << "MAKE += -s\n"
87
151
  end
152
+ if(@num_threads > 1)
153
+ @output << "MAKE += -j #{@num_threads}\n"
154
+ end
88
155
 
89
156
  compiler_settings = <<-END_OF_STRING
90
- CC = #{compiler}
157
+ CC = #{@compiler}
91
158
  OS := $(shell uname)
92
159
  PROCESSOR := $(shell uname -p)
93
160
  MACHINE := $(shell uname -m)
@@ -95,47 +162,54 @@ END_OF_STRING
95
162
 
96
163
  @output << compiler_settings
97
164
 
98
- compiler_flags = "FLAGS = #{flags}\n"
99
- if(linux_flags != "")
165
+ compiler_flags = "FLAGS = #{@flags}\n"
166
+ if(@linux_flags != "")
100
167
  compiler_flags << "ifeq '$(OS)' 'Linux'\n"
101
- compiler_flags << " FLAGS += #{linux_flags}\n"
168
+ compiler_flags << " FLAGS += #{@linux_flags}\n"
102
169
  compiler_flags << "endif\n"
103
170
  end
104
- if(darwin_flags != "")
171
+ if(@darwin_flags != "")
105
172
  compiler_flags << "ifeq '$(OS)' 'Darwin'\n"
106
- compiler_flags << " FLAGS += #{darwin_flags}\n"
173
+ compiler_flags << " FLAGS += #{@darwin_flags}\n"
107
174
  compiler_flags << "endif\n"
108
175
  end
109
- if(aarch64_flags != "")
176
+ if(@aarch64_flags != "")
110
177
  compiler_flags << "ifeq '$(MACHINE)' 'aarch64'\n"
111
- compiler_flags << " FLAGS += #{aarch64_flags}\n"
178
+ compiler_flags << " FLAGS += #{@aarch64_flags}\n"
112
179
  compiler_flags << "endif\n"
113
180
  end
114
- if(x86_64_flags != "")
181
+ if(@x86_64_flags != "")
115
182
  compiler_flags << "ifeq '$(MACHINE)' 'x86_64'\n"
116
- compiler_flags << " FLAGS += #{x86_64_flags}\n"
183
+ compiler_flags << " FLAGS += #{@x86_64_flags}\n"
117
184
  compiler_flags << "endif\n"
118
185
  end
119
186
  compiler_flags += <<-END_OF_STRING
120
- ifeq '$(DEBUG)' 'true'
121
- FLAGS += -g -Wall -W -Wconversion -Wshadow -Wcast-qual -Wwrite-strings
187
+ ifeq '$(CC)' 'gcc'
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
122
189
  else
123
- FLAGS += -O2
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
124
191
  endif
192
+ FLAGS += -O2
125
193
  CFLAGS = $(FLAGS)
126
194
  END_OF_STRING
127
195
  if(defined?($flags_override))
128
- STDERR.puts("Overriding compiler flags")
129
- compiler_flags = "FLAGS = #{flags}\nCFLAGS = $(FLAGS)\n"
196
+ notify("|ROverriding compiler flags|n:")
197
+ notify("|RFLAGS|n = #{@flags}")
198
+ compiler_flags = "FLAGS = #{@flags}\nCFLAGS = $(FLAGS)\n"
130
199
  end
131
-
132
200
  @output << compiler_flags
133
201
 
202
+ if(compiler_flags =~ /-static/)
203
+ library_extension = '.a'
204
+ else
205
+ library_extension = '.so'
206
+ end
207
+
134
208
  compiler_directories = <<-END_OF_STRING
135
- LIBS = #{libraries}
136
- BINARY = #{binary_directory}
137
- SOURCE = #{source_directory}
138
- OBJECT = #{object_directory}
209
+ LIBS = #{@libraries}
210
+ BINARY = #{@binary_directory}
211
+ SOURCE = #{@source_directory}
212
+ OBJECT = #{@object_directory}
139
213
  END_OF_STRING
140
214
 
141
215
  @output << compiler_directories
@@ -144,90 +218,171 @@ END_OF_STRING
144
218
  #OBJECTS = $(patsubst $(SOURCE)/%.c, $(OBJECT)/%.o, $(SOURCES))
145
219
 
146
220
  counter = 0
221
+ file_list = String.new
222
+ debug_file_list = String.new
147
223
  @applications.each do |app|
148
224
  counter += 1
149
- @output << "#\n# #{app[0]} - File List (FL#{counter})\n#\n"
225
+ file_list << "#\n# #{app[0]} - File List (FL#{counter})\n#\n"
226
+ debug_file_list << "#\n# #{app[0]}-debug - Debug File List (DFL#{counter})\n#\n"
150
227
  # test to see if there is a app.c and we need app.o
151
228
  begin
152
- File.open(source_directory + '/' + "#{app[0]}.c")
153
- @output << "FL#{counter} = #{app[0]}.o"
229
+ File.open(@source_directory + '/' + "#{app[0]}.c")
230
+ file_list << "FL#{counter} = #{app[0]}.o"
231
+ debug_file_list << "DFL#{counter} = #{app[0]}-debug.o"
154
232
  rescue Errno::ENOENT
155
- @output << "FL#{counter} ="
233
+ file_list << "FL#{counter} ="
234
+ debug_file_list << "DFL#{counter} ="
156
235
  end
157
- if(File.directory?(source_directory + '/' + app[0]) == true)
158
- Dir.entries(source_directory + '/' + app[0]).each do |e|
236
+ if(File.directory?(@source_directory + '/' + app[0]) == true)
237
+ Dir.entries(@source_directory + '/' + app[0]).each do |e|
159
238
  if(e != '.' && e != '..' && e =~ /(.*)\.cp?p?$/)
160
- Dir.chdir(source_directory + '/' + app[0]) do
239
+ Dir.chdir(@source_directory + '/' + app[0]) do
161
240
  if(File.directory?(e) == false)
162
- @output << " " + app[0] + '/' + $1 + '.o'
241
+ file_list << " " + app[0] + '/' + $1 + '.o'
242
+ debug_file_list << " " + app[0] + '/' + $1 + '-debug.o'
163
243
  end
164
244
  end
165
245
  end
166
246
  end
167
247
  end
168
- app[1]['dependencies'].each do |dep|
169
- if(File.directory?(source_directory + '/' + dep) == true)
170
- Dir.entries(source_directory + '/' + dep).each do |e|
248
+ @applications[app[0]].each do |dep|
249
+ if(File.directory?(@source_directory + '/' + dep) == true)
250
+ Dir.entries(@source_directory + '/' + dep).each do |e|
171
251
  if(e != '.' && e != '..' && e =~ /(.*)\.cp?p?$/)
172
- Dir.chdir(source_directory + '/' + dep) do
252
+ Dir.chdir(@source_directory + '/' + dep) do
173
253
  if(File.directory?(e) == false)
174
- @output << " " + dep + '/' + $1 + '.o'
254
+ file_list << " " + dep + '/' + $1 + '.o'
255
+ debug_file_list << " " + dep + '/' + $1 + '-debug.o'
175
256
  end
176
257
  end
177
258
  end
178
259
  end
179
260
  else
180
- @output << " " + dep.sub(/\.cp?p?$/, '.o')
261
+ file_list << " " + dep.sub(/\.cp?p?$/, '.o')
262
+ debug_file_list << " " + dep.sub(/\.o$/, '-debug.o').sub(/\.cp?p?$/, '-debug.o')
181
263
  end
182
264
  end
183
- @output << "\n"
184
- @output << "#\n# #{app[0]} - Object List (OL#{counter})\n#\n"
185
- @output << "OL#{counter} = $(patsubst %.o, $(OBJECT)/%.o, $(FL#{counter}))\n"
265
+ file_list << "\n"
266
+ file_list << "#\n# #{app[0]} - Object List (OL#{counter})\n#\n"
267
+ file_list << "OL#{counter} = $(patsubst %.o, $(OBJECT)/%.o, $(FL#{counter}))\n"
268
+ @output << file_list
269
+ debug_file_list << "\n"
270
+ debug_file_list << "#\n# #{app[0]}-debug - Debug Object List (DOL#{counter})\n#\n"
271
+ debug_file_list << "DOL#{counter} = $(patsubst %.o, $(OBJECT)/%.o, $(DFL#{counter}))\n"
272
+ @output << debug_file_list
273
+ end
274
+
275
+ file_list = String.new
276
+ debug_file_list = String.new
277
+ @build_libraries.each do |lib|
278
+ counter += 1
279
+ file_list << "#\n# #{lib[0]}#{library_extension} - File List (FL#{counter})\n#\n"
280
+ debug_file_list << "#\n# #{lib[0]}-debug#{library_extension} - Debug File List (DFL#{counter})\n#\n"
281
+ # test to see if there is a lib.c and we need lib.o
282
+ begin
283
+ File.open(@source_directory + '/' + "#{lib[0]}.c")
284
+ file_list << "FL#{counter} = #{lib[0]}.o"
285
+ debug_file_list << "DFL#{counter} = #{lib[0]}-debug.o"
286
+ rescue Errno::ENOENT
287
+ file_list << "FL#{counter} ="
288
+ debug_file_list << "DFL#{counter} ="
289
+ end
290
+ if(File.directory?(@source_directory + '/' + lib[0]) == true)
291
+ Dir.entries(@source_directory + '/' + lib[0]).each do |e|
292
+ if(e != '.' && e != '..' && e =~ /(.*)\.cp?p?$/)
293
+ Dir.chdir(@source_directory + '/' + lib[0]) do
294
+ if(File.directory?(e) == false)
295
+ file_list << " " + lib[0] + '/' + $1 + '.o'
296
+ debug_file_list << " " + lib[0] + '/' + $1 + '-debug.o'
297
+ end
298
+ end
299
+ end
300
+ end
301
+ end
302
+ @build_libraries[lib[0]].each do |dep|
303
+ if(File.directory?(@source_directory + '/' + dep) == true)
304
+ Dir.entries(@source_directory + '/' + dep).each do |e|
305
+ if(e != '.' && e != '..' && e =~ /(.*)\.cp?p?$/)
306
+ Dir.chdir(@source_directory + '/' + dep) do
307
+ if(File.directory?(e) == false)
308
+ file_list << " " + dep + '/' + $1 + '.o'
309
+ debug_file_list << " " + dep + '/' + $1 + '-debug.o'
310
+ end
311
+ end
312
+ end
313
+ end
314
+ else
315
+ file_list << " " + dep.sub(/\.cp?p?$/, '.o')
316
+ debug_file_list << " " + dep.sub(/\.o$/, '-debug.o').sub(/\.cp?p?$/, '-debug.o')
317
+ end
318
+ end
319
+ file_list << "\n"
320
+ file_list << "#\n# #{lib[0]}#{library_extension} - Object List (OL#{counter})\n#\n"
321
+ file_list << "OL#{counter} = $(patsubst %.o, $(OBJECT)/%.o, $(FL#{counter}))\n"
322
+ @output << file_list
323
+ debug_file_list << "\n"
324
+ debug_file_list << "#\n# #{lib[0]}-debug#{library_extension} - Debug Object List (DOL#{counter})\n#\n"
325
+ debug_file_list << "DOL#{counter} = $(patsubst %.o, $(OBJECT)/%.o, $(DFL#{counter}))\n"
326
+ @output << debug_file_list
186
327
  end
187
328
 
188
329
  menu_target = <<-END_OF_STRING
330
+ .PHONY : menu
189
331
  menu :
190
- \t@echo "|-[|23-]|o"
191
- \t@echo "|-! Make targets:|9 !|o"
192
- \t@echo "|-!|23 !|o"
193
- \t@echo "|-! |g|[wrench]|n |Cbuild|n|14 !|o"
194
- \t@echo "|-! |B|[droplet]|n |Cclean|n|14 !|o"
195
- \t@echo "|-! |s|[nut and bolt]|n |Cinstall|n|12 !|o"
196
- \t@echo "|-! |m|[counterclockwise arrows button]|n |Ctest|n|15 !|o"
197
- \t@echo "|-{|23-}|o"
332
+ \t@echo "|]78|=[|70-]|O"
333
+ \t@echo "|=!|;!|O"
334
+ \t@echo "|=!|26 Make targets:|;!|O"
335
+ \t@echo "|=!|;!|O"
336
+ \t@echo "|=!|28 #{@emoji_build} |cbuild|n|;!|O"
337
+ \t@echo "|=!|28 #{@emoji_clean} |cclean|n|;!|O"
338
+ \t@echo "|=!|28 #{@emoji_debug} |cdebug|n|;!|O"
339
+ \t@echo "|=!|28 #{@emoji_install} |cinstall|n|;!|O"
340
+ \t@echo "|=!|28 #{@emoji_test} |ctest|n|;!|O"
341
+ \t@echo "|=!|;!|O"
342
+ \t@echo "|=>|70-<|O"
198
343
  END_OF_STRING
199
- @output << "\n"
200
- @output << @pipe.pipetext(menu_target)
201
-
202
- default_target = <<-END_OF_STRING
203
- default :
204
- END_OF_STRING
205
-
206
344
  @applications.each do |app|
207
- execute_target = <<-END_OF_STRING
208
- \t@echo "|-[|50-]|o"
209
- \t@echo "|-! |g|[wrench] |nBuilding executable: |g#{app[0]}|n|17 !|o"
210
- \t@echo "|-{|50-}|o"
211
- \t@$(MAKE) #{app[0]}
212
- END_OF_STRING
213
- default_target << @pipe.pipetext(execute_target)
345
+ menu_target << "\t@echo \"|=!|]78 Executable: bin/|g#{app[0]}|n|;!|O\"\n"
214
346
  end
215
-
347
+ @build_libraries.each do |lib|
348
+ menu_target << "\t@echo \"|=!|]78 Library: bin/|g#{lib[0]}#{library_extension}|n|;!|O\"\n"
349
+ end
350
+ menu_target << "\t@echo \"|={|70-}|O\"\n"
216
351
  @output << "\n"
217
- @output << default_target
352
+ if(@emojis == false)
353
+ strip_emojis!(menu_target)
354
+ end
355
+ @output << @pipe.pipetext(menu_target)
218
356
 
219
357
  build_target = <<-END_OF_STRING
358
+ .PHONY : build
220
359
  build :
221
360
  END_OF_STRING
222
361
 
223
362
  @applications.each do |app|
224
- execute_target = <<-END_OF_STRING
225
- \t@echo "|-[|50-]|o"
226
- \t@echo "|-! |g|[wrench] |nBuilding executable: |g#{app[0]}|n|17 !|o"
227
- \t@echo "|-{|50-}|o"
228
- \t@$(MAKE) #{app[0]}
363
+ executable_target = <<-END_OF_STRING
364
+ \t@echo "|=[|70-]|O"
365
+ \t@echo "|]78|=! #{@emoji_build} Building executable: bin/|g#{app[0]}|n|;!|O"
366
+ \t@echo "|={|70-}|O"
367
+ \t@$(MAKE) $(BINARY)/#{app[0]}
229
368
  END_OF_STRING
230
- build_target << @pipe.pipetext(execute_target)
369
+ if(@emojis == false)
370
+ strip_emojis!(executable_target)
371
+ end
372
+ build_target << @pipe.pipetext(executable_target)
373
+ end
374
+
375
+ @build_libraries.each do |lib|
376
+ library_target = <<-END_OF_STRING
377
+ \t@echo "|=[|70-]|O"
378
+ \t@echo "|]78|=! #{@emoji_build} Building library: bin/|g#{lib[0]}|n|;!|O"
379
+ \t@echo "|={|70-}|O"
380
+ \t@$(MAKE) $(BINARY)/#{lib[0]}#{library_extension}
381
+ END_OF_STRING
382
+ if(@emojis == false)
383
+ strip_emojis!(library_target)
384
+ end
385
+ build_target << @pipe.pipetext(library_target)
231
386
  end
232
387
 
233
388
  @output << "\n"
@@ -238,6 +393,16 @@ def add_dependencies(filename, path)
238
393
  dependencies = String.new
239
394
  File.readlines(filename).each do |line|
240
395
  if(line =~ /^#include \"(.*)\"/)
396
+ file_name = @working_directory + '/' + @source_directory + path + $1
397
+ begin
398
+ File.open(file_name)
399
+ rescue Errno::ENOENT
400
+ notify("|YWARNING|n: included dependency does not exist - Removing #{filename}:#{file_name}\n")
401
+ next
402
+ rescue
403
+ notify("|YWARNING|n: #{$!} - Removing #{filename}:#{file_name}\n")
404
+ next
405
+ end
241
406
  dependencies << "\t\\\n\t$(SOURCE)#{path}#{$1}"
242
407
  end
243
408
  end
@@ -245,19 +410,35 @@ def add_dependencies(filename, path)
245
410
  dependency_targets = <<-END_OF_STRING
246
411
  # Dependencies
247
412
  $(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '.o')} : $(SOURCE)#{path}#{filename}#{dependencies}
248
- \t@echo "|=!|O |R|[fire]|n Compiling... |Y$(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '.o')}|n"
413
+ \t@echo "|=!|O #{@emoji_compile} Compiling... |Y$(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '.o')}|n"
249
414
  ifeq '$(OS)' 'Linux'
250
415
  \t@mkdir -p $(OBJECT)#{path}
416
+ else ifeq '$(OS)' 'FreeBSD'
417
+ \t@mkdir -p $(OBJECT)#{path}
251
418
  else
252
419
  \t@if not exist $(OBJECT)#{path} @mkdir $(OBJECT)#{path}
253
420
  endif
254
421
  \t$(CC) $(CFLAGS) -c $(SOURCE)#{path}#{filename} -o $(OBJECT)#{path}#{filename.gsub(/\.cp?p?$/, '.o')}
422
+ # Dependencies for debug
423
+ $(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '-debug.o')} : $(SOURCE)#{path}#{filename}#{dependencies}
424
+ \t@echo "|=!|O #{@emoji_debug} #{@emoji_compile} Compiling... |Y$(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '-debug.o')}|n"
425
+ ifeq '$(OS)' 'Linux'
426
+ \t@mkdir -p $(OBJECT)#{path}
427
+ else ifeq '$(OS)' 'FreeBSD'
428
+ \t@mkdir -p $(OBJECT)#{path}
429
+ else
430
+ \t@if not exist $(OBJECT)#{path} @mkdir $(OBJECT)#{path}
431
+ endif
432
+ \t$(CC) $(DEBUG_FLAGS) -c $(SOURCE)#{path}#{filename} -o $(OBJECT)#{path}#{filename.gsub(/\.cp?p?$/, '-debug.o')}
255
433
  END_OF_STRING
434
+ if(@emojis == false)
435
+ strip_emojis!(dependency_targets)
436
+ end
256
437
  @output << "\n" + @pipe.pipetext(dependency_targets)
257
438
  end
258
439
  rescue
259
- STDERR.puts(@pipe.pipetext("|YWARNING|n: #{$!}"))
260
- STDERR.puts(@pipe.pipetext("|YWARNING|n: including #{path}#{$1}#{filename} as raw binary"))
440
+ notify("|YWARNING|n: #{$!}")
441
+ notify("|YWARNING|n: including #{path}#{$1}#{filename} as raw binary")
261
442
  @raw_binary_files << " $(SOURCE)#{path}#{$1}#{filename}"
262
443
  end
263
444
  end
@@ -283,47 +464,152 @@ def add_all_dependencies(directory, path)
283
464
  end
284
465
  end
285
466
 
286
- add_all_dependencies(source_directory, '/')
467
+ add_all_dependencies(@source_directory, '/')
287
468
 
288
469
  counter = 0
289
470
  @applications.each do |app|
290
471
  counter += 1
291
- execute_target = <<-END_OF_STRING
292
- #{app[0]} : $(OL#{counter})
293
- \t@echo "|-[|50-]|o"
294
- \t@echo "|-! |B|[link]|n Linking Files... |g#{app[0]}|n|21 !|o"
295
- \t@echo "|-{|50-}|o"
472
+ executable_target = <<-END_OF_STRING
473
+ $(BINARY)/#{app[0]} : $(OL#{counter})
474
+ \t@echo "|=[|70-]|O"
475
+ \t@echo "|]78|=! #{@emoji_link} Linking Files...|O bin/|g#{app[0]}|=|n|;!|O"
476
+ \t@echo "|={|70-}|O"
296
477
  ifeq '$(OS)' 'Linux'
297
478
  \t@mkdir -p $(BINARY)
479
+ else ifeq '$(OS)' 'FreeBSD'
480
+ \t@mkdir -p $(BINARY)
298
481
  else
299
482
  \t@if not exist $(BINARY) @mkdir $(BINARY)
300
483
  endif
301
484
  \t$(CC) $(CFLAGS) $(LIBS) -o $(BINARY)/#{app[0]} $(OL#{counter})#{@raw_binary_files}
302
485
  END_OF_STRING
303
486
  @output << "\n"
304
- @output << @pipe.pipetext(execute_target)
487
+ if(@emojis == false)
488
+ strip_emojis!(executable_target)
489
+ end
490
+ @output << @pipe.pipetext(executable_target)
491
+ end
492
+
493
+ if(library_extension == ".so")
494
+ shared = " -shared"
495
+ else
496
+ shared = String.new
497
+ end
498
+
499
+ @build_libraries.each do |lib|
500
+ counter += 1
501
+ library_target = <<-END_OF_STRING
502
+ $(BINARY)/#{lib[0]}#{library_extension} : $(OL#{counter})
503
+ \t@echo "|=[|70-]|O"
504
+ \t@echo "|]78|=! #{@emoji_link} Linking Files...|O bin/|g#{lib[0]}#{library_extension}|=|n|;!|O"
505
+ \t@echo "|={|70-}|O"
506
+ ifeq '$(OS)' 'Linux'
507
+ \t@mkdir -p $(BINARY)
508
+ else ifeq '$(OS)' 'FreeBSD'
509
+ \t@mkdir -p $(BINARY)
510
+ else
511
+ \t@if not exist $(BINARY) @mkdir $(BINARY)
512
+ endif
513
+ \t$(CC)#{shared} $(CFLAGS) $(LIBS) -o $(BINARY)/#{lib[0]}#{library_extension} $(OL#{counter})#{@raw_binary_files}
514
+ END_OF_STRING
515
+ @output << "\n"
516
+ if(@emojis == false)
517
+ strip_emojis!(library_target)
518
+ end
519
+ @output << @pipe.pipetext(library_target)
520
+ end
521
+
522
+ # Debug
523
+ counter = 0
524
+ @applications.each do |app|
525
+ counter += 1
526
+ debug_executable_target = <<-END_OF_STRING
527
+ $(BINARY)/#{app[0]}-debug : $(DOL#{counter})
528
+ \t@echo "|=[|70-]|O"
529
+ \t@echo "|]78|=! #{@emoji_debug} #{@emoji_link} Linking Files...|O bin/|g#{app[0]}-debug|=|n|;!|O"
530
+ \t@echo "|={|70-}|O"
531
+ ifeq '$(OS)' 'Linux'
532
+ \t@mkdir -p $(BINARY)
533
+ else ifeq '$(OS)' 'FreeBSD'
534
+ \t@mkdir -p $(BINARY)
535
+ else
536
+ \t@if not exist $(BINARY) @mkdir $(BINARY)
537
+ endif
538
+ \t$(CC) $(DEBUG_FLAGS) $(LIBS) -o $(BINARY)/#{app[0]}-debug $(DOL#{counter})#{@raw_binary_files}
539
+ END_OF_STRING
540
+ @output << "\n"
541
+ if(@emojis == false)
542
+ strip_emojis!(debug_executable_target)
543
+ end
544
+ @output << @pipe.pipetext(debug_executable_target)
545
+ end
546
+
547
+ @build_libraries.each do |lib|
548
+ counter += 1
549
+ debug_library_target = <<-END_OF_STRING
550
+ $(BINARY)/#{lib[0]}-debug#{library_extension} : $(DOL#{counter})
551
+ \t@echo "|=[|70-]|O"
552
+ \t@echo "|]78|=! #{@emoji_debug} #{@emoji_link} Linking Files...|O bin/|g#{lib[0]}-debug#{library_extension}|=|n|;!|O"
553
+ \t@echo "|={|70-}|O"
554
+ ifeq '$(OS)' 'Linux'
555
+ \t@mkdir -p $(BINARY)
556
+ else ifeq '$(OS)' 'FreeBSD'
557
+ \t@mkdir -p $(BINARY)
558
+ else
559
+ \t@if not exist $(BINARY) @mkdir $(BINARY)
560
+ endif
561
+ \t$(CC)#{shared} $(DEBUG_FLAGS) $(LIBS) -o $(BINARY)/#{lib[0]}-debug#{library_extension} $(DOL#{counter})#{@raw_binary_files}
562
+ END_OF_STRING
563
+ @output << "\n"
564
+ if(@emojis == false)
565
+ strip_emojis!(debug_library_target)
566
+ end
567
+ @output << @pipe.pipetext(debug_library_target)
305
568
  end
306
569
 
307
570
  dependency_targets = <<-END_OF_STRING
308
571
  # General Auto-Dependencies
309
572
  $(OBJECT)/%.o : $(SOURCE)/%.c
310
- \t@echo "|=!|o |R|[fire]|n Compiling... |Y$(@)|n"
573
+ \t@echo "|=!|O #{@emoji_compile} Compiling... |Y$(@)|n"
311
574
  ifeq '$(OS)' 'Linux'
312
575
  \t@mkdir -p $(BINARY)
313
576
  \t@mkdir -p $(OBJECT)
577
+ else ifeq '$(OS)' 'FreeBSD'
578
+ \t@mkdir -p $(BINARY)
579
+ \t@mkdir -p $(OBJECT)
314
580
  else
315
581
  \t@if not exist $(BINARY) @mkdir $(BINARY)
316
582
  \t@if not exist $(OBJECT) @mkdir $(OBJECT)
317
583
  endif
318
584
  \t$(CC) $(CFLAGS) -c $< -o $@
585
+ # General Auto-Dependencies for debug
586
+ $(OBJECT)/%-debug.o : $(SOURCE)/%.c
587
+ \t@echo "|=!|O #{@emoji_debug} #{@emoji_compile} Compiling... |Y$(@)|n"
588
+ ifeq '$(OS)' 'Linux'
589
+ \t@mkdir -p $(BINARY)
590
+ \t@mkdir -p $(OBJECT)
591
+ else ifeq '$(OS)' 'FreeBSD'
592
+ \t@mkdir -p $(BINARY)
593
+ \t@mkdir -p $(OBJECT)
594
+ else
595
+ \t@if not exist $(BINARY) @mkdir $(BINARY)
596
+ \t@if not exist $(OBJECT) @mkdir $(OBJECT)
597
+ endif
598
+ \t$(CC) $(DEBUG_FLAGS) -c $< -o $@
319
599
  END_OF_STRING
600
+ if(@emojis == false)
601
+ strip_emojis!(dependency_targets)
602
+ end
320
603
  @output << "\n" + @pipe.pipetext(dependency_targets)
321
604
 
322
605
  clean_target = <<-END_OF_STRING
606
+ .PHONY : clean
323
607
  clean :
324
- \t@echo "|B|[droplet]|n Removed |Yeverything|n from |R$(OBJECT)|n and |R$(BINARY)|n directories"
608
+ \t@echo "#{@emoji_clean} Removed |Yeverything|n from |R$(OBJECT)|n and |R$(BINARY)|n directories"
325
609
  ifeq '$(OS)' 'Linux'
326
610
  \t@rm -rf $(OBJECT) $(BINARY)
611
+ else ifeq '$(OS)' 'FreeBSD'
612
+ \t@rm -rf $(OBJECT) $(BINARY)
327
613
  else
328
614
  \t@if exist $(OBJECT)\*.* erase /Q $(OBJECT)\*.*
329
615
  \t@if exist $(OBJECT) rmdir $(OBJECT)
@@ -331,40 +617,91 @@ else
331
617
  \t@if exist $(BINARY) rmdir $(BINARY)
332
618
  endif
333
619
  END_OF_STRING
334
- @output << @pipe.pipetext(clean_target + "\n")
620
+ if(@emojis == false)
621
+ strip_emojis!(clean_target)
622
+ end
623
+ @output << "\n" + @pipe.pipetext(clean_target)
624
+
625
+ debug_target = <<-END_OF_STRING
626
+ .PHONY : debug
627
+ debug :
628
+ END_OF_STRING
629
+
630
+ @applications.each do |app|
631
+ executable_debug_target = <<-END_OF_STRING
632
+ \t@echo "|=[|70-]|O"
633
+ \t@echo "|]78|=! #{@emoji_debug} #{@emoji_build} |nBuilding executable:|O bin/|g#{app[0]}-debug|=|n|;!|O"
634
+ \t@echo "|={|70-}|O"
635
+ \t@$(MAKE) $(BINARY)/#{app[0]}-debug
636
+ END_OF_STRING
637
+ if(@emojis == false)
638
+ strip_emojis!(executable_debug_target)
639
+ end
640
+ debug_target << @pipe.pipetext(executable_debug_target)
641
+ end
642
+
643
+ @build_libraries.each do |lib|
644
+ library_debug_target = <<-END_OF_STRING
645
+ \t@echo "|=[|70-]|O"
646
+ \t@echo "|]78|=! #{@emoji_debug} #{@emoji_build} Building library:|O bin/|g#{lib[0]}-debug#{library_extension}|=|n|;!|O"
647
+ \t@echo "|={|70-}|O"
648
+ \t@$(MAKE) $(BINARY)/#{lib[0]}-debug#{library_extension}
649
+ END_OF_STRING
650
+ if(@emojis == false)
651
+ strip_emojis!(library_debug_target)
652
+ end
653
+ debug_target << @pipe.pipetext(library_debug_target)
654
+ end
655
+
656
+ @output << "\n"
657
+ @output << debug_target
335
658
 
336
659
  test_target = <<-END_OF_STRING
337
660
  test :
338
- \t@echo -n "|m|[counterclockwise arrows button]|n Running tests"
661
+ \t@echo -n "#{@emoji_test} Running tests"
339
662
  END_OF_STRING
340
663
  begin
341
664
  code = File.open('demake/test-target.rb').read
665
+ if(@emojis == false)
666
+ strip_emojis!(code)
667
+ end
342
668
  eval code
343
669
  rescue Errno::ENOENT
344
670
  test_targets = <<-END_OF_STRING
345
- \t@echo "|R|[cross mark]|n |rNo tests have been executed|n"
671
+ \t@echo
672
+ \t@echo "#{@emoji_fail} |rWARNING: No tests have been created!|n"
346
673
  END_OF_STRING
347
674
  test_target << test_targets
348
675
  rescue
349
- STDERR.puts(@pipe.pipetext("\n|YWARNING|n: #{$!}\n\n"))
676
+ notify("\n|YWARNING|n: #{$!}\n\n")
677
+ end
678
+ if(@emojis == false)
679
+ strip_emojis!(test_target)
350
680
  end
351
- @output << @pipe.pipetext(test_target)
681
+ @output << "\n" + @pipe.pipetext(test_target)
352
682
 
353
683
  install_target = <<-END_OF_STRING
684
+ .PHONY : install
354
685
  install :
355
- \t@echo "|s|[nut and bolt]|n Starting install..."
686
+ \t@echo "#{@emoji_install} Starting install..."
356
687
  END_OF_STRING
357
688
  begin
358
689
  code = File.open('demake/install-target.rb').read
690
+ if(@emojis == false)
691
+ strip_emojis!(code)
692
+ end
359
693
  eval code
360
694
  rescue Errno::ENOENT
361
695
  install_targets = <<-END_OF_STRING
362
- \t@echo "|R|[cross mark]|n |rNo install scripts have been executed|n"
696
+ \t@echo "#{@emoji_fail} |rNo install scripts have been executed|n"
363
697
  END_OF_STRING
364
698
  install_target << install_targets
365
699
  rescue
366
- STDERR.puts(@pipe.pipetext("\n|YWARNING|n: #{$!}\n\n"))
700
+ notify("\n|YWARNING|n: #{$!}\n\n")
701
+ end
702
+ if(@emojis == false)
703
+ strip_emojis!(install_target)
367
704
  end
368
- @output << @pipe.pipetext(install_target)
705
+ @output << "\n" + @pipe.pipetext(install_target)
369
706
 
370
707
  puts @output
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.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minaswan Nakamoto