go4rake 1.5.2 → 1.5.8

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 (6) hide show
  1. checksums.yaml +5 -5
  2. data/NOTICE +1 -1
  3. data/README.md +2 -1
  4. data/lib/go4rake.rb +2 -0
  5. data/lib/go4rake/new.rb +154 -137
  6. metadata +26 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 3304d331b22198bb7e65b9c7ec25ddda9c0c34b3
4
- data.tar.gz: 875655832ca36c0d2e4a6d3d3420fb79460057c8
2
+ SHA256:
3
+ metadata.gz: 2d1a32828da5d99c21b33c9b3816a9eff3c34ddba43538c601300a61e28deb9c
4
+ data.tar.gz: d17cdd8691aa2977bfc9c72f2a837e6a026cde64f93f6a52c9923773b979b326
5
5
  SHA512:
6
- metadata.gz: b049812096d5ca2d33d5aa991bf8d7c44a27ea77cf0d09494d7ed80b8220752f23562a0212f4fa8f8655fba60a59098e588d10f90a08f6f3ebbb316ab4db5551
7
- data.tar.gz: 191e581a5afb73d7d59b50bc7e09addb358a93b0abcdd8865160c90fd182f4f2ef7b992301c19e9551d45973696c5c4fe7249d62aeb1a65821ac05f59e3837fe
6
+ metadata.gz: 45cb5d210da807689d94cf1423359b0ed011c98dfaac666f4ebdbab989f0bcc48548761f4d662e9274cdd170e29098bd9ffab9bd91760918fbc3e0125ed38be9
7
+ data.tar.gz: 53c4ed4a9fca37675a6efc1ebd7ce846a751985a2a7f5bdf7dc069c40d7f892a14f9643f45a432cc7343d01a367fcba51cdaf4fcc24af53c5406a351d2ed645a
data/NOTICE CHANGED
@@ -1,6 +1,6 @@
1
1
  go4rake: https://github.com/chillum/go4rake
2
2
 
3
- Copyright 2014-2016 Vasily Korytov
3
+ Copyright 2014-2019 Vasily Korytov
4
4
 
5
5
  Licensed under the Apache License, Version 2.0 (the "License");
6
6
  you may not use this software except in compliance with the License.
data/README.md CHANGED
@@ -50,7 +50,8 @@ These files will be also included into the ZIP files:
50
50
  Please note that:
51
51
 
52
52
  * If `out` is specified, ZIP files will appear in the specified
53
- directory; if not, they will be in `~/Downloads`.
53
+ directory; if not, they will be in `~/Downloads`.
54
+ Prior to 1.5.2 the default value was `.`
54
55
  * Also please note that current files with the same names as your targets are overwritten.
55
56
  * If `files` are not specified, a `NOTICE` file will be included in ZIP
56
57
  files, if it's found in the project directory
data/lib/go4rake.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'go4rake/new'
2
4
 
3
5
  Go4Rake.new
