visual_studio 0.0.0.4 → 0.0.0.5

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: 170f4bf5dfff415c14da637f32121dca1ae2774e
4
- data.tar.gz: 0b57db076db928c11688e9cbcc382c1fdbf6abbc
3
+ metadata.gz: a6aaa1737a0db9d1ec348f2076a8e1c29b4bad09
4
+ data.tar.gz: 0ba390804d52e478e005492b32a351fe23a69a3a
5
5
  SHA512:
6
- metadata.gz: 8a656e2a6472ec03ff48536a522b8f6bf0441004ba6d05e390d44ec3b5de56870d2d0cf5d3e263f1ea9b3de60cac6ecca141af8280c60ca91d868b49627d4057
7
- data.tar.gz: 521e8988157ef6c3165cbfc35a533d3a77186fc04ea553eda259af0cedf4f48dfe9d333acb4c6cfd38734be964c17244ad888c848ee0b050d93055806f2140b7
6
+ metadata.gz: 45e9a9716350c82a74f707ff0085994719f2f604e4c3ba06d112fbc01cd98ffab4d2be19aac77207c5bd0e91fb6029ebc016f16821e081eec707a0e76fcff9c9
7
+ data.tar.gz: 80249bc85d3f3b2fbf0c3f96ede80a0e279c2a6fb97f8ecd8ad04e3d533d479d6114ff7b8845bf0a488dc156221f26511c8025a0a5822a6125ef70c3b1791728
@@ -41,7 +41,7 @@ module VisualStudio
41
41
  end
42
42
 
43
43
  module VERSION #:nodoc:
44
- MAJOR, MINOR, PATCH, PRE = [0, 0, 0, 4]
44
+ MAJOR, MINOR, PATCH, PRE = [0, 0, 0, 5]
45
45
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.')
46
46
  end
47
47
 
@@ -66,8 +66,9 @@ module VisualStudio
66
66
  end
67
67
 
68
68
  # TODO(mtwilliams): Handle the Xbox One and PS4.
69
- # TODO(mtwilliams): Actually search for the SDKs.
70
- sdks = VisualStudio::VERSION_TO_SDKS[version][:windows]
69
+ sdks = (VisualStudio::VERSION_TO_SDKS[version][:windows].map do |version|
70
+ Windows::SoftwareDevelopmentKit.find(version)
71
+ end).compact
71
72
 
72
73
  platforms = [:windows]
73
74
  architectures = case product
