Esempio n. 1
0
def get_run_program(program_string, command_template=None):
    """
    Return the program name and argv of the process that would be executed by
    run_program(program_string, command_template).
    """
    #print "get_run_program_argv(program_string=%r, command_template=%r)" % (program_string, command_template)
    env = bld.env

    if command_template in (None, '%s'):
        argv = shlex.split(program_string)
        #print "%r ==shlex.split==> %r" % (program_string, argv)
        program_name = argv[0]

        try:
            program_obj = find_program(program_name, env)
        except ValueError, ex:
            raise Utils.WafError(str(ex))

        program_node = program_obj.path.find_or_declare(ccroot.get_target_name(program_obj))
        #try:
        #    program_node = program_obj.path.find_build(ccroot.get_target_name(program_obj))
        #except AttributeError:
        #    raise Utils.WafError("%s does not appear to be a program" % (program_name,))

        execvec = [program_node.abspath(env)] + argv[1:]
Esempio n. 2
0
def add_rpaths(self):
    self.env[ccroot.c_attrs['rpath']] = self.to_list(self.env[ccroot.c_attrs['rpath']])

    try:
        self.uselib_local
    except:
        return

    names = self.to_list(self.uselib_local)
    while names:
        x = names.pop(0)
        y = self.name_to_obj(x)

        if os.path.splitext(ccroot.get_target_name(y))[1] != y.env['shlib_PATTERN'].split('%s')[1]:
            continue
        y.post()

        newPath = os.path.split(y.link_task.outputs[0].abspath(self.env))[0]
        if not newPath in self.env[ccroot.c_attrs['rpath']]:
            self.env[ccroot.c_attrs['rpath']].append(newPath)
        for k in self.to_list(y.env[ccroot.c_attrs['rpath']]):
            if not k in self.env[ccroot.c_attrs['rpath']]:
                self.env[ccroot.c_attrs['rpath']].append(k)

    if '' in self.env[ccroot.c_attrs['rpath']] and len(self.env[ccroot.c_attrs['rpath']]) > 1:
        self.env[ccroot.c_attrs['rpath']].remove('')
Esempio n. 3
0
def extract_headers(self):
    lst = self.to_list(self.source)
    self.source = ''
    find_resource = self.path.find_resource

    self.uselib_local += ' sc_controller'

    try:
        obj_ext = self.obj_ext
    except AttributeError:
        self.obj_ext = '.o'

    self.srclist = []

    targetbase = os.path.splitext(ccroot.get_target_name(self))[0]

    find_resource = self.path.find_resource
    for filename in lst:
        # -- Extract the header files to be treated separately
        #
        base, ext = os.path.splitext(filename)
        if ext in self.header_ext:
            n = find_resource(Utils.split_path(filename))

            self.source += '\n' + filename
            self.srclist.append(n)
        else:
            self.source += '\n' + filename
Esempio n. 4
0
def get_run_program(program_string, command_template=None):
    """
    Return the program name and argv of the process that would be executed by
    run_program(program_string, command_template).
    """
    #print "get_run_program_argv(program_string=%r, command_template=%r)" % (program_string, command_template)
    env = bld.env

    if command_template in (None, '%s'):
        argv = shlex.split(program_string)
        #print "%r ==shlex.split==> %r" % (program_string, argv)
        program_name = argv[0]

        try:
            program_obj = find_program(program_name, env)
        except ValueError, ex:
            raise Utils.WafError(str(ex))

        program_node = program_obj.path.find_or_declare(ccroot.get_target_name(program_obj))
        #try:
        #    program_node = program_obj.path.find_build(ccroot.get_target_name(program_obj))
        #except AttributeError:
        #    raise Utils.WafError("%s does not appear to be a program" % (program_name,))

        execvec = [program_node.abspath(env)] + argv[1:]
