From 20ada5c5c826489180ae1a2993c9fbffe36d0bc3 Mon Sep 17 00:00:00 2001 From: Mateusz Masiarz Date: Wed, 13 Sep 2023 14:20:36 +0200 Subject: [PATCH 1/2] Change default compilers --- src/sinol_make/helpers/compiler.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/sinol_make/helpers/compiler.py b/src/sinol_make/helpers/compiler.py index 4162e0c3..6b11bc36 100644 --- a/src/sinol_make/helpers/compiler.py +++ b/src/sinol_make/helpers/compiler.py @@ -52,6 +52,8 @@ def get_cpp_compiler_path(): else: return 'g++' elif sys.platform == 'darwin': + if check_if_installed('g++-12'): # g++12 is currently the default compiler on sio. + return 'g++-12' for i in [9, 10, 11]: compiler = 'g++-' + str(i) if check_if_installed(compiler): @@ -65,10 +67,12 @@ def get_python_interpreter_path(): Get the Python interpreter """ - if not check_if_installed('python3'): - return None - else: - return 'python3' + if check_if_installed('python3.11'): # python3.11 is currently the default interpreter on sio. + return 'python3.11' + for ver in ['3.9', '3.8', '3.7', '3']: + if check_if_installed('python' + ver): + return 'python' + ver + return None def get_java_compiler_path(): From 6318acbadb974356ba874d87fd763bdffae92d70 Mon Sep 17 00:00:00 2001 From: Mateusz Masiarz Date: Wed, 13 Sep 2023 14:20:52 +0200 Subject: [PATCH 2/2] Change c++ and c standards --- src/sinol_make/commands/export/__init__.py | 4 ++-- src/sinol_make/helpers/compile.py | 4 ++-- tests/commands/export/util.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sinol_make/commands/export/__init__.py b/src/sinol_make/commands/export/__init__.py index ac643d87..7d0fb5a1 100644 --- a/src/sinol_make/commands/export/__init__.py +++ b/src/sinol_make/commands/export/__init__.py @@ -90,8 +90,8 @@ def create_makefile_in(self, target_dir: str, config: dict): :param config: Config dictionary. """ with open(os.path.join(target_dir, 'makefile.in'), 'w') as f: - cxx_flags = '-std=c++17' - c_flags = '-std=c17' + cxx_flags = '-std=c++20' + c_flags = '-std=gnu99' def format_multiple_arguments(obj): if isinstance(obj, str): return obj diff --git a/src/sinol_make/helpers/compile.py b/src/sinol_make/helpers/compile.py index a234b0d8..b8defdeb 100644 --- a/src/sinol_make/helpers/compile.py +++ b/src/sinol_make/helpers/compile.py @@ -100,11 +100,11 @@ def compile(program, output, compilers: Compilers = None, compile_log = None, we if ext == '.cpp': arguments = [compilers.cpp_compiler_path or compiler.get_cpp_compiler_path(), program] + \ extra_compilation_args + ['-o', output] + \ - f'--std=c++17 -O3 -lm {gcc_compilation_flags} -fdiagnostics-color'.split(' ') + f'--std=c++20 -O3 -lm {gcc_compilation_flags} -fdiagnostics-color'.split(' ') elif ext == '.c': arguments = [compilers.c_compiler_path or compiler.get_c_compiler_path(), program] + \ extra_compilation_args + ['-o', output] + \ - f'--std=c17 -O3 -lm {gcc_compilation_flags} -fdiagnostics-color'.split(' ') + f'--std=gnu99 -O3 -lm {gcc_compilation_flags} -fdiagnostics-color'.split(' ') elif ext == '.py': if sys.platform == 'win32' or sys.platform == 'cygwin': # TODO: Make this work on Windows diff --git a/tests/commands/export/util.py b/tests/commands/export/util.py index ac103636..9bf2f8bd 100644 --- a/tests/commands/export/util.py +++ b/tests/commands/export/util.py @@ -53,8 +53,8 @@ def _get_value_from_key(key, seperator): assert _get_value_from_key("SLOW_TIMELIMIT", "=") == str(4 * config["time_limit"]) assert _get_value_from_key("MEMLIMIT", "=") == str(config["memory_limit"]) - cxx_flags = '-std=c++17' - c_flags = '-std=c17' + cxx_flags = '-std=c++20' + c_flags = '-std=gnu99' def format_multiple_arguments(obj): if isinstance(obj, str): return obj