Sha256: d9c69879e124dc4d51a0e3d0fb641f24f6edc22caa2240828ec029079c8b8898

Contents?: true

Size: 1.76 KB

Versions: 33

Compression:

Stored size: 1.76 KB

Contents

ninja_tool_dir = File::absolute_path(File::join(
    File::dirname(__FILE__), '..', 'ninja-scan-light', 'tool'))

require "mkmf"
cflags = " -Wall -I#{ninja_tool_dir}"
$CFLAGS += cflags
$CPPFLAGS += cflags if RUBY_VERSION >= "2.0.0"
$LOCAL_LIBS += " -lstdc++ "

IO_TARGETS = [
  [Kernel, :instance_eval],
  [(class << File; self; end), :class_eval], # https://github.com/ruby/ruby/commit/19beb028
]
def IO_TARGETS.mod(&b)
  self.each{|class_, func| class_.send(func, &b)}
end

IO_TARGETS.mod{
  alias_method(:open_orig, :open)
}

Dir::glob(File::join(File::dirname(__FILE__), "*/")).each{|dir|
  mod_name = File::basename(dir)
  
  dst = File::join(Dir.getwd, mod_name)
  FileUtils::mkdir_p(dst) if dir != dst
  
  $stderr.puts "For #{mod_name} ..."

  # @see https://stackoverflow.com/a/35842162/15992898
  $srcs = Dir::glob(File::join(dir, '*.cxx')).collect{|path|
    File::join(mod_name, File::basename(path))
  }
  $objs = $srcs.collect{|path|
    path.sub(/\.[^\.]+$/, '.o')
  }

  IO_TARGETS.mod{
    # rename Makefile to Makefile.#{mod_name}
    define_method(:open){|*args, &b|
      args[0] += ".#{mod_name}" if (args[0] && (args[0] == "Makefile"))
      open_orig(*args, &b)
    }
  }
  create_makefile("gps_pvt/#{mod_name}")
}

IO_TARGETS.mod{
  alias_method(:open, :open_orig)
}

# manual generation of top-level Makefile
# @see https://yorickpeterse.com/articles/hacking-extconf-rb/
open("Makefile", 'w'){|io|
  # @see https://stackoverflow.com/a/17845120/15992898
  io.write(<<-__TOPLEVEL_MAKEFILE__)
TOPTARGETS := all clean distclean realclean install site-install

SUBMFS := $(wildcard Makefile.*)

$(TOPTARGETS): $(SUBMFS)
$(SUBMFS):
#{"\t"}$(MAKE) -f $@ $(MAKECMDGOALS)

.PHONY: $(TOPTARGETS) $(SUBMFS)
  __TOPLEVEL_MAKEFILE__
}

require 'fileutils'
FileUtils::touch("gps_pvt.so") # dummy

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
gps_pvt-0.9.3 ext/gps_pvt/extconf.rb
gps_pvt-0.9.2 ext/gps_pvt/extconf.rb
gps_pvt-0.9.1 ext/gps_pvt/extconf.rb
gps_pvt-0.9.0 ext/gps_pvt/extconf.rb
gps_pvt-0.8.5 ext/gps_pvt/extconf.rb
gps_pvt-0.8.4 ext/gps_pvt/extconf.rb
gps_pvt-0.8.3 ext/gps_pvt/extconf.rb
gps_pvt-0.8.2 ext/gps_pvt/extconf.rb
gps_pvt-0.8.1 ext/gps_pvt/extconf.rb
gps_pvt-0.8.0 ext/gps_pvt/extconf.rb
gps_pvt-0.7.2 ext/gps_pvt/extconf.rb
gps_pvt-0.7.1 ext/gps_pvt/extconf.rb
gps_pvt-0.7.0 ext/gps_pvt/extconf.rb
gps_pvt-0.6.4 ext/gps_pvt/extconf.rb
gps_pvt-0.6.3 ext/gps_pvt/extconf.rb
gps_pvt-0.6.2 ext/gps_pvt/extconf.rb
gps_pvt-0.6.1 ext/gps_pvt/extconf.rb
gps_pvt-0.6.0 ext/gps_pvt/extconf.rb
gps_pvt-0.5.1 ext/gps_pvt/extconf.rb
gps_pvt-0.5.0 ext/gps_pvt/extconf.rb