示例#1
0
文件: builtin.py 项目: Beman/build
    def extra_usage_requirements (self, created_targets, prop_set):
        
        result = property_set.empty ()
        extra = []
                        
        # Add appropriate <xdll-path> usage requirements.
        raw = prop_set.raw ()
        if '<link>shared' in raw:
            paths = []
            
            # TODO: is it safe to use the current directory? I think we should use 
            # another mechanism to allow this to be run from anywhere.
            pwd = os.getcwd()
            
            for t in created_targets:
                if type.is_derived(t.type(), 'SHARED_LIB'):
                    paths.append(path.root(path.make(t.path()), pwd))

            extra += replace_grist(paths, '<xdll-path>')
        
        # We need to pass <xdll-path> features that we've got from sources,
        # because if shared library is built, exe which uses it must know paths
        # to other shared libraries this one depends on, to be able to find them
        # all at runtime.
                        
        # Just pass all features in property_set, it's theorically possible
        # that we'll propagate <xdll-path> features explicitly specified by
        # the user, but then the user's to blaim for using internal feature.                
        values = prop_set.get('<xdll-path>')
        extra += replace_grist(values, '<xdll-path>')
        
        if extra:
            result = property_set.create(extra)

        return result
示例#2
0
    def extra_usage_requirements(self, created_targets, prop_set):

        result = property_set.empty()
        extra = []

        # Add appropriate <xdll-path> usage requirements.
        raw = prop_set.raw()
        if '<link>shared' in raw:
            paths = []

            # TODO: is it safe to use the current directory? I think we should use
            # another mechanism to allow this to be run from anywhere.
            pwd = os.getcwd()

            for t in created_targets:
                if type.is_derived(t.type(), 'SHARED_LIB'):
                    paths.append(path.root(path.make(t.path()), pwd))

            extra += replace_grist(paths, '<xdll-path>')

        # We need to pass <xdll-path> features that we've got from sources,
        # because if shared library is built, exe which uses it must know paths
        # to other shared libraries this one depends on, to be able to find them
        # all at runtime.

        # Just pass all features in property_set, it's theorically possible
        # that we'll propagate <xdll-path> features explicitly specified by
        # the user, but then the user's to blaim for using internal feature.
        values = prop_set.get('<xdll-path>')
        extra += replace_grist(values, '<xdll-path>')

        if extra:
            result = property_set.create(extra)

        return result
示例#3
0
文件: builtin.py 项目: wzssyqa/build
    def run(self, project, name, prop_set, sources):
        assert isinstance(project, targets.ProjectTarget)
        assert isinstance(name, basestring) or name is None
        assert isinstance(prop_set, property_set.PropertySet)
        assert is_iterable_typed(sources, virtual_target.VirtualTarget)

        # create a copy since sources is being modified
        sources = list(sources)
        sources.extend(prop_set.get('<library>'))

        # Add <library-path> properties for all searched libraries
        extra = []
        for s in sources:
            if s.type() == 'SEARCHED_LIB':
                search = s.search()
                extra.extend(
                    property.Property('<library-path>', sp) for sp in search)

        # It's possible that we have libraries in sources which did not came
        # from 'lib' target. For example, libraries which are specified
        # just as filenames as sources. We don't have xdll-path properties
        # for such target, but still need to add proper dll-path properties.
        extra_xdll_path = []
        for s in sources:
            if type.is_derived(s.type(), 'SHARED_LIB') and not s.action():
                # Unfortunately, we don't have a good way to find the path
                # to a file, so use this nasty approach.
                p = s.project()
                location = path.root(s.name(), p.get('source-location')[0])
                extra_xdll_path.append(os.path.dirname(location))

        # Hardcode DLL paths only when linking executables.
        # Pros: do not need to relink libraries when installing.
        # Cons: "standalone" libraries (plugins, python extensions) can not
        # hardcode paths to dependent libraries.
        if prop_set.get('<hardcode-dll-paths>') == ['true'] \
              and type.is_derived(self.target_types_ [0], 'EXE'):
            xdll_path = prop_set.get('<xdll-path>')
            extra.extend(property.Property('<dll-path>', sp) \
                 for sp in extra_xdll_path)
            extra.extend(property.Property('<dll-path>', sp) \
                 for sp in xdll_path)

        if extra:
            prop_set = prop_set.add_raw(extra)
        result = generators.Generator.run(self, project, name, prop_set,
                                          sources)

        if result:
            ur = self.extra_usage_requirements(result, prop_set)
            ur = ur.add(
                property_set.create(
                    ['<xdll-path>' + p for p in extra_xdll_path]))
        else:
            return None
        return (ur, result)
