Sha256: 3efdf2ffb6456cdfe52a7c533aa8c8ec7817a9f16371308688fddcf9272b18c2

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

exit(0) if ENV["USE_SYSTEM_LIBYAJL2"]

require 'pp'

module Libyajl2Build
  class BuildError < StandardError; end

  LIBYAJL2_VENDOR_DIR = File.expand_path("../vendor/yajl", __FILE__).freeze

  PREFIX = File.expand_path("../../../lib/libyajl2/vendored-libyajl2", __FILE__).freeze

  def self.windows?
    !!(RUBY_PLATFORM =~ /mswin|mingw|windows/)
  end

  def self.libyajl2_vendor_dir
    LIBYAJL2_VENDOR_DIR
  end

  def self.configure
    File.join(LIBYAJL2_VENDOR_DIR, "configure")
  end

  def self.prefix
    PREFIX
  end

  def self.configure_cmd
    # NB: this is not a gnu configure command
    %W[
      sh
      #{configure}
      -p
      #{prefix}
    ]
  end

  def self.setup_env
    if windows?
      ENV['CC'] = 'gcc.exe'
      ENV['CXX'] = 'g++.exe'
    end
  end

  def self.system(*args)
    print("-> #{args.join(' ')}\n")
    super(*args)
  end

  def self.run_build_commands
    setup_env
    puts `pwd`
    puts `env`
    puts configure_cmd
    system(*configure_cmd) &&
      system("make", "-j", "5", "install")
  end

  def self.run
    Dir.chdir(libyajl2_vendor_dir) do
      run_build_commands or raise BuildError, "Failed to build libyajl2 library."
    end
  end
end

Libyajl2Build.run

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
libyajl2-0.0.3 ext/libyajl2/extconf.rb