rubygems-build-binary 0.0.1
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 +7 -0
- data/LICENSE +20 -0
- data/README.md +33 -0
- data/Rakefile +20 -0
- data/lib/rubygems/commands/build_binary_command.rb +99 -0
- data/lib/rubygems-build-binary/version.rb +3 -0
- data/lib/rubygems_plugin.rb +3 -0
- metadata +48 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a6204175c51b60b521a2bde34b56e0605961544da17007e80ef1ea8be0594769
|
|
4
|
+
data.tar.gz: 37723691a4f32907f8c3877281c79fb348abb84fc5eb2ae4ab2e2f52a0e9d68d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: d2e686e4af43fd10eb77435caa881361a15de6a8321c6546aa8115e667f96d55fdce0db21cf86804c0dfa59dfda950902680e2a7532caf063f0e2c4441975464
|
|
7
|
+
data.tar.gz: 1d6e23364f06e70df65c5d2e92df2ba7a02c4d65aa65a619fe368a5b6e6d21e0cd612e9ec3558ad5f735e6aeca8da0f5a99a4c1d919b87255ff4bd4960f18867
|
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2026 RUBY-GNOME Project Team
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
'Software'), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# rubygems-build-binary
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
This is a RubyGems plugin. This adds `build_binary` `gem` sub command
|
|
6
|
+
that builds a binary gem for the current Ruby and platform from a
|
|
7
|
+
source (`ruby` platform) gem.
|
|
8
|
+
|
|
9
|
+
## How to use
|
|
10
|
+
|
|
11
|
+
Install `rubygems-build-binary` gem:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
gem install rubygems-build-binary
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Build a binary gem from a source gem:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
gem fetch cairo
|
|
21
|
+
gem build_binary cairo-*.gem
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
It builds `cairo-X.Y.Z-x86_64-linux.gem` that includes built binaries
|
|
25
|
+
for the current Ruby and platform.
|
|
26
|
+
|
|
27
|
+
## Motivation
|
|
28
|
+
|
|
29
|
+
...
|
|
30
|
+
|
|
31
|
+
## License
|
|
32
|
+
|
|
33
|
+
MIT. See [LICENSE](LICENSE) for details.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# -*- ruby -*-
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_helper"
|
|
4
|
+
|
|
5
|
+
base_dir = File.dirname(__FILE__)
|
|
6
|
+
helper = Bundler::GemHelper.new(base_dir)
|
|
7
|
+
def helper.version_tag
|
|
8
|
+
version
|
|
9
|
+
end
|
|
10
|
+
helper.install
|
|
11
|
+
|
|
12
|
+
release_task = Rake.application["release"]
|
|
13
|
+
# We use Trusted Publishing.
|
|
14
|
+
release_task.prerequisites.delete("build")
|
|
15
|
+
release_task.prerequisites.delete("release:rubygem_push")
|
|
16
|
+
release_task_comment = release_task.comment
|
|
17
|
+
if release_task_comment
|
|
18
|
+
release_task.clear_comments
|
|
19
|
+
release_task.comment = release_task_comment.gsub(/ and build.*$/, "")
|
|
20
|
+
end
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
require "fileutils"
|
|
2
|
+
require "tmpdir"
|
|
3
|
+
|
|
4
|
+
require "rubygems/dependency_installer"
|
|
5
|
+
|
|
6
|
+
class Gem::Commands::BuildBinaryCommand < Gem::Command
|
|
7
|
+
def initialize
|
|
8
|
+
super("build_binary", "Build a binary gem for the current platform")
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def arguments
|
|
12
|
+
"GEM_FILE source gem file to build"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def description
|
|
16
|
+
"Build binary gem"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def usage
|
|
20
|
+
"#{program_name} GEM_FILE"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def execute
|
|
24
|
+
gem_file, = options[:args]
|
|
25
|
+
Dir.mktmpdir do |dir|
|
|
26
|
+
options[:install_dir] = dir
|
|
27
|
+
|
|
28
|
+
name, version = install_gem(gem_file)
|
|
29
|
+
|
|
30
|
+
spec_path = File.join(dir, "specifications", "#{name}-#{version}.gemspec")
|
|
31
|
+
spec = Gem::Specification.load(spec_path)
|
|
32
|
+
|
|
33
|
+
dist_dir = File.join(dir, "dist")
|
|
34
|
+
adjust_spec(spec, dist_dir)
|
|
35
|
+
|
|
36
|
+
rebuild_gem(spec,
|
|
37
|
+
dist_dir,
|
|
38
|
+
"#{name}-#{version}-#{Gem::Platform.local}.gem")
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
def install_gem(gem_file)
|
|
44
|
+
dependency_installer = Gem::DependencyInstaller.new(options)
|
|
45
|
+
requirement = Gem::Requirement.create(nil)
|
|
46
|
+
request_set = dependency_installer.resolve_dependencies(gem_file,
|
|
47
|
+
requirement)
|
|
48
|
+
request_set.install(options)
|
|
49
|
+
|
|
50
|
+
name = request_set.dependencies[0].name
|
|
51
|
+
version = request_set.dependencies[0].requirement.requirements[0][1]
|
|
52
|
+
[name, version]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def adjust_spec(spec, dist_dir)
|
|
56
|
+
# gems/#{name}-#{version}/ ->
|
|
57
|
+
# dist/
|
|
58
|
+
FileUtils.cp_r(spec.gem_dir, dist_dir)
|
|
59
|
+
|
|
60
|
+
# extensions/#{platform}/#{ruby_api_version}/#{name}-#{version}/ ->
|
|
61
|
+
# dist/extension/#{platform}/#{ruby_api_version}/
|
|
62
|
+
base_extension_dir = File.join("extension",
|
|
63
|
+
Gem::Platform.local.to_s,
|
|
64
|
+
Gem.extension_api_version)
|
|
65
|
+
dist_extension_dir = File.join(dist_dir, base_extension_dir)
|
|
66
|
+
FileUtils.mkdir_p(File.dirname(dist_extension_dir))
|
|
67
|
+
FileUtils.cp_r(spec.extension_dir, dist_extension_dir)
|
|
68
|
+
|
|
69
|
+
# Use all files.
|
|
70
|
+
paths = Dir.glob("**/*", File::FNM_DOTMATCH, base: dist_dir)
|
|
71
|
+
paths.reject! do |path|
|
|
72
|
+
File.directory?(File.join(dist_dir, path))
|
|
73
|
+
end
|
|
74
|
+
spec.files = paths
|
|
75
|
+
|
|
76
|
+
# We don't need to build extension.
|
|
77
|
+
spec.extensions.clear
|
|
78
|
+
# Add binary directory to require paths.
|
|
79
|
+
spec.require_paths.unshift(base_extension_dir)
|
|
80
|
+
# Use the current platform.
|
|
81
|
+
spec.platform = Gem::Platform.local
|
|
82
|
+
# Available only for the current Ruby.
|
|
83
|
+
spec.required_ruby_version = required_ruby_version
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def required_ruby_version
|
|
87
|
+
major, minor = Gem.ruby_version.to_s.split(".")[0, 2]
|
|
88
|
+
start_version = "#{major}.#{minor}.0"
|
|
89
|
+
end_version = "#{major}.#{minor.next}.0.dev"
|
|
90
|
+
Gem::Requirement.new([">= #{start_version}", "< #{end_version}"])
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def rebuild_gem(spec, dist_dir, output_path)
|
|
94
|
+
output_path = File.expand_path(output_path)
|
|
95
|
+
Dir.chdir(dist_dir) do
|
|
96
|
+
Gem::Package.build(spec, true, false, output_path)
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rubygems-build-binary
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Sutou Kouhei
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: |-
|
|
13
|
+
`gem build_binary` builds a binary gem for the current Ruby and platform
|
|
14
|
+
from a source (`platform == ruby`) gem.
|
|
15
|
+
email:
|
|
16
|
+
- kou@clear-code.com
|
|
17
|
+
executables: []
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- LICENSE
|
|
22
|
+
- README.md
|
|
23
|
+
- Rakefile
|
|
24
|
+
- lib/rubygems-build-binary/version.rb
|
|
25
|
+
- lib/rubygems/commands/build_binary_command.rb
|
|
26
|
+
- lib/rubygems_plugin.rb
|
|
27
|
+
homepage: https://github.com/ruby-gnome/rubygems-build-binary
|
|
28
|
+
licenses:
|
|
29
|
+
- MIT
|
|
30
|
+
metadata: {}
|
|
31
|
+
rdoc_options: []
|
|
32
|
+
require_paths:
|
|
33
|
+
- lib
|
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '0'
|
|
44
|
+
requirements: []
|
|
45
|
+
rubygems_version: 4.0.3
|
|
46
|
+
specification_version: 4
|
|
47
|
+
summary: RubyGems plugin that adds `gem build_binary` sub command
|
|
48
|
+
test_files: []
|