demake 0.0.2 → 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 +497 -135
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f1ac5a31edb2868543dc574371715f1c5b06d6c1dda1de3a52172b5208bd7a19
4
- data.tar.gz: a393eec65c429d5dc9067f1e867870c5377a971e369f5cd19bf66bb6d01190aa
3
+ metadata.gz: b4eb15f543506fbb9bee17fa5f368f7ec5af0909ca9332417596bd964b682c8f
4
+ data.tar.gz: b2209882106107e8e0597147b003882b671071576402019f01b47e46eceaaba9
5
5
  SHA512:
6
- metadata.gz: 974c3c5b88f6f359215f971ba62a13055c2fd7a8556a841f28ac71ca4ecfd5cf58f39fab3eb7c67a24f0f3b8ec3aaf31d0efd0bdf0212225eba1882c7336cff2
7
- data.tar.gz: 94ed99765ca34c0bd95e5e052501695605e469f4b9733b8d75868f3fbb21d704d2c9a158d0fa94f60db2151f5d642b438f73c104b7f68fe422252c8c4b4482cd
6
+ metadata.gz: 4f23fe45f09af7fcdbd78b1b952a2f32dddba4a1181b9cc1ca647836e5027d8646fbf73896b4360ee3074a4a7ed742e31dd8dc57f896c89356b47769f4961673
7
+ data.tar.gz: 49d5e3ade0a5c73c1bbf89b2142c5852368e230ab6b056b54b7fe80ee2e43b4fb5bcd32d47f6ebf7e24bbe08227fa45074dd544f55293dca88c7d9b408e2030c
data/bin/demake CHANGED
@@ -1,83 +1,160 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  #
4
- # demake - Executeable script which uses Ruby to generate decorated make files
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
- debug = true
10
- quiet = false
11
- compiler = "gcc"
12
- #compiler = "clang"
13
- #compiler = "arm-none-eabi-gcc"
14
- #compiler = "arm-linux-gnu-gcc"
15
- binary_directory = "bin"
16
- source_directory = "src"
17
- object_directory = "obj"
18
- @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"
15
+
16
+ # Raise if you have more cores and a long compile time
17
+ @num_threads = 8
19
18
 
20
- flags = "-ansi -pedantic -D_DEFAULT_SOURCE"
21
- #flags = "-ansi -pedantic -static -static-libgcc"
19
+ # Contains code, does not get touched
20
+ @source_directory = "src"
22
21
 
23
- libraries = "-lc"
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 "
24
40
 
25
41
  @pipe = Class.new.extend(PipeText)
26
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
+
71
+ #
72
+ # !!! If there is a demake/settings.rb file that gets executed NOW as raw code !!!
73
+ #
74
+ # !!! Incredibly convenient, but potentially a security nightmare -- secure your environment !!!
75
+ #
27
76
  begin
28
77
  code = File.open('demake/settings.rb').read
78
+ if(@emojis == false)
79
+ strip_emojis!(code)
80
+ end
29
81
  eval code
30
82
  rescue Errno::ENOENT
31
83
  rescue
32
- STDERR.puts(@pipe.pipetext("\n|YWARNING|n: #{$!}\n\n"))
84
+ notify("\n|YWARNING|n: #{$!}\n\n")
33
85
  end
34
86
 
87
+ # Applications to build
88
+ no_applications_file = true
89
+ @applications = Hash.new
35
90
  begin
36
91
  # The expected format is the application followed by a list of its dependencies
37
- # all on the same line separated by space, : or tab.
92
+ # all on the same line separated by space, : or tab and # for comments
38
93
  application_and_dependencies = File.open('demake/applications').read.split(/\n/)
39
- @applications = Hash.new
94
+ no_applications_file = false
40
95
  application_and_dependencies.each do |app|
41
- if(app =~ /([^ :\t]*)[ :\t]*(.*)/)
42
- @applications[$1] = Hash.new
43
- @applications[$1]['dependencies'] = $2.split(/[ :\t]/)
44
- else
45
- @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
46
104
  end
47
105
  end
