Sha256: f711ede56b52af045570f83a5873f71ff01f2e59fffc0aa4b8d312b6f50bcea5

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

# -*- coding: utf-8 -*-


require 'xot/rake'
require 'xot/block_util'


module Xot


  class ExtConf

    include Xot::Rake

    attr_reader :modules, :defs, :include_dirs, :lib_dirs, :headers, :libs, :local_libs, :frameworks

    def initialize (*modules, &block)
      @modules = modules.map {|m| m.const_get :Module}
      @defs, @include_dirs, @lib_dirs, @headers, @libs, @local_libs, @frameworks =
        ([[]] * 7).map &:dup
      Xot::BlockUtil.instance_eval_or_block_call self, &block if block
    end

    def debug ()
      env :DEBUG, false
    end

    def setup ()
      yield if block_given?

      modules.each do |m|
        name = m.name.downcase
        headers << "#{name}.h"
        libs << name
      end

      local_libs << (clang? ? 'c++' : 'stdc++')

      $CPPFLAGS = cppflags $CPPFLAGS, defs, include_dirs
      $CFLAGS   = cflags   $CFLAGS + ' -x c++'
      $LDFLAGS  = ldflags  $LDFLAGS, lib_dirs, frameworks
      $LOCAL_LIBS << local_libs.map {|s| " -l#{s}"}.join
    end

    def create_makefile (*args)
      modules.each do |m|
        dir_config m.name.downcase, m.include_dir, m.lib_dir
      end

      exit 1 unless headers.all? {|s| have_header s}
      exit 1 unless libs.all?    {|s| have_library s, 't'}

      super
    end

  end# ExtConf


end# Xot

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
xot-0.1.12 lib/xot/extconf.rb
xot-0.1.11 lib/xot/extconf.rb
xot-0.1.10 lib/xot/extconf.rb
xot-0.1.9 lib/xot/extconf.rb
xot-0.1.8 lib/xot/extconf.rb
xot-0.1.7 lib/xot/extconf.rb