mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
load pre-compile configs from config files
When create a pre-compiled gem in MinGW MSYS shell passing Ruby or OpenCV's paths, the paths are converted to be invalid by MSYS shell. E.g. When we run the following command $ rake gem:precompile RUBIES=C:/ruby19/bin/ruby.exe,C:/ruby20/bin/ruby.exe The following paths are expected ENV['RUBIES'] = "C:/ruby19/bin/ruby.exe,C:/ruby20/bin/ruby.exe" But we get the following ENV['RUBIES'] = "C;C:\\MinGW\\msys\\1.0\\ruby19\\bin\\ruby.exe,C;C:\\MinGW\\msys\\1.0\\ruby20\\bin\\ruby.exe" This fix is for avoiding the problem.
This commit is contained in:
parent
ba32cc36ba
commit
6850627473
2 changed files with 14 additions and 16 deletions
23
Rakefile
23
Rakefile
|
@ -47,36 +47,27 @@ task 'gem:precompile' => ['gem'] do
|
||||||
installer = Gem::Installer.new(gemfile)
|
installer = Gem::Installer.new(gemfile)
|
||||||
installer.unpack(target_dir)
|
installer.unpack(target_dir)
|
||||||
|
|
||||||
rubies = ENV['RUBIES'] ? ENV['RUBIES'].split(',') : [Gem.ruby]
|
|
||||||
args = ENV['EXT_OPTS'] ? ENV['EXT_OPTS'].split(',') : []
|
|
||||||
|
|
||||||
gemspec = installer.spec
|
gemspec = installer.spec
|
||||||
extension = gemspec.extensions[0]
|
extension = gemspec.extensions[0]
|
||||||
gemspec.extensions.clear
|
gemspec.extensions.clear
|
||||||
gemspec.platform = ENV['PLATFORM'] || Gem::Platform::CURRENT
|
|
||||||
|
config = ENV['CONFIG'] ? YAML.load_file(ENV['CONFIG']) : {}
|
||||||
|
rubies = config['rubies'] || [Gem.ruby]
|
||||||
|
args = config['extopts'] || []
|
||||||
|
gemspec.platform = config['platform'] || Gem::Platform::CURRENT
|
||||||
|
|
||||||
multi = rubies.size > 1
|
multi = rubies.size > 1
|
||||||
rubies.each { |ruby|
|
rubies.each { |ruby|
|
||||||
results = []
|
|
||||||
|
|
||||||
# Convert MinGW's drive letters to Windows' ones
|
|
||||||
# e.g. /c/ruby/bin/ruby.exe => c:/ruby/bin/ruby.exe
|
|
||||||
ruby.gsub!(/^\/([a-zA-Z])\//, '\1:/')
|
|
||||||
|
|
||||||
lib_dir = 'lib'
|
lib_dir = 'lib'
|
||||||
if multi
|
if multi
|
||||||
major, minor, _ = `#{ruby} -e "print RUBY_VERSION"`.chomp.split('.')
|
major, minor, _ = `#{ruby} -e "print RUBY_VERSION"`.chomp.split('.')
|
||||||
lib_dir = File.join(lib_dir, [major, minor].join('.'))
|
lib_dir = File.join(lib_dir, [major, minor].join('.'))
|
||||||
end
|
end
|
||||||
|
|
||||||
target_platform = `#{ruby} -e "print RUBY_PLATFORM"`
|
make_cmd = (`#{ruby} -e "print RUBY_PLATFORM"` =~ /mswin/) ? 'nmake' : 'make'
|
||||||
# Convert MinGW's drive letters to Windows' ones
|
|
||||||
# e.g. --with-opencv-dir=/c/path/to/opencv => --with-opencv-dir=c:/path/to/opencv
|
|
||||||
args.map! { |a| a.gsub(/=\/([a-zA-Z])\//, '=\1:/') } if target_platform =~ /mingw/
|
|
||||||
|
|
||||||
make_cmd = (target_platform =~ /mswin/) ? 'nmake' : 'make'
|
|
||||||
Dir.chdir(target_dir) {
|
Dir.chdir(target_dir) {
|
||||||
cmd = [ruby, extension, *args].join(' ')
|
cmd = [ruby, extension, *args].join(' ')
|
||||||
|
results = []
|
||||||
Gem::Ext::ExtConfBuilder.run(cmd, results)
|
Gem::Ext::ExtConfBuilder.run(cmd, results)
|
||||||
Gem::Ext::ExtConfBuilder.make('', results)
|
Gem::Ext::ExtConfBuilder.make('', results)
|
||||||
|
|
||||||
|
|
7
config.yml
Normal file
7
config.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
platform: mingw32
|
||||||
|
rubies:
|
||||||
|
- C:/ruby-1.9.3-p392-mingw32/bin/ruby.exe
|
||||||
|
- C:/ruby-2.0.0-p0-mingw32/bin/ruby.exe
|
||||||
|
extopts:
|
||||||
|
- --with-opencv-include=C:/opencv-2.4.5/build/include
|
||||||
|
- --with-opencv-lib=C:/opencv-2.4.5/build/x86/mingw/lib
|
Loading…
Add table
Add a link
Reference in a new issue