go4rake 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/go4rake.gemspec +11 -10
- data/lib/go4rake/new.rb +22 -22
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f771ae426febcac53569eb33ee53a1d8b51292f
|
4
|
+
data.tar.gz: 2b7d73848d395c4b9db4517b18f380c9b5bcea79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a2d67a7044c63c2ee863a5f715e08a3806f710c1db140f1bdded1237cfe3fa348d538054c2d7e7327041808edf9794fcf63ddebe0fb326bc22a4221b476da40
|
7
|
+
data.tar.gz: 2efc6c0329bf83a17c2162e42630e8fb42a3dc748e83c593d317f897686af1db869396114f10b90d6f57faacb8780f5c0609da3fd19885f417f72adf3efe71ce
|
data/go4rake.gemspec
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
|
-
s.name
|
3
|
-
s.version
|
4
|
-
s.license
|
5
|
-
s.summary
|
6
|
-
s.description
|
7
|
-
s.
|
8
|
-
s.
|
9
|
-
s.
|
10
|
-
|
11
|
-
|
2
|
+
s.name = 'go4rake'
|
3
|
+
s.version = '1.0.8'
|
4
|
+
s.license = 'Apache-2.0'
|
5
|
+
s.summary = 'go4rake is a Rake helper for cross-compiling Go programs'
|
6
|
+
s.description = '`build`, `test` and `zip` tasks for cross-compilation of Go programs'
|
7
|
+
s.homepage = 'https://github.com/chillum/go4rake'
|
8
|
+
s.author = 'Vasily Korytov'
|
9
|
+
s.email = 'vasily.korytov@yahoo.com'
|
10
|
+
s.files = ['LICENSE.txt', 'README.md', 'examples/go4rake.yml',
|
11
|
+
'go4rake.gemspec', 'lib/go4rake.rb', 'lib/go4rake/new.rb']
|
12
|
+
s.add_dependency 'rake', '~> 10.0'
|
12
13
|
end
|
data/lib/go4rake/new.rb
CHANGED
@@ -26,20 +26,21 @@ require 'yaml'
|
|
26
26
|
#
|
27
27
|
# Offline copies of README and example config are also included in this gem.
|
28
28
|
class Go4Rake < ::Rake::TaskLib
|
29
|
-
attr_reader :yml
|
30
29
|
# Initialize Rake tasks for cross-compiling Go programs.
|
31
30
|
def initialize(yml = 'go4rake.yml')
|
32
31
|
# `build` and `zip` depend on config, `test` doesn't.
|
33
32
|
begin
|
34
|
-
@config = YAML.load_file
|
33
|
+
@config = YAML.load_file(yml)
|
35
34
|
|
36
35
|
desc "Build this project for the platforms in #{yml}"
|
37
36
|
task :build do
|
38
37
|
@config['platforms'].each { |os|
|
39
38
|
if os['arch'].respond_to?('each')
|
40
|
-
os['arch'].each { |arch|
|
39
|
+
os['arch'].each { |arch|
|
40
|
+
build(os['name'], arch)
|
41
|
+
}
|
41
42
|
else
|
42
|
-
build
|
43
|
+
build(os['name'], os['arch'])
|
43
44
|
end
|
44
45
|
}
|
45
46
|
end
|
@@ -50,47 +51,46 @@ class Go4Rake < ::Rake::TaskLib
|
|
50
51
|
|
51
52
|
@config['platforms'].each { |os|
|
52
53
|
if os['arch'].respond_to?('each')
|
53
|
-
os['arch'].each { |arch|
|
54
|
-
"#{os['zip']}_#{arch}" : "#{os['name']}_#{arch}"
|
54
|
+
os['arch'].each { |arch|
|
55
|
+
zip(os['name'], arch, @config['out'], os['zip'] ? "#{os['zip']}_#{arch}" : "#{os['name']}_#{arch}")
|
56
|
+
}
|
55
57
|
else
|
56
|
-
zip
|
58
|
+
zip(os['name'], os['arch'], @config['out'], os['zip'] || "#{os['name']}_#{os['arch']}")
|
57
59
|
end
|
58
60
|
}
|
59
61
|
end
|
60
62
|
rescue => e
|
61
|
-
$stderr.puts
|
63
|
+
$stderr.puts("WARNING: Skipping `build` and `zip` tasks: #{e}")
|
62
64
|
end
|
63
65
|
|
64
66
|
desc 'Run `go test` for the native platform'
|
65
67
|
task :test do
|
66
|
-
setenv
|
67
|
-
system
|
68
|
+
setenv(nil, nil)
|
69
|
+
system('go test') || die('Tests')
|
68
70
|
end
|
69
71
|
end
|
70
72
|
|
71
73
|
# Sets GOARCH and GOOS.
|
72
|
-
def setenv
|
74
|
+
def setenv(os, arch)
|
73
75
|
ENV['GOARCH'] = arch ? arch.to_s : nil
|
74
76
|
ENV['GOOS'] = os
|
75
77
|
end
|
76
78
|
|
77
79
|
# Exits with an error.
|
78
|
-
def die
|
79
|
-
abort
|
80
|
+
def die(task)
|
81
|
+
abort("#{task} failed. Exiting") # Rake returns 1 in something fails.
|
80
82
|
end
|
81
83
|
|
82
84
|
# Executes `go install` for the specified os/arch.
|
83
|
-
def build
|
84
|
-
setenv
|
85
|
-
puts
|
86
|
-
system
|
85
|
+
def build(os, arch)
|
86
|
+
setenv(os, arch)
|
87
|
+
puts("Building #{os}_#{arch}")
|
88
|
+
system('go install') || die('Build')
|
87
89
|
end
|
88
90
|
|
89
91
|
# Zips the compiled files.
|
90
|
-
def zip
|
91
|
-
setenv
|
92
|
-
|
93
|
-
puts "Wrote #{dir}/#{file}.zip"
|
94
|
-
end
|
92
|
+
def zip(os, arch, dir, file)
|
93
|
+
setenv(os, arch)
|
94
|
+
system("zip -qj #{dir}/#{file}.zip #{`go list -f '{{.Target}}'`}") && puts("Wrote #{dir}/#{file}.zip")
|
95
95
|
end
|
96
96
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
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.8
|
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-
|
12
|
-
dependencies:
|
11
|
+
date: 2014-11-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '10.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '10.0'
|
13
27
|
description: "`build`, `test` and `zip` tasks for cross-compilation of Go programs"
|
14
28
|
email: vasily.korytov@yahoo.com
|
15
29
|
executables: []
|