Skip to content

Commit

Permalink
Change c++ standard and default compilers (#120)
Browse files Browse the repository at this point in the history
* Change default compilers

* Change c++ and c standards
  • Loading branch information
MasloMaslane authored Sep 19, 2023
1 parent 2ea7989 commit 8e35b27
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/sinol_make/commands/export/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/sinol_make/helpers/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions src/sinol_make/helpers/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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():
Expand Down
4 changes: 2 additions & 2 deletions tests/commands/export/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8e35b27

Please sign in to comment.