From 634a8c4dad038c367d6a565a65296f73af6bc3ec Mon Sep 17 00:00:00 2001 From: Mateusz Masiarz Date: Thu, 25 Jul 2024 13:10:13 +0200 Subject: [PATCH] Dont use extras for ingen, inwer and checker --- src/sinol_make/commands/ingen/ingen_util.py | 2 +- src/sinol_make/commands/inwer/inwer_util.py | 2 +- src/sinol_make/commands/run/__init__.py | 2 +- src/sinol_make/helpers/compile.py | 13 +++++++++---- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/sinol_make/commands/ingen/ingen_util.py b/src/sinol_make/commands/ingen/ingen_util.py index a8c03ca8..35fb28a1 100644 --- a/src/sinol_make/commands/ingen/ingen_util.py +++ b/src/sinol_make/commands/ingen/ingen_util.py @@ -58,7 +58,7 @@ def compile_ingen(ingen_path: str, args: argparse.Namespace, compilation_flags=' compilers = compiler.verify_compilers(args, [ingen_path]) ingen_exe, compile_log_path = compile.compile_file(ingen_path, package_util.get_executable(ingen_path), compilers, compilation_flags, use_fsanitize=use_fsanitize, - additional_flags='-D_INGEN') + additional_flags='-D_INGEN', use_extras=False) if ingen_exe is None: compile.print_compile_log(compile_log_path) diff --git a/src/sinol_make/commands/inwer/inwer_util.py b/src/sinol_make/commands/inwer/inwer_util.py index 53618603..0c6eaab6 100644 --- a/src/sinol_make/commands/inwer/inwer_util.py +++ b/src/sinol_make/commands/inwer/inwer_util.py @@ -36,7 +36,7 @@ def compile_inwer(inwer_path: str, args: argparse.Namespace, compilation_flags=' compilers = compiler.verify_compilers(args, [inwer_path]) inwer_exe, compile_log_path = compile.compile_file(inwer_path, package_util.get_executable(inwer_path), compilers, compilation_flags, use_fsanitize=use_fsanitize, - additional_flags='-D_INWER') + additional_flags='-D_INWER', use_extras=False) if inwer_exe is None: compile.print_compile_log(compile_log_path) diff --git a/src/sinol_make/commands/run/__init__.py b/src/sinol_make/commands/run/__init__.py index 161b9e5a..18aad615 100644 --- a/src/sinol_make/commands/run/__init__.py +++ b/src/sinol_make/commands/run/__init__.py @@ -357,7 +357,7 @@ def compile_solutions(self, solutions, is_checker=False): os.makedirs(paths.get_compilation_log_path(), exist_ok=True) os.makedirs(paths.get_executables_path(), exist_ok=True) print("Compiling %d solutions..." % len(solutions)) - args = [(solution, True, is_checker) for solution in solutions] + args = [(solution, not is_checker, is_checker) for solution in solutions] with mp.Pool(self.cpus) as pool: compilation_results = pool.starmap(self.compile, args) return compilation_results diff --git a/src/sinol_make/helpers/compile.py b/src/sinol_make/helpers/compile.py index d3dc8958..027342d4 100644 --- a/src/sinol_make/helpers/compile.py +++ b/src/sinol_make/helpers/compile.py @@ -119,7 +119,7 @@ def compile(program, output, compilers: Compilers = None, compile_log=None, comp def compile_file(file_path: str, name: str, compilers: Compilers, compilation_flags='default', - use_fsanitize=False, additional_flags=None) \ + use_fsanitize=False, additional_flags=None, use_extras=True) \ -> Tuple[Union[str, None], str]: """ Compile a file @@ -129,6 +129,7 @@ def compile_file(file_path: str, name: str, compilers: Compilers, compilation_fl :param compilation_flags: Group of compilation flags to use :param use_fsanitize: Whether to use fsanitize when compiling C/C++ programs. Sanitizes address and undefined behavior. :param additional_flags: Additional flags for c / c++ compiler. + :param use_extras: Whether to use extra compilation files and arguments from config :return: Tuple of (executable path or None if compilation failed, log path) """ os.makedirs(paths.get_executables_path(), exist_ok=True) @@ -136,13 +137,17 @@ def compile_file(file_path: str, name: str, compilers: Compilers, compilation_fl config = package_util.get_config() - extra_compilation_files = [os.path.join(os.getcwd(), "prog", file) - for file in config.get("extra_compilation_files", [])] lang = os.path.splitext(file_path)[1][1:] args = config.get('extra_compilation_args', {}).get(lang, []) if isinstance(args, str): args = [args] - extra_compilation_args = [os.path.join(os.getcwd(), "prog", file) for file in args] + if use_extras: + extra_compilation_args = [os.path.join(os.getcwd(), "prog", file) for file in args] + extra_compilation_files = [os.path.join(os.getcwd(), "prog", file) + for file in config.get("extra_compilation_files", [])] + else: + extra_compilation_args = [] + extra_compilation_files = [] if additional_flags is not None: extra_compilation_args.append(additional_flags)