Skip to content

Commit

Permalink
Add ignore-warnings kompile option
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanCoRo committed Jun 21, 2024
1 parent b4c9228 commit a680cf8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pyk/src/pyk/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ def exec_kompile(options: KompileCommandOptions) -> None:
'gen_glr_bison_parser': options.gen_glr_bison_parser,
'bison_lists': options.bison_lists,
'outer_parsed_json': options.outer_parsed_json,
'ignore_warnings': options.ignore_warnings,
}
if options.backend == KompileBackend.LLVM:
kompile_dict['ccopts'] = options.ccopts
Expand Down Expand Up @@ -346,6 +347,7 @@ def exec_kompile(options: KompileCommandOptions) -> None:
warnings=options.warnings,
warnings_to_errors=options.warnings_to_errors,
no_exc_wrap=options.no_exc_wrap,
ignore_warnings=options.ignore_warnings,
)
except RuntimeError as err:
_, _, _, _, cpe = err.args
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] | None

@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': None,
}

@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', dest='ignore_warnings', default=None, action='append', help='Ignore provided warnings'
)
return args

@cached_property
Expand Down
16 changes: 16 additions & 0 deletions pyk/src/pyk/ktool/kompile.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def kompile(
verbose: bool = False,
cwd: Path | None = None,
check: bool = True,
ignore_warnings: Iterable[str] | None = None,
# ---
**kwargs: Any,
) -> Path:
Expand All @@ -83,6 +84,7 @@ def kompile(
cwd=cwd,
check=check,
kwargs=kwargs,
ignore_warnings=ignore_warnings,
)

kwargs['backend'] = KompileBackend(pyk_backend.value) if pyk_backend else None
Expand All @@ -100,6 +102,7 @@ def kompile(
verbose=verbose,
cwd=cwd,
check=check,
ignore_warnings=ignore_warnings,
)


Expand All @@ -116,6 +119,7 @@ def _booster_kompile(
verbose: bool,
cwd: Path | None,
check: bool,
ignore_warnings: Iterable[str] | None,
# ---
kwargs: Mapping[str, Any],
) -> Path:
Expand Down Expand Up @@ -150,6 +154,7 @@ def kompile_llvm() -> None:
verbose=verbose,
cwd=cwd,
check=check,
ignore_warnings=ignore_warnings,
)

def kompile_haskell() -> None:
Expand All @@ -165,6 +170,7 @@ def kompile_haskell() -> None:
verbose=verbose,
cwd=cwd,
check=check,
ignore_warnings=ignore_warnings,
)

with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor:
Expand Down Expand Up @@ -279,6 +285,7 @@ def __call__(
check: bool = True,
bug_report: BugReport | None = None,
outer_parsed_json: bool = False,
ignore_warnings: Iterable[str] | None = None,
) -> Path:
check_file_path(abs_or_rel_to(self.base_args.main_file, cwd or Path()))
for include_dir in self.base_args.include_dirs:
Expand Down Expand Up @@ -320,6 +327,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 Expand Up @@ -512,6 +522,7 @@ class KompileArgs:
coverage: bool
bison_lists: bool
outer_parsed_json: bool
ignore_warnings: Iterable[str] | None

def __init__(
self,
Expand All @@ -531,6 +542,7 @@ def __init__(
coverage: bool = False,
bison_lists: bool = False,
outer_parsed_json: bool = False,
ignore_warnings: Iterable[str] | None = None,
):
main_file = Path(main_file)
include_dirs = tuple(sorted(Path(include_dir) for include_dir in include_dirs))
Expand All @@ -551,6 +563,7 @@ def __init__(
object.__setattr__(self, 'coverage', coverage)
object.__setattr__(self, 'bison_lists', bison_lists)
object.__setattr__(self, 'outer_parsed_json', outer_parsed_json)
object.__setattr__(self, 'ignore_warnings', ignore_warnings)

def args(self) -> list[str]:
args = [str(self.main_file)]
Expand Down Expand Up @@ -597,6 +610,9 @@ def args(self) -> list[str]:
if self.outer_parsed_json:
args += ['--outer-parsed-json']

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

return args


Expand Down

0 comments on commit a680cf8

Please sign in to comment.