def feature_py(self):
	install_path=getattr(self,'install_path','${PYTHONDIR}')
	install_from=getattr(self,'install_from',None)
	if install_from and not isinstance(install_from,Node.Node):
		install_from=self.path.find_dir(install_from)
	inputs=[]
	for x in Utils.to_list(self.source):
		if isinstance(x,Node.Node):
			y=x
		else:
			y=self.path.find_resource(x)
		inputs.append(y)
		if install_path:
			if install_from:
				pyd=Utils.subst_vars("%s/%s"%(install_path,y.path_from(install_from)),self.env)
			else:
				pyd=Utils.subst_vars("%s/%s"%(install_path,y.path_from(self.path)),self.env)
		else:
			pyd=y.abspath()
		for ext in("pyc","pyo"):
			if install_from:
				pyobj=self.path.get_bld().make_node(y.change_ext(".%s"%ext).get_bld().path_from(install_from.get_bld()))
			else:
				pyobj=self.path.get_bld().make_node(y.change_ext(".%s"%ext).name)
			pyobj.parent.mkdir()
			tsk=self.create_task(ext,y,pyobj)
			tsk.pyd=pyd
			if install_path:
				self.bld.install_files(install_path,pyobj,cwd=self.path.get_bld(),relative_trick=True)
	if install_path:
		if install_from:
			self.bld.install_files(install_path,inputs,cwd=install_from,relative_trick=True)
		else:
			self.bld.install_files(install_path,inputs)
Beispiel #2
0
def process_py(self,node):
	assert(node.get_bld_sig())
	assert(getattr(self,'install_path')),'add features="py"'
	if self.install_path:
		if self.install_from:
			self.bld.install_files(self.install_path,[node],cwd=self.install_from,relative_trick=True)
		else:
			self.bld.install_files(self.install_path,[node],relative_trick=True)
	lst=[]
	if self.env.PYC:
		lst.append('pyc')
	if self.env.PYO:
		lst.append('pyo')
	if self.install_path:
		if self.install_from:
			pyd=Utils.subst_vars("%s/%s"%(self.install_path,node.path_from(self.install_from)),self.env)
		else:
			pyd=Utils.subst_vars("%s/%s"%(self.install_path,node.path_from(self.path)),self.env)
	else:
		pyd=node.abspath()
	for ext in lst:
		if self.env.PYTAG:
			name=node.name[:-3]
			pyobj=node.parent.get_bld().make_node('__pycache__').make_node("%s.%s.%s"%(name,self.env.PYTAG,ext))
			pyobj.parent.mkdir()
		else:
			pyobj=node.change_ext(".%s"%ext)
		tsk=self.create_task(ext,node,pyobj)
		tsk.pyd=pyd
		if self.install_path:
			self.bld.install_files(os.path.dirname(pyd),pyobj,cwd=node.parent.get_bld(),relative_trick=True)
Beispiel #3
0
	def prepare_env(self,env):
		if not env.PREFIX:
			env.PREFIX=os.path.abspath(os.path.expanduser(Options.options.prefix))
		if not env.BINDIR:
			env.BINDIR=Utils.subst_vars('${PREFIX}/bin',env)
		if not env.LIBDIR:
			env.LIBDIR=Utils.subst_vars('${PREFIX}/lib',env)
Beispiel #4
0
	def prepare_env(self,env):
		if not env.PREFIX:
			env.PREFIX=os.path.abspath(os.path.expanduser(Options.options.prefix))
		if not env.BINDIR:
			env.BINDIR=Utils.subst_vars('${PREFIX}/bin',env)
		if not env.LIBDIR:
			env.LIBDIR=Utils.subst_vars('${PREFIX}/lib',env)
Beispiel #5
0
	def prepare_env(self, env):
		"""insert various variables in the environment"""
		if not env.PREFIX:
			env.PREFIX = os.path.abspath(os.path.expanduser(Options.options.prefix))
		if not env.BINDIR:
			env.BINDIR = Utils.subst_vars('${PREFIX}/bin', env)
		if not env.LIBDIR:
			env.LIBDIR = Utils.subst_vars('${PREFIX}/lib', env)
