visual_studio 0.1.0.2 → 0.1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae6d44fc02888d2b58eb780623555953300a5d3e
4
- data.tar.gz: 5453ae213f25c12ea5b4caf335d14c455c6a2c24
3
+ metadata.gz: 9b96d8f75ac42d55c4d980ff6ee7c4d4647262e3
4
+ data.tar.gz: f595c1b74a1b1668af5a686ee1ac433840fcbf04
5
5
  SHA512:
6
- metadata.gz: 323f2c681f5744af4acd25576bf769e33577bc6c623fe8372bdbf8328a34560c6634d96d31f7f890a23dac29714348b34c1c7e5c3fe4863fb022cb4374c7b4d2
7
- data.tar.gz: b45b5568b66d4aaf52f218f2b8a6dbbde73d7ee473aeac414e1498c4e6b0b1c4f719e684edbdcc59d8c27e71f23851e83d99cfbca41d0f83e0ecbb4a53ac84b0
6
+ metadata.gz: 25da97f68cc5e58df1e967c0812b4b55484a1a43213beb44b27861e3278e8fd047df668a430b3185f52ec4984db7eae22a19c4cc11a4868b570d0a99eb8f9ea7
7
+ data.tar.gz: dd545f94acad51d0e08f20ba74717a36d87f54f4ece1a98bac22f02d130d3ef8b4b2094800243ca26e19af40ce7a95797bd4807fed5c51484845ff8c2438d115
@@ -1,9 +1,12 @@
1
1
  module VisualStudio
2
2
  NAMES = ['vs2015', 'vs2013', 'vs2012', 'vs2010', 'vs2008', 'vs2005']
3
3
 
4
- PRETTY_NAMES = ['Visual Studio 2015', 'Visual Studio 2013',
5
- 'Visual Studio 2012', 'Visual Studio 2010',
6
- 'Visual Studio 2008', 'Visual Studio 2005']
4
+ PRETTY_NAMES = ['Visual Studio 2015',
5
+ 'Visual Studio 2013',
6
+ 'Visual Studio 2012',
7
+ 'Visual Studio 2010',
8
+ 'Visual Studio 2008',
9
+ 'Visual Studio 2005']
7
10
 
8
11
  VERSIONS = [14.0, 12.0, 11.0, 10.0, 9.0, 8.0].map(&:to_s)
9
12
 
@@ -3,10 +3,14 @@ module VisualStudio
3
3
  SEARCH_DIRECTORIES = ['PATH', 'INCLUDE', 'LIB', 'LIBPATH']
4
4
 
5
5
  def self.merge(base, overlay)
6
+ # We merge case insensitively, because Windows. We treat |base| case as canonical
7
+ # unless the variable is only named by |overlay|.
8
+ cased = (overlay.keys + base.keys).uniq.map{|key| [key.upcase, key]}.to_h
9
+
6
10
  # TODO(mtwilliams): Verify match-up between VCInstallDir and VisualStudioVersion?
7
11
  # TODO(mtwilliams): Rederive environment variables based on VCInstallDir and/or WindowsSdkDir.
8
- env = base.to_h.merge(overlay.to_h) do |variable, base, overlay|
9
- if SEARCH_DIRECTORIES.include? variable
12
+ env = canonicalize(base).merge(canonicalize(overlay)) do |variable, base, overlay|
13
+ if SEARCH_DIRECTORIES.include? variable.upcase
10
14
  # TODO(mtwilliams): Detect new Visual Studio or Windows SDK related
11
15
  # paths and replace the old ones based on that.
12
16
  base = base.split(';')
@@ -29,6 +33,15 @@ module VisualStudio
29
33
  overlay
30
34
  end
31
35
  end
36
+
37
+ env.map { |canonical, value|
38
+ [cased[canonical], value]
39
+ }.to_h
32
40
  end
41
+
42
+ private
43
+ def self.canonicalize(environment)
44
+ environment.to_h.map{|key, value| [key.upcase, value]}.to_h
45
+ end
33
46
  end
34
47
  end
@@ -41,7 +41,7 @@ module VisualStudio
41
41
  end
