Exemplo n.º 1
0
    def __try_run(self, cmds):
        root_dir = os.getcwd()
        os.chdir(self.common_parameters.root_path)

        evaluated_artefacts = self.common_parameters.artefacts.eval()
        evaluated_prerequisites = self.common_parameters.prerequisites.eval()

        should_run = True
        if evaluated_prerequisites and evaluated_artefacts:
            should_run = False

            ui.debug("checking prerequisites ({!s}) for making {!s}".format(
                evaluated_prerequisites, evaluated_artefacts))

            for artefact in evaluated_artefacts:
                ui.debug("  " + artefact)
                if fsutils.is_any_newer_than(evaluated_prerequisites,
                                             artefact):
                    ui.debug(("going on because {!s}"
                              "needs to be rebuilt").format(artefact))
                    should_run = True
                    break

        if should_run:
            variables.pollute_environment(self.common_parameters.module_name)

            evaluated_cmds = cmds.eval()

            for cmd in evaluated_cmds:
                ui.debug("running {!s}".format(cmd))
                shell.execute(cmd)

        os.chdir(root_dir)
Exemplo n.º 2
0
    def link_application(self, out_filename, in_filenames, link_with,
                         library_dirs):
        if fsutils.is_any_newer_than(
                in_filenames,
                out_filename) or self.__are_libs_newer_than_target(
                    link_with, out_filename):
            ui.debug("linking application")
            ui.debug("  files: " + str(in_filenames))
            ui.debug("  with libs: " + str(link_with))
            ui.debug("  lib dirs: " + str(library_dirs))

            parameters = " ".join("-L " + lib_dir for lib_dir in library_dirs)

            ui.bigstep("linking", out_filename)
            try:
                shell.execute(" ".join([
                    configurations.compiler(),
                    configurations.linker_flags(), "-o", out_filename,
                    " ".join(in_filenames),
                    self.__prepare_linker_flags(link_with), parameters
                ]))
            except Exception as e:
                ui.fatal("cannot link {}, reason: {!s}".format(
                    out_filename, e))
        else:
            ui.bigstep("up to date", out_filename)
Exemplo n.º 3
0
    def build_object(self, target_name, out_filename, in_filename,
                     include_dirs, compiler_flags):
        ui.debug("building object " + out_filename)

        with ui.ident:
            prerequisites = self.__fetch_includes(target_name, in_filename,
                                                  include_dirs, compiler_flags)
            prerequisites.append(in_filename)

            ui.debug("appending prerequisites from pake modules: {!s}".format(
                fsutils.pake_files))

            prerequisites.extend(fsutils.pake_files)

            ui.debug("prerequisites: {!r}".format(prerequisites))

            if fsutils.is_any_newer_than(prerequisites, out_filename):
                fsutils.mkdir_recursive(os.path.dirname(out_filename))

                cmd = configurations.compiler(
                ) + " " + self.__prepare_compiler_flags(
                    include_dirs, compiler_flags
                ) + " -c -o " + out_filename + " " + in_filename
                if command_line.args.verbose:
                    ui.step(configurations.compiler(), cmd)
                else:
                    ui.step(configurations.compiler(), in_filename)

                shell.execute(cmd)
Exemplo n.º 4
0
    def build_object(self, target_name, out_filename, in_filename, include_dirs,
                     compiler_flags):

        abs_source = os.path.join(os.getcwd(), in_filename)

        ui.debug("building object " + out_filename)

        with ui.ident:
            prerequisites = self.__fetch_includes(target_name, abs_source,
                                                  include_dirs, compiler_flags)
            prerequisites.append(in_filename)

            ui.debug("appending prerequisites from pake modules: {!s}"
                     .format(fsutils.pake_files))

            prerequisites.extend(fsutils.pake_files)

            ui.debug("prerequisites: {!r}".format(prerequisites))

            if fsutils.is_any_newer_than(prerequisites, out_filename):
                fsutils.mkdir_recursive(os.path.dirname(out_filename));

                cmd = configurations.compiler() + " " + self.__prepare_compiler_flags(include_dirs, compiler_flags) + " -c -o " + out_filename + " " + abs_source
                if command_line.args.verbose:
                    ui.step(configurations.compiler(), cmd)
                else:
                    ui.step(configurations.compiler(), in_filename)

                shell.execute(cmd)
Exemplo n.º 5
0
    def build(self, toolchain):
        root_dir = os.getcwd()
        os.chdir(self.common_parameters.root_path)

        object_files = self.build_objects(toolchain)

        artefact = toolchain.static_library_filename(self.common_parameters.name)

        if fsutils.is_any_newer_than(object_files, artefact):
            toolchain.link_static_library(artefact, object_files)
        else:
            ui.bigstep("up to date", artefact)

        os.chdir(root_dir)
Exemplo n.º 6
0
    def __are_explicit_prerequisities_newer(self, artefacts, prerequisites):
        ui.debug("checking prerequisites ({!s}) for making {!s}"
                 .format(prerequisites, artefacts))

        if prerequisites and artefacts:
            for artefact in artefacts:
                ui.debug("  " + artefact)
                if fsutils.is_any_newer_than(prerequisites, artefact):
                    ui.debug(("going on because {!s}"
                              "needs to be rebuilt").format(artefact))
                    return True
            return False
        else:
            return True
Exemplo n.º 7
0
    def build(self, toolchain):
        root_dir = os.getcwd()
        os.chdir(self.common_parameters.root_path)

        object_files = self.build_objects(toolchain)

        artefact = toolchain.static_library_filename(
            self.common_parameters.name)

        if fsutils.is_any_newer_than(object_files, artefact):
            toolchain.link_static_library(artefact, object_files)
        else:
            ui.bigstep("up to date", artefact)

        os.chdir(root_dir)
Exemplo n.º 8
0
    def link_application(self, out_filename, in_filenames, link_with, library_dirs):
        if fsutils.is_any_newer_than(in_filenames, out_filename) or self.__are_libs_newer_than_target(link_with, out_filename):
            ui.debug("linking application")
            ui.debug("  files: " + str(in_filenames))
            ui.debug("  with libs: " + str(link_with))
            ui.debug("  lib dirs: " + str(library_dirs))

            parameters = " ".join("-L " + lib_dir for lib_dir in library_dirs)

            ui.bigstep("linking", out_filename)
            try:
                shell.execute(" ".join([configurations.compiler(),
                                        configurations.linker_flags(),
                                        "-o", out_filename,
                                        " ".join(in_filenames),
                                        self.__prepare_linker_flags(link_with),
                                        parameters]))
            except Exception as e:
                ui.fatal("cannot link {}, reason: {!s}".format(out_filename, e))
        else:
            ui.bigstep("up to date", out_filename)