48
- rescue Errno::ENOENT
49
- STDERR.puts(@pipe.pipetext("\n|RError|n: |Yapplications file|n |Rdoes not exist|n\n\n" +
50
- "You must create a file named |Yapplications|n which contains a list of\n" +
51
- "executeable application names and any dependencies to be compiled.\n\n"))
52
- exit!
53
106
  rescue
54
- puts $!.inspect
55
107
  end
56
108
 
57
- if(@applications == {})
58
- STDERR.puts(@pipe.pipetext("\n|RError|n: |Yapplications file|n |Rcannot be empty|n\n\n" +
59
- "You must create a file named |Yapplications|n which contains a list of\n" +
60
- "executeable application names and any dependencies to be compiled.\n\n"))
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
126
+ end
127
+ end
128
+ rescue
129
+ end
130
+
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")
61
140
  exit!
62
141
  end
63
142
 
64
143
  @output = <<-END_OF_STRING
65
144
  #
66
- # Makefile automatically generated by demake
145
+ # Makefile automatically generated by Ruby Gem - demake #{demake_version}
67
146
  #
68
147
  END_OF_STRING
69
148
 
70
- if(debug)
71
- @output << "DEBUG = true\n"
72
- else
73
- @output << "DEBUG = false\n"
74
- end
75
- if(quiet)
149
+ if(@silent == true)
76
150
  @output << "MAKE += -s\n"
77
151
  end
152
+ if(@num_threads > 1)
153
+ @output << "MAKE += -j #{@num_threads}\n"
154
+ end
78
155
 
79
156
  compiler_settings = <<-END_OF_STRING
80
- CC = #{compiler}
157
+ CC = #{@compiler}
81
158
  OS := $(shell uname)
82
159
  PROCESSOR := $(shell uname -p)
83
160
  MACHINE := $(shell uname -m)
@@ -85,40 +162,54 @@ END_OF_STRING
85
162
 
86
163
  @output << compiler_settings
87
164
 
88
- compiler_flags = <<-END_OF_STRING
89
- FLAGS = #{flags}
90
- ifeq '$(OS)' 'Linux'
91
- ifeq '$(CC)' 'gcc'
92
- FLAGS += -static -static-libgcc
93
- else
94
- FLAGS += -static
95
- endif
96
- endif
97
- ifeq '$(OS)' 'Darwin'
98
- FLAGS += -bundle
99
- endif
100
- ifeq '$(MACHINE)' 'aarch64'
101
- FLAGS += -march=native
102
- endif
103
- ifeq '$(DEBUG)' 'true'
104
- FLAGS += -g -Wall -W -Wconversion -Wshadow -Wcast-qual -Wwrite-strings
165
+ compiler_flags = "FLAGS = #{@flags}\n"
166
+ if(@linux_flags != "")
167
+ compiler_flags << "ifeq '$(OS)' 'Linux'\n"
168
+ compiler_flags << " FLAGS += #{@linux_flags}\n"
169
+ compiler_flags << "endif\n"
170
+ end
171
+ if(@darwin_flags != "")
172
+ compiler_flags << "ifeq '$(OS)' 'Darwin'\n"
173
+ compiler_flags << " FLAGS += #{@darwin_flags}\n"
174
+ compiler_flags << "endif\n"
175
+ end
176
+ if(@aarch64_flags != "")
177
+ compiler_flags << "ifeq '$(MACHINE)' 'aarch64'\n"
178
+ compiler_flags << " FLAGS += #{@aarch64_flags}\n"
179
+ compiler_flags << "endif\n"
180
+ end
181
+ if(@x86_64_flags != "")
182
+ compiler_flags << "ifeq '$(MACHINE)' 'x86_64'\n"
183
+ compiler_flags << " FLAGS += #{@x86_64_flags}\n"
184
+ compiler_flags << "endif\n"
185
+ end
186
+ compiler_flags += <<-END_OF_STRING
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
105
189
  else
106
- 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
107
191
  endif
192
+ FLAGS += -O2
108
193
  CFLAGS = $(FLAGS)
109
194
  END_OF_STRING
110
-
111
195
  if(defined?($flags_override))
112
- STDERR.puts("Overriding compiler flags")
113
- 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"
114
199
  end
115
200
  @output << compiler_flags
116
201
 
