Skip to content

Commit

Permalink
Support building without nix develop
Browse files Browse the repository at this point in the history
  • Loading branch information
makxenov committed Apr 22, 2024
1 parent 3bae30f commit dd169f1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Created by members of the [Ipsilon] (ex-[Ewasm]) team.

- [evmc](https://github.com/ethereum/evmc)
- [intx](https://github.com/chfast/intx)
- [ethash](https://github.com/chfast/ethash)
- [blueprint](https://github.com/NilFoundation/zkllvm-blueprint)
- [crypto3](https://github.com/NilFoundation/crypto3)

Expand All @@ -40,12 +41,18 @@ Run tests:
nix flake check
```

## Build
## Build without Nix

### Provide CMAKE_PREFIX_PATH with paths to dependent modules
```bash
export CMAKE_PREFIX_PATH=$EVMC_PATH:$INTX_PATH:$ETHASH_PATH:$BLUEPRINT_PATH:$CRYPTO3_PATH
```
Note: this variable could be retrieved from Nix shell environment

### Configure cmake

```bash
cmake -G "Ninja" -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_ASSIGNER_TESTS=TRUE
cmake -G "Ninja" -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_ASSIGNER_TESTS=TRUE -DHUNTER_ENABLED=OFF

```

Expand Down
18 changes: 18 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
hunter_add_package(intx)
find_package(intx CONFIG REQUIRED)

# Find crypto3 and blueprint packages
# TODO: replace with find_package if possible
string(REPLACE ":" ";" MODULE_LIST $ENV{CMAKE_PREFIX_PATH})
foreach(module_path ${MODULE_LIST})
if (module_path MATCHES ".*blueprint")
set(BLUEPRINT_DIR ${module_path})
elseif(module_path MATCHES ".*[cC]rypto3")
set(CRYPTO3_DIR ${module_path})
endif()
endforeach()

if ("${BLUEPRINT_DIR}" STREQUAL "")
message(FATAL_ERROR "blueprint library was not found. You should provide it through CMAKE_PREFIX_PATH")
endif()
if ("${CRYPTO3_DIR}" STREQUAL "")
message(FATAL_ERROR "crypto3 library was not found. You should provide it through CMAKE_PREFIX_PATH")
endif()

add_subdirectory(fprinter)
add_subdirectory(evmone)
add_subdirectory(assigner)
9 changes: 8 additions & 1 deletion lib/assigner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ option(BUILD_ASSIGNER_TESTS "Build unit tests" FALSE)

add_library(${PROJECT_NAME} STATIC src/vm_host.cpp)

find_package(Boost COMPONENTS REQUIRED filesystem log log_setup program_options thread system)

target_include_directories(${PROJECT_NAME} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${include_dir}/evmone
${CMAKE_CURRENT_SOURCE_DIR}/../evmone
${BLUEPRINT_DIR}/include
${CRYPTO3_DIR}/include

${Boost_INCLUDE_DIRS})

Expand All @@ -19,10 +23,13 @@ target_include_directories(${PROJECT_NAME} PUBLIC
target_link_libraries(${PROJECT_NAME} PUBLIC
evmone)

# Install assigner headers
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/nil/blueprint/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nil/blueprint)
# Install library
install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR})

#evmone
# Install evmone headers
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../evmone/vm.hpp
${CMAKE_CURRENT_SOURCE_DIR}/../evmone/execution_state.hpp
${CMAKE_CURRENT_SOURCE_DIR}/../evmone/tracing.hpp
Expand Down
2 changes: 1 addition & 1 deletion lib/evmone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ add_library(evmone ${evmone_sources})
get_target_property(FPRINTER_DIR fprinter SOURCE_DIR)

target_compile_features(evmone PUBLIC cxx_std_20)
target_link_libraries(evmone PUBLIC evmc::evmc intx::intx PRIVATE ethash::keccak)
target_link_libraries(evmone PUBLIC evmc::evmc intx::intx ethash::keccak)
target_include_directories(evmone PUBLIC
$<BUILD_INTERFACE:${include_dir}>$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
${FPRINTER_DIR}
Expand Down

0 comments on commit dd169f1

Please sign in to comment.