Skip to content

Instantly share code, notes, and snippets.

@unak
Created August 4, 2017 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unak/833b9031faaaea72f828f48d867276a3 to your computer and use it in GitHub Desktop.
Save unak/833b9031faaaea72f828f48d867276a3 to your computer and use it in GitHub Desktop.
pickup configure arguments defined in ext/**/extconf.rb
require "ripper"
def show(meth, arg)
case meth
when "dir_config"
puts "--with-#{arg}-dir"
when "enable_config"
puts "--enable-#{arg}"
when "with_config"
puts "--with-#{arg}"
end
end
def traverse(sexp, fname = "-")
method_list = %w"dir_config enable_config with_config"
parent = sexp
sexp.each do |s|
if s.is_a?(Array)
if s.first == :fcall && Array(method_list).include?(s[1][1])
show(s[1][1], get_arg(parent[2]))
elsif s.first == :command && Array(method_list).include?(s[1][1])
show(s[1][1], get_arg(s[2]))
else
traverse(s, fname)
end
end
end
end
def get_arg(sexp)
case sexp.first
when :arg_paren, :string_literal
get_arg(sexp[1])
when :args_add_block
get_arg(sexp[1].first)
when :string_content
sexp[1][1]
else
sexp
end
end
Dir.glob("ext/**/extconf.rb").each do |extconf|
src = File.read(extconf)
extconf = File.dirname(extconf).delete_prefix("mytree/ext/")
sexp = Ripper.sexp(src, extconf)
traverse(sexp, extconf)
end
--with-dbm-dir
--with-dbm-type
--enable-bundled-libffi
--with-libffi-dir
--with-gdbm-dir
--with-openssl-dir
--with-kerberos-dir
--with-debug
--enable-debug
--with-libyaml-dir
--enable-bundled-libyaml
--with-curses-dir
--with-ncurses-dir
--with-termcap-dir
--with-readline-dir
--enable-libedit
--with-libedit-dir
--enable-ipv6
--with-inet6-dir
--enable-close-fds-by-recvmsg-with-peek
--enable-wide-getaddrinfo
--with-lookup-order-hack
--enable-socks
--with-win32-dir
--with-zlib-dir
--with-os-code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment