autoproj 1.9.7.rc2 → 1.9.7.rc3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -30,6 +30,8 @@ namespace 'dist' do
30
30
  options_code = File.read(File.join(Dir.pwd, 'lib', 'autoproj', 'options.rb'))
31
31
  system_code = File.read(File.join(Dir.pwd, 'lib', 'autoproj', 'system.rb'))
32
32
  osdeps_defaults = File.read(File.join(Dir.pwd, 'lib', 'autoproj', 'default.osdeps'))
33
+ require 'autobuild'
34
+ tools_code = File.read(File.join(Autobuild::LIB_DIR, 'autobuild', 'tools.rb'))
33
35
  # Filter rubygems dependencies from the OSdeps default. They will be
34
36
  # installed at first build
35
37
  osdeps = YAML.load(osdeps_defaults)
@@ -44,7 +46,7 @@ namespace 'dist' do
44
46
  osdeps_defaults = YAML.dump(osdeps)
45
47
  # Since we are using gsub to replace the content in the bootstrap file,
46
48
  # we have to quote all \
47
- [osdeps_code, options_code, system_code, osdeps_defaults].each do |text|
49
+ [osdeps_code, options_code, system_code, osdeps_defaults, tools_code].each do |text|
48
50
  text.gsub! /\\/, '\\\\\\\\'
49
51
  end
50
52
 
@@ -52,7 +54,8 @@ namespace 'dist' do
52
54
  gsub('OSDEPS_CODE', osdeps_code).
53
55
  gsub('OPTIONS_CODE', options_code).
54
56
  gsub('SYSTEM_CODE', system_code).
55
- gsub('OSDEPS_DEFAULTS', osdeps_defaults)
57
+ gsub('OSDEPS_DEFAULTS', osdeps_defaults).
58
+ gsub('TOOLS_CODE', tools_code)
56
59
  File.open(File.join(Dir.pwd, 'bin', 'autoproj_bootstrap'), 'w') do |io|
57
60
  io.write bootstrap_code
58
61
  end
@@ -53,20 +53,12 @@ end
53
53
  # Environment is clean, so just mark it as so unconditionally
54
54
  ENV['AUTOPROJ_BOOTSTRAP_IGNORE_NONEMPTY_DIR'] = '1'
55
55
 
56
- needed_gem_home = ENV['AUTOPROJ_GEM_HOME'] || "#{Dir.pwd}/.gems"
57
- if $LOADED_FEATURES.find { |str| str =~ /bygems/ }
58
- if ENV['GEM_HOME'] != needed_gem_home
59
- require 'rbconfig'
60
- RUBY = RbConfig::CONFIG['RUBY_INSTALL_NAME']
61
-
62
- ENV['GEM_HOME'] = needed_gem_home
63
- ENV['GEM_PATH'] = nil
64
- exec RUBY, __FILE__, *ARGV
65
- end
66
- end
56
+ gem_home = ENV['AUTOPROJ_GEM_HOME'] || File.join(Dir.pwd, '.gems')
57
+ gem_path = ([gem_home] + Gem.default_path).join(":")
58
+ Gem.paths = Hash['GEM_HOME' => gem_home, 'GEM_PATH' => gem_path]
67
59
 
68
-
69
- ENV['GEM_HOME'] = needed_gem_home
60
+ ENV['GEM_HOME'] = gem_home
61
+ ENV['GEM_PATH'] = gem_path
70
62
  ENV['PATH'] = "#{ENV['GEM_HOME']}/bin:#{ENV['PATH']}"
71
63
 
72
64
  require 'yaml'
@@ -479,9 +471,7 @@ fi
479
471
  Autobuild.env_add_path 'PATH', "#{gem_home}/bin"
480
472
 
481
473
  # Now, reset the directories in our own RubyGems instance
482
- if Gem::Specification.respond_to?(:dirs=)
483
- Gem::Specification.dirs = ENV['GEM_PATH'].split(':')
484
- end
474
+ Gem.paths = ENV
485
475
  end
486
476
 
487
477
  # Return the directory in which RubyGems package should be installed
@@ -808,6 +798,14 @@ fi
808
798
  "ruby#{RUBY_VERSION.split('.')[0, 2].join("")}"
809
799
  end
810
800
 
801
+ def self.autodetect_ruby_program
802
+ ruby = RbConfig::CONFIG['RUBY_INSTALL_NAME']
803
+ ruby_bindir = RbConfig::CONFIG['bindir']
804
+ ruby_executable = File.join(ruby_bindir, ruby)
805
+ Autobuild.programs['ruby'] = ruby_executable
806
+ ruby_executable
807
+ end
808
+
811
809
  def self.autodetect_ruby
812
810
  self.alias(ruby_version_keyword, "ruby")
