Module: Ruby::Compiler::Utils
- Defined in:
- lib/ruby/compiler/utils.rb
Class Method Summary collapse
- .chdir(path) ⇒ Object
- .copy_static_libs(path, target) ⇒ Object
- .prepare_tmpdir(tmpdir) ⇒ Object
- .remove_dynamic_libs(path) ⇒ Object
- .run(*args) ⇒ Object
Class Method Details
.chdir(path) ⇒ Object
23 24 25 26 27 |
# File 'lib/ruby/compiler/utils.rb', line 23 def chdir(path) STDERR.puts "-> cd #{path}" Dir.chdir(path) { yield } STDERR.puts "-> cd #{Dir.pwd}" end |
.copy_static_libs(path, target) ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'lib/ruby/compiler/utils.rb', line 50 def copy_static_libs(path, target) ['lib', 'a'].each do |extname| Dir["#{path}/*.#{extname}"].each do |x| STDERR.puts "-> FileUtils.cp #{x}, #{target}" FileUtils.cp(x, target) end end end |
.prepare_tmpdir(tmpdir) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ruby/compiler/utils.rb', line 29 def prepare_tmpdir(tmpdir) STDERR.puts "-> FileUtils.mkdir_p(#{tmpdir})" FileUtils.mkdir_p(tmpdir) Dir[::Ruby::Compiler::VENDOR_DIR + '/*'].each do |dirpath| target = File.join(tmpdir, File.basename(dirpath)) unless Dir.exist?(target) STDERR.puts "-> FileUtils.cp_r(#{dirpath}, #{target})" FileUtils.cp_r(dirpath, target) end end end |
.remove_dynamic_libs(path) ⇒ Object
41 42 43 44 45 46 47 48 |
# File 'lib/ruby/compiler/utils.rb', line 41 def remove_dynamic_libs(path) ['dll', 'dylib', 'so'].each do |extname| Dir["#{path}/**/*.#{extname}"].each do |x| STDERR.puts "-> FileUtils.rm_f #{x}" FileUtils.rm_f(x) end end end |
.run(*args) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/ruby/compiler/utils.rb', line 16 def run(*args) STDERR.puts "-> Running #{args}" pid = spawn(*args) pid, status = Process.wait2(pid) raise Error, "Failed running #{args}" unless status.success? end |