~ubuntu-branches/ubuntu/utopic/ardour3/utopic

« back to all changes in this revision

Viewing changes to waflib/Tools/ruby.py

  • Committer: Package Import Robot
  • Author(s): Felipe Sateler, Felipe Sateler, Jaromír Mikeš
  • Date: 2013-09-21 19:05:02 UTC
  • Revision ID: package-import@ubuntu.com-20130921190502-9by89mlwhy6cpjxo
Tags: 3.4~dfsg-2
* Team upload.

[ Felipe Sateler ]
* Re-upload to unstable

[ Jaromír Mikeš ]
* Update copyright file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
# encoding: utf-8
 
3
# WARNING! Do not edit! http://waf.googlecode.com/git/docs/wafbook/single.html#_obtaining_the_waf_file
 
4
 
 
5
import os
 
6
from waflib import Task,Options,Utils
 
7
from waflib.TaskGen import before_method,feature,after_method,Task,extension
 
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
        else:
 
39
                cver=ver
 
40
        self.msg('Checking for ruby version %s'%str(minver or''),cver)
 
41
def check_ruby_ext_devel(self):
 
42
        if not self.env.RUBY:
 
43
                self.fatal('ruby detection is required first')
 
44
        if not self.env.CC_NAME and not self.env.CXX_NAME:
 
45
                self.fatal('load a c/c++ compiler first')
 
46
        version=tuple(map(int,self.env.RUBY_VERSION.split(".")))
 
47
        def read_out(cmd):
 
48
                return Utils.to_list(self.cmd_and_log([self.env.RUBY,'-rrbconfig','-e',cmd]))
 
49
        def read_config(key):
 
50
                return read_out('puts Config::CONFIG[%r]'%key)
 
51
        ruby=self.env['RUBY']
 
52
        archdir=read_config('archdir')
 
53
        cpppath=archdir
 
54
        if version>=(1,9,0):
 
55
                ruby_hdrdir=read_config('rubyhdrdir')
 
56
                cpppath+=ruby_hdrdir
 
57
                cpppath+=[os.path.join(ruby_hdrdir[0],read_config('arch')[0])]
 
58
        self.check(header_name='ruby.h',includes=cpppath,errmsg='could not find ruby header file')
 
59
        self.env.LIBPATH_RUBYEXT=read_config('libdir')
 
60
        self.env.LIBPATH_RUBYEXT+=archdir
 
61
        self.env.INCLUDES_RUBYEXT=cpppath
 
62
        self.env.CFLAGS_RUBYEXT=read_config('CCDLFLAGS')
 
63
        self.env.rubyext_PATTERN='%s.'+read_config('DLEXT')[0]
 
64
        flags=read_config('LDSHARED')
 
65
        while flags and flags[0][0]!='-':
 
66
                flags=flags[1:]
 
67
        if len(flags)>1 and flags[1]=="ppc":
 
68
                flags=flags[2:]
 
69
        self.env.LINKFLAGS_RUBYEXT=flags
 
70
        self.env.LINKFLAGS_RUBYEXT+=read_config('LIBS')
 
71
        self.env.LINKFLAGS_RUBYEXT+=read_config('LIBRUBYARG_SHARED')
 
72
        if Options.options.rubyarchdir:
 
73
                self.env.ARCHDIR_RUBY=Options.options.rubyarchdir
 
74
        else:
 
75
                self.env.ARCHDIR_RUBY=read_config('sitearchdir')[0]
 
76
        if Options.options.rubylibdir:
 
77
                self.env.LIBDIR_RUBY=Options.options.rubylibdir
 
78
        else:
 
79
                self.env.LIBDIR_RUBY=read_config('sitelibdir')[0]
 
80
def check_ruby_module(self,module_name):
 
81
        self.start_msg('Ruby module %s'%module_name)
 
82
        try:
 
83
                self.cmd_and_log([self.env['RUBY'],'-e','require \'%s\';puts 1'%module_name])
 
84
        except:
 
85
                self.end_msg(False)
 
86
                self.fatal('Could not find the ruby module %r'%module_name)
 
87
        self.end_msg(True)
 
88
def process(self,node):
 
89
        tsk=self.create_task('run_ruby',node)
 
90
class run_ruby(Task.Task):
 
91
        run_str='${RUBY} ${RBFLAGS} -I ${SRC[0].parent.abspath()} ${SRC}'
 
92
def options(opt):
 
93
        opt.add_option('--with-ruby-archdir',type='string',dest='rubyarchdir',help='Specify directory where to install arch specific files')
 
94
        opt.add_option('--with-ruby-libdir',type='string',dest='rubylibdir',help='Specify alternate ruby library path')
 
95
        opt.add_option('--with-ruby-binary',type='string',dest='rubybinary',help='Specify alternate ruby binary')
 
96
 
 
97
feature('rubyext')(init_rubyext)
 
98
before_method('apply_incpaths','apply_lib_vars','apply_bundle','apply_link')(init_rubyext)
 
99
feature('rubyext')(apply_ruby_so_name)
 
100
before_method('apply_link','propagate_uselib')(apply_ruby_so_name)
 
101
conf(check_ruby_version)
 
102
conf(check_ruby_ext_devel)
 
103
conf(check_ruby_module)
 
104
extension('.rb')(process)
 
 
b'\\ No newline at end of file'