Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont use extras for ingen, inwer and checker #244

Merged
merged 1 commit into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sinol_make/commands/ingen/ingen_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/sinol_make/commands/inwer/inwer_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/sinol_make/commands/run/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 9 additions & 4 deletions src/sinol_make/helpers/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -129,20 +129,25 @@ 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)
os.makedirs(paths.get_compilation_log_path(), exist_ok=True)

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)

Expand Down
Loading