emplace 0.1.7 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/emplace.rb +49 -30
- data/test/emplace-test.rb +39 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a19369de0e81e097444c4f2051ecdb68f1eb7d89
|
4
|
+
data.tar.gz: 6b7e1d5c808716b70647ba236d078f28b0d0fc05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64bab951484b11dd563c780d959dad949d098518142f89bdf179a3cd84cb4a5e969a06e6f19d11c6bf2a3ed858d824a4523850251701c7255f28f2bf6e51a8ea
|
7
|
+
data.tar.gz: 74a5cc73f81178e13bb220c262078788a34a7b3bbde065db6cb269da887578452bf5b36bf02cb9bec92a96ab1237b213a25f5c309c2a7b3f96a7125545d75f64
|
data/lib/emplace.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'fileutils'
|
2
|
+
require 'open-uri'
|
2
3
|
|
3
4
|
module Emplace
|
4
5
|
|
@@ -7,51 +8,63 @@ module Emplace
|
|
7
8
|
@name = name
|
8
9
|
@impl = impl
|
9
10
|
end
|
11
|
+
def build_dir
|
12
|
+
'build'
|
13
|
+
end
|
14
|
+
def dist_dir
|
15
|
+
'dist'
|
16
|
+
end
|
17
|
+
def vendor_dir
|
18
|
+
'vendor'
|
19
|
+
end
|
10
20
|
def clean!
|
11
|
-
|
21
|
+
FileUtils.rm_rf build_dir
|
22
|
+
FileUtils.rm_rf dist_dir
|
23
|
+
FileUtils.rm_rf vendor_dir
|
12
24
|
end
|
13
25
|
def cmake!
|
14
|
-
@impl.cmake @name
|
26
|
+
@impl.cmake @name, build_dir, dist_dir
|
15
27
|
end
|
16
28
|
def build!
|
17
|
-
@impl.build
|
29
|
+
@impl.build build_dir
|
18
30
|
end
|
19
31
|
def test!
|
20
|
-
@impl.test
|
32
|
+
@impl.test build_dir
|
21
33
|
end
|
22
34
|
def package!
|
23
|
-
@impl.package @name
|
35
|
+
@impl.package @name, dist_dir
|
36
|
+
end
|
37
|
+
def extract!
|
38
|
+
@impl.extract @name, vendor_dir
|
39
|
+
end
|
40
|
+
def fetch!(url)
|
41
|
+
package = @impl.package_name(@name)
|
42
|
+
source = open(File.join(url, package))
|
43
|
+
@impl.write_file(package, vendor_dir) {|dest|
|
44
|
+
IO.copy_stream(source, dest)
|
45
|
+
}
|
24
46
|
end
|
25
47
|
end
|
26
48
|
|
27
49
|
class CMakeBuild
|
28
|
-
def build_dir
|
29
|
-
|
30
|
-
end
|
31
|
-
def dist_dir
|
32
|
-
'dist'
|
33
|
-
end
|
34
|
-
def install_dir(name)
|
35
|
-
"#{dist_dir}/#{name}"
|
36
|
-
end
|
37
|
-
def cmake(name)
|
38
|
-
sh "cmake . -B#{build_dir} -DCMAKE_INSTALL_PREFIX=#{install_dir(name)} -G \"#{cmake_generator}\""
|
50
|
+
def cmake(name, build_dir, dist_dir)
|
51
|
+
sh "cmake . -B#{build_dir} -DCMAKE_INSTALL_PREFIX=#{dist_dir}/#{name} -G \"#{cmake_generator}\""
|
39
52
|
end
|
40
|
-
def build
|
41
|
-
sh "cmake --build #{
|
53
|
+
def build(dir)
|
54
|
+
sh "cmake --build #{dir} --target install"
|
42
55
|
end
|
43
|
-
def test
|
44
|
-
sh "ctest --verbose",
|
45
|
-
end
|
46
|
-
def clean
|
47
|
-
FileUtils.rm_rf build_dir
|
48
|
-
FileUtils.rm_rf dist_dir
|
56
|
+
def test(dir)
|
57
|
+
sh "ctest --verbose", dir
|
49
58
|
end
|
50
59
|
def sh(cmd, dir = '.')
|
51
60
|
Dir.chdir(dir) {
|
52
61
|
raise $? unless system cmd
|
53
62
|
}
|
54
63
|
end
|
64
|
+
def write_file(name, dir, &block)
|
65
|
+
FileUtils.mkdir_p(dir)
|
66
|
+
File.open(File.join(dir, name), 'wb', &block)
|
67
|
+
end
|
55
68
|
end
|
56
69
|
|
57
70
|
class Unix < CMakeBuild
|
@@ -64,8 +77,11 @@ module Emplace
|
|
64
77
|
def package_name(name)
|
65
78
|
"#{name}-#{system_name}.tgz"
|
66
79
|
end
|
67
|
-
def package(name)
|
68
|
-
sh "tar czf #{package_name(name)} #{name}",
|
80
|
+
def package(name, dir)
|
81
|
+
sh "tar czf #{package_name(name)} #{name}", dir
|
82
|
+
end
|
83
|
+
def extract(name, dir)
|
84
|
+
sh "tar xzf #{package_name(name)}", dir
|
69
85
|
end
|
70
86
|
end
|
71
87
|
|
@@ -128,15 +144,18 @@ module Emplace
|
|
128
144
|
"#{super}-msvc"
|
129
145
|
end
|
130
146
|
end
|
131
|
-
def build
|
147
|
+
def build(dir)
|
132
148
|
if cfg = ENV['CONFIGURATION']
|
133
|
-
sh "cmake --build #{
|
149
|
+
sh "cmake --build #{dir} --target install --config #{cfg}"
|
134
150
|
else
|
135
151
|
super
|
136
152
|
end
|
137
153
|
end
|
138
|
-
def package(name)
|
139
|
-
sh "7z a #{package_name(name)} #{name}",
|
154
|
+
def package(name, dir)
|
155
|
+
sh "7z a #{package_name(name)} #{name}", dir
|
156
|
+
end
|
157
|
+
def extract(name, dir)
|
158
|
+
sh "7z x #{package_name(name)}", dir
|
140
159
|
end
|
141
160
|
}
|
142
161
|
end
|
data/test/emplace-test.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'test/unit'
|
2
2
|
|
3
3
|
require 'emplace'
|
4
|
+
require 'fileutils'
|
4
5
|
|
5
6
|
ENV['CC'] = 'cc'
|
6
7
|
ENV['CONFIGURATION'] = 'CFG'
|
@@ -29,11 +30,13 @@ class TestEmplace < Test::Unit::TestCase
|
|
29
30
|
project.build!
|
30
31
|
project.test!
|
31
32
|
project.package!
|
33
|
+
project.extract!
|
32
34
|
assert_equal [
|
33
35
|
'cmake . -Bbuild -DCMAKE_INSTALL_PREFIX=dist/foo -G "Unix Makefiles"',
|
34
36
|
'cmake --build build --target install',
|
35
37
|
'ctest --verbose',
|
36
|
-
'tar czf foo-linux-x86_64-cc.tgz foo'
|
38
|
+
'tar czf foo-linux-x86_64-cc.tgz foo',
|
39
|
+
'tar xzf foo-linux-x86_64-cc.tgz'
|
37
40
|
], travis.commands
|
38
41
|
end
|
39
42
|
|
@@ -44,14 +47,48 @@ class TestEmplace < Test::Unit::TestCase
|
|
44
47
|
project.build!
|
45
48
|
project.test!
|
46
49
|
project.package!
|
50
|
+
project.extract!
|
47
51
|
assert_equal [
|
48
52
|
'cmake . -Bbuild -DCMAKE_INSTALL_PREFIX=dist/foo -G "Visual Studio 14 Win64"',
|
49
53
|
'cmake --build build --target install --config CFG',
|
50
54
|
'ctest --verbose',
|
51
|
-
'7z a foo-win-x64-msvc-cfg.zip foo'
|
55
|
+
'7z a foo-win-x64-msvc-cfg.zip foo',
|
56
|
+
'7z x foo-win-x64-msvc-cfg.zip'
|
52
57
|
], appveyor.commands
|
53
58
|
end
|
54
59
|
|
60
|
+
def testFetchTravis
|
61
|
+
FileUtils.mkdir_p 'url_source_dir'
|
62
|
+
FileUtils.mkdir_p 'vendor_test_dir'
|
63
|
+
|
64
|
+
File.write('url_source_dir/foo-linux-x86_64-cc.tgz', 'foo')
|
65
|
+
|
66
|
+
travis = Travis.new
|
67
|
+
project = Emplace::Project.new 'foo', travis
|
68
|
+
project.fetch! 'url_source_dir'
|
69
|
+
|
70
|
+
assert_equal 'foo', File.read('vendor/foo-linux-x86_64-cc.tgz')
|
71
|
+
ensure
|
72
|
+
FileUtils.rm_rf 'url_source_dir'
|
73
|
+
FileUtils.rm_rf 'vendor'
|
74
|
+
end
|
75
|
+
|
76
|
+
def testFetchAppVeyor
|
77
|
+
FileUtils.mkdir_p 'url_source_dir'
|
78
|
+
FileUtils.mkdir_p 'vendor'
|
79
|
+
|
80
|
+
File.write('url_source_dir/foo-win-x64-msvc-cfg.zip', 'foo')
|
81
|
+
|
82
|
+
appveyor = AppVeyor.new
|
83
|
+
project = Emplace::Project.new 'foo', appveyor
|
84
|
+
project.fetch! 'url_source_dir'
|
85
|
+
|
86
|
+
assert_equal 'foo', File.read('vendor/foo-win-x64-msvc-cfg.zip')
|
87
|
+
ensure
|
88
|
+
FileUtils.rm_rf 'url_source_dir'
|
89
|
+
FileUtils.rm_rf 'vendor'
|
90
|
+
end
|
91
|
+
|
55
92
|
class Travis < Emplace.send(:travis, Emplace::Linux)
|
56
93
|
attr_reader :commands
|
57
94
|
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.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Calhoun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-19 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:
|