gem-ext-zig_builder 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e6419f1ac0a59e19c259a8efce1fbef996083eb8489f6e76e8ed9a73ee7f3a36
4
+ data.tar.gz: d5754f2f5ed48b0faebc888aa675531a9c99ec815f6ed67386a8ebc8d9b8a4d9
5
+ SHA512:
6
+ metadata.gz: 3c625b25dff418ecaefac4aaed38441ae96f669bab96476e3ab7e2ae1538bffb85bdf743044b8d9260ec8ee363857d631004140730d3a9b8769924b5882956e2
7
+ data.tar.gz: 1af95db95f3f24293804ca784dc14948c9daeda2dbb649c4a9590b122487c2ab9cda6eb58f3e7f0acd35212e90eedc71ac40a96fbec27a4a48b2f37163a8681c
@@ -0,0 +1,8 @@
1
+ module Gem
2
+ module Ext
3
+ class Builder; end
4
+ class ZigBuilder < Builder
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+ require 'gem/ext/zig_builder/version'
3
+ require 'rubygems/ext/builder'
4
+ require 'rubygems/command'
5
+ require 'shellwords'
6
+ require 'rbconfig'
7
+
8
+ class Gem::Ext::Builder
9
+ def builder_for(extension) # :nodoc:
10
+ case extension
11
+ when /extconf/ then
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
27
+ end
28
+ end
29
+ end
30
+
31
+ class Gem::Ext::ZigBuilder < Gem::Ext::Builder
32
+ def self.build(extension, dest_path, results, args=[], lib_dir=nil, extension_dir=nil)
33
+ # older versions of ruby do not support the 5th `env` argument to run,
34
+ # so pollute the global ENV as a cheap workaround
35
+ ENV['PKG_CONFIG_PATH'] = "#{RbConfig::CONFIG['libdir']}/pkgconfig"
36
+ ENV['RUBY_PC' ] = "#{File.basename(RbConfig::CONFIG['ruby_pc'], '.pc')}"
37
+
38
+ run(
39
+ [].tap {|c|
40
+ c << 'zig' << 'build' << '-Doptimize=ReleaseSafe'
41
+ c << '--prefix-lib-dir' << dest_path
42
+ c << Gem::Command.build_args unless Gem::Command.build_args.empty?
43
+ c << 'test' << 'install'
44
+ },
45
+ results,
46
+ 'zig',
47
+ extension_dir
48
+ )
49
+
50
+ results
51
+ end
52
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gem-ext-zig_builder
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Frank J. Cameron
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-05-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: ''
14
+ email:
15
+ - fjc@fastmail.net
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/gem/ext/zig_builder.rb
21
+ - lib/gem/ext/zig_builder/version.rb
22
+ homepage: https://gitlab.com/fjc/gem-ext-zig_builder
23
+ licenses:
24
+ - MIT
25
+ metadata:
26
+ homepage_uri: https://gitlab.com/fjc/gem-ext-zig_builder
27
+ source_code_uri: https://gitlab.com/fjc/gem-ext-zig_builder
28
+ changelog_uri: https://gitlab.com/fjc/gem-ext-zig_builder
29
+ post_install_message:
30
+ rdoc_options: []
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: 2.3.0
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ requirements: []
44
+ rubygems_version: 3.2.5
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: Gem extension builder for zig
48
+ test_files: []