data/lib/go4rake/new.rb CHANGED
@@ -1,137 +1,154 @@
1
- require 'rake/tasklib'
2
- require 'yaml'
3
- require 'zip'
4
- require 'zip/filesystem'
5
-
6
- # Rake tasks to cross-compile Go project and ZIP the binaries:
7
- # `rake build`, `rake zip`, `rake test` and `rake clean`.
8
- #
9
- # Usage: `require 'go4rake'` in `Rakefile`. Settings are specified in a YAML file: `go4rake.yml`.
10
- #
11
- # Example config: https://github.com/chillum/go4rake/blob/master/examples/go4rake.yml
12
- #
13
- # Docs: https://github.com/chillum/go4rake/blob/master/README.md
14
- #
15
- # Offline copies of README and example config are also included in this gem.
16
- #
17
- class Go4Rake < ::Rake::TaskLib
18
- # Load configuration file and initialize Rake tasks for cross-compiling Go programs.
19
- def initialize(yml = 'go4rake.yml')
20
- begin
21
- @config = YAML.load_file(yml)
22
- @config['out'] ||= '~/Downloads' # Default to ~/Downloads, if 'out' is not specified.
23
- tasks(@config, yml)
24
- rescue => e
25
- $stderr.puts("WARNING: Skipping `build` and `zip` tasks: #{e}")
26
- end
27
- # `build`, `zip` and `clean` depend on config, `test` doesn't.
28
- task_test
29
- end
30
-
31
- # Initialize `build`, `zip` and `clean` tasks.
32
- def tasks(cfg, yml)
33
- desc "Build this project for the platforms in #{yml}"
34
- task :build do
35
- cfg['platforms'].each { |os|
36
- if os['arch'].respond_to?('each')
37
- os['arch'].each { |arch|
38
- build(os['name'], arch)
39
- }
40
- else
41
- build(os['name'], os['arch'])
42
- end
43
- }
44
- end
45
-
46
- desc 'ZIP this project binaries'
47
- task zip: [:build, :test] do
48
-
49
- cfg['platforms'].each { |os|
50
- if os['arch'].respond_to?('each')
51
- os['arch'].each { |arch|
52
- zip(os['name'], arch, cfg['out'], cfg['files'],
53
- os['zip'] ? "#{os['zip']}_#{arch}" : "#{os['name']}_#{arch}")
54
- }
55
- else
56
- zip(os['name'], os['arch'], cfg['out'], cfg['files'],
57
- os['zip'] || "#{os['name']}_#{os['arch']}")
58
- end
59
- }
60
- end
61
-
62
- desc 'Delete ZIP files'
63
- task :clean do
64
- cfg['platforms'].each { |os|
65
- if os['arch'].respond_to?('each')
66
- os['arch'].each { |arch|
67
- clean(cfg['out'], os['zip'] ? "#{os['zip']}_#{arch}" : "#{os['name']}_#{arch}")
68
- }
69
- else
70
- clean(cfg['out'], os['zip'] || "#{os['name']}_#{os['arch']}")
71
- end
72
- }
73
- end
74
- end
75
-
76
- # Initialize `test` task.
77
- def task_test
78
- desc 'Run `go test` for the native platform'
79
- task :test do
80
- setenv(nil, nil)
81
- system('go test') || die('Tests')
82
- end
83
- end
84
-
85
- # Set GOARCH and GOOS.
86
- def setenv(os, arch)
87
- ENV['GOARCH'] = arch ? arch.to_s : nil
88
- ENV['GOOS'] = os
89
- end
90
-
91
- # Exit with an error.
92
- def die(task)
93
- abort("#{task} failed. Exiting") # Rake returns 1 in something fails.
94
- end
95
-
96
- # Execute `go install` for the specified os/arch.
97
- def build(os, arch)
98
- setenv(os, arch)
99
- puts("Building #{os}_#{arch}")
100
- system('go install') || die('Build')
101
- end
102
-
103
- # Zip the compiled files.
104
- def zip(os, arch, dir, files, file)
105
- setenv(os, arch)
106
- bin = `go list -f '{{.Target}}'`.chomp
107
- return unless bin
108
- zip_file = File.expand_path(dir) + '/' + file + '.zip'
109
- name = File.basename(bin)
110
- unless files
111
- files = []
112
- # `NOTICE` file is required by Apache license.
113
- files.push('NOTICE') if File.exist?('NOTICE')
114
- end
115
-
116
- File.delete(zip_file) if File.exist?(zip_file)
117
- Zip::File.open(zip_file, Zip::File::CREATE) do |zip|
118
- [*files].each { |i|
119
- t = File.basename(i)
120
- zip.add(t, i)
121
- }
122
-
123
- # The executable file.
124
- zip.add(name, bin)
125
- zip.file.chmod(0755, name)
126
- end
127
- puts("Wrote #{zip_file}")
128
- end
129
-
130
- # Remove the ZIP file (specify path and basename).
131
- def clean(dir, file)
132
- zip_file = File.expand_path(dir) + '/' + file + '.zip'
133
- return unless File.exist?(zip_file)
134
- puts("Removing #{zip_file}")
135
- File.delete(zip_file)
136
- end
137
- end
1
+ # frozen_string_literal: true
2
+
3
+ require 'rake/tasklib'
4
+ require 'yaml'
5
+ require 'zip/filesystem'
6
+
7
+ # Rake tasks to cross-compile Go project and ZIP the binaries:
8
+ # `rake build`, `rake zip`, `rake test` and `rake clean`.
9
+ #
10
+ # Usage: `require 'go4rake'` in `Rakefile`. Settings are specified in a YAML file: `go4rake.yml`.
11
+ #
12
+ # Example config: https://github.com/chillum/go4rake/blob/master/examples/go4rake.yml
13
+ #
14
+ # Docs: https://github.com/chillum/go4rake/blob/master/README.md
15
+ #
16
+ # Offline copies of README and example config are also included in this gem.
17
+ #
18
+ class Go4Rake < ::Rake::TaskLib
19
+ # Load configuration file and initialize Rake tasks for cross-compiling Go programs.
20
+ def initialize(yml = 'go4rake.yml')
21
+ super()
22
+ begin
23
+ @yaml_file = yml
24
+ @config = YAML.load_file(@yaml_file)
25
+ @config['out'] ||= '~/Downloads' # Default to ~/Downloads, if 'out' is not specified.
26
+
27
+ init_tasks
28
+ rescue(Errno::ENOENT) => e
29
+ warn "WARNING: Skipping `build` and `zip` tasks: #{e}"
30
+ end
31
+ # `build`, `zip` and `clean` depend on config, `test` doesn't.
32
+ task_test
33
+ end
34
+
35
+ private
36
+
37
+ def init_tasks
38
+ task_build
39
+ task_zip
40
+ task_clean
41
+ end
42
+
43
+ # Initialize `build`, `zip` and `clean` tasks.
44
+ def task_build
45
+ desc "Build this project for the platforms in #{@yaml_file}"
46
+ task :build do
47
+ @config['platforms'].each { |os|
48
+ if os['arch'].respond_to?('each')
49
+ os['arch'].each { |arch|
50
+ build(os['name'], arch)
51
+ }
52
+ else
53
+ build(os['name'], os['arch'])
54
+ end
55
+ }
56
+ end
57
+ end
58
+
59
+ def task_zip
60
+ desc 'ZIP this project binaries'
61
+ task zip: %i[build test] do
62
+ @config['platforms'].each { |os|
63
+ if os['arch'].respond_to?('each')
64
+ os['arch'].each { |arch|
65
+ zip(os['name'], arch, @config['out'], @config['files'],
66
+ os['zip'] ? "#{os['zip']}_#{arch}" : "#{os['name']}_#{arch}")
67
+ }
68
+ else
69
+ zip(os['name'], os['arch'], @config['out'], @config['files'],
70
+ os['zip'] || "#{os['name']}_#{os['arch']}")
71
+ end
72
+ }
73
+ end
74
+ end
75
+
76
+ def task_clean
77
+ desc 'Delete ZIP files'
78
+ task :clean do
79
+ @config['platforms'].each { |os|
80
+ if os['arch'].respond_to?('each')
81
+ os['arch'].each { |arch|
82
+ clean(@config['out'], os['zip'] ? "#{os['zip']}_#{arch}" : "#{os['name']}_#{arch}")
83
+ }
84
+ else
85
+ clean(@config['out'], os['zip'] || "#{os['name']}_#{os['arch']}")
86
+ end
87
+ }
88
+ end
89
+ end
90
+
91
+ # Initialize `test` task.
92
+ def task_test
93
+ desc 'Run `go test` for the native platform'
94
+ task :test do
95
+ setenv(nil, nil)
96
+ system('go test') || die('Tests')
97
+ end
98
+ end
99
+
100
+ # Set GOARCH and GOOS.
101
+ def setenv(os, arch)
102
+ ENV['GOARCH'] = arch ? arch.to_s : nil
103
+ ENV['GOOS'] = os
104
+ end
105
+
106
+ # Exit with an error.
107
+ def die(task)
108
+ abort("#{task} failed. Exiting") # Rake returns 1 in something fails.
109
+ end
110
+
111
+ # Execute `go install` for the specified os/arch.
112
+ def build(os, arch)
113
+ setenv(os, arch)
114
+ puts("Building #{os}_#{arch}")
115
+ system('go install') || die('Build')
116
+ end
117
+
118
+ # Zip the compiled files.
119
+ def zip(os, arch, dir, files, file)
120
+ setenv(os, arch)
121
+ bin = `go list -f '{{.Target}}'`.chomp.delete_prefix("'").delete_suffix("'")
122
+ return unless bin
123
+
124
+ zip_file = "#{File.expand_path(dir)}/#{file}.zip"
125
+ name = File.basename(bin)
126
+ unless files
127
+ files = []
128
+ # `NOTICE` file is required by Apache license.
129
+ files.push('NOTICE') if File.exist?('NOTICE')
130
+ end
131
+
132
+ File.delete(zip_file) if File.exist?(zip_file)
133
+ Zip::File.open(zip_file, Zip::File::CREATE) do |zip|
134
+ [*files].each { |i|
135
+ t = File.basename(i)
136
+ zip.add(t, i)
137
+ }
138
+
139
+ # The executable file.
140
+ zip.add(name, bin)
141
+ zip.file.chmod(0o755, name)
142
+ end
143
+ puts("Wrote #{zip_file}")
144
+ end
145
+
146
+ # Remove the ZIP file (specify path and basename).
147
+ def clean(dir, file)
148
+ zip_file = "#{File.expand_path(dir)}/#{file}.zip"
149
+ return unless File.exist?(zip_file)
150
+
151
+ puts("Removing #{zip_file}")
152
+ File.delete(zip_file)
153
+ end
154
+ end
metadata CHANGED
@@ -1,46 +1,52 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: go4rake
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.2
4
+ version: 1.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vasily Korytov
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-15 00:00:00.000000000 Z
11
+ date: 2021-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '10.0'
19
+ version: '10'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '14'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - ~>
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '10'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: '10.0'
32
+ version: '14'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: rubyzip
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - ~>
37
+ - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: '1.2'
39
+ version: '2.0'
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
- - - ~>
44
+ - - "~>"
39
45
  - !ruby/object:Gem::Version
