rb_sys 0.9.127 → 0.9.128
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
- checksums.yaml.gz.sig +0 -0
- data/exe/rb-sys-dock +1 -1
- data/lib/rb_sys/cargo/config.rb +72 -0
- data/lib/rb_sys/cargo_builder.rb +2 -1
- data/lib/rb_sys/mkmf.rb +3 -3
- data/lib/rb_sys/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4907306eece620077a2b68e2b6f33a13a4e7c310e8937d1655229ff4cbc62605
|
|
4
|
+
data.tar.gz: bcca23169c98229da0467fffe834ac6de098261cea82fb7e90c6cb0273c048b8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 89690dc28b0a42302744554a4e9aac8c0573c88a016ffc67e4aed3873de3fad862947613403e46e711650eebf055751542473db0a64ce60b5c73134ac7ef9162
|
|
7
|
+
data.tar.gz: 10d2bd2e67bd9e937b300c5deb451c8d5fbdf88d39399815b6b7f7cdeb3c69a140048ed6c57b6d7a82a7a840fc47b66f04379a9c1273be200af383ee2f4923a0
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/exe/rb-sys-dock
CHANGED
|
@@ -339,7 +339,7 @@ def default_command_to_run(input_args)
|
|
|
339
339
|
input_cmd = input_args.empty? ? "true" : input_args.join(" ")
|
|
340
340
|
|
|
341
341
|
if OPTIONS[:build]
|
|
342
|
-
with_bundle =
|
|
342
|
+
with_bundle = "test -f Gemfile && bundle install && #{input_cmd} && bundle exec rake native:$RUBY_TARGET gem"
|
|
343
343
|
without_bundle = "#{input_cmd} && rake native:$RUBY_TARGET gem"
|
|
344
344
|
logger.info("Running default build command (rake native:#{ruby_platform} gem)")
|
|
345
345
|
"bash -c '(#{with_bundle}) || (#{without_bundle})'"
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RbSys
|
|
4
|
+
module Cargo
|
|
5
|
+
# Reads Cargo configuration files to extract build settings.
|
|
6
|
+
module Config
|
|
7
|
+
class << self
|
|
8
|
+
# Returns the build target from Cargo configuration files.
|
|
9
|
+
# Searches from start_dir up to root, then checks CARGO_HOME.
|
|
10
|
+
#
|
|
11
|
+
# @param start_dir [String] the directory to start searching from
|
|
12
|
+
# @return [String, nil] the target triple, or nil if not configured
|
|
13
|
+
def build_target(start_dir: Dir.pwd)
|
|
14
|
+
find_in_hierarchy(start_dir) || find_in_home
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def find_in_hierarchy(dir)
|
|
20
|
+
dir = File.expand_path(dir)
|
|
21
|
+
while (parent = File.dirname(dir)) != dir
|
|
22
|
+
target = read_build_target(File.join(dir, ".cargo"))
|
|
23
|
+
return target if target
|
|
24
|
+
dir = parent
|
|
25
|
+
end
|
|
26
|
+
nil
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def find_in_home
|
|
30
|
+
cargo_home = ENV["CARGO_HOME"] || File.join(Dir.home, ".cargo")
|
|
31
|
+
read_build_target(cargo_home)
|
|
32
|
+
rescue ArgumentError
|
|
33
|
+
# Dir.home can raise if HOME is not set
|
|
34
|
+
nil
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def read_build_target(cargo_dir)
|
|
38
|
+
# Version without `.toml` is for cargo < 1.39
|
|
39
|
+
%w[config.toml config].each do |name|
|
|
40
|
+
path = File.join(cargo_dir, name)
|
|
41
|
+
next unless File.exist?(path)
|
|
42
|
+
target = parse_build_target(File.read(path))
|
|
43
|
+
return target if target
|
|
44
|
+
rescue Errno::EACCES, Errno::ENOENT
|
|
45
|
+
next
|
|
46
|
+
end
|
|
47
|
+
nil
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def parse_build_target(content)
|
|
51
|
+
# That is a hacky way to avoid pulling a proper toml parser as a dependency
|
|
52
|
+
current_section = nil
|
|
53
|
+
content.each_line do |line|
|
|
54
|
+
line = line.sub(/#.*/, "").strip
|
|
55
|
+
next if line.empty?
|
|
56
|
+
|
|
57
|
+
if line =~ /^\["?([^\]"]+)"?\]/
|
|
58
|
+
current_section = $1.strip
|
|
59
|
+
elsif current_section.nil? && line =~ /^"?build"?\."?target"?\s*=\s*["']([^"']+)["']/
|
|
60
|
+
return $1
|
|
61
|
+
elsif current_section.nil? && line =~ /^"?build"?\s*=\s*\{[^}]*"?target"?\s*=\s*["']([^"']+)["']/
|
|
62
|
+
return $1
|
|
63
|
+
elsif current_section == "build" && line =~ /^"?target"?\s*=\s*["']([^"']+)["']/
|
|
64
|
+
return $1
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
nil
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
data/lib/rb_sys/cargo_builder.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require "rubygems/ext"
|
|
2
2
|
require "rubygems/ext/builder"
|
|
3
3
|
require_relative "cargo_builder/link_flag_converter"
|
|
4
|
+
require_relative "cargo/config"
|
|
4
5
|
|
|
5
6
|
module RbSys
|
|
6
7
|
# A class to build a Ruby gem Cargo. Extracted from `rubygems` gem, with some modifications.
|
|
@@ -21,7 +22,7 @@ module RbSys
|
|
|
21
22
|
@profile = ENV.fetch("RB_SYS_CARGO_PROFILE", :release).to_sym
|
|
22
23
|
@env = {}
|
|
23
24
|
@features = []
|
|
24
|
-
@target = ENV["CARGO_BUILD_TARGET"] || ENV["RUST_TARGET"]
|
|
25
|
+
@target = ENV["CARGO_BUILD_TARGET"] || ENV["RUST_TARGET"] || Cargo::Config.build_target
|
|
25
26
|
@extra_rustc_args = []
|
|
26
27
|
@extra_cargo_args = []
|
|
27
28
|
@dry_run = true
|
data/lib/rb_sys/mkmf.rb
CHANGED
|
@@ -56,7 +56,7 @@ module RbSys
|
|
|
56
56
|
# global_rustflags << "--cfg=rb_sys_gem" unless builder.use_cargo_build
|
|
57
57
|
global_rustflags << "--cfg=rb_sys_use_stable_api_compiled_fallback" if builder.use_stable_api_compiled_fallback?
|
|
58
58
|
|
|
59
|
-
make_install =
|
|
59
|
+
make_install = <<~MAKE
|
|
60
60
|
#{conditional_assign("RB_SYS_BUILD_DIR", File.join(Dir.pwd, ".rb-sys"))}
|
|
61
61
|
#{conditional_assign("CARGO", "cargo")}
|
|
62
62
|
#{conditional_assign("CARGO_BUILD_TARGET", builder.target)}
|
|
@@ -150,7 +150,7 @@ module RbSys
|
|
|
150
150
|
all: #{$extout ? "install" : "$(DLLIB)"}
|
|
151
151
|
MAKE
|
|
152
152
|
|
|
153
|
-
gsub_cargo_command!(make_install, builder: builder)
|
|
153
|
+
make_install = gsub_cargo_command!(make_install.dup, builder: builder)
|
|
154
154
|
|
|
155
155
|
File.write("Makefile", make_install)
|
|
156
156
|
end
|
|
@@ -334,7 +334,7 @@ module RbSys
|
|
|
334
334
|
|
|
335
335
|
def conditional_assign(a, b, export: false, indent: 0)
|
|
336
336
|
if $nmake
|
|
337
|
-
result =
|
|
337
|
+
result = "!IFNDEF #{a}\n#{a} = #{b}\n!ENDIF\n"
|
|
338
338
|
result << export_env(a, b) if export
|
|
339
339
|
result
|
|
340
340
|
else
|
data/lib/rb_sys/version.rb
CHANGED
data.tar.gz.sig
CHANGED
|
Binary file
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rb_sys
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.9.
|
|
4
|
+
version: 0.9.128
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ian Ker-Seymer
|
|
@@ -60,6 +60,7 @@ files:
|
|
|
60
60
|
- exe/rb-sys-dock
|
|
61
61
|
- lib/rb_sys.rb
|
|
62
62
|
- lib/rb_sys/cargo.rb
|
|
63
|
+
- lib/rb_sys/cargo/config.rb
|
|
63
64
|
- lib/rb_sys/cargo/metadata.rb
|
|
64
65
|
- lib/rb_sys/cargo_builder.rb
|
|
65
66
|
- lib/rb_sys/cargo_builder/link_flag_converter.rb
|
metadata.gz.sig
CHANGED
|
Binary file
|