示例#4
0
    def run (self, project, name, prop_set, sources):
        assert isinstance(project, targets.ProjectTarget)
        assert isinstance(name, basestring) or name is None
        assert isinstance(prop_set, property_set.PropertySet)
        assert is_iterable_typed(sources, virtual_target.VirtualTarget)

        # create a copy since sources is being modified
        sources = list(sources)
        sources.extend(prop_set.get('<library>'))

        # Add <library-path> properties for all searched libraries
        extra = []
        for s in sources:
            if s.type () == 'SEARCHED_LIB':
                search = s.search()
                extra.extend(property.Property('<library-path>', sp) for sp in search)

        # It's possible that we have libraries in sources which did not came
        # from 'lib' target. For example, libraries which are specified
        # just as filenames as sources. We don't have xdll-path properties
        # for such target, but still need to add proper dll-path properties.
        extra_xdll_path = []
        for s in sources:
                if type.is_derived (s.type (), 'SHARED_LIB') and not s.action ():
                    # Unfortunately, we don't have a good way to find the path
                    # to a file, so use this nasty approach.
                    p = s.project()
                    location = path.root(s.name(), p.get('source-location')[0])
                    extra_xdll_path.append(os.path.dirname(location))

        # Hardcode DLL paths only when linking executables.
        # Pros: do not need to relink libraries when installing.
        # Cons: "standalone" libraries (plugins, python extensions) can not
        # hardcode paths to dependent libraries.
        if prop_set.get('<hardcode-dll-paths>') == ['true'] \
              and type.is_derived(self.target_types_ [0], 'EXE'):
                xdll_path = prop_set.get('<xdll-path>')
                extra.extend(property.Property('<dll-path>', sp) \
                     for sp in extra_xdll_path)
                extra.extend(property.Property('<dll-path>', sp) \
                     for sp in xdll_path)

        if extra:
            prop_set = prop_set.add_raw (extra)
        result = generators.Generator.run(self, project, name, prop_set, sources)

        if result:
            ur = self.extra_usage_requirements(result, prop_set)
            ur = ur.add(property_set.create(['<xdll-path>' + p for p in extra_xdll_path]))
        else:
            return None
        return (ur, result)
示例#5
0
    def run(self, project, name, prop_set, sources):

        lib_sources = prop_set.get('<library>')
        sources.extend(lib_sources)

        # Add <library-path> properties for all searched libraries
        extra = []
        for s in sources:
            if s.type() == 'SEARCHED_LIB':
                search = s.search()
                extra.extend(
                    property.Property('<library-path>', sp) for sp in search)

        orig_xdll_path = []

        if prop_set.get('<hardcode-dll-paths>') == ['true'] \
               and type.is_derived(self.target_types_ [0], 'EXE'):
            xdll_path = prop_set.get('<xdll-path>')
            orig_xdll_path = [
                replace_grist(x, '<dll-path>') for x in xdll_path
            ]
            # It's possible that we have libraries in sources which did not came
            # from 'lib' target. For example, libraries which are specified
            # just as filenames as sources. We don't have xdll-path properties
            # for such target, but still need to add proper dll-path properties.
            for s in sources:
                if type.is_derived(s.type(), 'SHARED_LIB') and not s.action():
                    # Unfortunately, we don't have a good way to find the path
                    # to a file, so use this nasty approach.
                    p = s.project()
                    location = path.root(s.name(), p.get('source-location'))
                    xdll_path.append(path.parent(location))

            extra.extend(
                property.Property('<dll-path>', sp) for sp in xdll_path)

        if extra:
            prop_set = prop_set.add_raw(extra)

        result = generators.Generator.run(self, project, name, prop_set,
                                          sources)

        if result:
            ur = self.extra_usage_requirements(result, prop_set)
            ur = ur.add(property_set.create(orig_xdll_path))
        else:
            return None

        return (ur, result)
