|
3 | 3 | require_relative "../extconf_base"
|
4 | 4 |
|
5 | 5 | # Statically link `libmmtk_ruby.a`
|
6 |
| -$LIBS << " $(MMTK_BUILD)/libmmtk_ruby.#{RbConfig::CONFIG["LIBEXT"]}" |
| 6 | +$LIBS << " $(MMTK_BUILD)/$(LIBMMTK_RUBY)" |
7 | 7 |
|
8 |
| -create_gc_makefile("mmtk") |
| 8 | +rustsrcs = Dir.glob("src/*.rs", base: __dir__).map {|s| "$(srcdir)/#{s}"} |
9 | 9 |
|
10 |
| -makefile = File.read("Makefile") |
| 10 | +create_gc_makefile("mmtk") do |makefile| |
| 11 | + [ |
| 12 | + *makefile, |
11 | 13 |
|
12 |
| -makefile.prepend("MMTK_BUILD=debug\n") |
13 |
| - |
14 |
| -# Add `libmmtk_ruby.a` as an object file |
15 |
| -makefile.gsub!(/^OBJS = (.*)$/, "OBJS = \\1 $(MMTK_BUILD)/libmmtk_ruby.#{RbConfig::CONFIG["LIBEXT"]}") |
16 |
| - |
17 |
| -# Modify the `all` target to run the `libmmtk_ruby.a` target first |
18 |
| -makefile.gsub!(/^all:\s+(.*)$/, "all: $(MMTK_BUILD)/libmmtk_ruby.#{RbConfig::CONFIG["LIBEXT"]} \\1") |
19 |
| - |
20 |
| -# Add the `libmmtk_ruby.a` target to run `cargo build` |
21 |
| -makefile << <<~MAKEFILE |
22 |
| - $(MMTK_BUILD)/libmmtk_ruby.#{RbConfig::CONFIG["LIBEXT"]}: $(wildcard $(srcdir)/src/*.rs) $(srcdir)/Cargo.toml $(srcdir)/Cargo.toml |
23 |
| - $(Q) case $(MMTK_BUILD) in \ |
24 |
| - release) \ |
25 |
| - CARGO_TARGET_DIR="." cargo build --manifest-path=$(srcdir)/Cargo.toml --release \ |
26 |
| - ;; \ |
27 |
| - debug) \ |
28 |
| - CARGO_TARGET_DIR="." cargo build --manifest-path=$(srcdir)/Cargo.toml \ |
29 |
| - ;; \ |
30 |
| - *) \ |
31 |
| - $(ECHO) Unknown MMTK_BUILD=$(MMTK_BUILD) \ |
32 |
| - exit 1 \ |
33 |
| - ;; \ |
34 |
| - esac |
35 |
| -
|
36 |
| - clean: clean-mmtk |
37 |
| -
|
38 |
| - .PHONY: clean-mmtk |
39 |
| - clean-mmtk: |
40 |
| - -$(Q)$(RM_RF) debug release |
41 |
| - -$(Q)$(RM) .rustc_info.json |
42 |
| -MAKEFILE |
43 |
| - |
44 |
| -File.open("Makefile", "w") { |file| file.puts(makefile) } |
| 14 | + <<~MAKEFILE, |
| 15 | + MMTK_BUILD = debug |
| 16 | + LIBMMTK_RUBY = libmmtk_ruby.#$LIBEXT |
| 17 | + RUSTSRCS = #{rustsrcs.join(" \\\n\t ")} |
| 18 | + MAKEFILE |
| 19 | + ] |
| 20 | +end |
0 commit comments