source: waflib/Tools/ruby.py @ eeda761

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since eeda761 was 0fa325b, checked in by Paul Brossier <piem@piem.org>, 11 years ago

waf: unpack

  • Property mode set to 100644
File size: 3.8 KB
Line 
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
5import os
6from waflib import Task,Options,Utils
7from waflib.TaskGen import before_method,feature,after_method,Task,extension
8from waflib.Configure import conf
9@feature('rubyext')
10@before_method('apply_incpaths','apply_lib_vars','apply_bundle','apply_link')
11def init_rubyext(self):
12        self.install_path='${ARCHDIR_RUBY}'
13        self.uselib=self.to_list(getattr(self,'uselib',''))
14        if not'RUBY'in self.uselib:
15                self.uselib.append('RUBY')
16        if not'RUBYEXT'in self.uselib:
17                self.uselib.append('RUBYEXT')
18@feature('rubyext')
19@before_method('apply_link','propagate_uselib')
20def apply_ruby_so_name(self):
21        self.env['cshlib_PATTERN']=self.env['cxxshlib_PATTERN']=self.env['rubyext_PATTERN']
22@conf
23def check_ruby_version(self,minver=()):
24        if Options.options.rubybinary:
25                self.env.RUBY=Options.options.rubybinary
26        else:
27                self.find_program('ruby',var='RUBY')
28        ruby=self.env.RUBY
29        try:
30                version=self.cmd_and_log([ruby,'-e','puts defined?(VERSION) ? VERSION : RUBY_VERSION']).strip()
31        except Exception:
32                self.fatal('could not determine ruby version')
33        self.env.RUBY_VERSION=version
34        try:
35                ver=tuple(map(int,version.split(".")))
36        except Exception:
37                self.fatal('unsupported ruby version %r'%version)
38        cver=''
39        if minver:
40                if ver<minver:
41                        self.fatal('ruby is too old %r'%ver)
42                cver='.'.join([str(x)for x in minver])
43        else:
44                cver=ver
45        self.msg('Checking for ruby version %s'%str(minver or''),cver)
46@conf
47def check_ruby_ext_devel(self):
48        if not self.env.RUBY:
49                self.fatal('ruby detection is required first')
50        if not self.env.CC_NAME and not self.env.CXX_NAME:
51                self.fatal('load a c/c++ compiler first')
52        version=tuple(map(int,self.env.RUBY_VERSION.split(".")))
53        def read_out(cmd):
54                return Utils.to_list(self.cmd_and_log([self.env.RUBY,'-rrbconfig','-e',cmd]))
55        def read_config(key):
56                return read_out('puts Config::CONFIG[%r]'%key)
57        ruby=self.env['RUBY']
58        archdir=read_config('archdir')
59        cpppath=archdir
60        if version>=(1,9,0):
61                ruby_hdrdir=read_config('rubyhdrdir')
62                cpppath+=ruby_hdrdir
63                cpppath+=[os.path.join(ruby_hdrdir[0],read_config('arch')[0])]
64        self.check(header_name='ruby.h',includes=cpppath,errmsg='could not find ruby header file')
65        self.env.LIBPATH_RUBYEXT=read_config('libdir')
66        self.env.LIBPATH_RUBYEXT+=archdir
67        self.env.INCLUDES_RUBYEXT=cpppath
68        self.env.CFLAGS_RUBYEXT=read_config('CCDLFLAGS')
69        self.env.rubyext_PATTERN='%s.'+read_config('DLEXT')[0]
70        flags=read_config('LDSHARED')
71        while flags and flags[0][0]!='-':
72                flags=flags[1:]
73        if len(flags)>1 and flags[1]=="ppc":
74                flags=flags[2:]
75        self.env.LINKFLAGS_RUBYEXT=flags
76        self.env.LINKFLAGS_RUBYEXT+=read_config('LIBS')
77        self.env.LINKFLAGS_RUBYEXT+=read_config('LIBRUBYARG_SHARED')
78        if Options.options.rubyarchdir:
79                self.env.ARCHDIR_RUBY=Options.options.rubyarchdir
80        else:
81                self.env.ARCHDIR_RUBY=read_config('sitearchdir')[0]
82        if Options.options.rubylibdir:
83                self.env.LIBDIR_RUBY=Options.options.rubylibdir
84        else:
85                self.env.LIBDIR_RUBY=read_config('sitelibdir')[0]
86@conf
87def check_ruby_module(self,module_name):
88        self.start_msg('Ruby module %s'%module_name)
89        try:
90                self.cmd_and_log([self.env['RUBY'],'-e','require \'%s\';puts 1'%module_name])
91        except Exception:
92                self.end_msg(False)
93                self.fatal('Could not find the ruby module %r'%module_name)
94        self.end_msg(True)
95@extension('.rb')
96def process(self,node):
97        tsk=self.create_task('run_ruby',node)
98class run_ruby(Task.Task):
99        run_str='${RUBY} ${RBFLAGS} -I ${SRC[0].parent.abspath()} ${SRC}'
100def options(opt):
101        opt.add_option('--with-ruby-archdir',type='string',dest='rubyarchdir',help='Specify directory where to install arch specific files')
102        opt.add_option('--with-ruby-libdir',type='string',dest='rubylibdir',help='Specify alternate ruby library path')
103        opt.add_option('--with-ruby-binary',type='string',dest='rubybinary',help='Specify alternate ruby binary')
Note: See TracBrowser for help on using the repository browser.