Esempio n. 5
0
def no_rpath(self):
    """This would almost justify a new feature"""
    if self.link_task.__class__.__name__ != 'cc_link':
        return

    name = '__' + get_target_name(self)  # not always a .so
    tsk = self.create_task('inst_cc')
    tsk.inputs = self.link_task.inputs
    tsk.set_outputs(self.path.find_or_declare(name))

    tsk.set_run_after(self.link_task)
    self.link_task.env = tsk.env.copy()

    self.meths.remove('default_link_install')
    if not getattr(self, 'vnum', None):
        self.bld.install_as(self.install_path + '/' +
                            self.link_task.outputs[0].name,
                            tsk.outputs[0],
                            env=self.env,
                            chmod=self.chmod)
        return

    self.meths.remove('apply_vnum')

    # following is from apply_vnum
    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())

    bld = self.bld
    nums = self.vnum.split('.')

    path = self.install_path
    if not path: return

    bld.install_as(path + os.sep + name3, tsk.outputs[0],
                   env=self.env)  # not the link task node
    bld.symlink_as(path + os.sep + name2, name3)
    bld.symlink_as(path + os.sep + libname, name3)

    # the following task is just to enable execution from the build dir :-/
    tsk = self.create_task('vnum')
    tsk.set_inputs([node])
    tsk.set_outputs(node.parent.find_or_declare(name2))
Esempio n. 6
0
def no_rpath(self):
	"""This would almost justify a new feature"""
	if self.link_task.__class__.__name__ != 'cc_link':
		return

	name = '__' + get_target_name(self) # not always a .so
	tsk = self.create_task('inst_cc')
	tsk.inputs = self.link_task.inputs
	tsk.set_outputs(self.path.find_or_declare(name))

	tsk.set_run_after(self.link_task)
	self.link_task.env = tsk.env.copy()

	self.meths.remove('default_link_install')
	if not getattr(self, 'vnum', None):
		self.bld.install_as(self.install_path + '/' + self.link_task.outputs[0].name, tsk.outputs[0], env=self.env, chmod=self.chmod)
		return

	self.meths.remove('apply_vnum')

	# following is from apply_vnum
	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())

	bld = self.bld
	nums = self.vnum.split('.')

	path = self.install_path
	if not path: return

	bld.install_as(path + os.sep + name3, tsk.outputs[0], env=self.env) # not the link task node
	bld.symlink_as(path + os.sep + name2, name3)
	bld.symlink_as(path + os.sep + libname, name3)

	# the following task is just to enable execution from the build dir :-/
	tsk = self.create_task('vnum')
	tsk.set_inputs([node])
	tsk.set_outputs(node.parent.find_or_declare(name2))
Esempio n. 7
0
def apply_link_msvc(self):
	if'objects'in self.features:
		self.out_nodes=[]
		app=self.out_nodes.append
		for t in self.compiled_tasks:app(t.outputs[0])
		return
	link=getattr(self,'link',None)
	if not link:
		if'cstaticlib'in self.features:link='msvc_ar_link_static'
		elif'cxx'in self.features:link='msvc_cxx_link'
		else:link='msvc_cc_link'
	linktask=self.create_task(link)
	outputs=[t.outputs[0]for t in self.compiled_tasks]
	linktask.set_inputs(outputs)
	linktask.set_outputs(self.path.find_or_declare(ccroot.get_target_name(self)))
	linktask.features=self.features
	linktask.subsystem=getattr(self,'subsystem','')
	self.link_task=linktask
Esempio n. 8
0
        #try:
        #    program_node = program_obj.path.find_build(ccroot.get_target_name(program_obj))
        #except AttributeError:
        #    raise Utils.WafError("%s does not appear to be a program" % (program_name,))

        execvec = [program_node.abspath(env)] + argv[1:]

    else:

        program_name = program_string
        try:
            program_obj = find_program(program_name, env)
        except ValueError, ex:
            raise Utils.WafError(str(ex))

        program_node = program_obj.path.find_or_declare(ccroot.get_target_name(program_obj))
        #try:
        #    program_node = program_obj.path.find_build(ccroot.get_target_name(program_obj))
        #except AttributeError:
        #    raise Utils.WafError("%s does not appear to be a program" % (program_name,))

        tmpl = command_template % (program_node.abspath(env),)
        execvec = shlex.split(tmpl.replace('\\', '\\\\'))
        #print "%r ==shlex.split==> %r" % (command_template % (program_node.abspath(env),), execvec)
    return program_name, execvec