202
+ if(compiler_flags =~ /-static/)
203
+ library_extension = '.a'
204
+ else
205
+ library_extension = '.so'
206
+ end
207
+
117
208
  compiler_directories = <<-END_OF_STRING
118
- LIBS = #{libraries}
119
- BINARY = #{binary_directory}
120
- SOURCE = #{source_directory}
121
- OBJECT = #{object_directory}
209
+ LIBS = #{@libraries}
210
+ BINARY = #{@binary_directory}
211
+ SOURCE = #{@source_directory}
212
+ OBJECT = #{@object_directory}
122
213
  END_OF_STRING
123
214
 
124
215
  @output << compiler_directories
@@ -127,82 +218,171 @@ END_OF_STRING
127
218
  #OBJECTS = $(patsubst $(SOURCE)/%.c, $(OBJECT)/%.o, $(SOURCES))
128
219
 
129
220
  counter = 0
221
+ file_list = String.new
222
+ debug_file_list = String.new
130
223
  @applications.each do |app|
131
224
  counter += 1
132
- @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"
133
227
  # test to see if there is a app.c and we need app.o
134
228
  begin
135
- File.open(source_directory + '/' + "#{app[0]}.c")
136
- @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"
137
232
  rescue Errno::ENOENT
138
- @output << "FL#{counter} ="
233
+ file_list << "FL#{counter} ="
234
+ debug_file_list << "DFL#{counter} ="
139
235
  end
140
- app[1]['dependencies'].each do |dep|
141
- if(File.directory?(source_directory + '/' + dep) == true)
142
- Dir.entries(source_directory + '/' + dep).each do |e|
236
+ if(File.directory?(@source_directory + '/' + app[0]) == true)
237
+ Dir.entries(@source_directory + '/' + app[0]).each do |e|
238
+ if(e != '.' && e != '..' && e =~ /(.*)\.cp?p?$/)
239
+ Dir.chdir(@source_directory + '/' + app[0]) do
240
+ if(File.directory?(e) == false)
241
+ file_list << " " + app[0] + '/' + $1 + '.o'
242
+ debug_file_list << " " + app[0] + '/' + $1 + '-debug.o'
243
+ end
244
+ end
245
+ end
246
+ end
247
+ end
248
+ @applications[app[0]].each do |dep|
249
+ if(File.directory?(@source_directory + '/' + dep) == true)
250
+ Dir.entries(@source_directory + '/' + dep).each do |e|
143
251
  if(e != '.' && e != '..' && e =~ /(.*)\.cp?p?$/)
144
- Dir.chdir(source_directory + '/' + dep) do
252
+ Dir.chdir(@source_directory + '/' + dep) do
145
253
  if(File.directory?(e) == false)
146
- @output << " " + dep + '/' + $1 + '.o'
254
+ file_list << " " + dep + '/' + $1 + '.o'
255
+ debug_file_list << " " + dep + '/' + $1 + '-debug.o'
147
256
  end
148
257
  end
149
258
  end
150
259
  end
151
260
  else
152
- @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')
153
263
  end
154
264
  end
155
- @output << "\n"
156
- @output << "#\n# #{app[0]} - Object List (OL#{counter})\n#\n"
157
- @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
158
327
  end
159
328
 
160
329
  menu_target = <<-END_OF_STRING
330
+ .PHONY : menu
161
331
  menu :
162
- \t@clear
163
- \t@echo "|-[|20-]|o"
164
- \t@echo "|]28|-! Make targets:|;!|o"
165
- \t@echo "|]28|-!|;!|o"
166
- \t@echo "|]27|-! |g|[wrench]|n |Cbuild|n|;!|o"
167
- \t@echo "|]27|-! |B|[droplet]|n |Cclean|n|;!|o"
168
- \t@echo "|]27|-! |s|[nut and bolt]|n |Cinstall|n|;!|o"
169
- \t@echo "|]27|-! |m|[counterclockwise arrows button]|n |Ctest|n|;!|o"
170
- \t@echo "|-{|20-}|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"
171
343
  END_OF_STRING
172
- @output << "\n"
173
- @output << @pipe.pipetext(menu_target)
174
-
175
- default_target = <<-END_OF_STRING
176
- default :
177
- @clear
178
- END_OF_STRING
179
-
180
344
  @applications.each do |app|
