go4rake 1.0 → 1.0.7

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: 4abad49cb110822a811d5968068bdff92ce82c92
4
- data.tar.gz: bd11e40b70650c2a90703f365703474aa748019c
3
+ metadata.gz: 53f419be04c75a9148662310ac86bee3e84bfc52
4
+ data.tar.gz: 9d6dc125f8f4086ddefa52a670e56bd18652163f
5
5
  SHA512:
6
- metadata.gz: b716a055192a55fce55b90bdaa7d329768139a4c37278c96e5afb9263faf0188fa8638f8752a66261a3e1f0449ed2c458de5112f4c9ce5dce77d4f0963e32227
7
- data.tar.gz: 3b4ca2cc42f5e925704913196daa58f72aa708368608f1703899be1704b90ff3af8213c623714c109d2ebdaed4acf448e3158fa819ff15dc397bf1562df63f1d
6
+ metadata.gz: b682ae30deb1f68db4723507858090767eb0eb80545104465bf9c970fbc5d7b350e1c420c6ed703e6deb2f8a88bd62528ae1ce5a6fe79e5f39044db08a7f3075
7
+ data.tar.gz: 7f8971e939979192fecca957a8a6bd02cefcaac830479c4a3bbc72b9160be7ae01c137e8420a3ad5b4f0844f6d01f36a6b2cfbd4bb33b67ded8e6b4fdb6fb70a
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- ## go4rake is a Rake helper for cross-compiling Go programs
1
+ ## go4rake: Rake tasks for cross-compiling Go programs [![Gem Version](https://badge.fury.io/rb/go4rake.svg)](http://badge.fury.io/rb/go4rake)
2
2
 
3
- It provides the following tasks:
3
+ This gem provides the following tasks:
4
4
 
5
5
  * `rake build` for cross-compiling for the specified architectures
6
6
  * `rake zip` command for making ZIP files that contain binary builds