Beispiel #6
0
def process_py(self, node):
    """
    Add signature of .py file, so it will be byte-compiled when necessary
    """
    assert hasattr(self, "install_path"), 'add features="py"'

    # where to install the python file
    if self.install_path:
        if self.install_from:
            self.add_install_files(
                install_to=self.install_path,
                install_from=node,
                cwd=self.install_from,
                relative_trick=True,
            )
        else:
            self.add_install_files(install_to=self.install_path,
                                   install_from=node,
                                   relative_trick=True)

    lst = []
    if self.env.PYC:
        lst.append("pyc")
    if self.env.PYO:
        lst.append("pyo")

    if self.install_path:
        if self.install_from:
            pyd = Utils.subst_vars(
                "{}/{}".format(self.install_path,
                               node.path_from(self.install_from)), self.env)
        else:
            pyd = Utils.subst_vars(
                "{}/{}".format(self.install_path, node.path_from(self.path)),
                self.env)
    else:
        pyd = node.abspath()

    for ext in lst:
        if self.env.PYTAG and not self.env.NOPYCACHE:
            # __pycache__ installation for python 3.2 - PEP 3147
            name = node.name[:-3]
            pyobj = (node.parent.get_bld().make_node("__pycache__").make_node(
                f"{name}.{self.env.PYTAG}.{ext}"))
            pyobj.parent.mkdir()
        else:
            pyobj = node.change_ext(".%s" % ext)

        tsk = self.create_task(ext, node, pyobj)
        tsk.pyd = pyd

        if self.install_path:
            self.add_install_files(
                install_to=os.path.dirname(pyd),
                install_from=pyobj,
                cwd=node.parent.get_bld(),
                relative_trick=True,
            )
Beispiel #7
0
 def run(self):
     cmd = [
         Utils.subst_vars("${PYTHON}", self.env),
         Utils.subst_vars("${PYFLAGS_OPT}", self.env),
         "-c",
         INST,
         self.inputs[0].abspath(),
         self.outputs[0].abspath(),
         self.pyd,
     ]
     ret = self.generator.bld.exec_command(cmd)
     return ret
Beispiel #8
0
	def prepare_env(self, env):
		"""
		Insert *PREFIX*, *BINDIR* and *LIBDIR* values into ``env``

		:type env: :py:class:`waflib.ConfigSet.ConfigSet`
		:param env: a ConfigSet, usually ``conf.env``
		"""
		if not env.PREFIX:
			env.PREFIX = os.path.abspath(os.path.expanduser(Options.options.prefix))
		if not env.BINDIR:
			env.BINDIR = Utils.subst_vars('${PREFIX}/bin', env)
		if not env.LIBDIR:
			env.LIBDIR = Utils.subst_vars('${PREFIX}/lib', env)
Beispiel #9
0
def add_dependency(bld, tgt, src):
    # Expand configuration variables (e.g.
    # "${root}/tools" -> "/home/.../tenshi/tools")
    tgt = Utils.subst_vars(tgt, bld.env)
    src = Utils.subst_vars(src, bld.env)
    # Handle paths relative the current wscript
    src_node = bld.path.find_resource(src)
    if src_node is None:
        # Handle paths relative to the root and absolute paths.
        src_node = bld.root.find_resource(src)
    if src_node is None:
        bld.fatal("Could not find manual dependency '{}'".format(src))
    bld.add_manual_dependency(tgt, src_node)
Beispiel #10
0
def dep_build(self, *k, **kw):
    """Configure/Make/Make install to the dist directory"""
    k, kw = base(self, *k, **kw)
    k, kw = fetch(self, *k, **kw)

    self.start_msg("Building %s" % kw["name"])
    if not os.path.isdir(kw["prefix"]):
        config_cmd = kw.get("config_cmd", "%(src)s/configure --prefix=%(prefix)s")
        build_cmd = kw.get("build_cmd", Utils.subst_vars('${MAKE} ${JOBS}',self.env))
        install_cmd = kw.get("install_cmd", Utils.subst_vars('${MAKE} ${JOBS} install', self.env))
        self.end_msg("...")

        if not os.path.exists(kw["build"]):
            if kw.get("build_dir", True):
                os.makedirs(kw["build"])

            self.start_msg("  Configure %s" % kw["name"])
            self.cmd_and_log(
                config_cmd % kw, 
                #(config_cmd % kw).split(' '), 
                output=Context.BOTH, 
                shell=True,
                cwd=kw.get("config_cwd",kw["build"]) % kw
            )
            self.end_msg("Ok")

            self.start_msg("  Compile %s" % kw["name"])
            self.cmd_and_log(
                build_cmd % kw, 
                #(build_cmd % kw).split(' '), 
                output=Context.BOTH, 
                shell=True,
                cwd=kw.get("build_cwd",kw["build"]) % kw
            )
            self.end_msg("Ok")
        
        if not os.path.exists(kw["prefix"]):
            self.start_msg("  Install %s" % kw["name"])
            self.cmd_and_log(
                install_cmd % kw, 
                #(install_cmd % kw).split(' '), 
                output=Context.BOTH, 
                shell=True,
                cwd=kw.get("install_cwd",kw["build"]) % kw
            )
            self.end_msg("Ok")
    else:
        self.end_msg("Already done")
