~elementary-apps/noise/trunk

« back to all changes in this revision

Viewing changes to .waf-1.6.2-ad4cc42bd7d347f7e283789e711b993f/waflib/Tools/perl.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.Configure import conf
 
8
from waflib.TaskGen import extension,feature,before
 
9
def init_perlext(self):
 
10
        self.uselib=self.to_list(getattr(self,'uselib',[]))
 
11
        if not'PERLEXT'in self.uselib:self.uselib.append('PERLEXT')
 
12
        self.env['cshlib_PATTERN']=self.env['cxxshlib_PATTERN']=self.env['perlext_PATTERN']
 
13
def xsubpp_file(self,node):
 
14
        outnode=node.change_ext('.c')
 
15
        self.create_task('xsubpp',node,outnode)
 
16
        self.source.append(outnode)
 
17
class xsubpp(Task.Task):
 
18
        run_str='${PERL} ${XSUBPP} -noprototypes -typemap ${EXTUTILS_TYPEMAP} ${SRC} > ${TGT}'
 
19
        color='BLUE'
 
20
        ext_out=['.h']
 
21
def check_perl_version(self,minver=None):
 
22
        res=True
 
23
        if not getattr(Options.options,'perlbinary',None):
 
24
                perl=self.find_program('perl',var='PERL')
 
25
                if not perl:
 
26
                        return False
 
27
        else:
 
28
                self.env['PERL']=perl=Options.options.perlbinary
 
29
        version=self.cmd_and_log([perl,"-e",'printf \"%vd\", $^V'])
 
30
        if not version:
 
31
                res=False
 
32
                version="Unknown"
 
33
        elif not minver is None:
 
34
                ver=tuple(map(int,version.split(".")))
 
35
                if ver<minver:
 
36
                        res=False
 
37
        if minver is None:
 
38
                cver=""
 
39
        else:
 
40
                cver=".".join(map(str,minver))
 
41
        self.msg('Checking for perl version',cver)
 
42
        return res
 
43
def check_perl_module(self,module):
 
44
        cmd=[self.env['PERL'],'-e','use %s'%module]
 
45
        self.start_msg('perl module %s'%module)
 
46
        try:
 
47
                r=self.cmd_and_log(cmd)
 
48
        except:
 
49
                self.end_msg(False)
 
50
                return None
 
51
        self.end_msg(r or True)
 
52
        return r
 
53
def check_perl_ext_devel(self):
 
54
        env=self.env
 
55
        perl=env.PERL
 
56
        if not perl:
 
57
                self.fatal('find perl first')
 
58
        def read_out(cmd):
 
59
                return Utils.to_list(self.cmd_and_log(perl+cmd))
 
60
        env['LINKFLAGS_PERLEXT']=read_out(" -MConfig -e'print $Config{lddlflags}'")
 
61
        env['INCLUDES_PERLEXT']=read_out(" -MConfig -e'print \"$Config{archlib}/CORE\"'")
 
62
        env['CFLAGS_PERLEXT']=read_out(" -MConfig -e'print \"$Config{ccflags} $Config{cccdlflags}\"'")
 
63
        env['XSUBPP']=read_out(" -MConfig -e'print \"$Config{privlib}/ExtUtils/xsubpp$Config{exe_ext}\"'")
 
64
        env['EXTUTILS_TYPEMAP']=read_out(" -MConfig -e'print \"$Config{privlib}/ExtUtils/typemap\"'")
 
65
        if not getattr(Options.options,'perlarchdir',None):
 
66
                env['ARCHDIR_PERL']=self.cmd_and_log(perl+" -MConfig -e'print $Config{sitearch}'")
 
67
        else:
 
68
                env['ARCHDIR_PERL']=getattr(Options.options,'perlarchdir')
 
69
        env['perlext_PATTERN']='%s.'+self.cmd_and_log(perl+" -MConfig -e'print $Config{dlext}'")
 
70
def options(opt):
 
71
        opt.add_option('--with-perl-binary',type='string',dest='perlbinary',help='Specify alternate perl binary',default=None)
 
72
        opt.add_option('--with-perl-archdir',type='string',dest='perlarchdir',help='Specify directory where to install arch specific files',default=None)
 
73
 
 
74
before('apply_incpaths','apply_link','propagate_uselib_vars')(init_perlext)
 
75
feature('perlext')(init_perlext)
 
76
extension('.xs')(xsubpp_file)
 
77
conf(check_perl_version)
 
78
conf(check_perl_module)
 
79
conf(check_perl_ext_devel)
 
 
b'\\ No newline at end of file'