Skip to content

Instantly share code, notes, and snippets.

@ForeverZer0
Created October 3, 2018 18:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ForeverZer0/2bec871e61c3fc6be59969b1b02459c5 to your computer and use it in GitHub Desktop.
Save ForeverZer0/2bec871e61c3fc6be59969b1b02459c5 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