Beispiel #11
0
def apply_vnum(self):
	if not getattr(self,'vnum','')or os.name!='posix'or self.env.DEST_BINFMT not in('elf','mac-o'):
		return
	link=self.link_task
	nums=self.vnum.split('.')
	node=link.outputs[0]
	libname=node.name
	if libname.endswith('.dylib'):
		name3=libname.replace('.dylib','.%s.dylib'%self.vnum)
		name2=libname.replace('.dylib','.%s.dylib'%nums[0])
	else:
		name3=libname+'.'+self.vnum
		name2=libname+'.'+nums[0]
	if self.env.SONAME_ST:
		v=self.env.SONAME_ST%name2
		self.env.append_value('LINKFLAGS',v.split())
	self.create_task('vnum',node,[node.parent.find_or_declare(name2),node.parent.find_or_declare(name3)])
	if getattr(self.bld,'is_install',None):
		self.install_task.hasrun=Task.SKIP_ME
		bld=self.bld
		path=self.install_task.dest
		t1=bld.install_as(path+os.sep+name3,node,env=self.env,chmod=self.link_task.chmod)
		t2=bld.symlink_as(path+os.sep+name2,name3)
		t3=bld.symlink_as(path+os.sep+libname,name3)
		self.vnum_install_task=(t1,t2,t3)
	if'-dynamiclib'in self.env['LINKFLAGS']:
		try:
			inst_to=self.install_path
		except AttributeError:
			inst_to=self.link_task.__class__.inst_to
		if inst_to:
			p=Utils.subst_vars(inst_to,self.env)
			path=os.path.join(p,self.link_task.outputs[0].name)
			self.env.append_value('LINKFLAGS',['-install_name',path])
Beispiel #12
0
Datei: Build.py Projekt: zsx/waf
	def get_install_path(self):
		"installation path prefixed by the destdir, the variables like in '${PREFIX}/bin' are substituted"
		dest = self.dest.replace('/', os.sep)
		dest = Utils.subst_vars(self.dest, self.env)
		if Options.options.destdir:
			dest = os.path.join(Options.options.destdir, dest.lstrip(os.sep))
		return dest
Beispiel #13
0
def configure(self):
    try:
        if sys.version_info >= (3, 0):
            self.find_program('virtualenv', var="VIRTUALENV", mandatory=True, okmsg="ok")
        else:
            self.find_program('virtualenv2', var="VIRTUALENV", mandatory=True, okmsg="ok")
    except ConfigurationError as e:
        name    = "virtualenv"
        version = "trunk"
        self.dep_fetch(
          name    = name,
          version = version,
          git_url = "https://github.com/pypa/virtualenv.git",
        )
        self.find_program('virtualenv.py', var="VIRTUALENV", mandatory=True, okmsg="ok", path_list=[self.dep_path(name, version)])
    self.start_msg("Create python virtualenv")
    self.env["VENV_PATH"] = os.path.join(self.bldnode.abspath(), ".conf_check_venv")
    self.cmd_and_log(
        [Utils.subst_vars('${VIRTUALENV}',self.env), "-p", sys.executable, self.env.VENV_PATH],
        output=Context.BOTH,
        cwd=self.bldnode.abspath()
    )
    self.end_msg("ok")
    self.find_program('python', var="VPYTHON", mandatory=True, okmsg="ok", path_list=[os.path.join(self.env.VENV_PATH, "bin")])
    self.find_program('pip', var="VPIP", mandatory=True, okmsg="ok", path_list=[os.path.join(self.env.VENV_PATH, "bin")])
