go4rake 1.5.2 → 1.5.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/NOTICE +1 -1
- data/README.md +2 -1
- data/lib/go4rake.rb +2 -0
- data/lib/go4rake/new.rb +154 -137
- metadata +26 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2d1a32828da5d99c21b33c9b3816a9eff3c34ddba43538c601300a61e28deb9c
|
4
|
+
data.tar.gz: d17cdd8691aa2977bfc9c72f2a837e6a026cde64f93f6a52c9923773b979b326
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45cb5d210da807689d94cf1423359b0ed011c98dfaac666f4ebdbab989f0bcc48548761f4d662e9274cdd170e29098bd9ffab9bd91760918fbc3e0125ed38be9
|
7
|
+
data.tar.gz: 53c4ed4a9fca37675a6efc1ebd7ce846a751985a2a7f5bdf7dc069c40d7f892a14f9643f45a432cc7343d01a367fcba51cdaf4fcc24af53c5406a351d2ed645a
|
data/NOTICE
CHANGED
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
data/lib/go4rake/new.rb
CHANGED
@@ -1,137 +1,154 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
|
6
|
-
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
end
|
72
|
-
}
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
end
|
90
|
-
|
91
|
-
#
|
92
|
-
def
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
zip_file
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
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.
|
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:
|
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
|
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: '
|
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: '
|
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: '
|
41
|
-
description:
|
42
|
-
programs
|
43
|
-
email:
|
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:
|
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
|
-
|
73
|
-
|
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: []
|