181
- execute_target = <<-END_OF_STRING
182
- \t@echo "|-[|50-]|o"
183
- \t@echo "|]57|-! |g|[wrench] |nBuilding executable: |g#{app[0]}|n|;!|o"
184
- \t@echo "|-{|50-}|o"
185
- \t@$(MAKE) #{app[0]}
186
- END_OF_STRING
187
- default_target << @pipe.pipetext(execute_target)
345
+ menu_target << "\t@echo \"|=!|]78 Executable: bin/|g#{app[0]}|n|;!|O\"\n"
188
346
  end
189
-
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"
190
351
  @output << "\n"
191
- @output << default_target
352
+ if(@emojis == false)
353
+ strip_emojis!(menu_target)
354
+ end
355
+ @output << @pipe.pipetext(menu_target)
192
356
 
193
357
  build_target = <<-END_OF_STRING
358
+ .PHONY : build
194
359
  build :
195
- @clear
196
360
  END_OF_STRING
197
361
 
198
362
  @applications.each do |app|
199
- execute_target = <<-END_OF_STRING
200
- \t@echo "|-[|50-]|o"
201
- \t@echo "|]57|-! |g|[wrench] |nBuilding executable: |g#{app[0]}|n|;!|o"
202
- \t@echo "|-{|50-}|o"
203
- \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]}
204
368
  END_OF_STRING
205
- 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)
206
386
  end
207
387
 
208
388
  @output << "\n"
@@ -213,6 +393,16 @@ def add_dependencies(filename, path)
213
393
  dependencies = String.new
214
394
  File.readlines(filename).each do |line|
215
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
216
406
  dependencies << "\t\\\n\t$(SOURCE)#{path}#{$1}"
217
407
  end
218
408
  end
@@ -220,19 +410,35 @@ def add_dependencies(filename, path)
220
410
  dependency_targets = <<-END_OF_STRING
221
411
  # Dependencies
222
412
  $(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '.o')} : $(SOURCE)#{path}#{filename}#{dependencies}
223
- \t@echo "|=!|O |R|[fire]|n Compiling... |c$(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '.o')}|n"
413
+ \t@echo "|=!|O #{@emoji_compile} Compiling... |Y$(OBJECT)#{path}#{filename.sub(/\.cp?p?$/, '.o')}|n"
224
414
  ifeq '$(OS)' 'Linux'
225
415
  \t@mkdir -p $(OBJECT)#{path}
416
+ else ifeq '$(OS)' 'FreeBSD'
417
+ \t@mkdir -p $(OBJECT)#{path}
226
418
  else
227
419
  \t@if not exist $(OBJECT)#{path} @mkdir $(OBJECT)#{path}
228
420
  endif
229
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')}
230
433
  END_OF_STRING
434
+ if(@emojis == false)
435
+ strip_emojis!(dependency_targets)
436
+ end
231
437
  @output << "\n" + @pipe.pipetext(dependency_targets)
232
438
  end
233
439
  rescue
234
- STDERR.puts(@pipe.pipetext("|YWARNING|n: #{$!}"))
235
- 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")
236
442
  @raw_binary_files << " $(SOURCE)#{path}#{$1}#{filename}"
237
443
  end
238
444
  end
@@ -258,47 +464,152 @@ def add_all_dependencies(directory, path)
258
464
  end
259
465
  end
260
466
 
261
- add_all_dependencies(source_directory, '/')
467
+ add_all_dependencies(@source_directory, '/')
262
468
 
263
469
  counter = 0
264
470
  @applications.each do |app|
265
471
  counter += 1
266
- execute_target = <<-END_OF_STRING
267
- #{app[0]} : $(OL#{counter})
268
- \t@echo "|-[|50-]|o"
269
- \t@echo "|]57|-! |B|[link]|n Linking Files... |g#{app[0]}|n|;!|o"
270
- \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"
271
477
  ifeq '$(OS)' 'Linux'
272
478
  \t@mkdir -p $(BINARY)
479
+ else ifeq '$(OS)' 'FreeBSD'
480
+ \t@mkdir -p $(BINARY)
273
481
  else
274
482
  \t@if not exist $(BINARY) @mkdir $(BINARY)
275
483
  endif
