ruby/gc/mmtk/extconf.rb
Peter Zhu 770ca58cd3 [ruby/mmtk] Use extconf.rb for external GC compilation
This commit adds extconf.rb for both the default GC and and MMTk to build
the external GC. This allows common.mk to not need to contain any
implementation-specific build configuration.

db6a29b4a9
2024-11-22 09:55:25 +00:00

37 lines
881 B
Ruby

# frozen_string_literal: true
require_relative "../extconf_base"
# Statically link `libmmtk_ruby.a`
$LIBS << " $(MMTK_BUILD)/libmmtk_ruby.#{RbConfig::CONFIG["LIBEXT"]}"
create_gc_makefile("mmtk")
makefile = File.read("Makefile")
# Modify the `all` target to run the `mmtk` target first
makefile.gsub!(/^all:\s+(.*)$/, 'all: mmtk \1')
# Add the `mmtk` target to run `cargo build`
makefile << <<~'MAKEFILE'
$(srcdir)/mmtk.c: mmtk
MMTK_BUILD=debug
.PHONY: mmtk
mmtk:
$(Q) case $(MMTK_BUILD) in \
release) \
CARGO_TARGET_DIR="." cargo build --manifest-path=$(srcdir)/Cargo.toml --release \
;; \
debug) \
CARGO_TARGET_DIR="." cargo build --manifest-path=$(srcdir)/Cargo.toml \
;; \
*) \
$(ECHO) Unknown MMTK_BUILD=$(MMTK_BUILD) \
exit 1 \
;; \
esac
MAKEFILE
File.open("Makefile", "w") { |file| file.puts(makefile) }