demake 0.2.0 → 0.2.1
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 +163 -176
- 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 +14 -14
- data/lib/apps/example/demake/suggestion +1 -0
- data/lib/{data → apps}/example/demake/test-target.rb +0 -0
- 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/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 +13 -13
- 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/typedefs.h +61 -0
- data/lib/template/build_target.rb +0 -0
- data/lib/template/clean_target.rb +0 -0
- 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 +35 -20
- data/lib/data/oreo/src/defines.h +0 -29
- /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: 0dc09a132635560049c925c2abcdff0afc64a4e60b03de5f26da26ada3f2e084
|
|
4
|
+
data.tar.gz: 5742dfdd893a1fefc6e7d559b68227bc4f8009d11aa512f80872b3591043a3f0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8ecb2ab96a2e9e486d090e9f1e47ec16de7c91ad4b0f5ae4238b82c951d7a0cfe749fa61f03a0e6c03e5ac9711579d92e29788dfe06411eaba6cf054603c7e6b
|
|
7
|
+
data.tar.gz: 3d8264dae828999e98a93b6816dd9b16ebbbc466bb67fc91ca2d3d61e044ab1df4aa44cb5dec584e59d98361579828ca8c452d2353ef63fee1d398f8739433e6
|
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.1"
|
|
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/"
|
|
@@ -118,121 +118,119 @@ def notify(string)
|
|
|
118
118
|
end
|
|
119
119
|
|
|
120
120
|
@lib_data = File.join(File.expand_path("../..", __FILE__), "lib", "data")
|
|
121
|
+
@lib_apps = File.join(File.expand_path("../..", __FILE__), "lib", "apps")
|
|
121
122
|
@lib_dir = File.join(File.expand_path("../..", __FILE__), "lib")
|
|
123
|
+
@available_apps = Array.new
|
|
122
124
|
|
|
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!
|
|
125
|
+
Dir.entries(@lib_apps).each do |e|
|
|
126
|
+
if(e != '.' && e != '..')
|
|
127
|
+
@available_apps << e
|
|
128
|
+
end
|
|
131
129
|
end
|
|
132
130
|
|
|
133
131
|
def file_open_write_close(filename, data)
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
begin
|
|
133
|
+
File.open(filename, 'w') do |f|
|
|
134
|
+
f.write(data)
|
|
135
|
+
end
|
|
136
|
+
rescue
|
|
137
|
+
notify("|RError|n: #{$!}")
|
|
136
138
|
end
|
|
137
139
|
end
|
|
138
140
|
|
|
139
|
-
def file_open_read_close(filename)
|
|
141
|
+
def file_open_read_close(filename, notify_warning=true)
|
|
140
142
|
data = String.new
|
|
141
|
-
|
|
142
|
-
|
|
143
|
+
begin
|
|
144
|
+
File.open(filename, 'r') do |f|
|
|
145
|
+
data = f.read
|
|
146
|
+
end
|
|
147
|
+
rescue
|
|
148
|
+
if(notify_warning == true)
|
|
149
|
+
notify("|YWARNING|n: #{$!.to_s.sub(/@ rb_[a-zA-Z_]* /, '')}")
|
|
150
|
+
end
|
|
143
151
|
end
|
|
144
152
|
return(data)
|
|
145
153
|
end
|
|
146
154
|
|
|
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
|
|
155
|
+
def copy_template(filename)
|
|
156
|
+
if(File.directory?(filename) == true)
|
|
157
|
+
new_name = filename.sub(/^#{@lib_apps}./, '')
|
|
158
|
+
begin
|
|
159
|
+
if(File.directory?(new_name) != true)
|
|
160
|
+
Dir.mkdir(new_name)
|
|
161
|
+
notify("#{@emoji_success} Created directory: |g#{new_name}|n |[open file folder]\n")
|
|
162
|
+
end
|
|
163
|
+
Dir.entries(filename).each do |e|
|
|
164
|
+
if(e != '.' && e != '..')
|
|
165
|
+
copy_template(File.join(filename, e))
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
rescue Errno::EACCES
|
|
169
|
+
notify("|RError|n: #{$!.to_s.sub(/@ dir_s_mkdir /, '')}")
|
|
170
|
+
exit!
|
|
171
|
+
rescue
|
|
172
|
+
notify("|RError|n: #{$!}")
|
|
173
|
+
exit!
|
|
174
|
+
end
|
|
175
|
+
else
|
|
176
|
+
data = file_open_read_close(filename)
|
|
177
|
+
new_name = filename.sub(/^#{@lib_apps}./, '')
|
|
178
|
+
file_open_write_close(new_name, file_open_read_close(filename))
|
|
179
|
+
notify("#{@emoji_success} Created file: |y#{new_name}|n |[page facing up]\n")
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
@found_application = nil
|
|
184
|
+
@suggestion = String.new
|
|
185
|
+
@available_apps.sort.each do |app|
|
|
186
|
+
if(ARGV[0] =~ /^#{app}$/)
|
|
187
|
+
if(File.directory?(app) == true)
|
|
188
|
+
notify("\n#{@emoji_fail}|RError|n: |Ydirectory #{app} |Ralready exists, aborting creation|n\n\n" +
|
|
189
|
+
"Delete the directory and try again if you wish to recreate it.\n\n")
|
|
190
|
+
exit!
|
|
191
|
+
end
|
|
192
|
+
@found_application = app
|
|
193
|
+
copy_template(File.join(@lib_apps, app))
|
|
194
|
+
begin
|
|
195
|
+
File.open(File.join(@lib_apps, app, 'demake', 'suggestion'), 'r') do |f|
|
|
196
|
+
@suggestion = f.read.chomp
|
|
197
|
+
end
|
|
198
|
+
rescue
|
|
199
|
+
end
|
|
200
|
+
Dir.chdir(app)
|
|
201
|
+
@working_directory = Dir.pwd
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
need_help = false
|
|
206
|
+
if(ARGV[0] == "help" || ARGV[0] == "--help" || ARGV[0] == "-h" ||
|
|
207
|
+
ARGV[0] == "?" || ARGV[0] == "-?")
|
|
208
|
+
need_help = true
|
|
209
|
+
end
|
|
210
|
+
if(need_help == false && ARGV[0] != nil && @found_application == nil)
|
|
211
|
+
notify("Unknown argument: #{ARGV[0]}\n\n")
|
|
212
|
+
need_help = true
|
|
213
|
+
end
|
|
214
|
+
if(need_help == true)
|
|
215
|
+
program = File.basename($0)
|
|
216
|
+
COLUMN_WIDTH = 20
|
|
217
|
+
syntax = "|]#{COLUMN_WIDTH}Command syntax:\n\n" + "|y#{program}|n|; - Create or update Makefile\n"
|
|
218
|
+
@available_apps.sort.each do |app|
|
|
219
|
+
data = String.new
|
|
220
|
+
begin
|
|
221
|
+
File.open(File.join(@lib_apps, app, 'demake', 'brief_description'), 'r') do |f|
|
|
222
|
+
data = f.read.chomp
|
|
223
|
+
end
|
|
224
|
+
rescue
|
|
225
|
+
end
|
|
226
|
+
if(data != "")
|
|
227
|
+
syntax << "|y#{program} #{app}|n|; - #{data}\n"
|
|
228
|
+
else
|
|
229
|
+
syntax << "|y#{program} #{app}|n\n"
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
notify(syntax + "\n")
|
|
233
|
+
exit!
|
|
236
234
|
end
|
|
237
235
|
|
|
238
236
|
@applications = Hash.new
|
|
@@ -240,18 +238,11 @@ end
|
|
|
240
238
|
|
|
241
239
|
# Check for settings / default override
|
|
242
240
|
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
|
|
241
|
+
code = file_open_read_close('demake/settings.rb')
|
|
250
242
|
if(@emojis == false)
|
|
251
243
|
strip_emojis!(code)
|
|
252
244
|
end
|
|
253
245
|
eval code
|
|
254
|
-
rescue Errno::ENOENT
|
|
255
246
|
rescue
|
|
256
247
|
notify("\n|YWARNING|n: #{$!}\n\n")
|
|
257
248
|
end
|
|
@@ -262,64 +253,57 @@ else
|
|
|
262
253
|
@library_extension = '.so'
|
|
263
254
|
end
|
|
264
255
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
if(app
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
@applications[app] = Array.new
|
|
281
|
-
end
|
|
256
|
+
# Applications to build
|
|
257
|
+
no_applications_file = true
|
|
258
|
+
begin
|
|
259
|
+
# The expected format is the application followed by a list of its dependencies
|
|
260
|
+
# all on the same line separated by space, : or tab and # for comments
|
|
261
|
+
application_and_dependencies = file_open_read_close('demake/applications').split(/\n/)
|
|
262
|
+
no_applications_file = false
|
|
263
|
+
application_and_dependencies.each do |app|
|
|
264
|
+
if(app !~ /^#/ && app !~ /^[ \t]*#/)
|
|
265
|
+
if(app =~ /([^ :\t]*)[ :\t]*(.*)[ \t]*#?.*/)
|
|
266
|
+
application = $1
|
|
267
|
+
dependencies = $2.sub(/#.*$/, '').split(/[ :\t]/)
|
|
268
|
+
@applications[application] = dependencies
|
|
269
|
+
else
|
|
270
|
+
@applications[app] = Array.new
|
|
282
271
|
end
|
|
283
272
|
end
|
|
284
|
-
rescue
|
|
285
273
|
end
|
|
274
|
+
rescue
|
|
275
|
+
end
|
|
286
276
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
end
|
|
277
|
+
# Libraries to build
|
|
278
|
+
no_libraries_file = true
|
|
279
|
+
begin
|
|
280
|
+
# The expected format is the application followed by a list of its dependencies
|
|
281
|
+
# all on the same line separated by space, : or tab and # for comments
|
|
282
|
+
libraries_and_dependencies = file_open_read_close('demake/libraries', false).split(/\n/)
|
|
283
|
+
no_libraries_file = false
|
|
284
|
+
libraries_and_dependencies.each do |lib|
|
|
285
|
+
if(lib !~ /^#/ && lib !~ /^[ \t]*#/)
|
|
286
|
+
if(lib =~ /([^ :\t]*)[ :\t]*(.*)[ \t]*#?.*/)
|
|
287
|
+
library = $1
|
|
288
|
+
dependencies = $2.sub(/#.*$/, '').split(/[ :\t]/)
|
|
289
|
+
@build_libraries[library] = dependencies
|
|
290
|
+
else
|
|
291
|
+
@build_libraries[lib] = Array.new
|
|
303
292
|
end
|
|
304
293
|
end
|
|
305
|
-
rescue
|
|
306
294
|
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']
|
|
295
|
+
rescue
|
|
296
|
+
end
|
|
297
|
+
if(no_applications_file && no_libraries_file)
|
|
298
|
+
notify("\n#{@emoji_fail}|RError|n: |Yapplications file|n |Rdoes not exist|n\n\n" +
|
|
299
|
+
"You must create a file named |Yapplications|n which contains a list of\n" +
|
|
300
|
+
"executable application names and any dependencies to be compiled.\n\n")
|
|
301
|
+
exit!
|
|
302
|
+
elsif(@applications == {} && @build_libraries == {})
|
|
303
|
+
notify("\n#{@emoji_fail}|RError|n: |Yapplications file|n |Rcannot be empty|n\n\n" +
|
|
304
|
+
"You must create a file named |Yapplications|n which contains a list of\n" +
|
|
305
|
+
"executable application names and any dependencies to be compiled.\n\n")
|
|
306
|
+
exit!
|
|
323
307
|
end
|
|
324
308
|
|
|
325
309
|
@output = <<-END_OF_STRING
|
|
@@ -915,7 +899,10 @@ install : #{LICENSE}
|
|
|
915
899
|
\t@echo "#{@emoji_install} Starting install..."
|
|
916
900
|
END_OF_STRING
|
|
917
901
|
begin
|
|
918
|
-
code =
|
|
902
|
+
code = String.new
|
|
903
|
+
File.open('demake/install-target.rb', 'r') do |f|
|
|
904
|
+
code = f.read
|
|
905
|
+
end
|
|
919
906
|
if(@emojis == false)
|
|
920
907
|
strip_emojis!(code)
|
|
921
908
|
end
|
|
@@ -956,7 +943,10 @@ uninstall :
|
|
|
956
943
|
\t@echo "#{@emoji_uninstall} Starting uninstall..."
|
|
957
944
|
END_OF_STRING
|
|
958
945
|
begin
|
|
959
|
-
code =
|
|
946
|
+
code = String.new
|
|
947
|
+
File.open('demake/uninstall-target.rb', 'r') do |f|
|
|
948
|
+
code = f.read
|
|
949
|
+
end
|
|
960
950
|
if(@emojis == false)
|
|
961
951
|
strip_emojis!(code)
|
|
962
952
|
end
|
|
@@ -971,14 +961,11 @@ if(@emojis == false)
|
|
|
971
961
|
end
|
|
972
962
|
@output << "\n" + @pipe.pipetext(uninstall_target)
|
|
973
963
|
|
|
974
|
-
if(@
|
|
964
|
+
if(@found_application != nil)
|
|
975
965
|
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")
|
|
966
|
+
notify("#{@emoji_success} Created file: |y#{@found_application}/Makefile|n |[page facing up]\n\n")
|
|
967
|
+
if(@suggestion != "")
|
|
968
|
+
notify("Suggestion: |C#{@suggestion}|n\n")
|
|
982
969
|
end
|
|
983
970
|
Dir.chdir('..')
|
|
984
971
|
else
|