813
811
  end
@@ -1702,6 +1700,69 @@ So, what do you want ? (all, none or a comma-separated list of: os gem pip)
1702
1700
  end
1703
1701
 
1704
1702
 
1703
+ module Autobuild
1704
+ class << self
1705
+ # Configure the programs used by different packages
1706
+ attr_reader :programs
1707
+ # A cache of entries in programs to their resolved full path
1708
+ #
1709
+ # @return [{String=>[String,String,String]}] the triplet (full path,
1710
+ # tool name, value of ENV['PATH']). The last two values are used to
1711
+ # invalidate the cache when needed
1712
+ #
1713
+ # @see tool_in_path
1714
+ attr_reader :programs_in_path
1715
+
1716
+ # Get a given program, using its name as default value. For
1717
+ # instance
1718
+ # tool('automake')
1719
+ # will return 'automake' unless the autobuild script defined
1720
+ # another automake program in Autobuild.programs by doing
1721
+ # Autobuild.programs['automake'] = 'automake1.9'
1722
+ def tool(name)
1723
+ programs[name.to_sym] || programs[name.to_s] || name.to_s
1724
+ end
1725
+
1726
+ # Resolves the absolute path to a given tool
1727
+ def tool_in_path(name)
1728
+ path, path_name, path_env = programs_in_path[name]
1729
+ current = tool(name)
1730
+ if path_env != ENV['PATH'] || path_name != current
1731
+ # Delete the current entry given that it is invalid
1732
+ programs_in_path.delete(name)
1733
+ if current[0, 1] == "/"
1734
+ # This is already a full path
1735
+ path = current
1736
+ else
1737
+ path = ENV['PATH'].split(':').
1738
+ find { |dir| File.exists?(File.join(dir, current)) }
1739
+ if path
1740
+ path = File.join(path, current)
1741
+ end
1742
+ end
1743
+
1744
+ if !path
1745
+ raise ArgumentError, "tool #{name}, set to #{current}, can not be found in PATH=#{path_env}"
1746
+ end
1747
+
1748
+ # Verify that the new value is a file and is executable
1749
+ if !File.file?(path)
1750
+ raise ArgumentError, "tool #{name} is set to #{current}, but this resolves to #{path} which is not a file"
1751
+ elsif !File.executable?(path)
1752
+ raise ArgumentError, "tool #{name} is set to #{current}, but this resolves to #{path} which is not executable"
1753
+ end
1754
+ programs_in_path[name] = [path, current, ENV['PATH']]
1755
+ end
1756
+
1757
+ return path
1758
+ end
1759
+ end
1760
+
1761
+ @programs = Hash.new
1762
+ @programs_in_path = Hash.new
1763
+ end
1764
+
1765
+
1705
1766
  module Autoproj
1706
1767
  class InputError < RuntimeError; end
1707
1768
 
@@ -2340,6 +2401,7 @@ ENV['AUTOPROJ_OSDEPS_MODE'] = osdeps_mode
2340
2401
  # binary) by setting Autobuild.programs['gem'] to nil
2341
2402
  Autobuild.programs['gem'] = nil
2342
2403
  Autoproj::OSDependencies.autodetect_ruby
2404
+ Autoproj::OSDependencies.autodetect_ruby_program
2343
2405
 
2344
2406
  osdeps_management =
2345
2407
  if ENV['AUTOPROJ_DEFAULT_OSDEPS']
@@ -2376,8 +2438,8 @@ end
2376
2438
  File.open('env.sh', 'w') do |io|
2377
2439
  io.write <<-EOSHELL
2378
2440
  export RUBYOPT=-rubygems
2379
- export GEM_PATH=#{needed_gem_home}:$GEM_PATH
2380
- export GEM_HOME=#{needed_gem_home}
2441
+ export GEM_PATH=#{gem_path.join(":")}
2442
+ export GEM_HOME=#{gem_home}
2381
2443
  export PATH=$GEM_HOME/bin:$PATH
2382
2444
  EOSHELL
2383
2445
  end
@@ -53,20 +53,12 @@ end
53
53
  # Environment is clean, so just mark it as so unconditionally
54
54
  ENV['AUTOPROJ_BOOTSTRAP_IGNORE_NONEMPTY_DIR'] = '1'
55
55
 
56
- needed_gem_home = ENV['AUTOPROJ_GEM_HOME'] || "#{Dir.pwd}/.gems"
57
- if $LOADED_FEATURES.find { |str| str =~ /bygems/ }
58
- if ENV['GEM_HOME'] != needed_gem_home
59
- require 'rbconfig'
60
- RUBY = RbConfig::CONFIG['RUBY_INSTALL_NAME']
56
+ gem_home = ENV['AUTOPROJ_GEM_HOME'] || File.join(Dir.pwd, '.gems')
57
+ gem_path = ([gem_home] + Gem.default_path).join(":")
58
+ Gem.paths = Hash['GEM_HOME' => gem_home, 'GEM_PATH' => gem_path]
61
59
 
