Skip to content

Commit

Permalink
Expose -Wno via ignore-warnings kompile option (#4471)
Browse files Browse the repository at this point in the history
Address #4470
  • Loading branch information
JuanCoRo authored Jun 25, 2024
1 parent 94a069d commit 3bc2373
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyk/src/pyk/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ def exec_kompile(options: KompileCommandOptions) -> None:
type_inference_mode=options.type_inference_mode,
warnings=options.warnings,
warnings_to_errors=options.warnings_to_errors,
ignore_warnings=options.ignore_warnings,
no_exc_wrap=options.no_exc_wrap,
)
except RuntimeError as err:
Expand Down
5 changes: 5 additions & 0 deletions pyk/src/pyk/cli/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class KompileOptions(Options):
bison_lists: bool
no_exc_wrap: bool
outer_parsed_json: bool
ignore_warnings: list[str]

@staticmethod
def default() -> dict[str, Any]:
Expand All @@ -230,6 +231,7 @@ def default() -> dict[str, Any]:
'bison_lists': False,
'no_exc_wrap': False,
'outer_parsed_json': False,
'ignore_warnings': [],
}

@staticmethod
Expand Down Expand Up @@ -475,6 +477,9 @@ def kompile_args(self) -> ArgumentParser:
action='store_true',
help='Do not wrap the output on the CLI.',
)
args.add_argument(
'--ignore-warnings', '-Wno', dest='ignore_warnings', action='append', help='Ignore provided warnings'
)
return args

@cached_property
Expand Down
10 changes: 10 additions & 0 deletions pyk/src/pyk/ktool/kompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def kompile(
type_inference_mode: str | TypeInferenceMode | None = None,
warnings: str | Warnings | None = None,
warnings_to_errors: bool = False,
ignore_warnings: Iterable[str] = (),
no_exc_wrap: bool = False,
# ---
debug: bool = False,
Expand All @@ -78,6 +79,7 @@ def kompile(
type_inference_mode=type_inference_mode,
warnings=warnings,
warnings_to_errors=warnings_to_errors,
ignore_warnings=ignore_warnings,
no_exc_wrap=no_exc_wrap,
debug=debug,
verbose=verbose,
Expand All @@ -96,6 +98,7 @@ def kompile(
type_inference_mode=type_inference_mode,
warnings=warnings,
warnings_to_errors=warnings_to_errors,
ignore_warnings=ignore_warnings,
no_exc_wrap=no_exc_wrap,
debug=debug,
verbose=verbose,
Expand All @@ -111,6 +114,7 @@ def _booster_kompile(
type_inference_mode: str | TypeInferenceMode | None,
warnings: str | Warnings | None,
warnings_to_errors: bool,
ignore_warnings: Iterable[str],
no_exc_wrap: bool,
# ---
debug: bool,
Expand Down Expand Up @@ -146,6 +150,7 @@ def kompile_llvm() -> None:
type_inference_mode=type_inference_mode,
warnings=warnings,
warnings_to_errors=warnings_to_errors,
ignore_warnings=ignore_warnings,
no_exc_wrap=no_exc_wrap,
debug=debug,
verbose=verbose,
Expand All @@ -161,6 +166,7 @@ def kompile_haskell() -> None:
type_inference_mode=type_inference_mode,
warnings=warnings,
warnings_to_errors=warnings_to_errors,
ignore_warnings=ignore_warnings,
no_exc_wrap=no_exc_wrap,
debug=debug,
verbose=verbose,
Expand Down Expand Up @@ -273,6 +279,7 @@ def __call__(
type_inference_mode: str | TypeInferenceMode | None = None,
warnings: str | Warnings | None = None,
warnings_to_errors: bool = False,
ignore_warnings: Iterable[str] = (),
no_exc_wrap: bool = False,
debug: bool = False,
verbose: bool = False,
Expand Down Expand Up @@ -321,6 +328,9 @@ def __call__(
if outer_parsed_json:
args += ['--outer-parsed-json']

if ignore_warnings:
args += ['-Wno', ','.join(ignore_warnings)]

try:
proc_res = run_process(args, logger=_LOGGER, cwd=cwd, check=check)
except CalledProcessError as err:
Expand Down

0 comments on commit 3bc2373

Please sign in to comment.