Beispiel #14
0
    def collect_properties(self):
        """
		Visual studio projects are associated with platforms and configurations (for building especially)
		"""
        super(vsnode_target, self).collect_properties()
        for x in self.build_properties:
            variant_name = x.configuration.lower() + '_' + (
                'x86' if x.platform == 'Win32' else 'x64')
            target = self.ctx.get_target_variant(self.tg.name, variant_name)

            install_path = ''
            if hasattr(target, 'install_path'):
                # TODO:
                # 	The folowing code is very ungly, fix this!
                try:
                    install_path = Utils.subst_vars(
                        getattr(target, 'install_path', ''), target.env)
                except Exception, e:
                    pass

            x.outdir = install_path
            x.preprocessor_definitions = ''
            x.includes_search_path = ''

            try:
                tsk = target.link_task
            except AttributeError:
                pass
            else:
                x.output_file = os.path.join(
                    install_path, os.path.basename(tsk.outputs[0].abspath()))
                x.preprocessor_definitions = ';'.join(tsk.env.DEFINES)
                x.includes_search_path = ';'.join(target.env.INCPATHS)
 def setup_py_build(task):
     """
     """
     if bld.env.IS_WINDOWS:
         wsdk_env = cls._get_wdsk_env()
         cmd = Utils.subst_vars('${PYTHON} setup.py build'\
             ' --build-base="${BUILD_DIR}/3rdParty/python/${MODULE_NAME}_${MODULE_VERSION}"'\
             ' --build-platlib="${BUILD_DIR}/3rdParty/python/${MODULE_NAME}_${MODULE_VERSION}/${PLATFORM_NAME}"'\
             ' --compiler=msvc', bld.env)
         task.exec_command(cmd, cwd=bld.path.abspath(), env=wsdk_env)
     else:
         cmd = Utils.subst_vars('${PYTHON} setup.py build'\
             ' --build-base="${BUILD_DIR}/3rdParty/python/${MODULE_NAME}_${MODULE_VERSION}"'\
             ' --build-platlib="${BUILD_DIR}/3rdParty/python/${MODULE_NAME}_${MODULE_VERSION}/${PLATFORM_NAME}"',
             bld.env)
         task.exec_command(cmd, cwd=bld.path.abspath(), env=wsdk_env)
Beispiel #16
0
	def prepare_env(self,env):
		if not env.PREFIX:
			if Options.options.prefix or Utils.is_win32:
				env.PREFIX=Options.options.prefix
			else:
				env.PREFIX='/'
		if not env.BINDIR:
			if Options.options.bindir:
				env.BINDIR=Options.options.bindir
			else:
				env.BINDIR=Utils.subst_vars('${PREFIX}/bin',env)
		if not env.LIBDIR:
			if Options.options.libdir:
				env.LIBDIR=Options.options.libdir
			else:
				env.LIBDIR=Utils.subst_vars('${PREFIX}/lib%s'%Utils.lib64(),env)
Beispiel #17
0
def ApplyCustomManifestsSubTask(parent_task):
    # CATEGORIZE THE OUTPUT RESOURCE.
    output_node = parent_task.outputs[0]
    is_exe = (output_node.suffix() == '.exe')
    EXE_MODE = 1
    DLL_MODE = 2
    resource_id = EXE_MODE if is_exe else DLL_MODE

    # FORM THE COMMAND TO CALL THE MANIFEST TOOL.
    # See http://msdn.microsoft.com/en-us/library/aa375649%28v=vs.100%29.aspx for more info.
    # Multiple manifests can be specified in a single call by forming a space-separated list.
    get_quoted_path = lambda node: '"{}"'.format(node.abspath())
    manifest_tool_path = Utils.subst_vars('"${MT}"', parent_task.env)
    manifest_file_nodes = parent_task.generator.manifest_files
    quoted_manifest_paths = ' '.join(map(get_quoted_path, manifest_file_nodes))
    manifest_tool_command = ' '.join([
        '{manifest_tool}',
        '-manifest {manifest_paths}',
        '-outputresource:{exe_path};{resource_id}']).format(
        manifest_tool = manifest_tool_path,
        manifest_paths = quoted_manifest_paths,
        exe_path = get_quoted_path(output_node),
        resource_id = resource_id)

    # CALL THE MANIFEST TOOL.
    manifest_tool_result = parent_task.exec_command(manifest_tool_command)
    return manifest_tool_result
