gem-ext-zig_builder 0.1.0 → 0.2.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 +4 -4
- data/lib/gem/ext/zig_builder/version.rb +1 -1
- data/lib/gem/ext/zig_builder.rb +40 -35
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55b4bf2fe202be13789c3afbc3fc71d515d49f56b08b92720cd882ebed52d13d
|
4
|
+
data.tar.gz: 7fee2a3b6f222b25ce72b95275cdb8be2b2c61ca0948a44ae12f4d5098649e77
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38802825ac0b746613ef0fba7447db7cda21879eaef100307689a083e3f05640ccea6adce95f2805b0d5ce2af2150fc1a21a06b1b769a0f2875c060a62cba970
|
7
|
+
data.tar.gz: 570fd46fc68606563c097b858e763ea92564d3189e6bba9f43971ea591403bd4561033fbe073afafd5318d16b2c5d095abf672a0e45119b0d30f7f949e6aaf54
|
data/lib/gem/ext/zig_builder.rb
CHANGED
@@ -4,49 +4,54 @@ require 'rubygems/ext/builder'
|
|
4
4
|
require 'rubygems/command'
|
5
5
|
require 'shellwords'
|
6
6
|
require 'rbconfig'
|
7
|
+
require 'tmpdir'
|
7
8
|
|
8
|
-
class Gem::Ext::Builder
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
Gem::Ext::ExtConfBuilder
|
13
|
-
when /configure/ then
|
14
|
-
Gem::Ext::ConfigureBuilder
|
15
|
-
when /rakefile/i, /mkrf_conf/i then
|
16
|
-
@ran_rake = true
|
17
|
-
Gem::Ext::RakeBuilder
|
18
|
-
when /CMakeLists.txt/ then
|
19
|
-
Gem::Ext::CmakeBuilder
|
20
|
-
when /build.zig/ then
|
21
|
-
Gem::Ext::ZigBuilder
|
22
|
-
else
|
23
|
-
extension_dir = File.join @gem_dir, File.dirname(extension)
|
24
|
-
|
25
|
-
message = "No builder for extension '#{extension}'"
|
26
|
-
build_error extension_dir, message
|
9
|
+
class Gem::Ext::ZigBuilder < Gem::Ext::Builder
|
10
|
+
module PatchBuilderLookup
|
11
|
+
def builder_for(extension)
|
12
|
+
/build.zig/ === extension ? Gem::Ext::ZigBuilder : super
|
27
13
|
end
|
28
14
|
end
|
29
|
-
end
|
30
15
|
|
31
|
-
class Gem::Ext::ZigBuilder < Gem::Ext::Builder
|
32
16
|
def self.build(extension, dest_path, results, args=[], lib_dir=nil, extension_dir=nil)
|
17
|
+
tmp_dir = Dir.mktmpdir
|
18
|
+
dlext = RbConfig::CONFIG['DLEXT']
|
19
|
+
target_vendor = RbConfig::CONFIG['target_vendor']
|
20
|
+
pkg_config_path = "#{RbConfig::CONFIG['libdir']}/pkgconfig"
|
21
|
+
ruby_pc = "#{File.basename(RbConfig::CONFIG['ruby_pc'], '.pc')}"
|
22
|
+
|
23
|
+
cmd = [].tap {|c|
|
24
|
+
c << 'zig' << 'build' << '-Doptimize=ReleaseSafe'
|
25
|
+
c << '--prefix-lib-dir' << tmp_dir
|
26
|
+
c << 'test' << 'install'
|
27
|
+
}
|
28
|
+
|
33
29
|
# older versions of ruby do not support the 5th `env` argument to run,
|
34
30
|
# so pollute the global ENV as a cheap workaround
|
35
|
-
ENV['PKG_CONFIG_PATH'] =
|
36
|
-
ENV['RUBY_PC' ] =
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
31
|
+
ENV['PKG_CONFIG_PATH'] = pkg_config_path
|
32
|
+
ENV['RUBY_PC' ] = ruby_pc
|
33
|
+
|
34
|
+
# even older versions of ruby do not support the 4th extension_dir arg
|
35
|
+
Dir.chdir(extension_dir ? extension_dir : '.') do
|
36
|
+
run(cmd, results, 'zig')
|
37
|
+
end
|
38
|
+
|
39
|
+
Dir.chdir tmp_dir do
|
40
|
+
if target_vendor == 'apple' && dlext == 'bundle'
|
41
|
+
Dir.glob('*.dylib').each do |dylib|
|
42
|
+
FileUtils.mv dylib, "#{File.basename(dylib, '.dylib')}.bundle"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
FileUtils.mv Dir.glob("*.#{dlext}"), dest_path
|
47
|
+
end
|
49
48
|
|
50
49
|
results
|
50
|
+
ensure
|
51
|
+
FileUtils.remove_entry tmp_dir if tmp_dir
|
51
52
|
end
|
52
53
|
end
|
54
|
+
|
55
|
+
class Gem::Ext::Builder
|
56
|
+
prepend Gem::Ext::ZigBuilder::PatchBuilderLookup
|
57
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gem-ext-zig_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank J. Cameron
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ''
|
14
14
|
email:
|