Package wafadmin :: Package Tools :: Module perl
[hide private]
[frames] | no frames]

Source Code for Module wafadmin.Tools.perl

  1  #!/usr/bin/env python 
  2  # encoding: utf-8 
  3  # andersg at 0x63.nu 2007 
  4   
  5  import os 
  6  import pproc 
  7  import Task, Options 
  8  from Configure import conf 
  9  from TaskGen import extension, taskgen, feature, before 
 10   
 11  xsubpp_str = '${PERL} ${XSUBPP} -noprototypes -typemap ${EXTUTILS_TYPEMAP} ${SRC} > ${TGT}' 
 12  EXT_XS = ['.xs'] 
13 14 @taskgen 15 @before('apply_incpaths') 16 @feature('perlext') 17 -def init_pyext(self):
18 self.uselib = self.to_list(self.uselib) 19 if not 'PERL' in self.uselib: self.uselib.append('PERL') 20 if not 'PERLEXT' in self.uselib: self.uselib.append('PERLEXT') 21 self.env['shlib_PATTERN'] = self.env['perlext_PATTERN']
22
23 24 @extension(EXT_XS) 25 -def xsubpp_file(self, node):
26 gentask = self.create_task('xsubpp') 27 gentask.set_inputs(node) 28 outnode = node.change_ext('.c') 29 gentask.set_outputs(outnode) 30 31 self.allnodes.append(outnode)
32 33 Task.simple_task_type('xsubpp', xsubpp_str, color='BLUE', before="cc cxx")
34 35 @conf 36 -def check_perl_version(conf, minver=None):
37 """ 38 Checks if perl is installed. 39 40 If installed the variable PERL will be set in environment. 41 42 Perl binary can be overridden by --with-perl-binary config variable 43 44 """ 45 res = True 46 47 if not getattr(Options.options, 'perlbinary', None): 48 perl = conf.find_program("perl", var="PERL") 49 if not perl: 50 return False 51 else: 52 perl = Options.options.perlbinary 53 conf.env['PERL'] = perl 54 55 version = Utils.cmd_output(perl + " -e'printf \"%vd\", $^V'") 56 if not version: 57 res = False 58 version = "Unknown" 59 elif not minver is None: 60 ver = tuple(map(int, version.split("."))) 61 if ver < minver: 62 res = False 63 64 if minver is None: 65 cver = "" 66 else: 67 cver = ".".join(map(str,minver)) 68 conf.check_message("perl", cver, res, version) 69 return res
70
71 @conf 72 -def check_perl_module(conf, module):
73 """ 74 Check if specified perlmodule is installed. 75 76 Minimum version can be specified by specifying it after modulename 77 like this: 78 79 conf.check_perl_module("Some::Module 2.92") 80 """ 81 cmd = [conf.env['PERL'], '-e', 'use %s' % module] 82 r = pproc.call(cmd, stdout=pproc.PIPE, stderr=pproc.PIPE) == 0 83 conf.check_message("perl module %s" % module, "", r) 84 return r
85
86 @conf 87 -def check_perl_ext_devel(conf):
88 """ 89 Check for configuration needed to build perl extensions. 90 91 Sets different xxx_PERLEXT variables in the environment. 92 93 Also sets the ARCHDIR_PERL variable useful as installation path, 94 which can be overridden by --with-perl-archdir option. 95 """ 96 if not conf.env['PERL']: 97 return False 98 99 perl = conf.env['PERL'] 100 101 conf.env["LINKFLAGS_PERLEXT"] = Utils.cmd_output(perl + " -MConfig -e'print $Config{lddlflags}'") 102 conf.env["CPPPATH_PERLEXT"] = Utils.cmd_output(perl + " -MConfig -e'print \"$Config{archlib}/CORE\"'") 103 conf.env["CCFLAGS_PERLEXT"] = Utils.cmd_output(perl + " -MConfig -e'print \"$Config{ccflags} $Config{cccdlflags}\"'") 104 105 conf.env["XSUBPP"] = Utils.cmd_output(perl + " -MConfig -e'print \"$Config{privlib}/ExtUtils/xsubpp$Config{exe_ext}\"'") 106 conf.env["EXTUTILS_TYPEMAP"] = Utils.cmd_output(perl + " -MConfig -e'print \"$Config{privlib}/ExtUtils/typemap\"'") 107 108 if not getattr(Options.options, 'perlarchdir', None): 109 conf.env["ARCHDIR_PERL"] = Utils.cmd_output(perl + " -MConfig -e'print $Config{sitearch}'") 110 else: 111 conf.env["ARCHDIR_PERL"] = getattr(Options.options, 'perlarchdir') 112 113 conf.env['perlext_PATTERN'] = '%s.' + Utils.cmd_output(perl + " -MConfig -e'print $Config{dlext}'") 114 115 return True
116
117 -def detect(conf):
118 pass
119
120 -def set_options(opt):
121 opt.add_option("--with-perl-binary", type="string", dest="perlbinary", help = 'Specify alternate perl binary', default=None) 122 opt.add_option("--with-perl-archdir", type="string", dest="perlarchdir", help = 'Specify directory where to install arch specific files', default=None)
123