Beispiel #18
0
def get_inst_node(self, dest, name):
	dest = Utils.subst_vars(dest, self.env)
	dest = dest.replace('/', os.sep)
	if Options.options.destdir:
		dest = os.path.join(Options.options.destdir, os.path.splitdrive(dest)[1].lstrip(os.sep))

	return self.bld.srcnode.make_node([dest, name])
Beispiel #19
0
def configure(conf):
	def get_param(varname,default):
		return getattr(Options.options,varname,'')or default
	env=conf.env
	env.LIBDIR=env.BINDIR=[]
	env.EXEC_PREFIX=get_param('EXEC_PREFIX',env.PREFIX)
	corner_case=False
	if str(env.PREFIX)=='/usr':
		corner_case=True
		env.PREFIX=''
	env.PACKAGE=getattr(Context.g_module,'APPNAME',None)or env.PACKAGE
	complete=False
	iter=0
	while not complete and iter<len(_options)+1:
		iter+=1
		complete=True
		for name,help,default in _options:
			name=name.upper()
			if not env[name]:
				try:
					env[name]=Utils.subst_vars(get_param(name,default).replace('/',os.sep),env)
				except TypeError:
					complete=False
	if corner_case:
		env.PREFIX='/usr'
	if not complete:
		lst=[name for name,_,_ in _options if not env[name.upper()]]
		raise conf.errors.WafError('Variable substitution failure %r'%lst)
Beispiel #20
0
def configure(self):
    try:
        if sys.version_info >= (3, 0):
            self.find_program(['virtualenv', 'virtualenv.py', 'virtualenv.exe'], var="VIRTUALENV", mandatory=True, okmsg="ok")
        else:
            self.find_program(['virtualenv2', 'virtualenv2.py', 'virtualenv2.exe', 'virtualenv', 'virtualenv.py', 'virtualenv.exe'], var="VIRTUALENV", mandatory=True, okmsg="ok")
    except ConfigurationError as e:
        name    = "virtualenv"
        version = "trunk"
        self.dep_fetch(
          name    = name,
          version = version,
          git_url = "https://github.com/pypa/virtualenv.git",
        )
        self.find_program(['virtualenv', 'virtualenv.py', 'virtualenv.exe'], var="VIRTUALENV", mandatory=True, okmsg="ok", path_list=[self.dep_path(name, version)])
    self.start_msg("Create python virtualenv")
    self.env["VENV_PATH"] = os.path.join(self.bldnode.abspath(), ".conf_check_venv")
    self.cmd_and_log(
        [Utils.subst_vars('${VIRTUALENV}',self.env), "-p", sys.executable, self.env.VENV_PATH],
        output=Context.BOTH,
        cwd=self.bldnode.abspath()
    )
    self.end_msg("ok")
    self.find_program('python', var="VPYTHON", mandatory=True, okmsg="ok", path_list=[os.path.join(self.env.VENV_PATH, "bin")])
    self.find_program('pip', var="VPIP", mandatory=True, okmsg="ok", path_list=[os.path.join(self.env.VENV_PATH, "bin")])
Beispiel #21
0
	def run(self):
		if not self.env['VALADOCFLAGS']:
			self.env['VALADOCFLAGS'] = ''
		cmd = [Utils.subst_vars(VALADOC_STR, self.env)]
		cmd.append ('-o %s' % self.output_dir)
		if getattr(self, 'doclet', None):
			cmd.append ('--doclet %s' % self.doclet)
		cmd.append ('--package-name %s' % self.package_name)
		if getattr(self, 'package_version', None):
			cmd.append ('--package-version %s' % self.package_version)
		if getattr(self, 'packages', None):
			for package in self.packages:
				cmd.append ('--pkg %s' % package)
		if getattr(self, 'vapi_dirs', None):
			for vapi_dir in self.vapi_dirs:
				cmd.append ('--vapidir %s' % vapi_dir)
		if not getattr(self, 'protected', None):
			cmd.append ('--no-protected')
		if getattr(self, 'private', None):
			cmd.append ('--private')
		if getattr(self, 'inherit', None):
			cmd.append ('--inherit')
		if getattr(self, 'deps', None):
			cmd.append ('--deps')
		if getattr(self, 'enable_non_null_experimental', None):
			cmd.append ('--enable-non-null-experimental')
		if getattr(self, 'force', None):
			cmd.append ('--force')
		cmd.append (' '.join ([x.abspath() for x in self.files]))
		return self.generator.bld.exec_command(' '.join(cmd))
	def prepare_env(self,env):
		if not env.PREFIX:
			if Options.options.prefix or Utils.is_win32:
				env.PREFIX=os.path.abspath(os.path.expanduser(Options.options.prefix))
			else:
				env.PREFIX=''
		if not env.BINDIR:
			if Options.options.bindir:
				env.BINDIR=os.path.abspath(os.path.expanduser(Options.options.bindir))
			else:
				env.BINDIR=Utils.subst_vars('${PREFIX}/bin',env)
		if not env.LIBDIR:
			if Options.options.libdir:
				env.LIBDIR=os.path.abspath(os.path.expanduser(Options.options.libdir))
			else:
				env.LIBDIR=Utils.subst_vars('${PREFIX}/lib%s'%Utils.lib64(),env)
