[rubygems/rubygems] Always build in release mode

https://github.com/rubygems/rubygems/commit/7b84fc1f19
This commit is contained in:
Ian Ker-Seymer 2022-12-07 00:07:46 -05:00 коммит произвёл git
Родитель 37d10caa0d
Коммит 554161236a
2 изменённых файлов: 2 добавлений и 43 удалений

Просмотреть файл

@ -52,7 +52,7 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
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 += ["--"]
@ -75,7 +75,6 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
*rustc_dynamic_linker_flags(dest_dir),
*rustc_lib_flags(dest_dir),
*platform_specific_rustc_args(dest_dir),
*debug_flags,
]
end
@ -149,7 +148,7 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
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
@ -254,13 +253,6 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
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"
@ -299,14 +291,6 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder
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)

Просмотреть файл

@ -65,31 +65,6 @@ class TestGemExtCargoBuilder < Gem::TestCase
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_ffi_handle bundle, "Init_rust_ruby_example"
rescue Exception => e
pp output if output
raise(e)
end
def test_build_fail
skip_unsupported_platforms!
setup_rust_gem "rust_ruby_example"