276
- \t$(CC) $(LIBS) -o $(BINARY)/#{app[0]} $(OL#{counter})#{@raw_binary_files}
484
+ \t$(CC) $(CFLAGS) $(LIBS) -o $(BINARY)/#{app[0]} $(OL#{counter})#{@raw_binary_files}
277
485
  END_OF_STRING
278
486
  @output << "\n"
279
- @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)
280
568
  end
281
569
 
282
570
  dependency_targets = <<-END_OF_STRING
283
571
  # General Auto-Dependencies
284
572
  $(OBJECT)/%.o : $(SOURCE)/%.c
285
- \t@echo "|=!|o |R|[fire]|n Compiling... |c$(@)|n"
573
+ \t@echo "|=!|O #{@emoji_compile} Compiling... |Y$(@)|n"
286
574
  ifeq '$(OS)' 'Linux'
287
575
  \t@mkdir -p $(BINARY)
288
576
  \t@mkdir -p $(OBJECT)
577
+ else ifeq '$(OS)' 'FreeBSD'
578
+ \t@mkdir -p $(BINARY)
579
+ \t@mkdir -p $(OBJECT)
289
580
  else
290
581
  \t@if not exist $(BINARY) @mkdir $(BINARY)
291
582
  \t@if not exist $(OBJECT) @mkdir $(OBJECT)
292
583
  endif
293
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 $@
294
599
  END_OF_STRING
600
+ if(@emojis == false)
601
+ strip_emojis!(dependency_targets)
602
+ end
295
603
  @output << "\n" + @pipe.pipetext(dependency_targets)
296
604
 
297
605
  clean_target = <<-END_OF_STRING
606
+ .PHONY : clean
298
607
  clean :
299
- \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"
300
609
  ifeq '$(OS)' 'Linux'
301
610
  \t@rm -rf $(OBJECT) $(BINARY)
611
+ else ifeq '$(OS)' 'FreeBSD'
612
+ \t@rm -rf $(OBJECT) $(BINARY)
302
613
  else
303
614
  \t@if exist $(OBJECT)\*.* erase /Q $(OBJECT)\*.*
304
615
  \t@if exist $(OBJECT) rmdir $(OBJECT)
@@ -306,40 +617,91 @@ else
306
617
  \t@if exist $(BINARY) rmdir $(BINARY)
307
618
  endif
308
619
  END_OF_STRING
309
- @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
310
658
 
311
659
  test_target = <<-END_OF_STRING
312
660
  test :
313
- \t@echo "|m|[counterclockwise arrows button]|n Starting tests..."
661
+ \t@echo -n "#{@emoji_test} Running tests"
314
662
  END_OF_STRING
315
663
  begin
316
664
  code = File.open('demake/test-target.rb').read
665
+ if(@emojis == false)
666
+ strip_emojis!(code)
667
+ end
317
668
  eval code
318
669
  rescue Errno::ENOENT
319
670
  test_targets = <<-END_OF_STRING
320
- \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"
321
673
  END_OF_STRING
322
674
  test_target << test_targets
323
675
  rescue
324
- 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)
325
680
  end
326
- @output << @pipe.pipetext(test_target)
681
+ @output << "\n" + @pipe.pipetext(test_target)
327
682
 
328
683
  install_target = <<-END_OF_STRING
684
+ .PHONY : install
329
685
  install :
330
- \t@echo "|s|[nut and bolt]|n Starting install..."
686
+ \t@echo "#{@emoji_install} Starting install..."
331
687
  END_OF_STRING
332
688
  begin
333
689
  code = File.open('demake/install-target.rb').read
690
+ if(@emojis == false)
691
+ strip_emojis!(code)
692
+ end
334
693
  eval code
335
694
  rescue Errno::ENOENT
336
695
  install_targets = <<-END_OF_STRING
337
- \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"
338
697
  END_OF_STRING
339
698
  install_target << install_targets
340
699
  rescue
341
- 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)
342
704
  end
343
- @output << @pipe.pipetext(install_target)
705
+ @output << "\n" + @pipe.pipetext(install_target)
344
706
 
345
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.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minaswan Nakamoto
@@ -86,7 +86,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 1.8.7
90
90
  required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  requirements:
92
92
  - - ">="