def library_flags(self, libs):
    '''work out flags from pkg_config'''
    ccflags = []
    ldflags = []
    cpppath = []
    for lib in TO_LIST(libs):
        # note that we do not add the -I and -L in here, as that is added by the waf
        # core. Adding it here would just change the order that it is put on the link line
        # which can cause system paths to be added before internal libraries
        extra_ccflags = TO_LIST(
            getattr(self.env, 'CFLAGS_%s' % lib.upper(), []))
        extra_ldflags = TO_LIST(
            getattr(self.env, 'LDFLAGS_%s' % lib.upper(), []))
        extra_cpppath = TO_LIST(
            getattr(self.env, 'CPPPATH_%s' % lib.upper(), []))
        ccflags.extend(extra_ccflags)
        ldflags.extend(extra_ldflags)
        cpppath.extend(extra_cpppath)

        extra_cpppath = TO_LIST(
            getattr(self.env, 'INCLUDES_%s' % lib.upper(), []))
        cpppath.extend(extra_cpppath)
    if 'EXTRA_LDFLAGS' in self.env:
        ldflags.extend(self.env['EXTRA_LDFLAGS'])

    ccflags = unique_list(ccflags)
    ldflags = unique_list(ldflags)
    cpppath = unique_list(cpppath)
    return (ccflags, ldflags, cpppath)
Пример #2
0
def library_flags(self, libs):
    '''work out flags from pkg_config'''
    ccflags = []
    ldflags = []
    cpppath = []
    for lib in TO_LIST(libs):
        # note that we do not add the -I and -L in here, as that is added by the waf
        # core. Adding it here would just change the order that it is put on the link line
        # which can cause system paths to be added before internal libraries
        extra_ccflags = TO_LIST(getattr(self.env, 'CCFLAGS_%s' % lib.upper(), []))
        extra_ldflags = TO_LIST(getattr(self.env, 'LDFLAGS_%s' % lib.upper(), []))
        extra_cpppath = TO_LIST(getattr(self.env, 'CPPPATH_%s' % lib.upper(), []))
        ccflags.extend(extra_ccflags)
        ldflags.extend(extra_ldflags)
        cpppath.extend(extra_cpppath)
    if 'EXTRA_LDFLAGS' in self.env:
        ldflags.extend(self.env['EXTRA_LDFLAGS'])

    ccflags = unique_list(ccflags)
    ldflags = unique_list(ldflags)
    cpppath = unique_list(cpppath)
    return (ccflags, ldflags, cpppath)
Пример #3
0
def build_dependencies(self):
    '''This builds the dependency list for a target. It runs after all the targets are declared

    The reason this is not just done in the SAMBA_*() rules is that we have no way of knowing
    the full dependency list for a target until we have all of the targets declared.
    '''

    if self.samba_type in ['LIBRARY', 'BINARY', 'PYTHON']:
        self.uselib = list(self.final_syslibs)
        self.uselib_local = list(self.final_libs)
        self.add_objects = list(self.final_objects)

        # extra link flags from pkg_config
        libs = self.final_syslibs.copy()

        (cflags, ldflags, cpppath) = library_flags(self, list(libs))
        new_ldflags = getattr(self, 'samba_ldflags', [])[:]
        new_ldflags.extend(ldflags)
        self.ldflags = new_ldflags

        if getattr(self, 'allow_undefined_symbols',
                   False) and self.env.undefined_ldflags:
            for f in self.env.undefined_ldflags:
                self.ldflags.remove(f)

        if getattr(self, 'allow_undefined_symbols',
                   False) and self.env.undefined_ignore_ldflags:
            for f in self.env.undefined_ignore_ldflags:
                self.ldflags.append(f)

        debug(
            'deps: computed dependencies for target %s: uselib=%s uselib_local=%s add_objects=%s',
            self.sname, self.uselib, self.uselib_local, self.add_objects)

    if self.samba_type in ['SUBSYSTEM']:
        # this is needed for the cflags of libs that come from pkg_config
        self.uselib = list(self.final_syslibs)
        self.uselib.extend(list(self.direct_syslibs))
        for lib in self.final_libs:
            t = self.bld.get_tgen_by_name(lib)
            self.uselib.extend(list(t.final_syslibs))
        self.uselib = unique_list(self.uselib)

    if getattr(self, 'uselib', None):
        up_list = []
        for l in self.uselib:
            up_list.append(l.upper())
        self.uselib = up_list
