Sha256: e32087fb01a09deb6eea645a30927d8119c08c17d38e12eb88183daaeb9b906f

Contents?: true

Size: 990 Bytes

Versions: 2

Compression:

Stored size: 990 Bytes

Contents

require "rbconfig"
require "fileutils"

module OSTN02C
  module_function

  def make
    compile and package
  end

  def compile
    puts "Compiling libostn02"
    FileUtils.mkdir_p object_path
    Dir.chdir object_path do
      run RbConfig.expand("$(CC) -I#{include_path} $(CPPFLAGS) $(CFLAGS) -c #{sources.join(" ")}")
    end
  end

  def package
    puts "Packaging libostn02"
    FileUtils.mkdir_p lib_path
    run RbConfig.expand("$(AR) -crsv #{library} #{objects}")
  end

  def sources
    Dir.glob(File.join(include_path, "*.c"))
  end

  def objects
    File.join(object_path, "*.o")
  end

  def library
    File.join(lib_path, "libostn02.a")
  end

  def include_path
    File.expand_path("ostn02c/OSTN02", __dir__)
  end

  def lib_path
    File.join(output_path, "lib")
  end

  def object_path
    File.join(output_path, "obj")
  end

  def output_path
    File.expand_path("../tmp/ostn02c", __dir__)
  end

  def run(command)
    puts command
    system command
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
national_grid-0.2.0 ext/ostn02c.rb
national_grid-0.1.2 ext/ostn02c.rb