Beispiel #1
0
    def _prep_compile (self, sources, output_dir):
        """Determine the list of object files corresponding to 'sources',
        and figure out which ones really need to be recompiled.  Return a
        list of all object files and a dictionary telling which source
        files can be skipped.
        """
        # Get the list of expected output (object) files 
        objects = self.object_filenames (sources,
                                         strip_dir=1,
                                         output_dir=output_dir)

        if self.force:
            skip_source = {}            # rebuild everything
            for source in sources:
                skip_source[source] = 0
        else:
            # Figure out which source files we have to recompile according
            # to a simplistic check -- we just compare the source and
            # object file, no deep dependency checking involving header
            # files.
            skip_source = {}            # rebuild everything
            for source in sources:      # no wait, rebuild nothing
                skip_source[source] = 1

            (n_sources, n_objects) = newer_pairwise (sources, objects)
            for source in n_sources:    # no really, only rebuild what's
                skip_source[source] = 0 # out-of-date

        return (objects, skip_source)
Beispiel #2
0
    def _prep_compile(self, sources, output_dir):
        """Determine the list of object files corresponding to 'sources',
        and figure out which ones really need to be recompiled.  Return a
        list of all object files and a dictionary telling which source
        files can be skipped.
        """
        # Get the list of expected output (object) files
        objects = self.object_filenames(sources,
                                        strip_dir=1,
                                        output_dir=output_dir)

        if self.force:
            skip_source = {}  # rebuild everything
            for source in sources:
                skip_source[source] = 0
        else:
            # Figure out which source files we have to recompile according
            # to a simplistic check -- we just compare the source and
            # object file, no deep dependency checking involving header
            # files.
            skip_source = {}  # rebuild everything
            for source in sources:  # no wait, rebuild nothing
                skip_source[source] = 1

            (n_sources, n_objects) = newer_pairwise(sources, objects)
            for source in n_sources:  # no really, only rebuild what's
                skip_source[source] = 0  # out-of-date

        return (objects, skip_source)
 def test_newer_pairwise(self):
     tmpdir = self.mkdtemp()
     sources = os.path.join(tmpdir, 'sources')
     targets = os.path.join(tmpdir, 'targets')
     os.mkdir(sources)
     os.mkdir(targets)
     one = os.path.join(sources, 'one')
     two = os.path.join(sources, 'two')
     three = os.path.abspath(__file__)
     four = os.path.join(targets, 'four')
     self.write_file(one)
     self.write_file(two)
     self.write_file(four)
     self.assertEqual(newer_pairwise([one, two], [three, four]), ([one], [three]))
Beispiel #4
0
 def test_newer_pairwise(self):
     tmpdir = self.mkdtemp()
     sources = os.path.join(tmpdir, 'sources')
     targets = os.path.join(tmpdir, 'targets')
     os.mkdir(sources)
     os.mkdir(targets)
     one = os.path.join(sources, 'one')
     two = os.path.join(sources, 'two')
     three = os.path.abspath(__file__)
     four = os.path.join(targets, 'four')
     self.write_file(one)
     self.write_file(two)
     self.write_file(four)
     self.assertEqual(newer_pairwise([one, two], [three, four]), ([one], [three]))
Beispiel #5
0
 def test_newer_pairwise(self):
     tmpdir = self.mkdtemp()
     sources = os.path.join(tmpdir, "sources")
     targets = os.path.join(tmpdir, "targets")
     os.mkdir(sources)
     os.mkdir(targets)
     one = os.path.join(sources, "one")
     two = os.path.join(sources, "two")
     three = os.path.abspath(__file__)
     four = os.path.join(targets, "four")
     self.write_file(one)
     self.write_file(two)
     self.write_file(four)
     self.assertEqual(newer_pairwise([one, two], [three, four]), ([one], [three]))
Beispiel #6
0
    def _prep_compile(self, sources, output_dir, depends=None):
        """Decide which souce files must be recompiled.

        Determine the list of object files corresponding to 'sources',
        and figure out which ones really need to be recompiled.
        Return a list of all object files and a dictionary telling
        which source files can be skipped.
        """
        # Get the list of expected output (object) files
        objects = self.object_filenames(sources, output_dir=output_dir)
        assert len(objects) == len(sources)

        if self.force:
            skip_source = {}  # rebuild everything
            for source in sources:
                skip_source[source] = 0
        elif depends is None:
            # If depends is None, figure out which source files we
            # have to recompile according to a simplistic check. We
            # just compare the source and object file, no deep
            # dependency checking involving header files.
            skip_source = {}  # rebuild everything
            for source in sources:  # no wait, rebuild nothing
                skip_source[source] = 1

            n_sources, n_objects = newer_pairwise(sources, objects)
            for source in n_sources:  # no really, only rebuild what's
                skip_source[source] = 0  # out-of-date
        else:
            # If depends is a list of files, then do a different
            # simplistic check.  Assume that each object depends on
            # its source and all files in the depends list.
            skip_source = {}
            # L contains all the depends plus a spot at the end for a
            # particular source file
            L = depends[:] + [None]
            for i in range(len(objects)):
                source = sources[i]
                L[-1] = source
                if newer_group(L, objects[i]):
                    skip_source[source] = 0
                else:
                    skip_source[source] = 1

        return objects, skip_source
Beispiel #7
0
    def _prep_compile(self, sources, output_dir, depends=None):
        """Decide which souce files must be recompiled.

        Determine the list of object files corresponding to 'sources',
        and figure out which ones really need to be recompiled.
        Return a list of all object files and a dictionary telling
        which source files can be skipped.
        """
        # Get the list of expected output (object) files
        objects = self.object_filenames(sources, output_dir=output_dir)
        assert len(objects) == len(sources)

        if self.force:
            skip_source = {}            # rebuild everything
            for source in sources:
                skip_source[source] = 0
        elif depends is None:
            # If depends is None, figure out which source files we
            # have to recompile according to a simplistic check. We
            # just compare the source and object file, no deep
            # dependency checking involving header files.
            skip_source = {}            # rebuild everything
            for source in sources:      # no wait, rebuild nothing
                skip_source[source] = 1

            n_sources, n_objects = newer_pairwise(sources, objects)
            for source in n_sources:    # no really, only rebuild what's
                skip_source[source] = 0 # out-of-date
        else:
            # If depends is a list of files, then do a different
            # simplistic check.  Assume that each object depends on
            # its source and all files in the depends list.
            skip_source = {}
            # L contains all the depends plus a spot at the end for a
            # particular source file
            L = depends[:] + [None]
            for i in range(len(objects)):
                source = sources[i]
                L[-1] = source
                if newer_group(L, objects[i]):
                    skip_source[source] = 0
                else:
                    skip_source[source] = 1

        return objects, skip_source
Beispiel #8
0
def old_setup_compile(self, outdir, macros, incdirs, sources, depends, extra):
    """Process arguments and decide which source files to compile.

     Merges _fix_compile_args() and _prep_compile().
     """
    if outdir is None:
        outdir = self.output_dir
    elif type(outdir) is not StringType:
        raise TypeError, "'output_dir' must be a string or None"

    if macros is None:
        macros = self.macros
    elif type(macros) is ListType:
        macros = macros + (self.macros or [])
    else:
        raise TypeError, "'macros' (if supplied) must be a list of tuples"

    if incdirs is None:
        incdirs = self.include_dirs
    elif type(incdirs) in (ListType, TupleType):
        incdirs = list(incdirs) + (self.include_dirs or [])
    else:
        raise TypeError, \
              "'include_dirs' (if supplied) must be a list of strings"

    if extra is None:
        extra = []

    # Get the list of expected output (object) files
    objects = self.object_filenames(sources, strip_dir=0, output_dir=outdir)
    assert len(objects) == len(sources)

    # XXX should redo this code to eliminate skip_source entirely.
    # XXX instead create build and issue skip messages inline

    if self.force:
        skip_source = {}  # rebuild everything
        for source in sources:
            skip_source[source] = 0
    elif depends is None:
        # If depends is None, figure out which source files we
        # have to recompile according to a simplistic check. We
        # just compare the source and object file, no deep
        # dependency checking involving header files.
        skip_source = {}  # rebuild everything
        for source in sources:  # no wait, rebuild nothing
            skip_source[source] = 1

        n_sources, n_objects = newer_pairwise(sources, objects)
        for source in n_sources:  # no really, only rebuild what's
            skip_source[source] = 0  # out-of-date
    else:
        # If depends is a list of files, then do a different
        # simplistic check.  Assume that each object depends on
        # its source and all files in the depends list.
        skip_source = {}
        # L contains all the depends plus a spot at the end for a
        # particular source file
        L = depends[:] + [None]
        for i in range(len(objects)):
            source = sources[i]
            L[-1] = source
            if newer_group(L, objects[i]):
                skip_source[source] = 0
            else:
                skip_source[source] = 1

    pp_opts = gen_preprocess_options(macros, incdirs)

    build = {}
    for i in range(len(sources)):
        src = sources[i]
        obj = objects[i]
        ext = os.path.splitext(src)[1]
        self.mkpath(os.path.dirname(obj))
        if skip_source[src]:
            log.debug("skipping %s (%s up-to-date)", src, obj)
        else:
            build[obj] = src, ext

    return macros, objects, extra, pp_opts, build
Beispiel #9
0
    def build_libraries(self, libraries):
        for (lib_name, build_info) in libraries:
            sources = build_info.get('sources')
            if sources is None or not isinstance(sources, (list, tuple)):
                raise DistutilsSetupError(
                    "in 'libraries' option (library '%s'), "
                    "'sources' must be present and must be "
                    "a list of source filenames" % lib_name)
            sources = list(sources)

            # detect target language
            language = self.compiler.detect_language(sources)

            # do compiler specific customizations
            compiler_type = self.compiler.compiler_type

            # strip compile flags that are not valid for C++ to avoid warnings
            if compiler_type == "unix" and language == "c++":
                if "-Wstrict-prototypes" in self.compiler.compiler_so:
                    self.compiler.compiler_so.remove("-Wstrict-prototypes")

            # get compiler-specific preprocessor definitions
            macros = build_info.get("macros", [])
            if isinstance(macros, dict):
                if compiler_type in macros:
                    macros = macros[compiler_type]
                else:
                    macros = macros.get("", [])

            include_dirs = build_info.get('include_dirs')

            # get compiler-specific compile flags
            cflags = build_info.get("cflags", [])
            if isinstance(cflags, dict):
                if compiler_type in cflags:
                    cflags = cflags[compiler_type]
                else:
                    cflags = cflags.get("", [])

            expected_objects = self.compiler.object_filenames(
                sources, output_dir=self.build_temp)

            # TODO: also support objects' dependencies
            if (self.force or newer_pairwise(sources, expected_objects) !=
                ([], [])):
                log.info("building '%s' library", lib_name)
                # compile the source code to object files
                objects = self.compiler.compile(sources,
                                                output_dir=self.build_temp,
                                                macros=macros,
                                                include_dirs=include_dirs,
                                                extra_postargs=cflags,
                                                debug=self.debug)
            else:
                log.debug("skipping build '%s' objects (up-to-date)" %
                          lib_name)
                objects = expected_objects

            # Now "link" the object files together into a static library.
            # (On Unix at least, this isn't really linking -- it just
            # builds an archive.  Whatever.)
            self.compiler.create_static_lib(objects,
                                            lib_name,
                                            output_dir=self.build_clib,
                                            debug=self.debug)
Beispiel #10
0
def old_setup_compile(self, outdir, macros, incdirs, sources, depends,
                      extra):
     """Process arguments and decide which source files to compile.

     Merges _fix_compile_args() and _prep_compile().
     """
     if outdir is None:
         outdir = self.output_dir
     elif type(outdir) is not StringType:
         raise TypeError, "'output_dir' must be a string or None"

     if macros is None:
         macros = self.macros
     elif type(macros) is ListType:
         macros = macros + (self.macros or [])
     else:
         raise TypeError, "'macros' (if supplied) must be a list of tuples"

     if incdirs is None:
         incdirs = self.include_dirs
     elif type(incdirs) in (ListType, TupleType):
         incdirs = list(incdirs) + (self.include_dirs or [])
     else:
         raise TypeError, \
               "'include_dirs' (if supplied) must be a list of strings"

     if extra is None:
         extra = []

     # Get the list of expected output (object) files
     objects = self.object_filenames(sources,
                                     strip_dir=0,
                                     output_dir=outdir)
     assert len(objects) == len(sources)

     # XXX should redo this code to eliminate skip_source entirely.
     # XXX instead create build and issue skip messages inline

     if self.force:
         skip_source = {}  # rebuild everything
         for source in sources:
             skip_source[source] = 0
     elif depends is None:
         # If depends is None, figure out which source files we
         # have to recompile according to a simplistic check. We
         # just compare the source and object file, no deep
         # dependency checking involving header files.
         skip_source = {}  # rebuild everything
         for source in sources:  # no wait, rebuild nothing
             skip_source[source] = 1

         n_sources, n_objects = newer_pairwise(sources, objects)
         for source in n_sources:  # no really, only rebuild what's
             skip_source[source] = 0  # out-of-date
     else:
         # If depends is a list of files, then do a different
         # simplistic check.  Assume that each object depends on
         # its source and all files in the depends list.
         skip_source = {}
         # L contains all the depends plus a spot at the end for a
         # particular source file
         L = depends[:] + [None]
         for i in range(len(objects)):
             source = sources[i]
             L[-1] = source
             if newer_group(L, objects[i]):
                 skip_source[source] = 0
             else:
                 skip_source[source] = 1

     pp_opts = gen_preprocess_options(macros, incdirs)

     build = {}
     for i in range(len(sources)):
         src = sources[i]
         obj = objects[i]
         ext = os.path.splitext(src)[1]
         self.mkpath(os.path.dirname(obj))
         if skip_source[src]:
             log.debug("skipping %s (%s up-to-date)", src, obj)
         else:
             build[obj] = src, ext

     return macros, objects, extra, pp_opts, build
Beispiel #11
0
"""distutils.ccompiler
Beispiel #12
0
"""distutils.ccompiler