emplace 0.1.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 (7) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +22 -0
  3. data/README.md +35 -0
  4. data/Rakefile +9 -0
  5. data/lib/emplace.rb +118 -0
  6. data/test/emplace-test.rb +39 -0
  7. metadata +51 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 93b6b9467fc933b3c9a1093a04a57f80aacab3e6
4
+ data.tar.gz: 49e6edfa9d76015be537b24316cefc42b7137722
5
+ SHA512:
6
+ metadata.gz: 325f0c10a6fd1388a7bef29add3e77777b8ba4877e805becd010a691fa479a2a4dc68c9cacfa41279ba6ec61fea49cc18cff7c78d291db264bd33579dc738025
7
+ data.tar.gz: dd058c8c1d848353deefdc276a00ce80065e24921aca3a8cf54d2256cb44bd8865fa40ef40c71b42ec9eb90590274e9ded276f613fd6a79e3fba27b6466c130b
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Ryan Calhoun
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ [![Gem Version](https://badge.fury.io/rb/emplace.svg)](http://badge.fury.io/rb/emplace)
2
+
3
+ # Emplace
4
+
5
+ Gem for cmake build settings
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'emplace'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install emplace
20
+
21
+ ## Usage
22
+
23
+ require 'emplace'
24
+ Emplace.cmake
25
+ Emplace.build
26
+ Emplace.package('package-name')
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create new Pull Request
35
+
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new {|t|
4
+ t.test_files = FileList['test/**/*est.rb']
5
+ }
6
+
7
+ desc 'Run tests'
8
+ task :default => :test
9
+
data/lib/emplace.rb ADDED
@@ -0,0 +1,118 @@
1
+ module Emplace
2
+
3
+ class CmakeBuild
4
+ def cmake
5
+ sh "cmake -G \"#{cmake_generator}\" ."
6
+ end
7
+ def build
8
+ sh "cmake --build . --target install"
9
+ end
10
+ def sh(cmd)
11
+ raise $? unless system cmd
12
+ end
13
+ end
14
+
15
+ class Unix < CmakeBuild
16
+ def cmake_generator
17
+ 'Unix Makefiles'
18
+ end
19
+ def arch
20
+ 1.size == 4 ? 'x86' : 'x86_64'
21
+ end
22
+ def package_name(name)
23
+ "#{name}-#{system_name}.tgz"
24
+ end
25
+ def package(name)
26
+ sh "tar czf #{package_name(name)} #{name}"
27
+ end
28
+ end
29
+
30
+ class Linux < Unix
31
+ def system_name
32
+ "linux-#{arch}"
33
+ end
34
+ end
35
+
36
+ class Darwin < Unix
37
+ def system_name
38
+ "osx-#{arch}"
39
+ end
40
+ end
41
+
42
+ class Windows < CmakeBuild
43
+ def system_name
44
+ "win-#{arch}"
45
+ end
46
+ def package_name(name)
47
+ "#{name}-#{system_name}.zip"
48
+ end
49
+ end
50
+
51
+ module Travis
52
+ def system_name
53
+ if cc = ENV['CC']
54
+ "#{super}-#{cc}"
55
+ else
56
+ super
57
+ end
58
+ end
59
+ end
60
+
61
+ module AppVeyor
62
+ def cmake_generator
63
+ case arch
64
+ when 'x86'
65
+ 'Visual Studio 14'
66
+ when 'x64'
67
+ 'Visual Studio 14 Win64'
68
+ end
69
+ end
70
+ def arch
71
+ case ENV['PLATFORM']
72
+ when'x64'
73
+ 'x64'
74
+ else
75
+ 'x86'
76
+ end
77
+ end
78
+ def system_name
79
+ if cfg = ENV['CONFIGURATION']
80
+ "#{super}-msvc-#{cfg.downcase}"
81
+ else
82
+ "#{super}-msvc"
83
+ end
84
+ end
85
+ def package(name)
86
+ sh "7z a #{package_name(name)} #{name}"
87
+ end
88
+ end
89
+
90
+ private
91
+ def self.load_env
92
+ platform = case RUBY_PLATFORM
93
+ when /mswin|mingw/
94
+ Windows
95
+ when /darwin/
96
+ Darwin
97
+ when /linux/
98
+ Linux
99
+ else
100
+ Unix
101
+ end
102
+
103
+ if ENV['TRAVIS']
104
+ platform.send(:include, Travis)
105
+ elsif ENV['APPVEYOR']
106
+ platform.send(:include, AppVeyor)
107
+ end
108
+
109
+ platform.new.tap {|impl|
110
+ (impl.methods - Object.methods).each {|m|
111
+ define_singleton_method(m) {|*args,&block| impl.method(m).call(*args, &block) }
112
+ }
113
+ }
114
+ end
115
+
116
+ IMPL = load_env
117
+ end
118
+
@@ -0,0 +1,39 @@
1
+ require 'test/unit'
2
+
3
+ require 'emplace'
4
+
5
+ ENV['CC'] = 'cc'
6
+ ENV['CONFIGURATION'] = 'CFG'
7
+
8
+ class TestEmplace < Test::Unit::TestCase
9
+
10
+ def testSystemName
11
+ assert_equal 'linux-x86_64-cc', Travis.new.system_name
12
+ assert_equal 'win-x64-msvc-cfg', AppVeyor.new.system_name
13
+ end
14
+
15
+ def testPackageName
16
+ assert_equal 'foo-linux-x86_64-cc.tgz', Travis.new.package_name('foo')
17
+ assert_equal 'foo-win-x64-msvc-cfg.zip', AppVeyor.new.package_name('foo')
18
+ end
19
+
20
+ def testCmakeGenerator
21
+ assert_equal 'Unix Makefiles', Travis.new.cmake_generator
22
+ assert_equal 'Visual Studio 14 Win64', AppVeyor.new.cmake_generator
23
+ end
24
+
25
+ class Travis < Emplace::Linux
26
+ include Emplace::Travis
27
+ def arch
28
+ 'x86_64'
29
+ end
30
+ end
31
+
32
+ class AppVeyor < Emplace::Windows
33
+ include Emplace::AppVeyor
34
+ def arch
35
+ 'x64'
36
+ end
37
+ end
38
+
39
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: emplace
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Calhoun
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-16 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Keeps settings for running cmake builds on Travis-CI and AppVeyor.
14
+ email:
15
+ - ryanjamescalhoun@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - LICENSE
21
+ - README.md
22
+ - Rakefile
23
+ - lib/emplace.rb
24
+ - test/emplace-test.rb
25
+ homepage: https://github.com/theryan/emplace
26
+ licenses:
27
+ - MIT
28
+ metadata: {}
29
+ post_install_message:
30
+ rdoc_options: []
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ requirements: []
44
+ rubyforge_project:
45
+ rubygems_version: 2.4.5.1
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: Gem for cmake build settings
49
+ test_files:
50
+ - test/emplace-test.rb
51
+ - Rakefile