Skip to content

Commit 9e49fa7

Browse files
committed
Don't use make while building Prism
This commit teaches mkmf about the libprism sources and allows it to compile them directly Fixes #3273
1 parent a1888c8 commit 9e49fa7

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

ext/prism/extconf.rb

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,22 @@ def make(env, target)
133133
archive_target = "build/libprism.a"
134134
archive_path = File.expand_path("../../#{archive_target}", __dir__)
135135

136-
make(env, archive_target) unless File.exist?(archive_path)
137-
$LOCAL_LIBS << " #{archive_path}"
136+
def src_list(path)
137+
srcdir = path.dup
138+
RbConfig.expand(srcdir) # mutates srcdir :-/
139+
Dir[File.join(srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
140+
end
141+
142+
$srcs = src_list("$(srcdir)")
143+
144+
def add_libprism_source(path)
145+
$VPATH << path
146+
src_list path
147+
end
148+
149+
$srcs.concat add_libprism_source("$(srcdir)/../../src")
150+
$srcs.concat add_libprism_source("$(srcdir)/../../src/util")
138151

139152
# Finally, we'll create the `Makefile` that is going to be used to configure and
140153
# build the C extension.
141154
create_makefile("prism/prism")
142-
143-
# Now that the `Makefile` for the C extension is built, we'll append on an extra
144-
# rule that dictates that the extension should be rebuilt if the archive is
145-
# updated.
146-
File.open("Makefile", "a") do |mf|
147-
mf.puts
148-
mf.puts("# Automatically rebuild the extension if libprism.a changed")
149-
mf.puts("$(TARGET_SO): $(LOCAL_LIBS)")
150-
end

0 commit comments

Comments
 (0)