Mxx_ru 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,10 +26,13 @@
26
26
  # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
27
  #++
28
28
 
29
+ require 'rbconfig'
30
+
29
31
  require 'mxx_ru/cpp/toolset'
30
32
 
31
33
  module MxxRu
32
34
  module Cpp
35
+ ENV_VAR = "MXX_RU_CPP_TOOLSET"
33
36
 
34
37
  # Detect current toolset based on values of environment variables
35
38
  #
@@ -46,14 +49,7 @@ module MxxRu
46
49
  # saved to the toolset created using a setup_tag method.
47
50
  def Cpp.detect_toolset
48
51
  begin
49
- env_var = "MXX_RU_CPP_TOOLSET"
50
-
51
- env = ENV[ env_var ]
52
- if nil == env
53
- raise MxxRu::InvalidValueEx.new(
54
- "Environment variable '#{env_var}' not found (not set " +
55
- "or empty" )
56
- end
52
+ env = get_or_detect_toolset_variable_content
57
53
 
58
54
  # Exctracting file name, responsible for toolset object creation.
59
55
  toolset_file_name_regexp = /^(\S+)(.*)$/
@@ -117,6 +113,52 @@ module MxxRu
117
113
  "'#{files_to_load.join('; ')}'" ) unless load_result
118
114
  end
119
115
 
116
+ # Gets or detects value for MXX_RU_CPP_TOOLSET.
117
+ #
118
+ # Since v.1.5.1
119
+ #
120
+ def Cpp.get_or_detect_toolset_variable_content
121
+ env = ENV[ ENV_VAR ]
122
+ if env.nil?
123
+ $stderr.puts "Environment variable #{ENV_VAR} not found. " +
124
+ "Try to detect toolset by HOST_OS and/or PATH..."
125
+ env = try_detect_toolset_myself
126
+ if env
127
+ $stderr.puts "Detection successed. Toolset is: #{env}"
128
+ else
129
+ $stderr.puts "Detection failed."
130
+ raise MxxRu::InvalidValueEx.new(
131
+ "Environment variable '#{ENV_VAR}' not found (not set " +
132
+ "or empty" )
133
+ end
134
+ end
135
+
136
+ env
137
+ end
138
+
139
+ # Try to detect toolset from host_os and PATH.
140
+ #
141
+ # Since v.1.5.1
142
+ #
143
+ # Only Windows platform and MS C++, Linux and GCC is detected now.
144
+ #
145
+ # Returns name of toolset of throw exception if toolset is not detectable.
146
+ def Cpp.try_detect_toolset_myself
147
+ if Config::CONFIG['host_os'] =~ /linux/
148
+ # Assume that GCC is default compiler on Linux.
149
+ "gcc_linux"
150
+ else
151
+ case ENV['PATH']
152
+ when /Microsoft Visual Studio \.NET 2003\\VC7\\BIN/i
153
+ "vc7"
154
+ when /Microsoft Visual Studio 8\.0\\VC\\BIN/i
155
+ "vc8"
156
+ when /Microsoft Visual Studio 9\.0\\VC\\BIN/i
157
+ "vc9"
158
+ end
159
+ end
160
+ end
161
+
120
162
  end # module Cpp
121
163
  end # module MxxRu
122
164
 
data/lib/mxx_ru/util.rb CHANGED
@@ -367,6 +367,12 @@ module MxxRu
367
367
  return @@host_os
368
368
  end
369
369
 
370
+ # This flag is set to true on Windows.
371
+ #
372
+ # Since v.1.5.1
373
+ #
374
+ IS_WINDOWS_PLATFORM = !((Config::CONFIG['host_os'] =~ /mswin|mingw/).nil?)
375
+
370
376
  # Transform separators in file names to correct ones on the given platform.
371
377
  #
372
378
  # For example on mswin32 we change "/" to "\".
@@ -375,7 +381,7 @@ module MxxRu
375
381
  #
376
382
  # *IMPORTANT! In current version only mswin32 platform is tracked!*
377
383
  def Util.native_pathname( a_pathname )
378
- if "mswin32" == Util::host_os
384
+ if IS_WINDOWS_PLATFORM
379
385
  return a_pathname.gsub( "/", "\\" )
380
386
  end
381
387
 
@@ -34,5 +34,5 @@
34
34
  #
35
35
  # puts 'Mxx_ru version is: ' + MXX_RU_VERSION
36
36
  #
37
- MXX_RU_VERSION = '1.5.0'
37
+ MXX_RU_VERSION = '1.5.1'
38
38
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Mxx_ru
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Mxx_ru Project
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-22 00:00:00 +04:00
12
+ date: 2010-05-20 00:00:00 +04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15