40
- version: '1.2'
41
- description: '`build`, `zip, `test`` and `clean` tasks for cross-compilation of Go
42
- programs'
43
- email: vasily.korytov@icloud.com
46
+ version: '2.0'
47
+ description: "`build`, `zip, `test`` and `clean` tasks for cross-compilation of Go
48
+ programs"
49
+ email: v.korytov@outlook.com
44
50
  executables: []
45
51
  extensions: []
46
52
  extra_rdoc_files: []
@@ -54,24 +60,23 @@ homepage: https://github.com/chillum/go4rake
54
60
  licenses:
55
61
  - Apache-2.0
56
62
  metadata: {}
57
- post_install_message:
63
+ post_install_message:
58
64
  rdoc_options: []
59
65
  require_paths:
60
66
  - lib
61
67
  required_ruby_version: !ruby/object:Gem::Requirement
62
68
  requirements:
63
- - - '>='
69
+ - - ">="
64
70
  - !ruby/object:Gem::Version
65
- version: 1.9.2
71
+ version: '2.5'
66
72
  required_rubygems_version: !ruby/object:Gem::Requirement
67
73
  requirements:
68
- - - '>='
74
+ - - ">="
69
75
  - !ruby/object:Gem::Version
70
76
  version: '0'
71
77
  requirements: []
72
- rubyforge_project:
73
- rubygems_version: 2.0.14.1
74
- signing_key:
78
+ rubygems_version: 3.2.3
79
+ signing_key:
75
80
  specification_version: 4
76
81
  summary: Rake helper for cross-compiling Go programs
77
82
  test_files: []