emplace 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/emplace.rb +64 -44
  3. data/test/emplace-test.rb +16 -12
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 616eaccd78562d8b95c0d0417a48c41a1e95e023
4
- data.tar.gz: d026c50acace19c59eeda2f833d6ea545a6b6703
3
+ metadata.gz: dd4b86910331878cd8f5b88e19f73edc539fea6e
4
+ data.tar.gz: a1d034c9b52dc31bdaea329d4a06a20287bb8f75
5
5
  SHA512:
6
- metadata.gz: a283d879606a1f7d5e578fec01dd2bc008fffe1cf69392b5d456d0563fde9abbba698deaa85f55a60a5cdcd3d2dd2d2262e40fcb86a4c8a180371cf01b9e3cc2
7
- data.tar.gz: 485f717f7f0661001be8f23a310f8911d9c93c341c1e021c92b9fcb4261f37445ebc0e436c054c8725bafb35187bd6594db4e9fe4dee5bca846dc19fccccba51
6
+ metadata.gz: 3ffc15e87bf4e5c1b4aae44a896819bd4f54c40aaada9f656fe83a3436a8180233dc7cec6f140d5f6c3e534cb8830c98c46cdd9f95d3100a7ec699e35071471f
7
+ data.tar.gz: fce93cfc5f15bd4805e050e825d0131b421e18995849a88f7f8c23b7787b56b8bfa6df095b244e31a85cfbae28a232f6e18fb96a62c1d31d7356762b78258b72
data/lib/emplace.rb CHANGED
@@ -3,8 +3,9 @@ require 'fileutils'
3
3
  module Emplace
4
4
 
5
5
  class Project
6
- def initialize(name, impl = Emplace.load_env)
6
+ def initialize(name, opts = {}, impl = Emplace.load_env)
7
7
  @name = name
8
+ @opts = opts
8
9
  @impl = impl
9
10
  end
10
11
  def module_dir
@@ -39,14 +40,12 @@ module Emplace
39
40
  def extract!
40
41
  @impl.extract @name, vendor_dir
41
42
  end
42
- def fetch!(url)
43
- package = @impl.package_name(@name)
44
-
45
- IO.popen(['curl', '-fsSL', File.join(url, package)]) {|source|
46
- @impl.write_file(package, vendor_dir) {|dest|
47
- IO.copy_stream(source, dest)
48
- }
49
- }
43
+ def fetch!
44
+ @impl.fetch(@name, @opts, vendor_dir)
45
+ end
46
+ private
47
+ def fetch_url
48
+ @impl.fetch_url(@opts[:url], @opts[:version])
50
49
  end
51
50
  end
52
51
 
@@ -65,6 +64,16 @@ module Emplace
65
64
  raise $? unless system cmd
66
65
  }
67
66
  end
67
+ def fetch(name, opts, vendor_dir)
68
+ package = package_name(name)
69
+ url = File.join(opts[:url], opts[:version])
70
+
71
+ IO.popen(['curl', '-fsSL', File.join(url, package)]) {|source|
72
+ write_file(package, vendor_dir) {|dest|
73
+ IO.copy_stream(source, dest)
74
+ }
75
+ }
76
+ end
68
77
  def write_file(name, dir, &block)
69
78
  FileUtils.mkdir_p(dir)
70
79
  File.open(File.join(dir, name), 'wb', &block)
@@ -102,15 +111,59 @@ module Emplace
102
111
  end
103
112
 
104
113
  class Windows < CMakeBuild
114
+ def cmake_generator
115
+ case arch
116
+ when 'x86'
117
+ 'Visual Studio 14'
118
+ when 'x64'
119
+ 'Visual Studio 14 Win64'
120
+ end
121
+ end
122
+ def arch
123
+ case platform
124
+ when'x64'
125
+ 'x64'
126
+ else
127
+ 'x86'
128
+ end
129
+ end
130
+ def system_name
131
+ "#{super}-msvc"
132
+ end
133
+ def build(dir)
134
+ sh "cmake --build #{dir} --target install --config #{configuration}"
135
+ end
136
+ def package(name, dir)
137
+ sh "7z a #{package_name(name)} #{name}", dir
138
+ end
139
+ def extract(name, dir)
140
+ sh "7z x #{package_name(name)}", dir
141
+ end
105
142
  def system_name
