go4rake 0.9.1 → 0.9.2
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/go4rake.gemspec +1 -1
- data/lib/go4rake.rb +67 -67
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83d3706eb1603d1a3de8f8414b9d265e9bf062dc
|
4
|
+
data.tar.gz: 061c07b8591eab664d3492afef2490697996cf46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3fa93cb77a6cd34c035d9f70c8729c84390a56ec86cfecd7321b267546bbc0785a2ec416b27b16bd867a437c409085e32621c99789c5e9b4531f26d9f31955f
|
7
|
+
data.tar.gz: b222643d8d4ce0eb9daf7d3eb211defa82e4186c5b4815a99b92a9c48924046890be81bbbdc192ccd75257cfcbeca365519475011cc4a2f5572b222ef11134c3
|
data/README.md
CHANGED
@@ -25,7 +25,7 @@ on Windows (7-zip? Don't know).
|
|
25
25
|
[build Go from source](http://dave.cheney.net/2013/07/09/an-introduction-to-cross-compilation-with-go-1-1).)
|
26
26
|
* [Info-ZIP](http://www.info-zip.org/Zip.html) `zip` binary in path
|
27
27
|
(ships with MacOS X and most Unix systems).
|
28
|
-
* Install [Ruby](https://www.ruby-lang.org). `rake` and `gem` come with
|
28
|
+
* Install [Ruby](https://www.ruby-lang.org). `rake` and `gem` come with it.
|
29
29
|
* Install go4rake: `gem install go4rake`.
|
30
30
|
* Enable go4rake in `Rakefile`: include `require 'go4rake'` in it (create the file, if missing).
|
31
31
|
(Unix users can do: `echo "require 'go4rake'" >> Rakefile`.)
|
data/go4rake.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'go4rake'
|
3
|
-
s.version = '0.9.
|
3
|
+
s.version = '0.9.2'
|
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'
|
data/lib/go4rake.rb
CHANGED
@@ -1,14 +1,3 @@
|
|
1
|
-
# A script to cross-compile Go project and ZIP the binaries.
|
2
|
-
#
|
3
|
-
# Settings are specified in a YAML file: go4rake.yml.
|
4
|
-
#
|
5
|
-
# Example config: https://github.com/chillum/httpstress-go/blob/master/go4rake.yml
|
6
|
-
# `name` is OS name, `arch` is arch and `zip` is ZIP file name (optional).
|
7
|
-
# `arch` is appended to file name if `arch` is a list.
|
8
|
-
#
|
9
|
-
# If `out` is specified, ZIP files will appear in the specified directory;
|
10
|
-
# if not, they will be in current directory.
|
11
|
-
|
12
1
|
# Copyright 2014 Vasily Korytov
|
13
2
|
#
|
14
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -26,76 +15,87 @@
|
|
26
15
|
require 'rake/tasklib'
|
27
16
|
require 'yaml'
|
28
17
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
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)
|
36
33
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
if os['arch'].respond_to?('each')
|
41
|
-
os['arch'].each { |arch| build os['name'], arch }
|
42
|
-
else
|
43
|
-
build os['name'], os['arch']
|
44
|
-
end
|
45
|
-
}
|
46
|
-
end
|
34
|
+
begin
|
35
|
+
yml = 'go4rake.yml'
|
36
|
+
config = YAML.load_file yml
|
47
37
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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']
|
52
45
|
end
|
46
|
+
}
|
47
|
+
end
|
53
48
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
else
|
59
|
-
zip os['name'], os['arch'], config['out'], os['zip'] || "#{os['name']}_#{os['arch']}"
|
60
|
-
end
|
61
|
-
}
|
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.
|
62
53
|
end
|
63
|
-
rescue
|
64
|
-
puts "Warning: unable to load #{yml}. Disabling `build` and `zip` tasks."
|
65
|
-
end
|
66
54
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
+
}
|
71
63
|
end
|
64
|
+
rescue
|
65
|
+
puts "Warning: unable to load #{yml}. Disabling `build` and `zip` tasks."
|
66
|
+
end
|
72
67
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
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
|
77
73
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
74
|
+
def setenv os, arch
|
75
|
+
ENV['GOARCH'] = arch ? arch.to_s : nil
|
76
|
+
ENV['GOOS'] = os
|
77
|
+
end
|
82
78
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
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
|
88
89
|
|
89
|
-
|
90
|
-
|
90
|
+
def zip os, arch, dir, file
|
91
|
+
setenv os, arch
|
91
92
|
|
92
|
-
|
93
|
-
|
94
|
-
end
|
93
|
+
if system("zip -qj #{dir}/#{file}.zip #{`go list -f '{{.Target}}'`}")
|
94
|
+
puts "Wrote #{dir}/#{file}.zip"
|
95
95
|
end
|
96
|
-
|
97
96
|
end
|
97
|
+
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
-
Go4Rake
|
101
|
+
Go4Rake.new
|