Skip to content

Commit

Permalink
Directly pass in RUBY_TARGET to Rake task
Browse files Browse the repository at this point in the history
Previously rb-sys-dock relied on a static `RUBY_TARGET` being set, but
this value needs to be overriden in case an alias of
`x86_64-linux-gnu` is used for `x86_64-linux`.
  • Loading branch information
stanhu committed Jan 30, 2025
1 parent 7b03755 commit c7b6f47
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions docker/setup/rubybashrc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ main() {
echo "export PATH=\"/usr/local/cargo/bin:\$PATH\"" >> "$OUTFILE"
echo "export RUSTUP_HOME=\"$RUSTUP_HOME\"" >> "$OUTFILE"
echo "export CARGO_HOME=\"$CARGO_HOME\"" >> "$OUTFILE"
echo "export RUBY_TARGET=\"$RUBY_TARGET\"" >> "$OUTFILE"
echo "export RCD_PLATFORM=\"$RUBY_TARGET\"" >> "$OUTFILE"
echo "export RUST_TARGET=\"$RUST_TARGET\"" >> "$OUTFILE"
echo "export RUSTUP_DEFAULT_TOOLCHAIN=\"$RUSTUP_DEFAULT_TOOLCHAIN\"" >> "$OUTFILE"
Expand Down
9 changes: 6 additions & 3 deletions gem/exe/rb-sys-dock
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ def tmp_target_dir
@tmp_target_dir = dir
end

def ruby_target
OPTIONS.fetch(:platform)
end

def working_directory
OPTIONS.fetch(:directory)
end
Expand All @@ -310,8 +314,8 @@ def default_command_to_run(input_args)
input_cmd = input_args.empty? ? "true" : input_args.join(" ")

if OPTIONS[:build]
with_bundle = +"test -f Gemfile && bundle install && #{input_cmd} && bundle exec rake native:$RUBY_TARGET gem"
without_bundle = "#{input_cmd} && rake native:$RUBY_TARGET gem"
with_bundle = +"test -f Gemfile && bundle install && #{input_cmd} && bundle exec rake native:#{ruby_target} gem RUBY_TARGET=#{ruby_target}"
without_bundle = "#{input_cmd} && rake native:#{ruby_target} gem RUBY_TARGET=#{ruby_target}"
logger.info("Running default build command (rake native:#{ruby_platform} gem)")
"bash -c '(#{with_bundle}) || (#{without_bundle})'"
else
Expand Down Expand Up @@ -391,7 +395,6 @@ def rcd(input_args)
-e RB_SYS_DOCK_TMPDIR="/tmp/rb-sys-dock" \
-e RB_SYS_CARGO_TARGET_DIR=#{tmp_target_dir.inspect} \
-e RUBY_CC_VERSION="#{ruby_versions}" \
-e RUBY_TARGET="#{OPTIONS.fetch(:platform)}" \
-e RAKEOPT \
-e TERM \
-w #{working_directory} \
Expand Down

0 comments on commit c7b6f47

Please sign in to comment.