示例#6
0
    def run (self, project, name, prop_set, sources):
       
        lib_sources = prop_set.get('<library>')
        sources.extend(lib_sources)
        
        # Add <library-path> properties for all searched libraries
        extra = []
        for s in sources:
            if s.type () == 'SEARCHED_LIB':
                search = s.search()
                extra.extend(property.Property('<library-path>', sp) for sp in search)

        orig_xdll_path = []
                   
        if prop_set.get('<hardcode-dll-paths>') == ['true'] \
               and type.is_derived(self.target_types_ [0], 'EXE'):
            xdll_path = prop_set.get('<xdll-path>')
            orig_xdll_path = [ replace_grist(x, '<dll-path>') for x in xdll_path ]
            # It's possible that we have libraries in sources which did not came
            # from 'lib' target. For example, libraries which are specified
            # just as filenames as sources. We don't have xdll-path properties
            # for such target, but still need to add proper dll-path properties.
            for s in sources:
                if type.is_derived (s.type (), 'SHARED_LIB') and not s.action ():
                    # Unfortunately, we don't have a good way to find the path
                    # to a file, so use this nasty approach.
                    p = s.project()
                    location = path.root(s.name(), p.get('source-location'))
                    xdll_path.append(path.parent(location))
                          
            extra.extend(property.Property('<dll-path>', sp) for sp in xdll_path)
        
        if extra:
            prop_set = prop_set.add_raw (extra)
                        
        result = generators.Generator.run(self, project, name, prop_set, sources)

        if result:
            ur = self.extra_usage_requirements(result, prop_set)
            ur = ur.add(property_set.create(orig_xdll_path))
        else:
            return None
        
        return(ur, result)
示例#7
0
    def run(self, project, name, prop_set, sources):

        sources.extend(prop_set.get("<library>"))

        # Add <library-path> properties for all searched libraries
        extra = []
        for s in sources:
            if s.type() == "SEARCHED_LIB":
                search = s.search()
                extra.extend(property.Property("<library-path>", sp) for sp in search)

        # It's possible that we have libraries in sources which did not came
        # from 'lib' target. For example, libraries which are specified
        # just as filenames as sources. We don't have xdll-path properties
        # for such target, but still need to add proper dll-path properties.
        extra_xdll_path = []
        for s in sources:
            if type.is_derived(s.type(), "SHARED_LIB") and not s.action():
                # Unfortunately, we don't have a good way to find the path
                # to a file, so use this nasty approach.
                p = s.project()
                location = path.root(s.name(), p.get("source-location")[0])
                extra_xdll_path.append(os.path.dirname(location))

        # Hardcode DLL paths only when linking executables.
        # Pros: do not need to relink libraries when installing.
        # Cons: "standalone" libraries (plugins, python extensions) can not
        # hardcode paths to dependent libraries.
        if prop_set.get("<hardcode-dll-paths>") == ["true"] and type.is_derived(self.target_types_[0], "EXE"):
            xdll_path = prop_set.get("<xdll-path>")
            extra.extend(property.Property("<dll-path>", sp) for sp in extra_xdll_path)
            extra.extend(property.Property("<dll-path>", sp) for sp in xdll_path)

        if extra:
            prop_set = prop_set.add_raw(extra)
        result = generators.Generator.run(self, project, name, prop_set, sources)

        if result:
            ur = self.extra_usage_requirements(result, prop_set)
            ur = ur.add(property_set.create(["<xdll-path>" + p for p in extra_xdll_path]))
        else:
            return None
        return (ur, result)