@@ -0,0 +1,165 @@
1
+ module VisualStudio
2
+ module Windows
3
+ class SoftwareDevelopmentKit
4
+ VERSIONS = [10.0, 8.1, 8.0, 7.1, 7.0].map(&:to_s)
5
+
6
+ attr_reader :name,
7
+ :version,
8
+ :root,
9
+ :includes,
10
+ :libraries,
11
+ :binaries,
12
+ :supports
13
+
14
+ def initialize(desc)
15
+ @name = desc[:name]
16
+ @version = desc[:version]
17
+ @root = desc[:root]
18
+ @includes = desc[:includes]
19
+ @libraries = desc[:libraries]
20
+ @binaries = desc[:binaries]
21
+ @supports = desc[:supports]
22
+ end
23
+
24
+ def self.find(version)
25
+ if Windows::SoftwareDevelopmentKit::VERSIONS.include?(version)
26
+ # TODO(mtwilliams): Select the 64-bit and ARM host variants when
27
+ # applicable, i.e. when running on 64-bit or ARM.
28
+
29
+ name, version, root, includes, libraries, binaries, supports =
30
+ case version.to_f
31
+ when 7.0..7.1
32
+ name, root = self._find_via_registry(version)
33
+ return nil if root.nil?
34
+
35
+ includes = [File.join(root, 'include')]
36
+
37
+ libraries = {:x86 => [File.join(root, 'lib')],
38
+ :x86_64 => [File.join(root, 'lib', 'x64')].select{|path| Dir.exists?(path)}}
39
+ binaries = {:x86 => [File.join(root, 'bin')],
40
+ :x86_64 => [File.join(root, 'bin', 'x64')].select{|path| Dir.exists?(path)}}
41
+
42
+ supports = []
43
+ supports << :x86
44
+ supports << :x86_64 if !libraries[:x86_64].empty?
45
+
46
+ [name, version, root, includes, libraries, binaries, supports]
47
+ when 8.0
48
+ name, root = self._find_kit_via_registry(version)
49
+ return nil if root.nil?
50
+
51
+ includes = [File.join(root, 'include', 'shared'),
52
+ File.join(root, 'include', 'um')]
53
+ libraries = {:x86 => [File.join(root, 'lib', 'win8', 'um', 'x86')],
54
+ :x86_64 => [File.join(root, 'lib', 'win8', 'um', 'x64')]}
55
+ binaries = {:x86 => [File.join(root, 'bin', 'x86')],
56
+ :x86_64 => [File.join(root, 'bin', 'x64')]}
57
+
58
+ supports = [:x86, :x86_64]
59
+
60
+ [name, version, root, includes, libraries, binaries, supports]
61
+ when 8.1
62
+ name, root = self._find_kit_via_registry(version)
63
+ return nil if root.nil?
64
+
65
+ includes = [File.join(root, 'include', 'shared'),
66
+ File.join(root, 'include', 'um')]
67
+ libraries = {:x86 => [File.join(root, 'lib', 'winv6.3', 'um', 'x86')],
68
+ :x86_64 => [File.join(root, 'lib', 'winv6.3', 'um', 'x64')],
69
+ :arm => [File.join(root, 'lib', 'winv6.3', 'um', 'arm')]}
70
+ binaries = {:x86 => [File.join(root, 'bin', 'x86')],
71
+ :x86_64 => [File.join(root, 'bin', 'x64')],
72
+ :arm => [File.join(root, 'bin', 'arm')]}
73
+
74
+ supports = [:x86, :x86_64, :arm]
75
+
76
+ [name, version, root, includes, libraries, binaries, supports]
77
+ when 10.0
78
+ name, root = self._find_kit_via_registry(version)
79
+ return nil if root.nil?
80
+
81
+ # HACK(mtwilliams): Determine the latest and greatest version
82
+ # by finding the directory with the highest version number. We
83
+ # should look into using the 'PlatformIdentity' attribute in SDKManifest.xml.
84
+ version = Dir.entries(File.join(root, 'lib')).sort.last
85
+
86
+ includes = [File.join(root, 'include', version, 'ucrt'),
87
+ File.join(root, 'include', version, 'shared'),
88
+ File.join(root, 'include', version, 'um')]
89
+ libraries = {:x86 => [File.join(root, 'lib', version, 'ucrt', 'x86'),
90
+ File.join(root, 'lib', version, 'um', 'x86')],
91
+ :x86_64 => [File.join(root, 'lib', version, 'ucrt', 'x64'),
92
+ File.join(root, 'lib', version, 'um', 'x64')],
93
+ :arm => [File.join(root, 'lib', version, 'ucrt', 'arm'),
94
+ File.join(root, 'lib', version, 'um', 'arm')]}
95
+ binaries = {:x86 => [File.join(root, 'bin', 'x86')],
96
+ :x86_64 => [File.join(root, 'bin', 'x64')],
97
+ :arm => [File.join(root, 'bin', 'arm')]}
98
+
99
+ supports = [:x86, :x86_64, :arm]
100
+
101
+ [name, '10.0', root, includes, libraries, binaries, supports]
102
+ else
103
+ # TODO(mtwilliams): Raise an exception.
104
+ # raise VisualStudio::UnsupportedVersion.new(...)
105
+ end
106
+
107
+ Windows::SoftwareDevelopmentKit.new(name: name,
108
+ version: version,
109
+ root: root,
110
+ includes: includes,
111
+ libraries: libraries,
112
+ binaries: binaries,
113
+ supports: supports)
114
+ else
115
+ # TODO(mtwilliams): Raise an exception.
116
+ # raise VisualStudio::InvalidVersion.new(...)
117
+ end
118
+ end
119
+
120
+ private
121
+ def self._find_via_registry(version)
122
+ # We try to find an embedded version of the SDK. If we can't, then
123
+ # we look for standalone verions. They appear interchangeable, but
124
+ # this requires further testing to confirm.
125
+ keys = ["SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v#{version}A",
126
+ "SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v#{version}A",
127
+ "SOFTWARE\\Wow6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v#{version}",
128
+ "SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v#{version}"]
129
+ installs = keys.map do |key|
130
+ begin
131
+ require 'win32/registry'
132
+ key = ::Win32::Registry::HKEY_LOCAL_MACHINE.open(key, ::Win32::Registry::KEY_READ)
133
+ [key['ProductName'], File.expand_path(key['InstallationFolder']).to_s]
134
+ rescue
135
+ end
136
+ end
137
+ installs.compact.first
138
+ end
139
+
140
+ def self._find_kit_via_registry(version)
141
+ # There's no easy way to pull names out of the registry.
142
+ names = {'10.0' => "Windows Kit for Universal Windows",
143
+ '8.1' => "Windows Kit for Windows 8.1",
144
+ '8.0' => "Windows Kit for Windows 8.0"}
145
+ keys = ["SOFTWARE\\Wow6432Node\\Microsoft\\Windows Kits\\Installed Roots",
146
+ "SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots"]
147
+ # For some reason, Microsoft has decided to use properties instead of
148
+ # distinct keys for Windows Kits. Yet another case of them being
149
+ # unable to make up their minds.
150
+ properties = {'10.0' => "KitsRoot10",
151
+ '8.1' => "KitsRoot81",
152
+ '8.0' => "KitsRoot"}
153
+ installs = keys.map do |key|
154
+ begin
155
+ require 'win32/registry'
156
+ root = ::Win32::Registry::HKEY_LOCAL_MACHINE.open(key, ::Win32::Registry::KEY_READ)[properties[version]]
157
+ File.expand_path(root).to_s
158
+ rescue
159
+ end
160
+ end
161
+ [names[version], installs.compact.first]
162
+ end
163
+ end
164
+ end
165
+ end
data/lib/visual_studio.rb CHANGED
@@ -28,6 +28,8 @@ module VisualStudio
28
28
  require 'visual_studio/install'
29
29
  require 'visual_studio/product'
30
30
 
31
+ require 'visual_studio/sdks/windows'
32
+
31
33
  def self.available?(name_or_version=nil)
32
34
  self.installed?(name_or_version)
33
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visual_studio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.4
4
+ version: 0.0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Williams
@@ -69,6 +69,7 @@ files:
69
69
  - lib/visual_studio/helpers/pretty_string.rb
70
70
  - lib/visual_studio/install.rb
71
71
  - lib/visual_studio/product.rb
72
+ - lib/visual_studio/sdks/windows.rb
72
73
  - visual_studio.gemspec
73
74
  - visual_studio.sublime-project
74
75
  homepage: https://github.com/mtwilliams/visual_studio