From aaddbea2f905086d38ea31cc81f4cbb9c82dfedd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20T=C3=B3th?= Date: Fri, 16 Aug 2024 12:53:22 +0000 Subject: [PATCH] Simplify `plugin` build --- Dockerfile | 1 - README.md | 3 +- flake.nix | 3 +- kmultiversx/src/kmultiversx/kdist/plugin.py | 37 ++++----------------- 4 files changed, 8 insertions(+), 36 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2107f339..9935199c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,6 @@ RUN apt-get update \ curl \ wget \ libcrypto++-dev \ - libprocps-dev \ libsecp256k1-dev \ libssl-dev \ pandoc \ diff --git a/README.md b/README.md index 21629a61..4d712cbd 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,6 @@ sudo apt-get install --yes \ curl \ wget \ libcrypto++-dev \ - libprocps-dev \ libsecp256k1-dev \ libssl-dev \ python3 \ @@ -45,7 +44,7 @@ bash <(curl https://kframework.org/install) ``` Once `kup` is installed, to get the correct version of K run: ```bash -kup install k.openssl.procps.secp256k1 --version v$(cat deps/k_release) +kup install k.openssl.secp256k1 --version v$(cat deps/k_release) ``` #### Poetry diff --git a/flake.nix b/flake.nix index 42172e55..353497d1 100644 --- a/flake.nix +++ b/flake.nix @@ -70,13 +70,12 @@ secp256k1 nixpkgs-pyk.pyk-python310 k-framework.packages.${system}.k - kmultiversx-pyk + kmultiversx-pyk cmake openssl.dev clang mpfr pkg-config - procps llvmPackages.llvm ]; diff --git a/kmultiversx/src/kmultiversx/kdist/plugin.py b/kmultiversx/src/kmultiversx/kdist/plugin.py index 0b6e47bc..65bec854 100644 --- a/kmultiversx/src/kmultiversx/kdist/plugin.py +++ b/kmultiversx/src/kmultiversx/kdist/plugin.py @@ -1,15 +1,14 @@ from __future__ import annotations import shutil -import sys from distutils.dir_util import copy_tree from pathlib import Path from typing import TYPE_CHECKING -from pyk.kbuild.utils import k_version, sync_files +from pyk.kbuild.utils import k_version from pyk.kdist.api import Target from pyk.ktool.kompile import PykBackend, kompile -from pyk.utils import run_process +from pyk.utils import run_process_2 if TYPE_CHECKING: from collections.abc import Callable, Mapping @@ -35,26 +34,9 @@ class PluginTarget(Target): PLUGIN_DIR: Final = Path(__file__).parent / 'plugin' def build(self, output_dir: Path, deps: dict[str, Any], args: dict[str, Any], verbose: bool) -> None: - sync_files( - source_dir=self.PLUGIN_DIR / 'plugin-c', - target_dir=output_dir / 'plugin-c', - file_names=[ - 'blake2.h', - 'crypto.cpp', - 'plugin_util.cpp', - 'plugin_util.h', - ], - ) - copy_tree(str(self.PLUGIN_DIR), '.') - run_process( - ['make', 'libcryptopp', 'libff', 'blake2', '-j8'], - pipe_stdout=not verbose, - ) - - copy_tree('./build/libcryptopp', str(output_dir / 'libcryptopp')) - copy_tree('./build/libff', str(output_dir / 'libff')) - copy_tree('./build/blake2', str(output_dir / 'blake2')) + run_process_2(['make', '-j8']) + shutil.copy('./build/krypto/lib/krypto.a', str(output_dir)) def source(self) -> tuple[Path]: return (self.PLUGIN_DIR,) @@ -86,15 +68,8 @@ def ccopts(plugin_dir: Path) -> list[str]: '-lcrypto', '-lsecp256k1', '-lssl', - str(plugin_dir / 'blake2/lib/blake2.a'), - f"-I{plugin_dir / 'blake2/include'}", - str(plugin_dir / 'libcryptopp/lib/libcryptopp.a'), - f"-I{plugin_dir / 'libcryptopp/include'}", - str(plugin_dir / 'libff/lib/libff.a'), - f"-I{plugin_dir / 'libff/include'}", - str(plugin_dir / 'plugin-c/crypto.cpp'), - str(plugin_dir / 'plugin-c/plugin_util.cpp'), - ] + (['-lprocps'] if sys.platform == 'linux' else []) + str(plugin_dir / 'krypto.a'), + ] return KompileTarget(