Skip to content

Commit

Permalink
Don't use make while building Prism
Browse files Browse the repository at this point in the history
This commit teaches mkmf about the libprism sources and allows it to
compile them directly

Fixes #3273
  • Loading branch information
tenderlove committed Dec 5, 2024
1 parent a1888c8 commit 210f9a3
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions ext/prism/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,25 @@ def make(env, target)
archive_target = "build/libprism.a"
archive_path = File.expand_path("../../#{archive_target}", __dir__)

make(env, archive_target) unless File.exist?(archive_path)
$LOCAL_LIBS << " #{archive_path}"
def gem_sources
srcprefix = "$(srcdir)/".chomp('/')
srcdir = srcprefix.dup
RbConfig.expand(srcdir) # mutates srcdir :-/
Dir[File.join(srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
end

def libprism_sources
srcprefix = "$(srcdir)/../../src".chomp('/')
srcdir = srcprefix.dup
RbConfig.expand(srcdir)
Dir[File.join(srcdir, "**/*.{#{SRC_EXT.join(%q{,})}}")]
end

$VPATH << "$(srcdir)/../../src"
$VPATH << "$(srcdir)/../../src/util"

$srcs = gem_sources + libprism_sources

# Finally, we'll create the `Makefile` that is going to be used to configure and
# build the C extension.
create_makefile("prism/prism")

# Now that the `Makefile` for the C extension is built, we'll append on an extra
# rule that dictates that the extension should be rebuilt if the archive is
# updated.
File.open("Makefile", "a") do |mf|
mf.puts
mf.puts("# Automatically rebuild the extension if libprism.a changed")
mf.puts("$(TARGET_SO): $(LOCAL_LIBS)")
end

0 comments on commit 210f9a3

Please sign in to comment.