42
42
 
43
43
  module VERSION #:nodoc:
44
- MAJOR, MINOR, PATCH, PRE = [0, 1, 0, 2]
44
+ MAJOR, MINOR, PATCH, PRE = [0, 1, 0, 3]
45
45
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
46
46
  end
47
47
 
@@ -11,7 +11,8 @@ module VisualStudio
11
11
  :libraries,
12
12
  :binaries,
13
13
  :sdks,
14
- :supports
14
+ :supports,
15
+ :shared
15
16
 
16
17
  def initialize(desc)
17
18
  @name = desc[:name]
@@ -22,33 +23,77 @@ module VisualStudio
22
23
  @binaries = desc[:binaries]
23
24
  @sdks = desc[:sdks]
24
25
  @supports = desc[:supports]
26
+ @shared = desc[:shared]
25
27
  end
26
28
 
27
29
  def environment(opts={})
28
30
  # TODO(mtwilliams): Raise an exception.
29
31
  return nil unless @name.to_s == 'VC'
30
32
 
31
- # HACK(mtwilliams): We should reimplement this logic inside this gem.
32
- require 'open3'
33
- require 'json'
34
-
35
33
  target = opts[:target] || {platform: :windows,
36
34
  architecture: :x86}
35
+
37
36
  # TODO(mtwilliams): Handle other platforms.
37
+ # TODO(mtwilliams): Check if the architecture is supported.
38
38
  platform = :windows
39
39
  arch = {:x86 => 'x86', :x86_64 => 'amd64', :arm => 'arm'}[target[:architecture]]
40
- # TODO(mtwilliams): Check if the architecture is supported.
41
- # @supports.include?(target[:architecture])
42
40
 
43
- cmd = "call \"#{File.join(@root, 'vcvarsall.bat')}\" #{arch} & " +
44
- "echo require('json'); print JSON.generate(ENV.to_h); | ruby\n"
45
- out, _, status = Open3.capture3(ENV.to_h, "cmd.exe /C \"#{cmd}\"")
46
- return nil unless status == 0
41
+ # TODO(mtwilliams): Raise an exception.
42
+ return nil unless arch
43
+
44
+ if @shared
45
+ # HACK(mtwilliams): Microsoft shipped a broken `vcvarsall.bat`, so
46
+ # we need to build the envrionment ourself.
47
+
48
+ root = File.expand_path(File.join(@root, ".."))
49
+
50
+ # TODO(mtwilliams): Insert missing variables into environment.
51
+ # WindowsSdkDir
52
+ # WindowsLibPath
53
+ # WindowsSDKVersion
54
+ # UCRTVersion
55
+ # UniversalCRTSdkDir
56
+ # DevEnvDir
57
+ # INCLUDE
58
+ # LIB
59
+ # LIBPATH
60
+
61
+ path = []
62
+
63
+ # TODO(mtwilliams): Inject latest Windows SDK into PATH.
64
+ case arch
65
+ when 'x86'
66
+ path << File.join(@root, "bin")
67
+ else
68
+ path << File.join(@root, "bin", arch)
69
+ end
70
+
71
+ env = {
72
+ "VS140COMNTOOLS" => File.join(root, "Common7", "Tools"),
73
+ "VSINSTALLDIR" => root,
74
+ "VCINSTALLDIR" => File.join(root, "VC"),
75
+ "PATH" => path.join(';')
76
+ }
77
+
78
+ env = VisualStudio::Environment.merge(opts[:base] || {}, env)
79
+ env = VisualStudio::Environment.merge(env, opts[:overlay] || {})
80
+
81
+ env
82
+ else
83
+ # HACK(mtwilliams): We should reimplement this logic inside this gem.
84
+ require 'open3'
85
+ require 'json'
47
86
 
48
- env = VisualStudio::Environment.merge(opts[:base] || {}, JSON.parse(out))
49
- env = VisualStudio::Environment.merge(env, opts[:overlay] || {})
87
+ cmd = "call \"#{File.join(@root, 'vcvarsall.bat')}\" #{arch} & " +
88
+ "echo require('json'); print JSON.generate(ENV.to_h); | ruby\n"
89
+ out, _, status = Open3.capture3(ENV.to_h, "cmd.exe /C \"#{cmd}\"")
90
+ return nil unless status == 0
50
91
 