Пример #4
0
def build_dependencies(self):
    '''This builds the dependency list for a target. It runs after all the targets are declared

    The reason this is not just done in the SAMBA_*() rules is that we have no way of knowing
    the full dependency list for a target until we have all of the targets declared.
    '''

    if self.samba_type in ['LIBRARY', 'BINARY', 'PYTHON']:
        self.uselib        = list(self.final_syslibs)
        self.uselib_local  = list(self.final_libs)
        self.add_objects   = list(self.final_objects)

        # extra link flags from pkg_config
        libs = self.final_syslibs.copy()

        (ccflags, ldflags, cpppath) = library_flags(self, list(libs))
        new_ldflags        = getattr(self, 'samba_ldflags', [])[:]
        new_ldflags.extend(ldflags)
        self.ldflags       = new_ldflags

        if getattr(self, 'allow_undefined_symbols', False) and self.env.undefined_ldflags:
            for f in self.env.undefined_ldflags:
                self.ldflags.remove(f)

        if getattr(self, 'allow_undefined_symbols', False) and self.env.undefined_ignore_ldflags:
            for f in self.env.undefined_ignore_ldflags:
                self.ldflags.append(f)

        debug('deps: computed dependencies for target %s: uselib=%s uselib_local=%s add_objects=%s',
              self.sname, self.uselib, self.uselib_local, self.add_objects)

    if self.samba_type in ['SUBSYSTEM']:
        # this is needed for the ccflags of libs that come from pkg_config
        self.uselib = list(self.final_syslibs)
        self.uselib.extend(list(self.direct_syslibs))
        for lib in self.final_libs:
            t = self.bld.get_tgen_by_name(lib)
            self.uselib.extend(list(t.final_syslibs))
        self.uselib = unique_list(self.uselib)

    if getattr(self, 'uselib', None):
        up_list = []
        for l in self.uselib:
           up_list.append(l.upper())
        self.uselib = up_list
Пример #5
0
def expand_subsystem_deps(bld):
    '''expand the reverse dependencies resulting from subsystem
       attributes of modules. This is walking over the complete list
       of declared subsystems, and expands the samba_deps_extended list for any
       module<->subsystem dependencies'''

    subsystem_list = LOCAL_CACHE(bld, 'INIT_FUNCTIONS')
    targets = LOCAL_CACHE(bld, 'TARGET_TYPE')

    for subsystem_name in subsystem_list:
        bld.ASSERT(subsystem_name in targets,
                   "Subsystem target %s not declared" % subsystem_name)
        type = targets[subsystem_name]
        if type == 'DISABLED' or type == 'EMPTY':
            continue

        # for example,
        #    subsystem_name = dcerpc_server (a subsystem)
        #    subsystem      = dcerpc_server (a subsystem object)
        #    module_name    = rpc_epmapper (a module within the dcerpc_server subsystem)
        #    module         = rpc_epmapper (a module object within the dcerpc_server subsystem)

        subsystem = bld.get_tgen_by_name(subsystem_name)
        bld.ASSERT(subsystem is not None,
                   "Unable to find subsystem %s" % subsystem_name)
        for d in subsystem_list[subsystem_name]:
            module_name = d['TARGET']
            module_type = targets[module_name]
            if module_type in ['DISABLED', 'EMPTY']:
                continue
            bld.ASSERT(
                subsystem is not None,
                "Subsystem target %s for %s (%s) not found" %
                (subsystem_name, module_name, module_type))
            if module_type in ['SUBSYSTEM']:
                # if a module is a plain object type (not a library) then the
                # subsystem it is part of needs to have it as a dependency, so targets
                # that depend on this subsystem get the modules of that subsystem
                subsystem.samba_deps_extended.append(module_name)
        subsystem.samba_deps_extended = unique_list(
            subsystem.samba_deps_extended)
Пример #6
0
def expand_subsystem_deps(bld):
    '''expand the reverse dependencies resulting from subsystem
       attributes of modules. This is walking over the complete list
       of declared subsystems, and expands the samba_deps_extended list for any
       module<->subsystem dependencies'''

    subsystem_list = LOCAL_CACHE(bld, 'INIT_FUNCTIONS')
    targets    = LOCAL_CACHE(bld, 'TARGET_TYPE')

    for subsystem_name in subsystem_list:
        bld.ASSERT(subsystem_name in targets, "Subsystem target %s not declared" % subsystem_name)
        type = targets[subsystem_name]
        if type == 'DISABLED' or type == 'EMPTY':
            continue

        # for example,
        #    subsystem_name = dcerpc_server (a subsystem)
        #    subsystem      = dcerpc_server (a subsystem object)
        #    module_name    = rpc_epmapper (a module within the dcerpc_server subsystem)
        #    module         = rpc_epmapper (a module object within the dcerpc_server subsystem)

        subsystem = bld.get_tgen_by_name(subsystem_name)
        bld.ASSERT(subsystem is not None, "Unable to find subsystem %s" % subsystem_name)
        for d in subsystem_list[subsystem_name]:
            module_name = d['TARGET']
            module_type = targets[module_name]
            if module_type in ['DISABLED', 'EMPTY']:
                continue
            bld.ASSERT(subsystem is not None,
                       "Subsystem target %s for %s (%s) not found" % (subsystem_name, module_name, module_type))
            if module_type in ['SUBSYSTEM']:
                # if a module is a plain object type (not a library) then the
                # subsystem it is part of needs to have it as a dependency, so targets
                # that depend on this subsystem get the modules of that subsystem
                subsystem.samba_deps_extended.append(module_name)
        subsystem.samba_deps_extended = unique_list(subsystem.samba_deps_extended)
