Skip to content

Commit

Permalink
Fix passing arbitrary args to compiler
Browse files Browse the repository at this point in the history
Only prepend cwd to the arg if it actually is a path.
This allows passing actual compile arguments that are not additional files.

(cherry picked from commit 7fe4509974079ba08a67ca88cb4a7e71a2895572)
  • Loading branch information
j4b6ski authored and MasloMaslane committed Aug 22, 2024
1 parent d140852 commit bac71a4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
8 changes: 6 additions & 2 deletions src/sinol_make/commands/run/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,12 @@ def compile(self, solution, dest=None, use_extras=False, clear_cache=False, name
args = self.config.get("extra_compilation_args", {}).get(lang, [])
if isinstance(args, str):
args = [args]
for file in args:
extra_compilation_args.append(os.path.join(os.getcwd(), "prog", file))
for arg in args:
path = os.path.join(os.getcwd(), "prog", arg)
if os.path.exists(path):
extra_compilation_args.append(path)
else:
extra_compilation_args.append(arg)

for file in self.config.get("extra_compilation_files", []):
extra_compilation_files.append(os.path.join(os.getcwd(), "prog", file))
Expand Down
25 changes: 15 additions & 10 deletions src/sinol_make/helpers/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,22 @@ def compile_file(file_path: str, name: str, compilers: Compilers, compilation_fl

config = package_util.get_config()

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 = []
extra_compilation_files = []
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 = []
lang = os.path.splitext(file_path)[1][1:]
args = config.get("extra_compilation_args", {}).get(lang, [])
if isinstance(args, str):
args = [args]
for arg in args:
path = os.path.join(os.getcwd(), "prog", arg)
if os.path.exists(path):
extra_compilation_args.append(path)
else:
extra_compilation_args.append(arg)

for file in config.get("extra_compilation_files", []):
extra_compilation_files.append(os.path.join(os.getcwd(), "prog", file))
if additional_flags is not None:
extra_compilation_args.append(additional_flags)

Expand Down

0 comments on commit bac71a4

Please sign in to comment.