Beispiel #23
0
def configure(conf):
	"""
	Read the command-line options to set lots of variables in *conf.env*. The variables
	BINDIR and LIBDIR will be overwritten.
	"""
	def get_param(varname, default):
		return getattr(Options.options, varname, '') or default

	env = conf.env
	conf.env.LIBDIR = conf.env.BINDIR = []
	env['EXEC_PREFIX'] = get_param('EXEC_PREFIX', env['PREFIX'])
	env['PACKAGE'] = getattr(Context.g_module, 'APPNAME', None) or env['PACKAGE']

	complete = False
	iter = 0
	while not complete and iter < len(_options) + 1:
		iter += 1
		complete = True
		for name, help, default in _options:
			name = name.upper()
			if not env[name]:
				try:
					env[name] = Utils.subst_vars(get_param(name, default).replace('/', os.sep), env)
				except TypeError:
					complete = False
	if not complete:
		lst = [name for name, _, _ in _options if not env[name.upper()]]
		raise conf.errors.WafError('Variable substitution failure %r' % lst)
Beispiel #24
0
def apply_target_framework(self):
	if getattr(self.bld, 'is_idegen', False):
		return

	# Add TargetFrameworkAttribute to the assembly
	self.env.EMIT_SOURCE = Utils.subst_vars(target_framework_template, self.env)
	name = '.NETFramework,Version=%s.AssemblyAttributes.cs' % self.env.TARGET_FRAMEWORK
	target = self.path.find_or_declare(name)
	tsk = self.create_task('emit', None, [ target ])
	self.source = self.to_nodes(self.source) + tsk.outputs

	# For any use entries that can't be resolved to a task generator
	# assume they are system reference assemblies and add them to the
	# ASSEMBLIES variable so they get full path linkage automatically added
	filtered = []
	names = self.to_list(getattr(self, 'use', []))
	get = self.bld.get_tgen_by_name
	for x in names:
		try:
			y = get(x)
			if 'fake_lib' in getattr(y, 'features', ''):
				y.post()
				install_outputs(y)
			filtered.append(x)
		except Errors.WafError:
			self.env.append_value('ASSEMBLIES', x)
	self.use = filtered
Beispiel #25
0
	def scan(self):
		"""
		Scan gresource dependencies through ``glib-compile-resources --generate-dependencies command``
		"""
		bld = self.generator.bld
		kw = {}
		try:
			if not kw.get('cwd', None):
				kw['cwd'] = bld.cwd
		except AttributeError:
			bld.cwd = kw['cwd'] = bld.variant_dir
		kw['quiet'] = Context.BOTH

		cmd = Utils.subst_vars('${GLIB_COMPILE_RESOURCES} --sourcedir=%s --sourcedir=%s --generate-dependencies %s' % (
			self.inputs[0].parent.srcpath(),
			self.inputs[0].bld_dir(),
			self.inputs[0].bldpath()
		), self.env)

		output = bld.cmd_and_log(cmd, **kw)

		nodes = []
		names = []
		for dep in output.splitlines():
			if dep:
				node = bld.bldnode.find_node(dep)
				if node:
					nodes.append(node)
				else:
					names.append(dep)

		return (nodes, names)
