libshit

Just some random shit
git clone https://git.neptards.moe/neptards/libshit.git
Log | Files | Refs | Submodules | README | LICENSE

ci_conf.iwyu.rb (2067B)


      1 step :iwyu_setup do
      2   opt.os = 'linux'
      3   opt.architecture = 'amd64'
      4   opt.compiler = 'gcc'
      5   opt.mode = 'debug'
      6   opt.lua = 'lua'
      7   opt.is_cross = false
      8   opt.is_iwyu = true
      9   opt.iwyu_targets ||= %w(
     10     libshit-lua-gen-hdr libshit-translate-generate
     11     translate-gen-libshit-test-builtin)
     12 end
     13 
     14 iwyu_cond = -> { opt.is_iwyu }
     15 step :iwyu_opts, always_after: :default_values, before: :final_opts, cond: iwyu_cond do
     16   opt.config_opts.append '--luac-mode=copy'
     17   opt.build_opts.append "--targets=#{opt.iwyu_targets.join ','}"
     18 end
     19 
     20 step :iwyu_build_if_needed, after: :do_build, cond: -> { !opt.iwyu_targets.empty? }
     21 
     22 def parallel_run dir, files, keep_going: true
     23   calc_env []
     24   print_cd dir
     25   Signal.trap 'CHLD', 'DEFAULT'
     26 
     27   files_mtx = Mutex.new
     28   console_mtx = Mutex.new
     29   failed = false
     30   n = files.size
     31   digits = n.to_s.size # ehh...
     32   i = 0
     33   einfo "Running #{n} tasks with -j#{opt.jobs}#{keep_going ? ' -k' : ''}"
     34   opt.jobs.times.map do
     35     Thread.new do
     36       loop do
     37         f = files_mtx.synchronize do
     38           break if failed && !keep_going
     39           files.pop
     40         end
     41         break unless f
     42 
     43         args = yield f
     44         out, err, st = Open3.capture3 @last_env, *args, chdir: dir
     45         files_mtx.synchronize { failed = true } unless st.success?
     46         console_mtx.synchronize do
     47           ecmd format '[%*d/%d] %s', digits, i+=1, n, args.shelljoin
     48           $stdout.write out
     49           $stderr.write err
     50           eerror "Command failure: #{st}" unless st.success?
     51         end
     52       end
     53     end
     54   # somewhy Thread.join deadlocks sometimes when failing, but not with a timeout
     55   end.each { |t| nil until t.join 1 }
     56   fail 'Parallell commands failed' if failed
     57 end
     58 
     59 step :iwyu, after: [:iwyu_setup, :prepare_checkout, :iwyu_build_if_needed] do
     60   fail if opt.is_cross || !opt.is_iwyu
     61 
     62   Linux.clonens_wait do
     63     files = Dir.glob '{src,test}/**/*.[ch]{,pp}', base: opt.base_dir
     64     env.build_dir = File.join opt.run_dir, 'build'
     65     cd = rel_from opt.base_dir, opt.run_dir
     66 
     67     parallel_run(opt.base_dir, files) {|f| ['./iwyu.sh', f] }
     68   end
     69 end