akro 0.0.2 → 0.0.3

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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/akro.rb +27 -0
  3. data/lib/akrobuild.rake +16 -14
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2cfc55b40c833fc26689d6f9724b557b9b77da6b
4
- data.tar.gz: 32be5819893daff110d04e18ffcaf66fb39be062
3
+ metadata.gz: 4ab35077aadb1258fa54ecfd13766efdfa25abfc
4
+ data.tar.gz: a5b99d0e7d0ddd1fa232111dd3b85089f49d36cd
5
5
  SHA512:
6
- metadata.gz: 04c2891f876400791f538b41692c982624200c3e4b5fe3ce6c9ce40c5aca3d98b8e9fb9f7493ec227263e23b4c63e7a1656f8f8c9ef1434185be18450d011208
7
- data.tar.gz: 327ef1219233fba4631585251aeac70f1cd1e9d476c4eaac1d70040999d61b73fa8cfc93c4064c6edbba24461e28da64e04eb7a5a653fa7a49bf47afcceb042c
6
+ metadata.gz: b95c84ba3ff59c354d61a74d4e5034dc3eae61b027613fda0b1e3a5ca1ac549b33be660945231da7ada0dcd40c5e0f18a0d72757f90d8aed6ef9c96fb9b72689
7
+ data.tar.gz: b583d46338483e265ee078f735b49c9518dac3d0b57794c8173e70a4b55ba129cc3b29473696e30a077cdc491ff3e3e4740ca88a4eb8726e57a162e25787bd0f
data/lib/akro.rb CHANGED
@@ -19,6 +19,7 @@
19
19
  # IN THE SOFTWARE.
20
20
 
21
21
  require 'rake'
22
+ require 'tempfile'
22
23
 
23
24
  $VERBOSE_BUILD = false
24
25
 
@@ -48,6 +49,7 @@ $STATIC_LIB_EXTENSION = ".a"
48
49
  $DYNAMIC_LIB_EXTENSION = ".so"
49
50
 
50
51
  $LIB_CAPTURE_MAP = Hash.new
52
+ $CAPTURING_LIBS = Set.new
51
53
 
52
54
  AkroTest = Struct.new("AkroTest", :name, :script, :binary, :cmdline)
53
55
  $AKRO_TESTS = []
@@ -133,3 +135,28 @@ module CmdLine
133
135
  "#{$LINKER_PREFIX}#{$COMPILER} -shared #{$COMPILE_FLAGS} #{$MODE_COMPILE_FLAGS[mode]} -Wl,-soname,#{soname} -o #{bin} #{objs.join(' ')}#{extra_params}"
134
136
  end
135
137
  end
138
+
139
+ # Execute command, redirect output to temporary file, and print if error
140
+ def silent_exec(command, verbose: false, lines_if_error: 200, env: {})
141
+ Tempfile.open('testout') do |output|
142
+ puts command if verbose
143
+ if !system(env, command, [:out, :err] => output)
144
+ output.close(unlink_now=false)
145
+ if env.empty?()
146
+ puts "Command <#{command}> failed:"
147
+ else
148
+ envstr = env.map{|k,v| "#{k}=#{v}"}.join(' ')
149
+ puts "Command <#{envstr} #{command}> failed:"
150
+ end
151
+ lines = IO.readlines(output.path)
152
+ lines = lines[-lines_if_error..-1] if lines.size() > lines_if_error
153
+ puts lines
154
+ return false
155
+ end
156
+ end
157
+ return true
158
+ end
159
+
160
+ def akro_multitask
161
+ Rake.application.options.enable_multitask = true
162
+ end
data/lib/akrobuild.rake CHANGED
@@ -341,14 +341,6 @@ def libname(mode, lib)
341
341
  "#{mode}/#{lib.path}#{if lib.static then $STATIC_LIB_EXTENSION else $DYNAMIC_LIB_EXTENSION end}"
342
342
  end
343
343
 
344
- def invoke_all_capturing_libs(mode)
345
- $AKRO_LIBS.each do |lib|
346
- if lib.capture_deps
347
- Rake::Task[libname(mode, lib)].invoke
348
- end
349
- end
350
- end
351
-
352
344
  $LINK_BINARY_OBJS = Hash.new
353
345
 
