~ubuntu-branches/ubuntu/trusty/xiphos/trusty

« back to all changes in this revision

Viewing changes to wafadmin/Tools/perl.py

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs, Dmitrijs Ledkovs
  • Date: 2012-03-11 18:43:32 UTC
  • mfrom: (17.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20120311184332-splq3ecpx7tyi87d
Tags: 3.1.5+dfsg-1
[ Dmitrijs Ledkovs <dmitrij.ledkov@ubuntu.com> ]  
* New upstream release.
* Build using webkit backend
* Contains unpacked source for waf binary (Closes: #654511)
* Update debian/copyright to latest specification

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/env python
 
2
# encoding: utf-8
 
3
 
 
4
import os
 
5
import Task,Options,Utils
 
6
from Configure import conf
 
7
from TaskGen import extension,taskgen,feature,before
 
8
xsubpp_str='${PERL} ${XSUBPP} -noprototypes -typemap ${EXTUTILS_TYPEMAP} ${SRC} > ${TGT}'
 
9
EXT_XS=['.xs']
 
10
def init_perlext(self):
 
11
        self.uselib=self.to_list(getattr(self,'uselib',''))
 
12
        if not'PERL'in self.uselib:self.uselib.append('PERL')
 
13
        if not'PERLEXT'in self.uselib:self.uselib.append('PERLEXT')
 
14
        self.env['shlib_PATTERN']=self.env['perlext_PATTERN']
 
15
def xsubpp_file(self,node):
 
16
        outnode=node.change_ext('.c')
 
17
        self.create_task('xsubpp',node,outnode)
 
18
        self.allnodes.append(outnode)
 
19
Task.simple_task_type('xsubpp',xsubpp_str,color='BLUE',before='cc cxx',shell=False)
 
20
def check_perl_version(conf,minver=None):
 
21
        if getattr(Options.options,'perlbinary',None):
 
22
                conf.env.PERL=Options.options.perlbinary
 
23
        else:
 
24
                conf.find_program('perl',var='PERL',mandatory=True)
 
25
        try:
 
26
                version=Utils.cmd_output([conf.env.PERL,'-e','printf "%vd",$^V'])
 
27
        except:
 
28
                conf.fatal('could not determine the perl version')
 
29
        conf.env.PERL_VERSION=version
 
30
        cver=''
 
31
        if minver:
 
32
                try:
 
33
                        ver=tuple(map(int,version.split('.')))
 
34
                except:
 
35
                        conf.fatal('unsupported perl version %r'%version)
 
36
                if ver<minver:
 
37
                        conf.fatal('perl is too old')
 
38
                cver='.'.join(map(str,minver))
 
39
        conf.check_message('perl',cver,True,version)
 
40
def check_perl_module(conf,module):
 
41
        cmd=[conf.env['PERL'],'-e','use %s'%module]
 
42
        r=Utils.pproc.call(cmd,stdout=Utils.pproc.PIPE,stderr=Utils.pproc.PIPE)==0
 
43
        conf.check_message("perl module %s"%module,"",r)
 
44
        return r
 
45
def check_perl_ext_devel(conf):
 
46
        if not conf.env.PERL:
 
47
                conf.fatal('perl detection is required first')
 
48
        def read_out(cmd):
 
49
                return Utils.to_list(Utils.cmd_output([conf.env.PERL,'-MConfig','-e',cmd]))
 
50
        conf.env.LINKFLAGS_PERLEXT=read_out('print $Config{lddlflags}')
 
51
        conf.env.CPPPATH_PERLEXT=read_out('print "$Config{archlib}/CORE"')
 
52
        conf.env.CCFLAGS_PERLEXT=read_out('print "$Config{ccflags} $Config{cccdlflags}"')
 
53
        conf.env.XSUBPP=read_out('print "$Config{privlib}/ExtUtils/xsubpp$Config{exe_ext}"')
 
54
        conf.env.EXTUTILS_TYPEMAP=read_out('print "$Config{privlib}/ExtUtils/typemap"')
 
55
        conf.env.perlext_PATTERN='%s.'+read_out('print $Config{dlext}')[0]
 
56
        if getattr(Options.options,'perlarchdir',None):
 
57
                conf.env.ARCHDIR_PERL=Options.options.perlarchdir
 
58
        else:
 
59
                conf.env.ARCHDIR_PERL=read_out('print $Config{sitearch}')[0]
 
60
def set_options(opt):
 
61
        opt.add_option("--with-perl-binary",type="string",dest="perlbinary",help='Specify alternate perl binary',default=None)
 
62
        opt.add_option("--with-perl-archdir",type="string",dest="perlarchdir",help='Specify directory where to install arch specific files',default=None)
 
63
 
 
64
before('apply_incpaths','apply_type_vars','apply_lib_vars')(init_perlext)
 
65
feature('perlext')(init_perlext)
 
66
extension(EXT_XS)(xsubpp_file)
 
67
conf(check_perl_version)
 
68
conf(check_perl_module)
 
69
conf(check_perl_ext_devel)