def run_program(program_string, env, command_template=None, cwd=None):
    """
    if command_template is not None, then program_string == program
    name and argv is given by command_template with %s replaced by the
    full path to the program.  Else, program_string is interpreted as
Esempio n. 9
0
        #try:
        #    program_node = program_obj.path.find_build(ccroot.get_target_name(program_obj))
        #except AttributeError:
        #    raise Utils.WafError("%s does not appear to be a program" % (program_name,))

        execvec = [program_node.abspath(env)] + argv[1:]

    else:

        program_name = program_string
        try:
            program_obj = find_program(program_name, env)
        except ValueError, ex:
            raise Utils.WafError(str(ex))

        program_node = program_obj.path.find_or_declare(ccroot.get_target_name(program_obj))
        #try:
        #    program_node = program_obj.path.find_build(ccroot.get_target_name(program_obj))
        #except AttributeError:
        #    raise Utils.WafError("%s does not appear to be a program" % (program_name,))

        tmpl = command_template % (program_node.abspath(env),)
        execvec = shlex.split(tmpl.replace('\\', '\\\\'))
        #print "%r ==shlex.split==> %r" % (command_template % (program_node.abspath(env),), execvec)
    return program_name, execvec

def run_program(program_string, env, command_template=None, cwd=None, visualize=False):
    """
    if command_template is not None, then program_string == program
    name and argv is given by command_template with %s replaced by the
    full path to the program.  Else, program_string is interpreted as
Esempio n. 10
0
        #    program_node = program_obj.path.find_build(ccroot.get_target_name(program_obj))
        #except AttributeError:
        #    raise Utils.WafError("%s does not appear to be a program" % (program_name,))

        execvec = [program_node.abspath(env)] + argv[1:]

    else:

        program_name = program_string
        try:
            program_obj = find_program(program_name, env)
        except ValueError, ex:
            raise Utils.WafError(str(ex))

        program_node = program_obj.path.find_or_declare(
            ccroot.get_target_name(program_obj))
        #try:
        #    program_node = program_obj.path.find_build(ccroot.get_target_name(program_obj))
        #except AttributeError:
        #    raise Utils.WafError("%s does not appear to be a program" % (program_name,))

        tmpl = command_template % (program_node.abspath(env), )
        execvec = shlex.split(tmpl.replace('\\', '\\\\'))
        #print "%r ==shlex.split==> %r" % (command_template % (program_node.abspath(env),), execvec)
    return program_name, execvec