Пример #7
0
def build_includes(self):
    '''This builds the right set of includes for a target.

    One tricky part of this is that the includes= attribute for a
    target needs to use paths which are relative to that targets
    declaration directory (which we can get at via t.path).

    The way this works is the includes list gets added as
    samba_includes in the main build task declaration. Then this
    function runs after all of the tasks are declared, and it
    processes the samba_includes attribute to produce a includes=
    attribute
    '''

    if getattr(self, 'samba_includes', None) is None:
        return

    bld = self.bld

    inc_deps = includes_objects(bld, self, set(), {})

    includes = []

    # maybe add local includes
    if getattr(self, 'local_include', True) and getattr(self, 'local_include_first', True):
        includes.append('.')

    includes.extend(self.samba_includes_extended)

    if 'EXTRA_INCLUDES' in bld.env and getattr(self, 'global_include', True):
        includes.extend(bld.env['EXTRA_INCLUDES'])

    includes.append('#')

    inc_set = set()
    inc_abs = []

    for d in inc_deps:
        t = bld.get_tgen_by_name(d)
        bld.ASSERT(t is not None, "Unable to find dependency %s for %s" % (d, self.sname))
        inclist = getattr(t, 'samba_includes_extended', [])[:]
        if getattr(t, 'local_include', True):
            inclist.append('.')
        if inclist == []:
            continue
        tpath = t.samba_abspath
        for inc in inclist:
            npath = tpath + '/' + inc
            if not npath in inc_set:
                inc_abs.append(npath)
                inc_set.add(npath)

    mypath = self.path.abspath(bld.env)
    for inc in inc_abs:
        relpath = os_path_relpath(inc, mypath)
        includes.append(relpath)

    if getattr(self, 'local_include', True) and not getattr(self, 'local_include_first', True):
        includes.append('.')

    # now transform the includes list to be relative to the top directory
    # which is represented by '#' in waf. This allows waf to cache the
    # includes lists more efficiently
    includes_top = []
    for i in includes:
        if i[0] == '#':
            # some are already top based
            includes_top.append(i)
            continue
        absinc = os.path.join(self.path.abspath(), i)
        relinc = os_path_relpath(absinc, self.bld.srcnode.abspath())
        includes_top.append('#' + relinc)

    self.includes = unique_list(includes_top)
    debug('deps: includes for target %s: includes=%s',
          self.sname, self.includes)
Пример #8
0
def build_includes(self):
    '''This builds the right set of includes for a target.

    One tricky part of this is that the includes= attribute for a
    target needs to use paths which are relative to that targets
    declaration directory (which we can get at via t.path).

    The way this works is the includes list gets added as
    samba_includes in the main build task declaration. Then this
    function runs after all of the tasks are declared, and it
    processes the samba_includes attribute to produce a includes=
    attribute
    '''

    if getattr(self, 'samba_includes', None) is None:
        return

    bld = self.bld

    inc_deps = includes_objects(bld, self, set(), {})

    includes = []

    # maybe add local includes
    if getattr(self, 'local_include', True) and getattr(self, 'local_include_first', True):
        includes.append('.')

    includes.extend(self.samba_includes_extended)

    if 'EXTRA_INCLUDES' in bld.env and getattr(self, 'global_include', True):
        includes.extend(bld.env['EXTRA_INCLUDES'])

    includes.append('#')

    inc_set = set()
    inc_abs = []

    for d in inc_deps:
        t = bld.get_tgen_by_name(d)
        bld.ASSERT(t is not None, "Unable to find dependency %s for %s" % (d, self.sname))
        inclist = getattr(t, 'samba_includes_extended', [])[:]
        if getattr(t, 'local_include', True):
            inclist.append('.')
        if inclist == []:
            continue
        tpath = t.samba_abspath
        for inc in inclist:
            npath = tpath + '/' + inc
            if not npath in inc_set:
                inc_abs.append(npath)
                inc_set.add(npath)

    mypath = self.path.abspath(bld.env)
    for inc in inc_abs:
        relpath = os_path_relpath(inc, mypath)
        includes.append(relpath)

    if getattr(self, 'local_include', True) and not getattr(self, 'local_include_first', True):
        includes.append('.')

    # now transform the includes list to be relative to the top directory
    # which is represented by '#' in waf. This allows waf to cache the
    # includes lists more efficiently
    includes_top = []
    for i in includes:
        if i[0] == '#':
            # some are already top based
            includes_top.append(i)
            continue
        absinc = os.path.join(self.path.abspath(), i)
        relinc = os_path_relpath(absinc, self.bld.srcnode.abspath())
        includes_top.append('#' + relinc)

    self.includes = unique_list(includes_top)
    debug('deps: includes for target %s: includes=%s',
          self.sname, self.includes)