From 1f0dd2f8f3d22565e8686a89a19f1ea27202bc70 Mon Sep 17 00:00:00 2001 From: akokoshn Date: Thu, 18 Apr 2024 16:31:10 +0300 Subject: [PATCH] Build assigner with nix --- .github/workflows/run-tests-linux.yml | 3 +++ README.md | 13 ++++++++++--- bin/assigner/CMakeLists.txt | 15 ++++++--------- flake.nix | 7 +++++++ 4 files changed, 26 insertions(+), 12 deletions(-) diff --git a/.github/workflows/run-tests-linux.yml b/.github/workflows/run-tests-linux.yml index d2bfa89..b418768 100644 --- a/.github/workflows/run-tests-linux.yml +++ b/.github/workflows/run-tests-linux.yml @@ -31,5 +31,8 @@ jobs: with: fetch-depth: 0 + - name: Run build + run: nix build -L + - name: Run checks run: nix flake -L check diff --git a/README.md b/README.md index f3398df..43a1cef 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ nix develop ## Clone ```plain -git clone https://github.com/NilFoundation/zkEVM-framework.git +git clone https://@github.com/NilFoundation/zkEVM-framework.git ``` If you want Nix to use your local version of dependency instead of cloning it from GitHub, @@ -79,8 +79,8 @@ Same option applies to `nix build` and etc. ## Build ```plain -cmake -B ${BUILD_DIR:-build} -DCMAKE_BUILD_TYPE=Release . -cmake --build ${BUILD_DIR:-build} +cmake --preset release +cmake --build --preset release ``` Or with Nix: @@ -88,6 +88,13 @@ Or with Nix: ```bash nix build ``` +## Assigner + +### Build && run + +```bash +nix run .#assigner -- -b block -t assignments -e pallas +``` ## Test diff --git a/bin/assigner/CMakeLists.txt b/bin/assigner/CMakeLists.txt index 8f1077e..aa1da99 100644 --- a/bin/assigner/CMakeLists.txt +++ b/bin/assigner/CMakeLists.txt @@ -2,18 +2,15 @@ set(TARGET_NAME assigner) set(SOURCES src/main.cpp) -add_executable(${TARGET_NAME} ${SOURCES}) - -target_compile_options(${TARGET_NAME} PRIVATE -std=c++23) +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_STANDARD_REQUIRED True) -set(ASSIGNER_INCLUDES ${CMAKE_INSTALL_PREFIX}/include ${CMAKE_CURRENT_SOURCE_DIR}/include) -set(ASSIGNER_LIBS ${CMAKE_INSTALL_PREFIX}/lib) +add_executable(${TARGET_NAME} ${SOURCES}) target_include_directories(${TARGET_NAME} PRIVATE - $ - $<$:${Boost_INCLUDE_DIRS}> - ${ASSIGNER_INCLUDES}) + ${CMAKE_CURRENT_SOURCE_DIR}/include) -target_link_directories(${TARGET_NAME} PRIVATE ${ASSIGNER_LIBS}) target_link_libraries(${TARGET_NAME} PRIVATE evmone zkEVMDataTypes ${Boost_LIBRARIES}) + +install(TARGETS ${TARGET_NAME}) diff --git a/flake.nix b/flake.nix index e141d10..0aef816 100644 --- a/flake.nix +++ b/flake.nix @@ -83,6 +83,7 @@ ninja boost deps.sszpp + deps.evmc evm_assigner crypto3 blueprint @@ -157,6 +158,12 @@ { packages = forAllSystems ({ pkgs }: { default = makeReleaseBuild { inherit pkgs; }; }); checks = forAllSystems ({ pkgs }: { default = makeTests { inherit pkgs; }; }); + apps = forAllSystems ({ pkgs }: { + assigner = { + type = "app"; + program = "${self.packages.${pkgs.system}.default}/bin/assigner"; + }; + }); devShells = forAllSystems ({ pkgs }: { default = makeDevShell { inherit pkgs; }; }); }; }