106
143
  "win-#{arch}"
107
144
  end
108
145
  def package_name(name)
109
146
  "#{name}-#{system_name}.zip"
110
147
  end
148
+ def platform
149
+ ENV['PLATFORM'] || 'x64'
150
+ end
151
+ def configuration
152
+ ENV['CONFIGURATION'] || 'Debug'
153
+ end
111
154
  end
112
155
 
113
156
  private
157
+
158
+ def self.local(base)
159
+ Class.new(base) {
160
+ def fetch(name, opts, vendor_dir)
161
+ FileUtils.mkdir_p(vendor_dir)
162
+ FileUtils.cp "../#{name}/dist/#{package_name(name)}", vendor_dir
163
+ end
164
+ }
165
+ end
166
+
114
167
  def self.travis(base)
115
168
  Class.new(base) {
116
169
  def system_name
@@ -125,41 +178,8 @@ module Emplace
125
178
 
126
179
  def self.appveyor(base)
127
180
  Class.new(base) {
128
- def cmake_generator
129
- case arch
130
- when 'x86'
131
- 'Visual Studio 14'
132
- when 'x64'
133
- 'Visual Studio 14 Win64'
134
- end
135
- end
136
- def arch
137
- case ENV['PLATFORM']
138
- when'x64'
139
- 'x64'
140
- else
141
- 'x86'
142
- end
143
- end
144
181
  def system_name
145
- if cfg = ENV['CONFIGURATION']
146
- "#{super}-msvc-#{cfg.downcase}"
147
- else
148
- "#{super}-msvc"
149
- end
150
- end
151
- def build(dir)
152
- if cfg = ENV['CONFIGURATION']
153
- sh "cmake --build #{dir} --target install --config #{cfg}"
154
- else
155
- super
156
- end
157
- end
158
- def package(name, dir)
159
- sh "7z a #{package_name(name)} #{name}", dir
160
- end
161
- def extract(name, dir)
162
- sh "7z x #{package_name(name)}", dir
182
+ "#{super}-msvc-#{configuration.downcase}"
163
183
  end
164
184
  }
165
185
  end
@@ -181,7 +201,7 @@ module Emplace
181
201
  elsif ENV['APPVEYOR']
182
202
  appveyor platform
183
203
  else
184
- platform
204
+ local platform
185
205
  end.new
186
206
  end
187
207
 
data/test/emplace-test.rb CHANGED
@@ -25,14 +25,14 @@ class TestEmplace < Test::Unit::TestCase
25
25
 
26
26
  def testProjectTravis
27
27
  travis = Travis.new
28
- project = Emplace::Project.new 'foo', travis
28
+ project = Emplace::Project.new 'foo', {}, travis
29
29
  project.cmake!
30
30
  project.build!
31
31
  project.test!
32
32
  project.package!
33
33
  project.extract!
34
34
  assert_equal [
35
- 'cmake . -Bbuild -DCMAKE_INSTALL_PREFIX=dist/foo -G "Unix Makefiles"',
35
+ "cmake . -Bbuild -DCMAKE_MODULE_PATH=#{modpath} -DCMAKE_INSTALL_PREFIX=dist/foo -G \"Unix Makefiles\"",
36
36
  'cmake --build build --target install',
37
37
  'ctest --verbose',
38
38
  'tar czf foo-linux-x86_64-cc.tgz foo',
@@ -42,14 +42,14 @@ class TestEmplace < Test::Unit::TestCase
42
42
 
43
43
  def testProjectAppVeyor
44
44
  appveyor = AppVeyor.new
45
- project = Emplace::Project.new 'foo', appveyor
45
+ project = Emplace::Project.new 'foo', {}, appveyor
46
46
  project.cmake!
47
47
  project.build!
48
48
  project.test!
49
49
  project.package!
50
50
  project.extract!
51
51
  assert_equal [
52
- 'cmake . -Bbuild -DCMAKE_INSTALL_PREFIX=dist/foo -G "Visual Studio 14 Win64"',
52
+ "cmake . -Bbuild -DCMAKE_MODULE_PATH=#{modpath} -DCMAKE_INSTALL_PREFIX=dist/foo -G \"Visual Studio 14 Win64\"",
53
53
  'cmake --build build --target install --config CFG',
54
54
  'ctest --verbose',
55
55
  '7z a foo-win-x64-msvc-cfg.zip foo',
@@ -58,14 +58,14 @@ class TestEmplace < Test::Unit::TestCase
58
58
  end
59
59
 
60
60
  def testFetchTravis
61
- FileUtils.mkdir_p 'url_source_dir'
61
+ FileUtils.mkdir_p 'url_source_dir/1.0'
62
62
  FileUtils.mkdir_p 'vendor_test_dir'
63
63
 
64
- File.write('url_source_dir/foo-linux-x86_64-cc.tgz', 'foo')
64
+ File.write('url_source_dir/1.0/foo-linux-x86_64-cc.tgz', 'foo')
65
65
 
66
66
  travis = Travis.new
67
- project = Emplace::Project.new 'foo', travis
68
- project.fetch! "file://#{FileUtils.pwd}/url_source_dir"
67
+ project = Emplace::Project.new 'foo', {url: "file://#{FileUtils.pwd}/url_source_dir", version: '1.0'}, travis
68
+ project.fetch!
69
69
 
70
70
  assert_equal 'foo', File.read('vendor/foo-linux-x86_64-cc.tgz')
71
71
  ensure
@@ -74,14 +74,14 @@ class TestEmplace < Test::Unit::TestCase
74
74
  end
75
75
 
76
76
  def testFetchAppVeyor
77
- FileUtils.mkdir_p 'url_source_dir'
77
+ FileUtils.mkdir_p 'url_source_dir/1.0'
78
78
  FileUtils.mkdir_p 'vendor'
79
79
 
80
- File.write('url_source_dir/foo-win-x64-msvc-cfg.zip', 'foo')
80
+ File.write('url_source_dir/1.0/foo-win-x64-msvc-cfg.zip', 'foo')
81
81
 
82
82
  appveyor = AppVeyor.new
83
- project = Emplace::Project.new 'foo', appveyor
84
- project.fetch! "file://#{FileUtils.pwd}/url_source_dir"
83
+ project = Emplace::Project.new 'foo', {url: "file://#{FileUtils.pwd}/url_source_dir", version: '1.0'}, appveyor
84
+ project.fetch!
85
85
 
86
86
  assert_equal 'foo', File.read('vendor/foo-win-x64-msvc-cfg.zip')
87
87
  ensure
@@ -89,6 +89,10 @@ class TestEmplace < Test::Unit::TestCase
89
89
  FileUtils.rm_rf 'vendor'
90
90
  end
91
91
 
92
+ def modpath
93
+ File.join(File.dirname(File.dirname(__FILE__)), 'modules')
94
+ end
95
+
92
96
  class Travis < Emplace.send(:travis, Emplace::Linux)
93
97
  attr_reader :commands
94
98
  def arch
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emplace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Calhoun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-13 00:00:00.000000000 Z
11
+ date: 2016-04-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Keeps settings for running cmake builds on Travis-CI and AppVeyor.
14
14
  email:
@@ -45,7 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
45
  version: '0'
46
46
  requirements: []
47
47
  rubyforge_project:
48
- rubygems_version: 2.4.5.1
48
+ rubygems_version: 2.5.1
49
49
  signing_key:
50
50
  specification_version: 4
51
51
  summary: Gem for cmake build settings