Files
chromebrew/lib/buildsystems/rust.rb
github-actions[bot] 8796d687f5 Fix method reporting in buildsystems, Fix Rust buildsystem, Rebuild uutils_coreutils. (#11930)
* Revamp rust buildsystem.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Rebuild uutils_coreutils correctly.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add better method printing to buildsystems.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Unify gem_name and gem_version variables.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* cleanup

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Add variable for packages to skip during install testing portion of unit tests.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Avoid system override in python3 postinstall.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

* Remove old pip 23.2.1 workaround.

Signed-off-by: Satadru Pramanik <satadru@gmail.com>

---------

Signed-off-by: Satadru Pramanik <satadru@gmail.com>
Co-authored-by: Satadru Pramanik <satadru@gmail.com>
2025-05-22 15:52:26 +00:00

59 lines
1.9 KiB
Ruby

require 'package'
require 'require_gem'
class RUST < Package
property :rust_features, :rust_options, :rust_release_profile, :rust_targets, :pre_rust_options, :rust_build_extras, :rust_install_extras
def self.build
rust_env =
{
LD: 'mold',
LIBRARY_PATH: CREW_LIB_PREFIX,
PATH: "#{CREW_PREFIX}/share/cargo/bin:" + ENV.fetch('PATH', nil)
}.transform_keys(&:to_s)
puts "Additional #{superclass.to_s.capitalize} options being used:".orange
method_list = methods.grep(/rust_/).delete_if { |i| send(i).blank? }
require_gem 'method_source'
method_blocks = []
method_strings = []
method_list.sort.each do |method|
@method_info = send method
if @method_info.is_a? String
method_strings << "#{method}: #{@method_info}".orange
else
method_blocks << @method_info.source.to_s.orange
end
end
puts method_strings
puts method_blocks
system rust_env, "rustup target add #{@rust_targets}" unless @rust_targets.to_s.empty?
system rust_env, "#{@pre_rust_options} cargo fetch"
system rust_env, "#{@pre_rust_options} cargo build \
--profile=#{@rust_release_profile.to_s.empty? ? 'release' : @rust_release_profile} \
#{@rust_features.to_s.empty? ? '' : "--features #{@rust_features}"} \
#{@rust_options}"
@rust_build_extras&.call
end
def self.install
rust_env =
{
LD: 'mold',
LIBRARY_PATH: CREW_LIB_PREFIX,
PATH: "#{CREW_PREFIX}/share/cargo/bin:" + ENV.fetch('PATH', nil)
}.transform_keys(&:to_s)
system rust_env, "cargo install \
--profile=#{@rust_release_profile.to_s.empty? ? 'release' : @rust_release_profile} \
--offline \
--no-track \
--path . \
#{@rust_features.to_s.empty? ? '' : "--features #{@rust_features}"} \
#{@rust_options} \
--root #{CREW_DEST_PREFIX}"
@rust_install_extras&.call
end
end