@@ -37,13 +37,14 @@ on Windows (7-zip? Don't know).
37
37
  `zip` and `build` tasks expect a YAML config, `go4rake.yml`. Say, we
38
38
  have [this config](https://github.com/chillum/httpstress-go/blob/master/go4rake.yml).
39
39
 
40
- This way, you run `rake zip` and you get these files containing the static binary files for all the specified platforms:
40
+ This way, you run `rake zip` and you get the following ZIP files
41
+ containing the static binary builds in your `~/Downloads` directory:
41
42
 
42
- * win32.zip
43
- * win64.zip
44
- * linux_amd64.zip
45
- * linux_i386.zip
46
- * mac.zip
43
+ * `win32.zip`
44
+ * `win64.zip`
45
+ * `linux_amd64.zip`
46
+ * `linux_386.zip`
47
+ * `mac.zip`
47
48
 
48
49
  For each platform:
49
50
 
@@ -0,0 +1,16 @@
1
+ out: ~/Downloads
2
+
3
+ platforms:
4
+ - name: windows
5
+ arch: 386
6
+ zip: win32
7
+ - name: windows
8
+ arch: amd64
9
+ zip: win64
10
+ - name: darwin
11
+ arch: amd64
12
+ zip: mac
13
+ - name: linux
14
+ arch:
15
+ - 386
16
+ - amd64
data/go4rake.gemspec CHANGED
@@ -1,11 +1,12 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'go4rake'
3
- s.version = '1.0'
3
+ s.version = '1.0.7'
4
4
  s.license = 'Apache-2.0'
5
5
  s.summary = 'go4rake is a Rake helper for cross-compiling Go programs'
6
6
  s.description = '`build`, `test` and `zip` tasks for cross-compilation of Go programs'
7
7
  s.author = 'Vasily Korytov'
8
8
  s.email = 'vasily.korytov@yahoo.com'
9
- s.files = ['README.md', 'LICENSE.txt', 'go4rake.gemspec', 'lib/go4rake.rb']
9
+ s.files = ['LICENSE.txt', 'README.md', 'examples/go4rake.yml',
10
+ 'go4rake.gemspec', 'lib/go4rake.rb', 'lib/go4rake/new.rb']
10
11
  s.homepage = 'https://github.com/chillum/go4rake'
11
12
  end
@@ -0,0 +1,96 @@
1
+ # Copyright 2014 Vasily Korytov
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'rake/tasklib'
16
+ require 'yaml'
17
+
18
+ # Rake tasks to cross-compile Go project and ZIP the binaries:
19
+ # `rake build`, `rake test` and `rake zip`.
20
+ #
21
+ # Usage: `require 'go4rake'` in `Rakefile`. Settings are specified in a YAML file: `go4rake.yml`.
22
+ #
23
+ # Example config: https://github.com/chillum/httpstress-go/blob/master/go4rake.yml
24
+ #
25
+ # Docs: https://github.com/chillum/go4rake/blob/master/README.md
26
+ #
27
+ # Offline copies of README and example config are also included in this gem.
28
+ class Go4Rake < ::Rake::TaskLib
29
+ attr_reader :yml
30
+ # Initialize Rake tasks for cross-compiling Go programs.
31
+ def initialize(yml = 'go4rake.yml')
32
+ # `build` and `zip` depend on config, `test` doesn't.
33
+ begin
34
+ @config = YAML.load_file yml
35
+
36
+ desc "Build this project for the platforms in #{yml}"
37
+ task :build do
38
+ @config['platforms'].each { |os|
39
+ if os['arch'].respond_to?('each')
40
+ os['arch'].each { |arch| build os['name'], arch }
41
+ else
42
+ build os['name'], os['arch']
43
+ end
44
+ }
45
+ end
46
+
47
+ desc 'ZIP this project binaries'
48
+ task :zip => [:build, :test] do
49
+ @config['out'] ||= '.' # Default to the current directory, if 'out' is not specified.
50
+
51
+ @config['platforms'].each { |os|
52
+ if os['arch'].respond_to?('each')
53
+ os['arch'].each { |arch| zip os['name'], arch, @config['out'], os['zip'] ? \
54
+ "#{os['zip']}_#{arch}" : "#{os['name']}_#{arch}" }
55
+ else
56
+ zip os['name'], os['arch'], @config['out'], os['zip'] || "#{os['name']}_#{os['arch']}"
57
+ end
58
+ }
59
+ end
60
+ rescue => e
61
+ $stderr.puts "WARNING: Skipping `build` and `zip` tasks: #{e}"
62
+ end
63
+
64
+ desc 'Run `go test` for the native platform'
65
+ task :test do
66
+ setenv nil, nil
67
+ system 'go test' or die 'Tests'
68
+ end
69
+ end
70
+
71
+ # Sets GOARCH and GOOS.
72
+ def setenv os, arch
73
+ ENV['GOARCH'] = arch ? arch.to_s : nil
74
+ ENV['GOOS'] = os
75
+ end
76
+
77
+ # Exits with an error.
78
+ def die task
79
+ abort "#{task} failed. Exiting" # Rake returns 1 in something fails.
80
+ end
81
+
82
+ # Executes `go install` for the specified os/arch.
83
+ def build os, arch
84
+ setenv os, arch
85
+ puts "Building #{os}_#{arch}"
86
+ system 'go install' or die 'Build'
87
+ end
88
+
89
+ # Zips the compiled files.
90
+ def zip os, arch, dir, file
91
+ setenv os, arch
92
+ if system "zip -qj #{dir}/#{file}.zip #{`go list -f '{{.Target}}'`}"
93
+ puts "Wrote #{dir}/#{file}.zip"
94
+ end
95
+ end
96
+ end
data/lib/go4rake.rb CHANGED
@@ -12,90 +12,6 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- require 'rake/tasklib'
16
- require 'yaml'
17
-
18
- # Rake tasks to cross-compile Go project and ZIP the binaries:
19
- # `rake build`, `rake test` and `rake zip`.
20
- #
21
- # Usage: `require 'go4rake'` in `Rakefile`. Settings are specified in a YAML file: `go4rake.yml`.
22
- #
23
- # Example config: https://github.com/chillum/httpstress-go/blob/master/go4rake.yml
24
- #
25
- # `name` is OS name, `arch` is arch and `zip` is ZIP file name (optional).
26
- # `arch` is appended to file name if `arch` is a list.
27
- #
28
- # If `out` is specified, ZIP files will appear in the specified directory;
29
- # if not, they will be in current directory.
30
- class Go4Rake < ::Rake::TaskLib
31
- # Initialize Rake tasks for cross-compiling Go programs.
32
- def initialize(*args)
33
-
34
- begin
35
- yml = 'go4rake.yml'
36
- config = YAML.load_file yml
37
-
38
- desc "Build this project for the platforms in #{yml}"
39
- task :build do
40
- config['platforms'].each { |os|
41
- if os['arch'].respond_to?('each')
42
- os['arch'].each { |arch| build os['name'], arch }
43
- else
44
- build os['name'], os['arch']
45
- end
46
- }
47
- end
48
-
49
- desc 'ZIP this project binaries'
50
- task :zip => [:build, :test] do
51
- unless config['out']
52
- config['out'] = '.' # Default to the current directory, if 'out' is not specified.
53
- end
54
-
55
- config['platforms'].each { |os|
56
- if os['arch'].respond_to?('each')
57
- os['arch'].each { |arch| zip os['name'], arch, config['out'], os['zip'] ? \
58
- "#{os['zip']}_#{arch}" : "#{os['name']}_#{arch}" }
59
- else
60
- zip os['name'], os['arch'], config['out'], os['zip'] || "#{os['name']}_#{os['arch']}"
61
- end
62
- }
63
- end
64
- rescue
65
- puts "Warning: unable to load #{yml}. Disabling `build` and `zip` tasks."
66
- end
67
-
68
- desc 'Run `go test` for the native platform'
69
- task :test do
70
- setenv nil, nil
71
- unless system('go test'); die 'Tests' end
72
- end
73
-
74
- def setenv os, arch
75
- ENV['GOARCH'] = arch ? arch.to_s : nil
76
- ENV['GOOS'] = os
77
- end
78
-
79
- def die task
80
- puts "#{task} failed. Exiting"
81
- exit 1 # Rake returns 1 if something fails.
82
- end
83
-
84
- def build os, arch
85
- setenv os, arch
86
- puts "Building #{os}_#{arch}"
87
- unless system('go install'); die 'Build' end
88
- end
89
-
90
- def zip os, arch, dir, file
91
- setenv os, arch
92
-
93
- if system("zip -qj #{dir}/#{file}.zip #{`go list -f '{{.Target}}'`}")
94
- puts "Wrote #{dir}/#{file}.zip"
95
- end
96
- end
97
-
98
- end
99
- end
15
+ require_relative 'go4rake/new'
100
16
 
101
17
  Go4Rake.new
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: go4rake
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasily Korytov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-20 00:00:00.000000000 Z
11
+ date: 2014-09-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: "`build`, `test` and `zip` tasks for cross-compilation of Go programs"
14
14
  email: vasily.korytov@yahoo.com
@@ -18,8 +18,10 @@ extra_rdoc_files: []
18
18
  files:
19
19
  - LICENSE.txt
20
20
  - README.md
21
+ - examples/go4rake.yml
21
22
  - go4rake.gemspec
22
23
  - lib/go4rake.rb
24
+ - lib/go4rake/new.rb
23
25
  homepage: https://github.com/chillum/go4rake
24
26
  licenses:
25
27
  - Apache-2.0