demake 0.2.2 → 0.2.4
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 +296 -26
- data/lib/apps/example/demake/auto_bits.rb +59 -0
- data/lib/apps/example/demake/auto_list.rb +60 -0
- data/lib/apps/example/src/Makefile +6 -0
- data/lib/apps/oreo/oreo_test.txt +0 -0
- data/lib/apps/oreo/src/Makefile +6 -0
- data/lib/data/libsrc/auto_bits.c +41 -0
- data/lib/data/libsrc/auto_bits.h +212 -4
- data/lib/data/libsrc/auto_bits.rb +9 -0
- data/lib/data/libsrc/auto_list.rb +9 -0
- data/lib/data/libsrc/auto_string.c +300 -0
- data/lib/data/libsrc/auto_string.h +1023 -0
- data/lib/data/libsrc/auto_string_clamp_test.c +52 -0
- data/lib/data/libsrc/defines.h +29 -3
- data/lib/data/libsrc/memory_arena.c +32 -0
- data/lib/data/libsrc/memory_arena.h +345 -0
- data/lib/data/libsrc/memory_arena_test.c +173 -0
- data/lib/data/libsrc/simple_linked_list.c +42 -22
- data/lib/data/libsrc/simple_linked_list.h +140 -56
- data/lib/data/libsrc/typedefs.h +5 -3
- data/lib/to_plural.rb +126 -0
- metadata +47 -15
- data/lib/data/libsrc/simple_linked_list +0 -0
- data/lib/data/libsrc/smart_alloc.h +0 -45
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2ffe6f303e6b1353350fca9dfbfe5b4cff29a4150797efb62677fef654c0ad96
|
|
4
|
+
data.tar.gz: e104191198f2de99aa479e9c577dd623829b8b19e4b437e7f1dc140c11d9ca99
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a5e213d7abbdc81750dcff7afc5caf988265e105cf386dfc40d366f7a2a03f531859c49e453b160c24baa3044f86a7ee360f2ac04447e86c21f28af0e6005071
|
|
7
|
+
data.tar.gz: 602615ed7ccf3bc3a7af337d0f453b6f4160c8539180f89b82ea575b9c54090f272ed1b0d6a3ca350f915b443758182c86b23e587ff23ab285d3b9de80f85ce4
|
data/bin/demake
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
#
|
|
3
|
-
# demake
|
|
4
|
-
#
|
|
3
|
+
# demake
|
|
4
|
+
#
|
|
5
|
+
# Develop, Decorate and manage Dependencies for C (GNU) Makefiles easily with Ruby
|
|
5
6
|
#
|
|
6
7
|
require 'rbconfig' # Needed by older versions of Ruby
|
|
7
8
|
require 'pipetext'
|
|
9
|
+
@lib_dir = File.join(File.expand_path("../..", __FILE__), "lib")
|
|
10
|
+
@lib_data = File.join(File.expand_path("../..", __FILE__), "lib", "data")
|
|
11
|
+
@lib_apps = File.join(File.expand_path("../..", __FILE__), "lib", "apps")
|
|
12
|
+
load @lib_dir + '/to_plural.rb'
|
|
8
13
|
|
|
9
|
-
demake_version = "0.2.
|
|
14
|
+
demake_version = "0.2.4"
|
|
10
15
|
|
|
11
16
|
@silent = false
|
|
12
17
|
@compiler = "gcc"
|
|
@@ -119,11 +124,7 @@ def notify(string)
|
|
|
119
124
|
STDERR.puts(@pipe.pipetext(string))
|
|
120
125
|
end
|
|
121
126
|
|
|
122
|
-
@lib_data = File.join(File.expand_path("../..", __FILE__), "lib", "data")
|
|
123
|
-
@lib_apps = File.join(File.expand_path("../..", __FILE__), "lib", "apps")
|
|
124
|
-
@lib_dir = File.join(File.expand_path("../..", __FILE__), "lib")
|
|
125
127
|
@available_apps = Array.new
|
|
126
|
-
|
|
127
128
|
Dir.entries(@lib_apps).each do |e|
|
|
128
129
|
if(e != '.' && e != '..')
|
|
129
130
|
@available_apps << e
|
|
@@ -151,7 +152,7 @@ def file_open_read_close(filename, notify_warning=true)
|
|
|
151
152
|
notify("|YWARNING|n: #{$!.to_s.sub(/@ rb_[a-zA-Z_]* /, '')}")
|
|
152
153
|
end
|
|
153
154
|
end
|
|
154
|
-
return
|
|
155
|
+
return data
|
|
155
156
|
end
|
|
156
157
|
|
|
157
158
|
def copy_template(filename)
|
|
@@ -175,32 +176,291 @@ def copy_template(filename)
|
|
|
175
176
|
exit!
|
|
176
177
|
end
|
|
177
178
|
else
|
|
178
|
-
data = file_open_read_close(filename)
|
|
179
|
+
# data = file_open_read_close(filename)
|
|
179
180
|
new_name = filename.sub(/^#{@lib_apps}./, '')
|
|
180
181
|
file_open_write_close(new_name, file_open_read_close(filename))
|
|
181
182
|
notify("#{@emoji_success} Created file: |y#{new_name}|n |[page facing up]\n")
|
|
182
183
|
end
|
|
183
184
|
end
|
|
184
185
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
notify("\n#{@emoji_fail}|RError|n: |Ydirectory #{app} |Ralready exists, aborting creation|n\n\n" +
|
|
191
|
-
"Delete the directory and try again if you wish to recreate it.\n\n")
|
|
192
|
-
exit!
|
|
186
|
+
def create_new_application(new_name)
|
|
187
|
+
begin
|
|
188
|
+
if(File.directory?(new_name) != true)
|
|
189
|
+
Dir.mkdir(new_name)
|
|
190
|
+
notify("#{@emoji_success} Created directory: |g#{new_name}|n |[open file folder]\n")
|
|
193
191
|
end
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
if(File.directory?(new_name + "/demake") != true)
|
|
193
|
+
Dir.mkdir(new_name + "/demake")
|
|
194
|
+
notify("#{@emoji_success} Created directory: |g#{new_name}/demake|n |[open file folder]\n")
|
|
195
|
+
end
|
|
196
|
+
begin
|
|
197
|
+
File.open("#{new_name}/demake/applications", 'w') do |f|
|
|
198
|
+
f.write("#{new_name}\n")
|
|
199
|
+
end
|
|
200
|
+
notify("#{@emoji_success} Created file: |y#{new_name}/demake/applications|n |[page facing up]\n")
|
|
201
|
+
rescue
|
|
202
|
+
notify("|RError|n: #{$!}")
|
|
203
|
+
end
|
|
204
|
+
file_open_write_close(new_name + "/demake/settings.rb", file_open_read_close(@lib_apps + "/example/demake/settings.rb"))
|
|
205
|
+
notify("#{@emoji_success} Created file: |y#{new_name}/demake/settings.rb|n |[page facing up]\n")
|
|
206
|
+
file_open_write_close(new_name + "/demake/license", file_open_read_close(@lib_apps + "/example/demake/license"))
|
|
207
|
+
notify("#{@emoji_success} Created file: |y#{new_name}/demake/license|n |[page facing up]\n")
|
|
208
|
+
file_open_write_close(new_name + "/demake/auto_bits.rb", file_open_read_close(@lib_apps + "/example/demake/auto_bits.rb"))
|
|
209
|
+
notify("#{@emoji_success} Created file: |y#{new_name}/demake/auto_bits.rb|n |[page facing up]\n")
|
|
210
|
+
file_open_write_close(new_name + "/demake/auto_list.rb", file_open_read_close(@lib_apps + "/example/demake/auto_list.rb"))
|
|
211
|
+
notify("#{@emoji_success} Created file: |y#{new_name}/demake/auto_list.rb|n |[page facing up]\n")
|
|
196
212
|
begin
|
|
197
|
-
File.open(
|
|
198
|
-
|
|
213
|
+
File.open("#{new_name}/demake/test-target.rb", 'w') do |f|
|
|
214
|
+
f.write("test_targets = <<-END_OF_STRING\n")
|
|
215
|
+
f.write("\t@echo\n\t@echo \"|YTesting command:|n\"\n\tbin/#{new_name}\n")
|
|
216
|
+
f.write("END_OF_STRING\n")
|
|
217
|
+
f.write("test_target << test_targets\n")
|
|
199
218
|
end
|
|
219
|
+
notify("#{@emoji_success} Created file: |y#{new_name}/demake/test-target.rb|n |[page facing up]\n")
|
|
200
220
|
rescue
|
|
221
|
+
notify("|RError|n: #{$!}")
|
|
222
|
+
end
|
|
223
|
+
if(File.directory?(new_name + "/src") != true)
|
|
224
|
+
Dir.mkdir(new_name + "/src")
|
|
225
|
+
notify("#{@emoji_success} Created directory: |g#{new_name}/src|n |[open file folder]\n")
|
|
226
|
+
end
|
|
227
|
+
file_open_write_close(new_name + "/src/Makefile", file_open_read_close(@lib_apps + "/example/src/Makefile"))
|
|
228
|
+
notify("#{@emoji_success} Created file: |y#{new_name}/src/Makefile|n |[page facing up]\n")
|
|
229
|
+
file_open_write_close(new_name + "/src/typedefs.h", file_open_read_close(@lib_data + "/libsrc/typedefs.h"))
|
|
230
|
+
notify("#{@emoji_success} Created file: |y#{new_name}/src/typedefs.h|n |[page facing up]\n")
|
|
231
|
+
file_open_write_close(new_name + "/src/defines.h", file_open_read_close(@lib_data + "/libsrc/defines.h"))
|
|
232
|
+
notify("#{@emoji_success} Created file: |y#{new_name}/src/defines.h|n |[page facing up]\n")
|
|
233
|
+
file_open_write_close(new_name + "/src/base.h", file_open_read_close(@lib_data + "/libsrc/base.h"))
|
|
234
|
+
notify("#{@emoji_success} Created file: |y#{new_name}/src/base.h|n |[page facing up]\n")
|
|
235
|
+
begin
|
|
236
|
+
File.open("#{new_name}/src/#{new_name}.c", 'w') do |f|
|
|
237
|
+
f.write("/*\n\n #{new_name}.c - #{new_name} main application entry point\n\n*/\n\n" +
|
|
238
|
+
"#include <stdio.h>\n\n#include \"base.h\"\n\n" +
|
|
239
|
+
"i32 main(i32 argc, c8 *argv[]) {\n printf(\"Hello, world!\\n\");\n return 0;\n}\n")
|
|
240
|
+
end
|
|
241
|
+
notify("#{@emoji_success} Created file: |y#{new_name}/src/#{new_name}.c|n |[page facing up]\n")
|
|
242
|
+
rescue
|
|
243
|
+
notify("|RError|n: #{$!}")
|
|
244
|
+
end
|
|
245
|
+
rescue Errno::EACCES
|
|
246
|
+
notify("|RError|n: #{$!.to_s.sub(/@ dir_s_mkdir /, '')}")
|
|
247
|
+
exit!
|
|
248
|
+
rescue
|
|
249
|
+
notify("|RError|n: #{$!}")
|
|
250
|
+
end
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
@auto_bits = Hash.new
|
|
254
|
+
def auto_bits_add(prefix, list, file=nil)
|
|
255
|
+
@auto_bits[prefix] = { 'prefix' => prefix, 'list' => list, 'file' => file }
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
@auto_list = Hash.new
|
|
259
|
+
def auto_list_add(prefix, list, file=nil)
|
|
260
|
+
@auto_list[prefix] = { 'prefix' => prefix, 'list' => list, 'file' => file }
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
@found_application = nil
|
|
264
|
+
@suggestion = String.new
|
|
265
|
+
|
|
266
|
+
if(ARGV[0] =~ /^new/)
|
|
267
|
+
if(ARGV[1] == nil || ARGV[1] == "")
|
|
268
|
+
notify("\n#{@emoji_fail}|RError|n: |Ynew application name |Rrequired|n.\n\n");
|
|
269
|
+
exit!
|
|
270
|
+
end
|
|
271
|
+
@found_application = "new"
|
|
272
|
+
create_new_application(ARGV[1])
|
|
273
|
+
Dir.chdir(ARGV[1])
|
|
274
|
+
@working_directory = Dir.pwd
|
|
275
|
+
elsif(ARGV[0] =~ /^auto_bits/ || ARGV[0] =~ /^auto-bits/ || ARGV[0] =~ /^auto_list/ || ARGV[0] =~ /^auto-list/)
|
|
276
|
+
if(ARGV[0] =~ /^auto_bits/ || ARGV[0] =~ /^auto-bits/)
|
|
277
|
+
auto_bits = true
|
|
278
|
+
elsif(ARGV[0] =~ /^auto_list/ || ARGV[0] =~ /^auto-list/)
|
|
279
|
+
auto_list = true
|
|
280
|
+
end
|
|
281
|
+
begin
|
|
282
|
+
if(ARGV[1] != nil)
|
|
283
|
+
code = file_open_read_close(ARGV[1])
|
|
284
|
+
else
|
|
285
|
+
if(auto_bits)
|
|
286
|
+
code = file_open_read_close('demake/auto_bits.rb')
|
|
287
|
+
elsif(auto_list)
|
|
288
|
+
code = file_open_read_close('demake/auto_list.rb')
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
if(@emojis == false)
|
|
292
|
+
strip_emojis!(code)
|
|
293
|
+
end
|
|
294
|
+
eval code
|
|
295
|
+
rescue Errno::ENOENT
|
|
296
|
+
if(auto_bits)
|
|
297
|
+
notify("\n#{@emoji_fail}|RError|n: |Ydemake/auto_bits.rb|n or |Yadditional argument|n |Rrequired|n.\n\n")
|
|
298
|
+
elsif(auto_list)
|
|
299
|
+
notify("\n#{@emoji_fail}|RError|n: |Ydemake/auto_list.rb|n or |Yadditional argument|n |Rrequired|n.\n\n")
|
|
300
|
+
end
|
|
301
|
+
exit!
|
|
302
|
+
rescue
|
|
303
|
+
notify("\n#{@emoji_fail}|RError|n: #{$!}\n\n")
|
|
304
|
+
exit!
|
|
305
|
+
end
|
|
306
|
+
if(@auto_bits == {} && auto_bits)
|
|
307
|
+
notify("\n#{@emoji_fail}|RError|n: No auto_bits.rb configurations found.\n\n")
|
|
308
|
+
exit!
|
|
309
|
+
end
|
|
310
|
+
if(@auto_list == {} && auto_list)
|
|
311
|
+
notify("\n#{@emoji_fail}|RError|n: No auto_list.rb configurations found.\n\n")
|
|
312
|
+
exit!
|
|
313
|
+
end
|
|
314
|
+
if(!defined?(@prespace))
|
|
315
|
+
@prespace = 0
|
|
316
|
+
end
|
|
317
|
+
if(!defined?(@target_tab_column))
|
|
318
|
+
@target_tab_column = 5
|
|
319
|
+
end
|
|
320
|
+
@text = String.new
|
|
321
|
+
@spaces = " " * @prespace
|
|
322
|
+
@auto_bits.each do |bits|
|
|
323
|
+
bits[1]['list'].each_with_index do |entry, index|
|
|
324
|
+
text = @spaces + "#define #{bits[1]['prefix'].upcase.gsub(' ', '_')}_"
|
|
325
|
+
text << entry.upcase.gsub(' ', '_')
|
|
326
|
+
text << "\t" * [1, @target_tab_column - (text.length / 8).floor].max
|
|
327
|
+
text << "(1 << #{index})\n"
|
|
328
|
+
@text << text
|
|
329
|
+
end
|
|
330
|
+
text = @spaces + "#define NUM_#{to_plural(bits[1]['prefix']).upcase.gsub(' ', '_')}"
|
|
331
|
+
text << "\t" * [1, @target_tab_column - (text.length / 8).floor].max
|
|
332
|
+
text << bits[1]['list'].count.to_s + "\n"
|
|
333
|
+
@text << "\n" + text
|
|
334
|
+
@text << "\n" + @spaces + "cc8 #{to_plural(bits[1]['prefix']).gsub(' ', '_')}_list[] = {\n"
|
|
335
|
+
bits[1]['list'].each do |entry|
|
|
336
|
+
text = @spaces + " \"#{entry}\",\n"
|
|
337
|
+
@text << text
|
|
338
|
+
end
|
|
339
|
+
@text << @spaces + " NULL\n"
|
|
340
|
+
@text << @spaces + "};\n\n"
|
|
341
|
+
if(bits[1]['file'] == nil)
|
|
342
|
+
file_name = "auto_bits_generated.h"
|
|
343
|
+
else
|
|
344
|
+
file_name = bits[1]['file']
|
|
345
|
+
end
|
|
346
|
+
same_file = false
|
|
347
|
+
@auto_bits.each do |bits2|
|
|
348
|
+
if(bits == bits2)
|
|
349
|
+
break
|
|
350
|
+
elsif(bits[1]['file'] == bits2[1]['file'])
|
|
351
|
+
same_file = true
|
|
352
|
+
break
|
|
353
|
+
elsif(bits[1]['file'] == nil && bits2[1]['file'] == file_name)
|
|
354
|
+
same_file = true
|
|
355
|
+
break
|
|
356
|
+
end
|
|
357
|
+
end
|
|
358
|
+
if(same_file == true) # Append
|
|
359
|
+
File.open(file_name, "a") do |file|
|
|
360
|
+
file.puts(@text)
|
|
361
|
+
end
|
|
362
|
+
else # New File
|
|
363
|
+
output = <<-END_OF_STRING
|
|
364
|
+
/*
|
|
365
|
+
|
|
366
|
+
This file automatically generated by Ruby Gem - demake #{demake_version}
|
|
367
|
+
|
|
368
|
+
*/
|
|
369
|
+
|
|
370
|
+
#ifndef NULL
|
|
371
|
+
#define NULL ((void *) 0)
|
|
372
|
+
#endif
|
|
373
|
+
|
|
374
|
+
END_OF_STRING
|
|
375
|
+
File.open(file_name, "w") do |file|
|
|
376
|
+
file.puts(output)
|
|
377
|
+
file.puts(@text)
|
|
378
|
+
end
|
|
379
|
+
notify("#{@emoji_success} Created file: |y#{file_name}|n |[page facing up]\n\n")
|
|
380
|
+
end
|
|
381
|
+
@text = String.new
|
|
382
|
+
end
|
|
383
|
+
@auto_list.each do |list|
|
|
384
|
+
list[1]['list'].each_with_index do |entry, index|
|
|
385
|
+
text = @spaces + "#define #{list[1]['prefix'].upcase.gsub(' ', '_')}_"
|
|
386
|
+
text << entry.upcase.gsub(' ', '_')
|
|
387
|
+
text << "\t" * [1, @target_tab_column - (text.length / 8).floor].max
|
|
388
|
+
text << "#{index}\n"
|
|
389
|
+
@text << text
|
|
390
|
+
end
|
|
391
|
+
text = @spaces + "#define NUM_#{to_plural(list[1]['prefix']).upcase.gsub(' ', '_')}"
|
|
392
|
+
text << "\t" * [1, @target_tab_column - (text.length / 8).floor].max
|
|
393
|
+
text << list[1]['list'].count.to_s + "\n"
|
|
394
|
+
@text << "\n" + text
|
|
395
|
+
@text << "\n" + @spaces + "cc8 #{to_plural(list[1]['prefix']).gsub(' ', '_')}_list[] = {\n"
|
|
396
|
+
list[1]['list'].each do |entry|
|
|
397
|
+
text = @spaces + " \"#{entry}\",\n"
|
|
398
|
+
@text << text
|
|
399
|
+
end
|
|
400
|
+
@text << @spaces + " NULL\n"
|
|
401
|
+
@text << @spaces + "};\n\n"
|
|
402
|
+
if(list[1]['file'] == nil)
|
|
403
|
+
file_name = "auto_list_generated.h"
|
|
404
|
+
else
|
|
405
|
+
file_name = list[1]['file']
|
|
406
|
+
end
|
|
407
|
+
same_file = false
|
|
408
|
+
@auto_list.each do |list2|
|
|
409
|
+
if(list == list2)
|
|
410
|
+
break
|
|
411
|
+
elsif(list[1]['file'] == list2[1]['file'])
|
|
412
|
+
same_file = true
|
|
413
|
+
break
|
|
414
|
+
elsif(list[1]['file'] == nil && list2[1]['file'] == file_name)
|
|
415
|
+
same_file = true
|
|
416
|
+
break
|
|
417
|
+
end
|
|
418
|
+
end
|
|
419
|
+
if(same_file == true) # Append
|
|
420
|
+
File.open(file_name, "a") do |file|
|
|
421
|
+
file.puts(@text)
|
|
422
|
+
end
|
|
423
|
+
else # New File
|
|
424
|
+
output = <<-END_OF_STRING
|
|
425
|
+
/*
|
|
426
|
+
|
|
427
|
+
This file automatically generated by Ruby Gem - demake #{demake_version}
|
|
428
|
+
|
|
429
|
+
*/
|
|
430
|
+
|
|
431
|
+
#ifndef NULL
|
|
432
|
+
#define NULL ((void *) 0)
|
|
433
|
+
#endif
|
|
434
|
+
|
|
435
|
+
END_OF_STRING
|
|
436
|
+
File.open(file_name, "w") do |file|
|
|
437
|
+
file.puts(output)
|
|
438
|
+
file.puts(@text)
|
|
439
|
+
end
|
|
440
|
+
notify("#{@emoji_success} Created file: |y#{file_name}|n |[page facing up]\n\n")
|
|
441
|
+
end
|
|
442
|
+
@text = String.new
|
|
443
|
+
end
|
|
444
|
+
exit!
|
|
445
|
+
else
|
|
446
|
+
@available_apps.sort.each do |app|
|
|
447
|
+
if(ARGV[0] =~ /^#{app}$/)
|
|
448
|
+
if(File.directory?(app) == true)
|
|
449
|
+
notify("\n#{@emoji_fail}|RError|n: |Ydirectory #{app} |Ralready exists, aborting creation|n\n\n" +
|
|
450
|
+
"Delete the directory and try again if you wish to recreate it.\n\n")
|
|
451
|
+
exit!
|
|
452
|
+
end
|
|
453
|
+
@found_application = app
|
|
454
|
+
copy_template(File.join(@lib_apps, app))
|
|
455
|
+
begin
|
|
456
|
+
File.open(File.join(@lib_apps, app, 'demake', 'suggestion'), 'r') do |f|
|
|
457
|
+
@suggestion = f.read.chomp
|
|
458
|
+
end
|
|
459
|
+
rescue
|
|
460
|
+
end
|
|
461
|
+
Dir.chdir(app)
|
|
462
|
+
@working_directory = Dir.pwd
|
|
201
463
|
end
|
|
202
|
-
Dir.chdir(app)
|
|
203
|
-
@working_directory = Dir.pwd
|
|
204
464
|
end
|
|
205
465
|
end
|
|
206
466
|
|
|
@@ -217,6 +477,10 @@ if(need_help == true)
|
|
|
217
477
|
program = File.basename($0)
|
|
218
478
|
COLUMN_WIDTH = 20
|
|
219
479
|
syntax = "|]#{COLUMN_WIDTH}Command syntax:\n\n" + "|y#{program}|n|; - Create or update Makefile\n"
|
|
480
|
+
syntax << "|y#{program} ?|n|; - View this help information\n"
|
|
481
|
+
syntax << "|y#{program} new <name>|n|; - Create new application\n"
|
|
482
|
+
syntax << "|y#{program} auto_bits|n|; - Generate auto_bits code\n"
|
|
483
|
+
syntax << "|y#{program} auto_list|n|; - Generate auto_list code\n"
|
|
220
484
|
@available_apps.sort.each do |app|
|
|
221
485
|
data = String.new
|
|
222
486
|
begin
|
|
@@ -231,6 +495,7 @@ if(need_help == true)
|
|
|
231
495
|
syntax << "|y#{program} #{app}|n\n"
|
|
232
496
|
end
|
|
233
497
|
end
|
|
498
|
+
syntax << "\nVersion: |c#{demake_version}|n\n"
|
|
234
499
|
notify(syntax + "\n")
|
|
235
500
|
exit!
|
|
236
501
|
end
|
|
@@ -965,9 +1230,14 @@ end
|
|
|
965
1230
|
|
|
966
1231
|
if(@found_application != nil)
|
|
967
1232
|
File.open('Makefile', 'w').write(@output)
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
notify("Suggestion: |
|
|
1233
|
+
if(@found_application == "new")
|
|
1234
|
+
notify("#{@emoji_success} Created file: |y#{ARGV[1]}/Makefile|n |[page facing up]\n\n")
|
|
1235
|
+
notify("Suggestion: |Ccd #{ARGV[1]} ; make ; make build ; make test|n\n")
|
|
1236
|
+
else
|
|
1237
|
+
notify("#{@emoji_success} Created file: |y#{@found_application}/Makefile|n |[page facing up]\n\n")
|
|
1238
|
+
if(@suggestion != "")
|
|
1239
|
+
notify("Suggestion: |C#{@suggestion}|n\n")
|
|
1240
|
+
end
|
|
971
1241
|
end
|
|
972
1242
|
Dir.chdir('..')
|
|
973
1243
|
else
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#file = "auto_bits_generated.h"
|
|
2
|
+
prefix = "bit"
|
|
3
|
+
list = [ "0", "1", "2", "3" ]
|
|
4
|
+
auto_bits_add(prefix, list)
|
|
5
|
+
#auto_bits_add(prefix, list, file)
|
|
6
|
+
|
|
7
|
+
prefix = "flag"
|
|
8
|
+
list = [ "A", "B", "C", "D" ]
|
|
9
|
+
auto_bits_add(prefix, list)
|
|
10
|
+
|
|
11
|
+
@prespace = 0
|
|
12
|
+
@target_tab_column = 5
|
|
13
|
+
notify("|g|[check mark]|n demake/auto_bits.rb is present - generating code")
|
|
14
|
+
|
|
15
|
+
=begin
|
|
16
|
+
|
|
17
|
+
The default configuration above generates the following C code
|
|
18
|
+
in the file auto_bits_generated.h:
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
|
|
22
|
+
This file automatically generated by Ruby Gem - demake 0.2.4
|
|
23
|
+
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
#ifndef NULL
|
|
27
|
+
#define NULL ((void *) 0)
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
#define BIT_0 (1 << 0)
|
|
31
|
+
#define BIT_1 (1 << 1)
|
|
32
|
+
#define BIT_2 (1 << 2)
|
|
33
|
+
#define BIT_3 (1 << 3)
|
|
34
|
+
|
|
35
|
+
#define NUM_BITS 4
|
|
36
|
+
|
|
37
|
+
cc8 bits_list[] = {
|
|
38
|
+
"0",
|
|
39
|
+
"1",
|
|
40
|
+
"2",
|
|
41
|
+
"3",
|
|
42
|
+
NULL
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
#define FLAG_A (1 << 0)
|
|
46
|
+
#define FLAG_B (1 << 1)
|
|
47
|
+
#define FLAG_C (1 << 2)
|
|
48
|
+
#define FLAG_D (1 << 3)
|
|
49
|
+
|
|
50
|
+
#define NUM_FLAGS 4
|
|
51
|
+
|
|
52
|
+
cc8 flags_list[] = {
|
|
53
|
+
"A",
|
|
54
|
+
"B",
|
|
55
|
+
"C",
|
|
56
|
+
"D",
|
|
57
|
+
NULL
|
|
58
|
+
};
|
|
59
|
+
=end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#file = "auto_list_generated.h"
|
|
2
|
+
prefix = "color"
|
|
3
|
+
list = [ "blue", "green", "red", "purple" ]
|
|
4
|
+
auto_list_add(prefix, list)
|
|
5
|
+
#auto_bits_add(prefix, list, file)
|
|
6
|
+
|
|
7
|
+
prefix = "shape"
|
|
8
|
+
list = [ "circle", "triangle", "square", "hexagon" ]
|
|
9
|
+
auto_list_add(prefix, list)
|
|
10
|
+
|
|
11
|
+
@prespace = 0
|
|
12
|
+
@target_tab_column = 5
|
|
13
|
+
notify("|g|[check mark]|n demake/auto_list.rb is present - generating code")
|
|
14
|
+
|
|
15
|
+
=begin
|
|
16
|
+
|
|
17
|
+
The default configuration above generates the following C code
|
|
18
|
+
in the file auto_list_generated.h:
|
|
19
|
+
|
|
20
|
+
/*
|
|
21
|
+
|
|
22
|
+
This file automatically generated by Ruby Gem - demake 0.2.4
|
|
23
|
+
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
#ifndef NULL
|
|
27
|
+
#define NULL ((void *) 0)
|
|
28
|
+
#endif
|
|
29
|
+
|
|
30
|
+
#define COLOR_BLUE 0
|
|
31
|
+
#define COLOR_GREEN 1
|
|
32
|
+
#define COLOR_RED 2
|
|
33
|
+
#define COLOR_PURPLE 3
|
|
34
|
+
|
|
35
|
+
#define NUM_COLORS 4
|
|
36
|
+
|
|
37
|
+
cc8 colors_list[] = {
|
|
38
|
+
"blue",
|
|
39
|
+
"green",
|
|
40
|
+
"red",
|
|
41
|
+
"purple",
|
|
42
|
+
NULL
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
#define SHAPE_CIRCLE 0
|
|
46
|
+
#define SHAPE_TRIANGLE 1
|
|
47
|
+
#define SHAPE_SQUARE 2
|
|
48
|
+
#define SHAPE_HEXAGON 3
|
|
49
|
+
|
|
50
|
+
#define NUM_SHAPES 4
|
|
51
|
+
|
|
52
|
+
cc8 shapes_list[] = {
|
|
53
|
+
"circle",
|
|
54
|
+
"triangle",
|
|
55
|
+
"square",
|
|
56
|
+
"hexagon",
|
|
57
|
+
NULL
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
=end
|
data/lib/apps/oreo/oreo_test.txt
CHANGED
|
File without changes
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#define AUTO_BITS_IMPLEMENTATION
|
|
2
|
+
#include "auto_bits.h"
|
|
3
|
+
|
|
4
|
+
#define BIT_0 (1 << 0)
|
|
5
|
+
#define BIT_1 (1 << 1)
|
|
6
|
+
#define BIT_2 (1 << 2)
|
|
7
|
+
#define BIT_3 (1 << 3)
|
|
8
|
+
|
|
9
|
+
cc8 *bit_list[] = {
|
|
10
|
+
"0",
|
|
11
|
+
"1",
|
|
12
|
+
"2",
|
|
13
|
+
"3",
|
|
14
|
+
NULL
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
i32 main(i32 argc, c8 *argv[])
|
|
18
|
+
{
|
|
19
|
+
b8 bits = 0;
|
|
20
|
+
|
|
21
|
+
printf("-- Set both bits 1 & 2:\n");
|
|
22
|
+
SET_BIT(bits, BIT_1|BIT_2);
|
|
23
|
+
auto_bits_print(bit_list, bits);
|
|
24
|
+
if(IS_SET(bits, BIT_2))
|
|
25
|
+
printf("Bit #2 is set.\n");
|
|
26
|
+
printf("Manual list set bits: ");
|
|
27
|
+
auto_bits_show(bit_list, bits, "|");
|
|
28
|
+
printf("\n\n-- Remove both bits 1 & 2:\n");
|
|
29
|
+
REMOVE_BIT(bits, BIT_1|BIT_2);
|
|
30
|
+
auto_bits_print(bit_list, bits);
|
|
31
|
+
printf("\n-- Set all 4 bits:\n");
|
|
32
|
+
SET_BIT(bits, BIT_0|BIT_1|BIT_2|BIT_3);
|
|
33
|
+
auto_bits_print(bit_list, bits);
|
|
34
|
+
printf("Manual list set bits: ");
|
|
35
|
+
auto_bits_show(bit_list, bits, " + ");
|
|
36
|
+
printf("\n\n-- Toggle both bits 1 & 2:\n");
|
|
37
|
+
TOGGLE_BIT(bits, BIT_1|BIT_2);
|
|
38
|
+
auto_bits_print(bit_list, bits);
|
|
39
|
+
|
|
40
|
+
return 0;
|
|
41
|
+
}
|