Beispiel #26
0
def apply_bdevnum(self):
    if (not getattr(self, 'bdevnum', '') or
       os.name != 'posix' or
       self.env.DEST_BINFMT not in ('elf', 'mac-o')):
        return

    link = self.link_task
    nums = self.bdevnum.split('.')
    node = link.outputs[0]

    libname = node.name
    if libname.endswith('.dylib'):
        name3 = libname.replace('.dylib', '.%s.dylib' % self.bdevnum)
        name2 = libname.replace('.dylib',
                                '.%s.dylib' % (nums[0] + '.' + nums[1]))
    else:
        name3 = libname + '.' + self.bdevnum
        name2 = libname + '.' + nums[0] + '.' + nums[1]

    # add the so name for the ld linker - to disable, just unset env.SONAME_ST
    if self.env.SONAME_ST:
        if getattr(self, 'bdesoname', None):
            v = self.env.SONAME_ST % self.bdesoname
        else:
            v = self.env.SONAME_ST % name2
        self.env.append_value('LINKFLAGS', v.split())

    # the following task is just to enable execution from the build dir :-/

    if self.env.DEST_OS != 'openbsd':
        self.create_task('vnum', node, [node.parent.find_or_declare(name2),
                                        node.parent.find_or_declare(name3)])

    if getattr(self, 'install_task', None):
        self.install_task.hasrun = Task.SKIP_ME
        bld = self.bld
        path = self.install_task.dest
        if self.env.DEST_OS == 'openbsd':
            libname = self.link_task.outputs[0].name
            t1 = bld.install_as('%s%s%s' % (path, os.sep, libname), node,
                                env=self.env, chmod=self.link_task.chmod)
            self.vnum_install_task = (t1,)
        else:
            t1 = bld.install_as(path + os.sep + name3, node, env=self.env,
                                chmod=self.link_task.chmod)
            t2 = bld.symlink_as(path + os.sep + name2, name3)
            t3 = bld.symlink_as(path + os.sep + libname, name3)
            self.vnum_install_task = (t1, t2, t3)

    if '-dynamiclib' in self.env['LINKFLAGS']:
        # this requires after(propagate_uselib_vars)
        try:
            inst_to = self.install_path
        except AttributeError:
            inst_to = self.link_task.__class__.inst_to
        if inst_to:
            p = Utils.subst_vars(inst_to, self.env)
            path = os.path.join(p, self.link_task.outputs[0].name)
            self.env.append_value('LINKFLAGS', ['-install_name', path])
Beispiel #27
0
	def get_ssh_hosts(self):
		lst = []
		for v in Context.g_module.variants:
			self.env.HOST = self.login_to_host(self.variant_to_login(v))
			cmd = Utils.subst_vars('${SSH_KEYSCAN} -t rsa,ecdsa ${HOST}', self.env)
			out, err = self.cmd_and_log(cmd, output=Context.BOTH, quiet=Context.BOTH)
			lst.append(out.strip())
		return lst
Beispiel #28
0
def python_get(self, name):
    self.start_msg("Install %s into virtualenv" % (name))
    self.cmd_and_log(
        [Utils.subst_vars('${VPIP}',self.env), "install", name],
        output=Context.BOTH,
        cwd=self.env.VENV_PATH
    )
    self.end_msg("ok")
Beispiel #29
0
	def run(self):
		code='\n'.join(['%s = %s'%(x,self.pars[x])for x in self.pars])
		code=code
		cmd=Utils.subst_vars(DOXY_STR,self.env)
		env=self.env.env or None
		proc=Utils.subprocess.Popen(cmd,shell=True,stdin=Utils.subprocess.PIPE,env=env,cwd=self.generator.bld.path.get_bld().abspath())
		proc.communicate(code)
		return proc.returncode
Beispiel #30
0
 def run(self):
     from waflib import Utils
     if getattr(self, 'code', None):
         txt = self.code
     else:
         txt = self.inputs[0].read()
     txt = Utils.subst_vars(txt, self.env)
     self.outputs[0].write(txt)
Beispiel #31
0
	def run(self):
		code = '\n'.join(['%s = %s' % (x, self.pars[x]) for x in self.pars])
		code = code.encode() # for python 3
		#fmt = DOXY_STR % (self.inputs[0].parent.abspath())
		cmd = Utils.subst_vars(DOXY_STR, self.env)
		proc = Utils.subprocess.Popen(cmd, shell=True, stdin=Utils.subprocess.PIPE)
		proc.communicate(code)
		return proc.returncode
Beispiel #32
0
	def get_install_path(self,destdir=True):
		if isinstance(self.install_to,Node.Node):
			dest=self.install_to.abspath()
		else:
			dest=Utils.subst_vars(self.install_to,self.env)
		if destdir and Options.options.destdir:
			dest=os.path.join(Options.options.destdir,os.path.splitdrive(dest)[1].lstrip(os.sep))
		return dest
