~elementary-apps/noise/trunk

« back to all changes in this revision

Viewing changes to .waf-1.6.2-ad4cc42bd7d347f7e283789e711b993f/waflib/Tools/ruby.py

  • Committer: Scott Ringwelski
  • Date: 2011-02-10 21:30:53 UTC
  • Revision ID: sgringwe@mtu.edu-20110210213053-d3c7mnexeref3cwj
sexy icons, sexy waf

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
# encoding: utf-8
 
3
# WARNING! All changes made to this file will be lost!
 
4
 
 
5
import os
 
6
from waflib import Task,Options,Utils
 
7
from waflib.TaskGen import before,feature,after
 
8
from waflib.Configure import conf
 
9
def init_rubyext(self):
 
10
        self.install_path='${ARCHDIR_RUBY}'
 
11
        self.uselib=self.to_list(getattr(self,'uselib',''))
 
12
        if not'RUBY'in self.uselib:
 
13
                self.uselib.append('RUBY')
 
14
        if not'RUBYEXT'in self.uselib:
 
15
                self.uselib.append('RUBYEXT')
 
16
def apply_ruby_so_name(self):
 
17
        self.env['cshlib_PATTERN']=self.env['cxxshlib_PATTERN']=self.env['rubyext_PATTERN']
 
18
def check_ruby_version(self,minver=()):
 
19
        if Options.options.rubybinary:
 
20
                self.env.RUBY=Options.options.rubybinary
 
21
        else:
 
22
                self.find_program('ruby',var='RUBY')
 
23
        ruby=self.env.RUBY
 
24
        try:
 
25
                version=self.cmd_and_log([ruby,'-e','puts defined?(VERSION) ? VERSION : RUBY_VERSION']).strip()
 
26
        except:
 
27
                self.fatal('could not determine ruby version')
 
28
        self.env.RUBY_VERSION=version
 
29
        try:
 
30
                ver=tuple(map(int,version.split(".")))
 
31
        except:
 
32
                self.fatal('unsupported ruby version %r'%version)
 
33
        cver=''
 
34
        if minver:
 
35
                if ver<minver:
 
36
                        self.fatal('ruby is too old %r'%ver)
 
37
                cver='.'.join([str(x)for x in minver])
 
38
        self.msg('ruby',cver)
 
39
def check_ruby_ext_devel(self):
 
40
        if not self.env.RUBY:
 
41
                self.fatal('ruby detection is required first')
 
42
        if not self.env.CC_NAME and not self.env.CXX_NAME:
 
43
                self.fatal('load a c/c++ compiler first')
 
44
        version=tuple(map(int,self.env.RUBY_VERSION.split(".")))
 
45
        def read_out(cmd):
 
46
                return Utils.to_list(self.cmd_and_log([self.env.RUBY,'-rrbconfig','-e',cmd]))
 
47
        def read_config(key):
 
48
                return read_out('puts Config::CONFIG[%r]'%key)
 
49
        ruby=self.env['RUBY']
 
50
        archdir=read_config('archdir')
 
51
        cpppath=archdir
 
52
        if version>=(1,9,0):
 
53
                ruby_hdrdir=read_config('rubyhdrdir')
 
54
                cpppath+=ruby_hdrdir
 
55
                cpppath+=[os.path.join(ruby_hdrdir[0],read_config('arch')[0])]
 
56
        self.check(header_name='ruby.h',includes=cpppath,errmsg='could not find ruby header file')
 
57
        self.env.LIBPATH_RUBYEXT=read_config('libdir')
 
58
        self.env.LIBPATH_RUBYEXT+=archdir
 
59
        self.env.INCLUDES_RUBYEXT=cpppath
 
60
        self.env.CFLAGS_RUBYEXT=read_config('CCDLFLAGS')
 
61
        self.env.rubyext_PATTERN='%s.'+read_config('DLEXT')[0]
 
62
        flags=read_config('LDSHARED')
 
63
        while flags and flags[0][0]!='-':
 
64
                flags=flags[1:]
 
65
        if len(flags)>1 and flags[1]=="ppc":
 
66
                flags=flags[2:]
 
67
        self.env.LINKFLAGS_RUBYEXT=flags
 
68
        self.env.LINKFLAGS_RUBYEXT+=read_config('LIBS')
 
69
        self.env.LINKFLAGS_RUBYEXT+=read_config('LIBRUBYARG_SHARED')
 
70
        if Options.options.rubyarchdir:
 
71
                self.env.ARCHDIR_RUBY=Options.options.rubyarchdir
 
72
        else:
 
73
                self.env.ARCHDIR_RUBY=read_config('sitearchdir')[0]
 
74
        if Options.options.rubylibdir:
 
75
                self.env.LIBDIR_RUBY=Options.options.rubylibdir
 
76
        else:
 
77
                self.env.LIBDIR_RUBY=read_config('sitelibdir')[0]
 
78
def options(opt):
 
79
        opt.add_option('--with-ruby-archdir',type='string',dest='rubyarchdir',help='Specify directory where to install arch specific files')
 
80
        opt.add_option('--with-ruby-libdir',type='string',dest='rubylibdir',help='Specify alternate ruby library path')
 
81
        opt.add_option('--with-ruby-binary',type='string',dest='rubybinary',help='Specify alternate ruby binary')
 
82
 
 
83
feature('rubyext')(init_rubyext)
 
84
before('apply_incpaths','apply_lib_vars','apply_bundle','apply_link')(init_rubyext)
 
85
feature('rubyext')(apply_ruby_so_name)
 
86
before('apply_link','propagate_uselib')(apply_ruby_so_name)
 
87
conf(check_ruby_version)
 
88
conf(check_ruby_ext_devel)
 
 
b'\\ No newline at end of file'