354
346
  rule ".exe" => ->(binary){
@@ -356,6 +348,7 @@ rule ".exe" => ->(binary){
356
348
  mode = FileMapper.get_mode(binary)
357
349
  cpp = FileMapper.map_obj_to_cpp(obj)
358
350
  raise "No proper #{$CPP_EXTENSIONS.join(',')} file found for #{binary}" if cpp.nil?
351
+ Rake::Task["#{mode}/all_capturing_libs"].invoke
359
352
  obj_list = []
360
353
  # Two passes through the object list - the capturing libraries will
361
354
  # be inserted on the position of the *last* object in the list
@@ -382,6 +375,13 @@ rule ".exe" => ->(binary){
382
375
  Builder.link_binary(task.prerequisites[1..-1], task.name)
383
376
  end
384
377
 
378
+ $MODES.each do |mode|
379
+ rule /^#{mode}\/all_capturing_libs$/ => $AKRO_LIBS.keep_if{|l| l.capture_deps}.collect{|l| libname(mode, l)} do |task|
380
+ FileUtils.mkdir_p(mode)
381
+ FileUtils::touch(task.name)
382
+ end
383
+ end
384
+
385
385
  rule $STATIC_LIB_EXTENSION => ->(library) {
386
386
  mode = FileMapper.get_mode(library)
387
387
  srcs = []
@@ -395,19 +395,21 @@ rule $STATIC_LIB_EXTENSION => ->(library) {
395
395
  end
396
396
  end
397
397
  raise "Library #{library} not found!" if libspec.nil?
398
+ Rake::Task["#{mode}/all_capturing_libs"].invoke if !libspec.capture_deps
398
399
  srcs.flatten!
399
400
  if libspec.recurse
400
401
  objs = Builder.depcache_object_collect(mode, srcs)
401
402
  else
402
403
  objs = srcs.collect{|src| FileMapper.map_cpp_to_obj(mode, src)}
403
404
  end
404
- if libspec.capture_deps
405
+ if libspec.capture_deps && !$CAPTURING_LIBS.include?(library)
405
406
  objs.each do |obj|
406
407
  if $LIB_CAPTURE_MAP.has_key?(obj)
407
408
  raise "Object #{obj} has dependency captures for multiple libraries - #{$LIB_CAPTURE_MAP[obj]} and #{library}"
408
409
  end
409
410
  $LIB_CAPTURE_MAP[obj] = library
410
411
  end
412
+ $CAPTURING_LIBS << library
411
413
  end
412
414
  $LINK_BINARY_OBJS[library] = objs
413
415
  [FileMapper.map_static_lib_to_linkcmd(library)] + objs
@@ -428,19 +430,22 @@ rule $DYNAMIC_LIB_EXTENSION => ->(library) {
428
430
  end
429
431
  end
430
432
  raise "Library #{library} not found!" if libspec.nil?
433
+ Rake::Task["#{mode}/all_capturing_libs"].invoke if !libspec.capture_deps
434
+
431
435
  srcs.flatten!
432
436
  if libspec.recurse
433
437
  objs = Builder.depcache_object_collect(mode, srcs)
434
438
  else
435
439
  objs = srcs.collect{|src| FileMapper.map_cpp_to_obj(mode, src)}
436
440
  end
437
- if libspec.capture_deps
441
+ if libspec.capture_deps && !$CAPTURING_LIBS.include?(library)
438
442
  objs.each do |obj|
439
443
  if $LIB_CAPTURE_MAP.has_key?(obj)
440
444
  raise "Object #{obj} has dependency captures for multiple libraries - #{$LIB_CAPTURE_MAP[obj]} and #{library}"
441
445
  end
442
446
  $LIB_CAPTURE_MAP[obj] = library
443
447
  end
448
+ $CAPTURING_LIBS << library
444
449
  end
445
450
  $LINK_BINARY_OBJS[library] = objs
446
451
  [FileMapper.map_dynamic_lib_to_linkcmd(library)] + objs
@@ -462,7 +467,6 @@ task :clean do
462
467
  end
463
468
 
464
469
  $MODES.each do |mode|
465
- invoke_all_capturing_libs(mode)
466
470
  task mode
467
471
  task "test_#{mode}"
468
472
  $AKRO_BINARIES.each do |bin|
@@ -482,9 +486,7 @@ $MODES.each do |mode|
482
486
  base = (if !test.script.nil? then "#{test.script}" else "#{mode}/#{test.binary}" end)
483
487
  params = (if !test.cmdline.nil? then " " + test.cmdline else "" end)
484
488
  new_ld_path = if ENV.has_key?("LD_LIBRARY_PATH") then "#{mode}/:#{ENV['LD_LIBRARY_PATH']}" else "#{mode}/" end
485
- system({"MODE" => mode, "LD_LIBRARY_PATH" => new_ld_path}, base + params) do |ok, res|
486
- raise "Test #{task.name} failed" if !ok
487
- end
489
+ raise "Test #{task.name} failed" if !silent_exec(base + params, verbose: $VERBOSE_BUILD, env: {"MODE" => mode, "LD_LIBRARY_PATH" => new_ld_path})
488
490
  puts "Test #{task.name} passed"
489
491
  end
490
492
  Rake::Task["test_#{mode}"].enhance(["#{test.name}_test_#{mode}"])
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vlad Petric
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-25 00:00:00.000000000 Z
11
+ date: 2016-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake