Skip to content

Instantly share code, notes, and snippets.

@suhovius
Forked from ForeverZer0/extconfig.rb
Created October 16, 2021 17:45
Show Gist options
  • Save suhovius/0f42fff048226b318e061cc8bf3470c8 to your computer and use it in GitHub Desktop.
Save suhovius/0f42fff048226b318e061cc8bf3470c8 to your computer and use it in GitHub Desktop.
Automatically include/compile all Ruby C extension source files (including subdirectories) using mkmf
require "mkmf"
ext_name = 'my_extension'
excluded = ['x86', 'x64']
dir_config(ext_name)
$srcs = Dir.glob("#{$srcdir}/**/*.c").map { |path| File.basename(path) }
Dir.glob("#{$srcdir}/*/") do |path|
dir = File.basename(path)
next if excluded.include?(dir)
$VPATH << "$(srcdir)/#{dir}"
$INCFLAGS << " -I$(srcdir)/#{dir}"
end
create_makefile(ext_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment