Skip to content

Commit

Permalink
Merge pull request #6104 from ianks/rb-sys-0.9.46
Browse files Browse the repository at this point in the history
Updates rb-sys to 0.9.46
  • Loading branch information
simi committed Dec 7, 2022
2 parents 771c94e + 7d50e99 commit f11febd
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 123 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/daily-rubygems.yml
Expand Up @@ -31,9 +31,10 @@ jobs:
ruby-version: ${{ matrix.ruby }}
bundler: none

- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
- uses: dtolnay/rust-toolchain@e645b0cf01249a964ec099494d38d2da0f0b349f
with:
toolchain: ${{ matrix.cargo }}
components: rustfmt

- name: Show Ruby version
run: ruby --version
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows-rubygems.yml
Expand Up @@ -40,10 +40,10 @@ jobs:
ruby-version: ${{ matrix.ruby.value }}
bundler: none
mingw: clang
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
- uses: dtolnay/rust-toolchain@e645b0cf01249a964ec099494d38d2da0f0b349f
with:
toolchain: ${{ matrix.cargo.toolchain }}-${{ matrix.cargo.target }}
default: true
components: rustfmt
- name: Print debugging info
run: |
echo "RbConfig::MAKEFILE_CONFIG"
Expand Down
20 changes: 2 additions & 18 deletions lib/rubygems/ext/cargo_builder.rb
Expand Up @@ -52,7 +52,7 @@ def cargo_command(cargo_dir, dest_path, args = [])
cmd += ["--manifest-path", manifest]
cmd += ["--lib"]
cmd += ["--profile", profile.to_s]
cmd += ["--locked"] if profile == :release
cmd += ["--locked"]
cmd += Gem::Command.build_args
cmd += args
cmd += ["--"]
Expand All @@ -75,7 +75,6 @@ def cargo_rustc_args(dest_dir)
*rustc_dynamic_linker_flags(dest_dir),
*rustc_lib_flags(dest_dir),
*platform_specific_rustc_args(dest_dir),
*debug_flags,
]
end

Expand Down Expand Up @@ -149,7 +148,7 @@ def cargo_dylib_path(dest_path)
prefix = so_ext == "dll" ? "" : "lib"
path_parts = [dest_path]
path_parts << ENV["CARGO_BUILD_TARGET"] if ENV["CARGO_BUILD_TARGET"]
path_parts += [profile_target_directory, "#{prefix}#{cargo_crate_name}.#{so_ext}"]
path_parts += ["release", "#{prefix}#{cargo_crate_name}.#{so_ext}"]
File.join(*path_parts)
end

Expand Down Expand Up @@ -254,13 +253,6 @@ def makefile_config(var_name)
RbConfig.expand(val.dup)
end

# Good balance between binary size and debugability
def debug_flags
return [] if profile == :dev

["-C", "debuginfo=1"]
end

# Copied from ExtConfBuilder
def finalize_directory(dest_path, lib_dir, extension_dir)
require "fileutils"
Expand Down Expand Up @@ -299,14 +291,6 @@ def get_relative_path(path, base)
path
end

def profile_target_directory
case profile
when :release then "release"
when :dev then "debug"
else raise "unknown target directory for profile: #{profile}"
end
end

# Error raised when no cdylib artifact was created
class DylibNotFoundError < StandardError
def initialize(dir)
Expand Down
28 changes: 2 additions & 26 deletions test/rubygems/test_gem_ext_cargo_builder.rb
Expand Up @@ -57,32 +57,8 @@ def test_build_cdylib
output = output.join "\n"
bundle = File.join(@dest_path, "release/rust_ruby_example.#{RbConfig::CONFIG['DLEXT']}")

assert_match "Finished release [optimized] target(s)", output
assert_ffi_handle bundle, "Init_rust_ruby_example"
rescue Exception => e
pp output if output

raise(e)
end

def test_build_dev_profile
skip_unsupported_platforms!
setup_rust_gem "rust_ruby_example"

output = []

Dir.chdir @ext do
ENV.update(@rust_envs)
spec = Gem::Specification.new "rust_ruby_example", "0.1.0"
builder = Gem::Ext::CargoBuilder.new(spec)
builder.profile = :dev
builder.build nil, @dest_path, output
end

output = output.join "\n"
bundle = File.join(@dest_path, "debug/rust_ruby_example.#{RbConfig::CONFIG['DLEXT']}")

assert_match "Finished dev [unoptimized + debuginfo] target(s)", output
assert_match(/Finished/, output)
assert_match(/release/, output)
assert_ffi_handle bundle, "Init_rust_ruby_example"
rescue Exception => e
pp output if output
Expand Down
54 changes: 22 additions & 32 deletions test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -7,4 +7,4 @@ edition = "2021"
crate-type = ["cdylib"]

[dependencies]
rb-sys = "0.9.37"
rb-sys = "0.9.46"

0 comments on commit f11febd

Please sign in to comment.