51
- env
92
+ env = VisualStudio::Environment.merge(opts[:base] || {}, JSON.parse(out))
93
+ env = VisualStudio::Environment.merge(env, opts[:overlay] || {})
94
+
95
+ env
96
+ end
52
97
  end
53
98
 
54
99
  def self.find(product, version)
@@ -59,6 +104,10 @@ module VisualStudio
59
104
  root = self._find_via_registry(product, version)
60
105
  return nil if root.nil?
61
106
 
107
+ # If shared, indicates everything is fucked up and Microsoft can't be
108
+ # trusted. As such, we need to unfuck things downstream.
109
+ shared = root.downcase.include? 'shared'
110
+
62
111
  includes, libraries, binaries =
63
112
  case product
64
113
  when 'VC'
@@ -120,7 +169,8 @@ module VisualStudio
120
169
  binaries: binaries,
121
170
  sdks: ({windows: sdks}),
122
171
  supports: ({platforms: platforms,
123
- architectures: architectures}))
172
+ architectures: architectures}),
173
+ shared: shared)
124
174
  else
125
175
  # TODO(mtwilliams): Raise an exception.
126
176
  # raise VisualStudio::InvalidVersion.new(...)
@@ -129,22 +179,27 @@ module VisualStudio
129
179
 
130
180
  private
131
181
  def self._find_via_registry(product, version)
132
- # We try to find a full version of Visual Studio. If we can't, then
133
- # we look for standalone verions, i.e. Express Editions. This is only
134
- # required for 2005-2010 so this logic can be removed when we drop
135
- # support for them.
136
- keys = ["SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\#{version}\\Setup\\#{product}",
137
- "SOFTWARE\\Microsoft\\VisualStudio\\#{version}\\Setup\\#{product}",
138
- "SOFTWARE\\Wow6432Node\\Microsoft\\VCExpress\\#{version}\\Setup\\#{product}",
139
- "SOFTWARE\\Microsoft\\VCExpress\\#{version}\\Setup\\#{product}"]
140
- installs = keys.map do |key|
141
- begin
142
- require 'win32/registry'
143
- return File.expand_path(::Win32::Registry::HKEY_LOCAL_MACHINE.open(key, ::Win32::Registry::KEY_READ)['ProductDir']).to_s
144
- rescue
145
- end
146
- end
147
- installs.compact.first
182
+ case version.to_f
183
+ when 8.0..14.0
184
+ # We try to find a full version of Visual Studio. If we can't, then
185
+ # we look for standalone verions, i.e. Express Editions. This is only
186
+ # required for 2005-2010 so this logic can be removed when we drop
187
+ # support for them.
188
+ keys = ["SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\#{version}\\Setup\\#{product}",
189
+ "SOFTWARE\\Microsoft\\VisualStudio\\#{version}\\Setup\\#{product}",
190
+ "SOFTWARE\\Wow6432Node\\Microsoft\\VCExpress\\#{version}\\Setup\\#{product}",
191
+ "SOFTWARE\\Microsoft\\VCExpress\\#{version}\\Setup\\#{product}"]
192
+ installs = keys.map do |key|
193
+ begin
194
+ require 'win32/registry'
195
+ return File.expand_path(::Win32::Registry::HKEY_LOCAL_MACHINE.open(key, ::Win32::Registry::KEY_READ)['ProductDir']).to_s
196
+ rescue
197
+ end
198
+ end
199
+ installs.compact.first
200
+ when 15.0
201
+ raise "Not supported yet!"
202
+ end
148
203
  end
149
204
  end
150
205
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visual_studio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.2
4
+ version: 0.1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-07 00:00:00.000000000 Z
11
+ date: 2017-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -93,9 +93,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project:
96
- rubygems_version: 2.4.5
96
+ rubygems_version: 2.6.11
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: Inspect Visual Studio installs and generate Visual Studio project files.
100
100
  test_files: []
101
- has_rdoc: