Beispiel #1
0
    def run(data,
            skip_on_failure=False,
            compiler_flags=strings.COMPILER_WARNING_FLAGS):
        program_dir_abs = data["program_dir_abs"]
        args = data["args"]
        lines_of_code = data["lines_of_code"]
        excluded_paths = data["excluded_paths"]
        cpp = data["use_cpp"]
        """
        Run the automatic compilation of the target project.
        :param args: The "args" Namespace as returned from parse_arguments().
        :param lines_of_code: The lines of pure code count.
        :param cpp: Whether C++ is used or not. True if C++, False if C.
        :param compiler_flags: The flags to be used for compilation. Typically, these should be strings.COMPILE_FLAGS
            or, if no_execution, strings.COMPILER_WARNING_FLAGS.
        :param excluded_paths: A tuple containing the paths to be excluded.
        :return: The compiler score.
        """
        command_file = args.commandfile

        if args.make:
            if command_file:
                score = compile_phase.compile_program_make(
                    program_dir_abs,
                    lines_of_code,
                    compiler_flags,
                    excluded_paths,
                    make_command_file=command_file[0])
            else:
                score = compile_phase.compile_program_make(
                    program_dir_abs, lines_of_code, compiler_flags,
                    excluded_paths)
        elif args.clang:
            score = compile_phase.compile_program_clang(
                program_dir_abs, args.clang, lines_of_code, compiler_flags,
                excluded_paths, cpp)
        else:
            if command_file:
                score = compile_phase.compile_program_cmake(
                    program_dir_abs,
                    lines_of_code,
                    compiler_flags,
                    excluded_paths,
                    make_command_file=command_file[0])
            else:
                score = compile_phase.compile_program_cmake(
                    program_dir_abs, lines_of_code, compiler_flags,
                    excluded_paths)

        return score
Beispiel #2
0
def compile_program(args, lines_of_code, cpp, compiler_flags, excluded_paths):
    """
    Run the automatic compilation of the target project.
    :param args: The "args" Namespace as returned from parse_arguments().
    :param lines_of_code: The lines of pure code count.
    :param cpp: Whether C++ is used or not. True if C++, False if C.
    :param compiler_flags: The flags to be used for compilation. Typically, these should be strings.COMPILE_FLAGS or,
    if no_execution, strings.COMPILER_WARNING_FLAGS.
    :param excluded_paths: A tupel containing the paths to be excluded.
    :return: The compiler score.
    """
    print(strings.RUN_COMPILER_HEADER)
    program_dir_abs = os.path.abspath(args.programdir)
    command_file = args.commandfile

    if args.make:
        if command_file:
            score = compile_phase.compile_program_make(
                program_dir_abs,
                lines_of_code,
                compiler_flags,
                excluded_paths,
                make_command_file=command_file[0])
        else:
            score = compile_phase.compile_program_make(program_dir_abs,
                                                       lines_of_code,
                                                       compiler_flags,
                                                       excluded_paths)
    elif args.clang:
        score = compile_phase.compile_program_clang(program_dir_abs,
                                                    args.clang, lines_of_code,
                                                    compiler_flags,
                                                    excluded_paths, cpp)
    else:
        if command_file:
            score = compile_phase.compile_program_cmake(
                program_dir_abs,
                lines_of_code,
                compiler_flags,
                excluded_paths,
                make_command_file=command_file[0])
        else:
            score = compile_phase.compile_program_cmake(
                program_dir_abs, lines_of_code, compiler_flags, excluded_paths)

    return score
Beispiel #3
0
def handle_kwstyle_download():
    git_link = 'https://github.com/Kitware/KWStyle.git'
    git_clone_command = ['git', 'clone', git_link]
    softwipe_dir = util.get_softwipe_directory()

    subprocess.run(git_clone_command, cwd=softwipe_dir)

    kwstyle_dir = os.path.join(softwipe_dir, 'KWStyle')
    print('Building KWStyle...')
    compile_phase.compile_program_cmake(
        kwstyle_dir,
        1,
        dont_check_for_warnings=True,
        compiler_flags="",
        excluded_paths=())  # The argument lines_of_code does not matter here
    print('Done!')
    print()