def run_program(program_string,
                env,
                command_template=None,
                cwd=None,
Esempio n. 11
0
def process_headers(self):
    """ This function separates header files from .cpp files, and
        treats them separately.
    """
    #if sys.platform == 'darwin':
        #so_ext = '.so'
    #else:
        #so_ext = self.env['shlib_PATTERN'].split('%s')[1]
    #self.env['shlib_PATTERN'] = '%s'+so_ext
    try:
        self.custom_code = get_code_blocks(self.custom_code)
    except:
        self.custom_code = []

    targetbase, ext = os.path.splitext(ccroot.get_target_name(self))

    for i in self.to_list(self.uselib_local):
        lib = self.name_to_obj(i).env['INC_PATHS']
        if len(lib)>0:
            self.env.append_unique('INC_PATHS', lib[0])

    if len(self.srclist) > 0:
        # Includes are objects: to keep dependencies working, objects have
        # to be *posted* before they can be used
        include_lst = self.to_list(self.include)

        # Find the target node, i.e. the generated file
        if self.split < 1:
            raise Exception('Error, specified ' + str(self.split) + ' output files for task ' + targetbase + '; a number > 0 should be used')
        tgnodes = []
        if self.split == 1:
            tgnodes.append(self.path.find_or_declare(targetbase + '.pypp.cpp'))
        else:
            for i in range( 1 , self.split ):
                name = targetbase + '_classes_' + str(i)
                tgnodes.append(self.path.find_or_declare(name + '.pypp.cpp'))
            tgnodes.append(self.path.find_or_declare(targetbase + '.main.cpp'))

        # Create a pypp task with all the input headerfiles and one output module
        pypptask = self.create_task('pypp', self.env)

        # Apply parameters passed by the wscript to the task
        pypptask.bldpath = self.bld.bldnode.abspath()
        pypptask.srcpath = self.bld.srcnode.abspath()
        pypptask.custom_code = self.custom_code
        pypptask.custom_declaration_code = self.custom_declaration_code
        pypptask.custom_registration_code = self.custom_registration_code
        pypptask.target = ccroot.get_target_name(self)
        pypptask.split = self.split
        pypptask.start_decls = Utils.to_list(self.start_decls)
        pypptask.virtuality = self.virtuality
        pypptask.path_lst = self.env['INC_PATHS']
        pypptask.includes = [os.path.join(self.path.abspath(), i) for i in self.to_list(self.includes)]
        pypptask.templates  = self.templates

        # Now I have to parse the CPPFLAGS and CXXFLAGS environment variables and extract the synmbol definitions;
        pypptask.define_symbols = []
        for symbol in self.env['CXXFLAGS']:
            if symbol.find('-D')  == 0:
                symbol = symbol.replace('-D',  '',  1)
                if not symbol in pypptask.define_symbols:
                    pypptask.define_symbols.append(symbol)
        for symbol in self.env['CPPFLAGS']:
            if symbol.find('-D')  == 0:
                symbol = symbol.replace('-D',  '',  1)
                if not symbol in pypptask.define_symbols:
                    pypptask.define_symbols.append(symbol)

        # Create a node for every include
        incl = []
        includeCustomCode = []
        includeStartDecls = []
        if include_lst:
            for x in include_lst:
                obj = self.name_to_obj(x)
                if( not  obj ):
                    print targetbase + ' --> Warning: Object '+ x +' not found'
                    continue
                try:
                    includeCustomCode += obj.custom_code
                except AttributeError:
                    pass
                try:
                    includeStartDecls += Utils.to_list(obj.start_decls)
                except AttributeError:
                    pass

        # Now I add the custom code of the includes, so that their elements are also
        # exported; I also have to add their start declarations
        pypptask.custom_code_include = includeCustomCode
        pypptask.start_decls = includeStartDecls + pypptask.start_decls

        # ********************** TODO ************** set the dipendences well, so that only the tasks
        # ************************* depending on each other are (either directly or because they include the
        # same wrapper) are serialized *****************************************************
        # Adding dependencies to all already-processed pypp files
        all_tasks = self.bld.task_manager.groups[self.bld.task_manager.current_group].tasks
        dependencies = filter(lambda tsk: isinstance(tsk, Task.TaskBase.classes['pypp']) and (pypptask != tsk) , all_tasks)
        if dependencies:
            pypptask.set_run_after(dependencies[-1])
            #print dependencies[-1]
        for x in dependencies:
            incl.append( x.outputs[0] )

        pypptask.include = incl

        # Generate template task if templates are specified
        if self.templates:
            templatetask = self.create_task('generate_header', self.env)
            templatetask.templates = self.templates

            # The source files are augmented with the autogenerated template instantiation
            templatetask.inputs = self.srclist
            templatetask.outputs = [self.path.find_or_declare(targetbase+'_exp.hpp')]
            templatetask.target = self.target

            # If templates are enabled, py++ will process only the autogenerated header
            pypptask.inputs = templatetask.outputs
            pypptask.set_run_after(templatetask)
        else:
            # If there are no templates, the input of py++ are the source files
            pypptask.inputs = self.srclist

        #print Build.bld.bdir
        pypptask.ext_headers = map(lambda a: os.path.join(Build.bld.bdir, a.srcpath(self.env)) , self.srclist)

        pypptask.outputs = tgnodes

        # Compile the autogenerated C++ files
        if self.split == 1:
            task = self.create_task('cxx', self.env)
            task.inputs = [tgnodes[0]]
            task.outputs = [pypptask.outputs[0].change_ext(self.obj_ext)]
            task.set_run_after(pypptask)
            #task.defines  = self.scanner_defines
            self.compiled_tasks.append(task)
        else:
            for i in range (0, self.split):
                task = self.create_task('cxx', self.env)

                task.inputs = [tgnodes[i]]
                task.outputs = [pypptask.outputs[i].change_ext(self.obj_ext)]
                task.set_run_after(pypptask)
                #task.defines  = self.scanner_defines
                self.compiled_tasks.append(task)