-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6aba0b6
commit f70ac81
Showing
5 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,9 @@ authors = [ | |
"Runtime Verification, Inc. <[email protected]>", | ||
] | ||
|
||
[tool.poetry.plugins.kdist] | ||
riscv-semantics = "kriscv.kdist.plugin" | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.10" | ||
pyk = { git = "https://github.com/runtimeverification/k.git", tag = "v7.0.56", subdirectory = "pyk" } | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from __future__ import annotations | ||
|
||
import shutil | ||
from pathlib import Path | ||
from typing import TYPE_CHECKING | ||
|
||
from pyk.kbuild.utils import k_version | ||
from pyk.kdist.api import Target | ||
from pyk.ktool.kompile import kompile | ||
|
||
if TYPE_CHECKING: | ||
from collections.abc import Callable, Mapping | ||
from typing import Any, Final | ||
|
||
|
||
class SourceTarget(Target): | ||
SRC_DIR: Final = Path(__file__).parent | ||
|
||
def build(self, output_dir: Path, deps: dict[str, Path], args: dict[str, Any], verbose: bool) -> None: | ||
shutil.copytree(self.SRC_DIR / 'riscv-semantics', output_dir / 'riscv-semantics') | ||
|
||
def source(self) -> tuple[Path, ...]: | ||
return (self.SRC_DIR,) | ||
|
||
|
||
class KompileTarget(Target): | ||
_kompile_args: Callable[[Path], Mapping[str, Any]] | ||
|
||
def __init__(self, kompile_args: Callable[[Path], Mapping[str, Any]]): | ||
self._kompile_args = kompile_args | ||
|
||
def build(self, output_dir: Path, deps: dict[str, Path], args: dict[str, Any], verbose: bool) -> None: | ||
kompile_args = self._kompile_args(deps['riscv-semantics.source']) | ||
kompile(output_dir=output_dir, verbose=verbose, **kompile_args) | ||
|
||
def context(self) -> dict[str, str]: | ||
return {'k-version': k_version().text} | ||
|
||
def deps(self) -> tuple[str]: | ||
return ('riscv-semantics.source',) | ||
|
||
|
||
__TARGETS__: Final = { | ||
'source': SourceTarget(), | ||
'llvm': KompileTarget( | ||
lambda src_dir: { | ||
'main_file': src_dir / 'riscv-semantics/riscv.md', | ||
'syntax_module': 'RISCV', | ||
'include_dirs': [src_dir], | ||
'md_selector': 'k', | ||
'warnings_to_errors': True, | ||
}, | ||
), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
```k | ||
module RISCV | ||
endmodule | ||
``` |