62
- ENV['GEM_HOME'] = needed_gem_home
63
- ENV['GEM_PATH'] = nil
64
- exec RUBY, __FILE__, *ARGV
65
- end
66
- end
67
-
68
-
69
- ENV['GEM_HOME'] = needed_gem_home
60
+ ENV['GEM_HOME'] = gem_home
61
+ ENV['GEM_PATH'] = gem_path
70
62
  ENV['PATH'] = "#{ENV['GEM_HOME']}/bin:#{ENV['PATH']}"
71
63
 
72
64
  require 'yaml'
@@ -123,6 +115,7 @@ module Autobuild
123
115
  end
124
116
 
125
117
  OSDEPS_CODE
118
+ TOOLS_CODE
126
119
  OPTIONS_CODE
127
120
  SYSTEM_CODE
128
121
 
@@ -147,6 +140,7 @@ ENV['AUTOPROJ_OSDEPS_MODE'] = osdeps_mode
147
140
  # binary) by setting Autobuild.programs['gem'] to nil
148
141
  Autobuild.programs['gem'] = nil
149
142
  Autoproj::OSDependencies.autodetect_ruby
143
+ Autoproj::OSDependencies.autodetect_ruby_program
150
144
 
151
145
  osdeps_management =
152
146
  if ENV['AUTOPROJ_DEFAULT_OSDEPS']
@@ -183,8 +177,8 @@ end
183
177
  File.open('env.sh', 'w') do |io|
184
178
  io.write <<-EOSHELL
185
179
  export RUBYOPT=-rubygems
186
- export GEM_PATH=#{needed_gem_home}:$GEM_PATH
187
- export GEM_HOME=#{needed_gem_home}
180
+ export GEM_PATH=#{gem_path.join(":")}
181
+ export GEM_HOME=#{gem_home}
188
182
  export PATH=$GEM_HOME/bin:$PATH
189
183
  EOSHELL
190
184
  end
@@ -47,10 +47,8 @@ module Autoproj
47
47
  end
48
48
 
49
49
  def self.handle_ruby_version
50
- ruby = RbConfig::CONFIG['RUBY_INSTALL_NAME']
51
- ruby_bindir = RbConfig::CONFIG['bindir']
50
+ @ruby_executable = Autoproj::OSDependencies.autodetect_ruby_program
52
51
 
53
- @ruby_executable = File.join(ruby_bindir, ruby)
54
52
  if Autoproj.has_config_key?('ruby_executable')
55
53
  expected = Autoproj.user_config('ruby_executable')
56
54
  if expected != ruby_executable
@@ -58,7 +56,6 @@ module Autoproj
58
56
  end
59
57
  end
60
58
  Autoproj.change_option('ruby_executable', ruby_executable, true)
61
- Autobuild.programs['ruby'] = ruby_executable
62
59
 
63
60
  install_suffix = ""
64
61
  if match = /ruby(.*)$/.match(ruby)
@@ -355,9 +355,7 @@ fi
355
355
  Autobuild.env_add_path 'PATH', "#{gem_home}/bin"
356
356
 
357
357
  # Now, reset the directories in our own RubyGems instance
358
- if Gem::Specification.respond_to?(:dirs=)
359
- Gem::Specification.dirs = ENV['GEM_PATH'].split(':')
360
- end
358
+ Gem.paths = ENV
361
359
  end
362
360
 
363
361
  # Return the directory in which RubyGems package should be installed
@@ -684,6 +682,14 @@ fi
684
682
  "ruby#{RUBY_VERSION.split('.')[0, 2].join("")}"
685
683
  end
686
684
 
685
+ def self.autodetect_ruby_program
686
+ ruby = RbConfig::CONFIG['RUBY_INSTALL_NAME']
687
+ ruby_bindir = RbConfig::CONFIG['bindir']
688
+ ruby_executable = File.join(ruby_bindir, ruby)
689
+ Autobuild.programs['ruby'] = ruby_executable
690
+ ruby_executable
691
+ end
692
+
687
693
  def self.autodetect_ruby
688
694
  self.alias(ruby_version_keyword, "ruby")
689
695
  end
@@ -1,3 +1,3 @@
1
1
  module Autoproj
2
- VERSION = "1.9.7.rc2"
2
+ VERSION = "1.9.7.rc3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoproj
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.7.rc2
4
+ version: 1.9.7.rc3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-20 00:00:00.000000000 Z
12
+ date: 2014-05-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: autobuild