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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/go4rake.gemspec +1 -1
  4. data/lib/go4rake.rb +67 -67
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58970731ad3e47bbb64c07be38d665f7e4fc9bc0
4
- data.tar.gz: 6bffff0cf8f6735924e35c22aca935019c983737
3
+ metadata.gz: 83d3706eb1603d1a3de8f8414b9d265e9bf062dc
4
+ data.tar.gz: 061c07b8591eab664d3492afef2490697996cf46
5
5
  SHA512:
6
- metadata.gz: 3863d7477e98c178d9e881e44db2497fae3da06e94f63b3a9e5e874ab194f134b4b14496842f8470eced50d786a57b72f2b889090b8bf5375a44074bc8c60542
7
- data.tar.gz: a1f4a8ac0f62d483fbf4424c52d80e1e8d4b89772b49e3eee64a589f32fa4f381ba29866bf1a4f4c9b14444382e715091b993d82563bcd4bcb2597582146ed9b
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 is.
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.1'
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
- class Go4Rake
30
- class RakeTask < ::Rake::TaskLib
31
- def initialize(*args)
32
-
33
- begin
34
- yml = 'go4rake.yml'
35
- config = YAML.load_file yml
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
- desc "Build this project for the platforms in #{yml}"
38
- task :build do
39
- config['platforms'].each { |os|
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
- desc 'ZIP this project binaries'
49
- task :zip => [:build, :test] do
50
- unless config['out']
51
- config['out'] = '.' # Default to the current directory, if 'out' is not specified.
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
- config['platforms'].each { |os|
55
- if os['arch'].respond_to?('each')
56
- os['arch'].each { |arch| zip os['name'], arch, config['out'], os['zip'] ? \
57
- "#{os['zip']}_#{arch}" : "#{os['name']}_#{arch}" }
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
- desc 'Run `go test` for the native platform'
68
- task :test do
69
- setenv nil, nil
70
- unless system('go test'); die 'Tests' end
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
- def setenv os, arch
74
- ENV['GOARCH'] = arch ? arch.to_s : nil
75
- ENV['GOOS'] = os
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
- def die task
79
- puts "#{task} failed. Exiting"
80
- exit 1 # Rake returns 1 if something fails.
81
- end
74
+ def setenv os, arch
75
+ ENV['GOARCH'] = arch ? arch.to_s : nil
76
+ ENV['GOOS'] = os
77
+ end
82
78
 
83
- def build os, arch
84
- setenv os, arch
85
- puts "Building #{os}_#{arch}"
86
- unless system('go install'); die 'Build' end
87
- end
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
- def zip os, arch, dir, file
90
- setenv os, arch
90
+ def zip os, arch, dir, file
91
+ setenv os, arch
91
92
 
92
- if system("zip -qj #{dir}/#{file}.zip #{`go list -f '{{.Target}}'`}")
93
- puts "Wrote #{dir}/#{file}.zip"
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::RakeTask.new
101
+ Go4Rake.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: go4rake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasily Korytov