demake 0.2.0 → 0.2.2
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 +166 -177
- data/lib/apps/example/Makefile +374 -0
- data/lib/{data → apps}/example/demake/applications +1 -1
- data/lib/apps/example/demake/brief_description +1 -0
- data/lib/{data → apps}/example/demake/license +0 -0
- data/lib/{data → apps}/example/demake/settings.rb +18 -15
- data/lib/apps/example/demake/suggestion +1 -0
- data/lib/{data → apps}/example/demake/test-target.rb +0 -0
- data/lib/apps/oreo/Makefile +260 -0
- data/lib/{data → apps}/oreo/demake/applications +0 -0
- data/lib/apps/oreo/demake/brief_description +1 -0
- data/lib/{data → apps}/oreo/demake/license +0 -0
- data/lib/{data → apps}/oreo/demake/settings.rb +14 -11
- data/lib/apps/oreo/demake/suggestion +1 -0
- data/lib/{data → apps}/oreo/demake/test-target.rb +0 -0
- data/lib/apps/oreo/src/defines.h +29 -0
- data/lib/{data → apps}/oreo/src/fast_read_file.h +18 -18
- data/lib/{data → apps}/oreo/src/oreo.c +4 -4
- data/lib/{data → apps}/oreo/src/typedefs.h +8 -8
- data/lib/data/libsrc/auto_bits.h +33 -0
- data/lib/data/libsrc/base.h +10 -0
- data/lib/data/libsrc/cpu_mark_check.h +267 -0
- data/lib/data/libsrc/defines.h +29 -0
- data/lib/data/libsrc/fast_read_file.h +259 -0
- data/lib/data/libsrc/fast_sha2.h +1840 -0
- data/lib/data/libsrc/parse_arguments.h +0 -0
- data/lib/data/libsrc/rb_library.c +140 -0
- data/lib/data/libsrc/simple_linked_list +0 -0
- data/lib/data/libsrc/simple_linked_list.c +36 -0
- data/lib/data/libsrc/simple_linked_list.h +91 -0
- data/lib/data/libsrc/smart_alloc.h +45 -0
- data/lib/data/libsrc/typedefs.h +61 -0
- data/lib/template/build_target.rb +0 -0
- data/lib/template/clean_target.rb +25 -1
- data/lib/template/debug_executable_target.rb +0 -0
- data/lib/template/debug_library_target.rb +0 -0
- data/lib/template/debug_target.rb +0 -0
- data/lib/template/dependency_targets.rb +0 -0
- data/lib/template/executable_debug_target.rb +0 -0
- data/lib/template/executable_target.rb +0 -0
- data/lib/template/generic_dependency_targets.rb +0 -0
- data/lib/template/library_debug_target.rb +0 -0
- data/lib/template/library_target.rb +0 -0
- data/lib/template/license_target.rb +0 -0
- data/lib/template/link_library_target.rb +0 -0
- data/lib/template/strip_build.rb +0 -0
- metadata +39 -20
- data/lib/data/oreo/src/defines.h +0 -29
- /data/lib/{data → apps}/example/src/goodbye.c +0 -0
- /data/lib/{data → apps}/example/src/hello.c +0 -0
- /data/lib/{data → apps}/example/src/string/string.c +0 -0
- /data/lib/{data → apps}/example/src/string/string.h +0 -0
- /data/lib/{data → apps}/oreo/oreo_test.txt +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3274ff2579bbe99e1f34dc59d4ea928cc8038f2887299035ce4dd91b48ec1e5f
|
|
4
|
+
data.tar.gz: d3b8bd0a0c724ae6ecf7934fc51ac2d0dabeef510688c864643e6fad63c8dbac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 19fbd37bdbae3376ff3a3a2b08d1957d849b10d28d166db72b95e08caac6bae7ad77d6bfbcf038344684fa73a781c2eac26d3d49f44db530f75d49c4fd187e64
|
|
7
|
+
data.tar.gz: a12f2d3c0f18888b523332fc3dbfb612236c11a5bce1112fbede19f7123eac5448095f01c89a4982080849de86256579be314ee0bb09218b3d4a3ca587968b95
|
data/bin/demake
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
#
|
|
3
|
-
# demake -
|
|
3
|
+
# demake - Executable script which uses Ruby to generate decorated GNU Makefiles
|
|
4
4
|
# for multiple related applications.
|
|
5
5
|
#
|
|
6
|
-
require 'rbconfig'
|
|
6
|
+
require 'rbconfig' # Needed by older versions of Ruby
|
|
7
7
|
require 'pipetext'
|
|
8
8
|
|
|
9
|
-
demake_version = "0.2.
|
|
9
|
+
demake_version = "0.2.2"
|
|
10
10
|
|
|
11
11
|
@silent = false
|
|
12
12
|
@compiler = "gcc"
|
|
@@ -19,9 +19,9 @@ demake_version = "0.2.0"
|
|
|
19
19
|
# Raise if you have more cores and a long compile time
|
|
20
20
|
@num_threads = 8
|
|
21
21
|
|
|
22
|
-
WIDTH
|
|
23
|
-
BOX_WIDTH
|
|
24
|
-
SHORT_WIDTH
|
|
22
|
+
WIDTH = 75
|
|
23
|
+
BOX_WIDTH = WIDTH + "\t@echo".length # To normalize for Makefile format
|
|
24
|
+
SHORT_WIDTH = BOX_WIDTH - 8
|
|
25
25
|
|
|
26
26
|
# Where to install binaries / libraries
|
|
27
27
|
@prefix = "/usr/local/bin/"
|
|
@@ -30,8 +30,10 @@ SHORT_WIDTH = BOX_WIDTH - 8
|
|
|
30
30
|
# Contains code, does not get touched
|
|
31
31
|
@source_directory = "src"
|
|
32
32
|
|
|
33
|
-
# These get completely blown away with make clean
|
|
33
|
+
# These can get completely blown away with make clean
|
|
34
|
+
@clean_includes_binary_directory = false
|
|
34
35
|
@binary_directory = "bin"
|
|
36
|
+
@clean_includes_library_directory = false
|
|
35
37
|
@library_directory = "lib"
|
|
36
38
|
@object_directory = "obj"
|
|
37
39
|
|
|
@@ -118,121 +120,119 @@ def notify(string)
|
|
|
118
120
|
end
|
|
119
121
|
|
|
120
122
|
@lib_data = File.join(File.expand_path("../..", __FILE__), "lib", "data")
|
|
123
|
+
@lib_apps = File.join(File.expand_path("../..", __FILE__), "lib", "apps")
|
|
121
124
|
@lib_dir = File.join(File.expand_path("../..", __FILE__), "lib")
|
|
125
|
+
@available_apps = Array.new
|
|
122
126
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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!
|
|
127
|
+
Dir.entries(@lib_apps).each do |e|
|
|
128
|
+
if(e != '.' && e != '..')
|
|
129
|
+
@available_apps << e
|
|
130
|
+
end
|
|
131
131
|
end
|
|
132
132
|
|
|
133
133
|
def file_open_write_close(filename, data)
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
begin
|
|
135
|
+
File.open(filename, 'w') do |f|
|
|
136
|
+
f.write(data)
|
|
137
|
+
end
|
|
138
|
+
rescue
|
|
139
|
+
notify("|RError|n: #{$!}")
|
|
136
140
|
end
|
|
137
141
|
end
|
|
138
142
|
|
|
139
|
-
def file_open_read_close(filename)
|
|
143
|
+
def file_open_read_close(filename, notify_warning=true)
|
|
140
144
|
data = String.new
|
|
141
|
-
|
|
142
|
-
|
|
145
|
+
begin
|
|
146
|
+
File.open(filename, 'r') do |f|
|
|
147
|
+
data = f.read
|
|
148
|
+
end
|
|
149
|
+
rescue
|
|
150
|
+
if(notify_warning == true)
|
|
151
|
+
notify("|YWARNING|n: #{$!.to_s.sub(/@ rb_[a-zA-Z_]* /, '')}")
|
|
152
|
+
end
|
|
143
153
|
end
|
|
144
154
|
return(data)
|
|
145
155
|
end
|
|
146
156
|
|
|
147
|
-
|
|
148
|
-
if(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
file_open_write_close('oreo/demake/settings.rb', oreo_settings_rb)
|
|
227
|
-
notify("#{@emoji_success} Created file: |goreo|n/|gdemake|n/|ysettings.rb|n |[page facing up]\n")
|
|
228
|
-
file_open_write_close('oreo/demake/test-target.rb', testtarget_rb)
|
|
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")
|
|
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")
|
|
235
|
-
@working_directory = Dir.pwd
|
|
157
|
+
def copy_template(filename)
|
|
158
|
+
if(File.directory?(filename) == true)
|
|
159
|
+
new_name = filename.sub(/^#{@lib_apps}./, '')
|
|
160
|
+
begin
|
|
161
|
+
if(File.directory?(new_name) != true)
|
|
162
|
+
Dir.mkdir(new_name)
|
|
163
|
+
notify("#{@emoji_success} Created directory: |g#{new_name}|n |[open file folder]\n")
|
|
164
|
+
end
|
|
165
|
+
Dir.entries(filename).each do |e|
|
|
166
|
+
if(e != '.' && e != '..')
|
|
167
|
+
copy_template(File.join(filename, e))
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
rescue Errno::EACCES
|
|
171
|
+
notify("|RError|n: #{$!.to_s.sub(/@ dir_s_mkdir /, '')}")
|
|
172
|
+
exit!
|
|
173
|
+
rescue
|
|
174
|
+
notify("|RError|n: #{$!}")
|
|
175
|
+
exit!
|
|
176
|
+
end
|
|
177
|
+
else
|
|
178
|
+
data = file_open_read_close(filename)
|
|
179
|
+
new_name = filename.sub(/^#{@lib_apps}./, '')
|
|
180
|
+
file_open_write_close(new_name, file_open_read_close(filename))
|
|
181
|
+
notify("#{@emoji_success} Created file: |y#{new_name}|n |[page facing up]\n")
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
@found_application = nil
|
|
186
|
+
@suggestion = String.new
|
|
187
|
+
@available_apps.sort.each do |app|
|
|
188
|
+
if(ARGV[0] =~ /^#{app}$/)
|
|
189
|
+
if(File.directory?(app) == true)
|
|
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!
|
|
193
|
+
end
|
|
194
|
+
@found_application = app
|
|
195
|
+
copy_template(File.join(@lib_apps, app))
|
|
196
|
+
begin
|
|
197
|
+
File.open(File.join(@lib_apps, app, 'demake', 'suggestion'), 'r') do |f|
|
|
198
|
+
@suggestion = f.read.chomp
|
|
199
|
+
end
|
|
200
|
+
rescue
|
|
201
|
+
end
|
|
202
|
+
Dir.chdir(app)
|
|
203
|
+
@working_directory = Dir.pwd
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
need_help = false
|
|
208
|
+
if(ARGV[0] == "help" || ARGV[0] == "--help" || ARGV[0] == "-h" ||
|
|
209
|
+
ARGV[0] == "?" || ARGV[0] == "-?")
|
|
210
|
+
need_help = true
|
|
211
|
+
end
|
|
212
|
+
if(need_help == false && ARGV[0] != nil && @found_application == nil)
|
|
213
|
+
notify("Unknown argument: #{ARGV[0]}\n\n")
|
|
214
|
+
need_help = true
|
|
215
|
+
end
|
|
216
|
+
if(need_help == true)
|
|
217
|
+
program = File.basename($0)
|
|
218
|
+
COLUMN_WIDTH = 20
|
|
219
|
+
syntax = "|]#{COLUMN_WIDTH}Command syntax:\n\n" + "|y#{program}|n|; - Create or update Makefile\n"
|
|
220
|
+
@available_apps.sort.each do |app|
|
|
221
|
+
data = String.new
|
|
222
|
+
begin
|
|
223
|
+
File.open(File.join(@lib_apps, app, 'demake', 'brief_description'), 'r') do |f|
|
|
224
|
+
data = f.read.chomp
|
|
225
|
+
end
|
|
226
|
+
rescue
|
|
227
|
+
end
|
|
228
|
+
if(data != "")
|
|
229
|
+
syntax << "|y#{program} #{app}|n|; - #{data}\n"
|
|
230
|
+
else
|
|
231
|
+
syntax << "|y#{program} #{app}|n\n"
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
notify(syntax + "\n")
|
|
235
|
+
exit!
|
|
236
236
|
end
|
|
237
237
|
|
|
238
238
|
@applications = Hash.new
|
|
@@ -240,18 +240,11 @@ end
|
|
|
240
240
|
|
|
241
241
|
# Check for settings / default override
|
|
242
242
|
begin
|
|
243
|
-
|
|
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
|
|
243
|
+
code = file_open_read_close('demake/settings.rb')
|
|
250
244
|
if(@emojis == false)
|
|
251
245
|
strip_emojis!(code)
|
|
252
246
|
end
|
|
253
247
|
eval code
|
|
254
|
-
rescue Errno::ENOENT
|
|
255
248
|
rescue
|
|
256
249
|
notify("\n|YWARNING|n: #{$!}\n\n")
|
|
257
250
|
end
|
|
@@ -262,64 +255,57 @@ else
|
|
|
262
255
|
@library_extension = '.so'
|
|
263
256
|
end
|
|
264
257
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
if(app
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
@applications[app] = Array.new
|
|
281
|
-
end
|
|
258
|
+
# Applications to build
|
|
259
|
+
no_applications_file = true
|
|
260
|
+
begin
|
|
261
|
+
# The expected format is the application followed by a list of its dependencies
|
|
262
|
+
# all on the same line separated by space, : or tab and # for comments
|
|
263
|
+
application_and_dependencies = file_open_read_close('demake/applications').split(/\n/)
|
|
264
|
+
no_applications_file = false
|
|
265
|
+
application_and_dependencies.each do |app|
|
|
266
|
+
if(app !~ /^#/ && app !~ /^[ \t]*#/)
|
|
267
|
+
if(app =~ /([^ :\t]*)[ :\t]*(.*)[ \t]*#?.*/)
|
|
268
|
+
application = $1
|
|
269
|
+
dependencies = $2.sub(/#.*$/, '').split(/[ :\t]/)
|
|
270
|
+
@applications[application] = dependencies
|
|
271
|
+
else
|
|
272
|
+
@applications[app] = Array.new
|
|
282
273
|
end
|
|
283
274
|
end
|
|
284
|
-
rescue
|
|
285
275
|
end
|
|
276
|
+
rescue
|
|
277
|
+
end
|
|
286
278
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
end
|
|
279
|
+
# Libraries to build
|
|
280
|
+
no_libraries_file = true
|
|
281
|
+
begin
|
|
282
|
+
# The expected format is the application followed by a list of its dependencies
|
|
283
|
+
# all on the same line separated by space, : or tab and # for comments
|
|
284
|
+
libraries_and_dependencies = file_open_read_close('demake/libraries', false).split(/\n/)
|
|
285
|
+
no_libraries_file = false
|
|
286
|
+
libraries_and_dependencies.each do |lib|
|
|
287
|
+
if(lib !~ /^#/ && lib !~ /^[ \t]*#/)
|
|
288
|
+
if(lib =~ /([^ :\t]*)[ :\t]*(.*)[ \t]*#?.*/)
|
|
289
|
+
library = $1
|
|
290
|
+
dependencies = $2.sub(/#.*$/, '').split(/[ :\t]/)
|
|
291
|
+
@build_libraries[library] = dependencies
|
|
292
|
+
else
|
|
293
|
+
@build_libraries[lib] = Array.new
|
|
303
294
|
end
|
|
304
295
|
end
|
|
305
|
-
rescue
|
|
306
296
|
end
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
@applications['oreo'] = Array.new
|
|
320
|
-
elsif(@example == true)
|
|
321
|
-
@applications['hello'] = ['string']
|
|
322
|
-
@applications['goodbye'] = ['string']
|
|
297
|
+
rescue
|
|
298
|
+
end
|
|
299
|
+
if(no_applications_file && no_libraries_file)
|
|
300
|
+
notify("\n#{@emoji_fail}|RError|n: |Yapplications file|n |Rdoes not exist|n\n\n" +
|
|
301
|
+
"You must create a file named |Yapplications|n which contains a list of\n" +
|
|
302
|
+
"executable application names and any dependencies to be compiled.\n\n")
|
|
303
|
+
exit!
|
|
304
|
+
elsif(@applications == {} && @build_libraries == {})
|
|
305
|
+
notify("\n#{@emoji_fail}|RError|n: |Yapplications file|n |Rcannot be empty|n\n\n" +
|
|
306
|
+
"You must create a file named |Yapplications|n which contains a list of\n" +
|
|
307
|
+
"executable application names and any dependencies to be compiled.\n\n")
|
|
308
|
+
exit!
|
|
323
309
|
end
|
|
324
310
|
|
|
325
311
|
@output = <<-END_OF_STRING
|
|
@@ -915,7 +901,10 @@ install : #{LICENSE}
|
|
|
915
901
|
\t@echo "#{@emoji_install} Starting install..."
|
|
916
902
|
END_OF_STRING
|
|
917
903
|
begin
|
|
918
|
-
code =
|
|
904
|
+
code = String.new
|
|
905
|
+
File.open('demake/install-target.rb', 'r') do |f|
|
|
906
|
+
code = f.read
|
|
907
|
+
end
|
|
919
908
|
if(@emojis == false)
|
|
920
909
|
strip_emojis!(code)
|
|
921
910
|
end
|
|
@@ -956,7 +945,10 @@ uninstall :
|
|
|
956
945
|
\t@echo "#{@emoji_uninstall} Starting uninstall..."
|
|
957
946
|
END_OF_STRING
|
|
958
947
|
begin
|
|
959
|
-
code =
|
|
948
|
+
code = String.new
|
|
949
|
+
File.open('demake/uninstall-target.rb', 'r') do |f|
|
|
950
|
+
code = f.read
|
|
951
|
+
end
|
|
960
952
|
if(@emojis == false)
|
|
961
953
|
strip_emojis!(code)
|
|
962
954
|
end
|
|
@@ -971,14 +963,11 @@ if(@emojis == false)
|
|
|
971
963
|
end
|
|
972
964
|
@output << "\n" + @pipe.pipetext(uninstall_target)
|
|
973
965
|
|
|
974
|
-
if(@
|
|
966
|
+
if(@found_application != nil)
|
|
975
967
|
File.open('Makefile', 'w').write(@output)
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
elsif(@oreo)
|
|
980
|
-
notify("#{@emoji_success} Created file: |goreo|n/|yMakefile|n |[page facing up]\n\n" +
|
|
981
|
-
"Suggestion: |Ccd oreo ; make ; make build ; make test|n\n")
|
|
968
|
+
notify("#{@emoji_success} Created file: |y#{@found_application}/Makefile|n |[page facing up]\n\n")
|
|
969
|
+
if(@suggestion != "")
|
|
970
|
+
notify("Suggestion: |C#{@suggestion}|n\n")
|
|
982
971
|
end
|
|
983
972
|
Dir.chdir('..')
|
|
984
973
|
else
|