Beispiel #33
0
	def run(self):
		dct=self.pars.copy()
		code='\n'.join(['%s = %s'%(x,dct[x])for x in self.pars])
		code=code
		cmd=Utils.subst_vars(DOXY_STR,self.env)
		env=self.env.env or None
		proc=Utils.subprocess.Popen(cmd,shell=True,stdin=Utils.subprocess.PIPE,env=env,cwd=self.inputs[0].parent.abspath())
		proc.communicate(code)
		return proc.returncode
Beispiel #34
0
def get_zip_src(self, tsk):
	destpath = Utils.subst_vars(tsk.dest, tsk.env).replace('/', os.sep)
	bindir = Utils.subst_vars('${BINDIR}', tsk.env)
	destpath = os.path.relpath(destpath, bindir)

	for src in tsk.source:
		if not hasattr(tsk, 'relative_trick'):
			destfile = destpath
		elif tsk.relative_trick:
			destfile = os.path.join(destpath, src.path_from(tsk.path))
		else:
			destfile = os.path.join(destpath, src.name)

		external_attr = tsk.chmod << 16L

		destfile = os.path.normpath(destfile).replace('\\', '/')

		self.zip_inputs.append((src, destfile, external_attr))
Beispiel #35
0
def apply_vnum(self):
	"""
	Enforce version numbering on shared libraries. The valid version numbers must have at most two dots::

		def build(bld):
			bld.shlib(source='a.c', target='foo', vnum='14.15.16')

	In this example, ``libfoo.so`` is installed as ``libfoo.so.1.2.3``, and the following symbolic links are created:

	* ``libfoo.so   → libfoo.so.1.2.3``
	* ``libfoo.so.1 → libfoo.so.1.2.3``
	"""
	if not getattr(self, 'vnum', '') or os.name != 'posix' or self.env.DEST_BINFMT not in ('elf', 'mac-o'):
		return

	link = self.link_task
	if not re_vnum.match(self.vnum):
		raise Errors.WafError('Invalid version %r for %r' % (self.vnum, self))
	nums = self.vnum.split('.')
	node = link.outputs[0]

	libname = node.name
	if libname.endswith('.dylib'):
		name3 = libname.replace('.dylib', '.%s.dylib' % self.vnum)
		name2 = libname.replace('.dylib', '.%s.dylib' % nums[0])
	else:
		name3 = libname + '.' + self.vnum
		name2 = libname + '.' + nums[0]

	# add the so name for the ld linker - to disable, just unset env.SONAME_ST
	if self.env.SONAME_ST:
		v = self.env.SONAME_ST % name2
		self.env.append_value('LINKFLAGS', v.split())

	# the following task is just to enable execution from the build dir :-/
	self.create_task('vnum', node, [node.parent.find_or_declare(name2), node.parent.find_or_declare(name3)])

	if getattr(self, 'install_task', None):
		self.install_task.hasrun = Task.SKIP_ME
		bld = self.bld
		path = self.install_task.dest
		t1 = bld.install_as(path + os.sep + name3, node, env=self.env, chmod=self.link_task.chmod)
		t2 = bld.symlink_as(path + os.sep + name2, name3)
		t3 = bld.symlink_as(path + os.sep + libname, name3)
		self.vnum_install_task = (t1, t2, t3)

	if '-dynamiclib' in self.env['LINKFLAGS']:
		# this requires after(propagate_uselib_vars)
		try:
			inst_to = self.install_path
		except AttributeError:
			inst_to = self.link_task.__class__.inst_to
		if inst_to:
			p = Utils.subst_vars(inst_to, self.env)
			path = os.path.join(p, self.link_task.outputs[0].name)
			self.env.append_value('LINKFLAGS', ['-install_name', path])
Beispiel #36
0
	def get_install_path(self, destdir=True):
		"""
		Installation path obtained from ``self.dest`` and prefixed by the destdir.
		The variables such as '${PREFIX}/bin' are substituted.
		"""
		dest = Utils.subst_vars(self.dest, self.env)
		dest = dest.replace('/', os.sep)
		if destdir and Options.options.destdir:
			dest = os.path.join(Options.options.destdir, os.path.splitdrive(dest)[1].lstrip(os.sep))
		return dest