Skip to content

Commit

Permalink
adjust nix build
Browse files Browse the repository at this point in the history
  • Loading branch information
neodix42 committed Nov 25, 2024
1 parent 8292bcd commit 997753a
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 15 deletions.
28 changes: 15 additions & 13 deletions CMake/BuildSECP256K1.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ if (NOT SECP256K1_LIBRARY)
set(SECP256K1_INCLUDE_DIR ${SECP256K1_BINARY_DIR}/include)
add_custom_command(
WORKING_DIRECTORY ${SECP256K1_SOURCE_DIR}
COMMAND cmake -E env CFLAGS="/WX" cmake -A x64 -B build -DSECP256K1_ENABLE_MODULE_RECOVERY=ON -DSECP256K1_ENABLE_MODULE_EXTRAKEYS=ON -DSECP256K1_BUILD_EXAMPLES=OFF -DBUILD_SHARED_LIBS=OFF
COMMAND cmake -E env CFLAGS="/WX" cmake -A x64 -B build
COMMAND cmake --build build --config Release
COMMENT "Build Secp256k1 with vs2017"
COMMENT "Build Secp256k1"
DEPENDS ${SECP256K1_SOURCE_DIR}
OUTPUT ${SECP256K1_LIBRARY}
)
Expand All @@ -32,17 +32,19 @@ if (NOT SECP256K1_LIBRARY)
OUTPUT ${SECP256K1_LIBRARY}
)
else()
set(SECP256K1_LIBRARY ${SECP256K1_BINARY_DIR}/lib/libsecp256k1.a)
add_custom_command(
WORKING_DIRECTORY ${SECP256K1_SOURCE_DIR}
COMMAND ./autogen.sh
COMMAND ./configure -q --disable-option-checking --enable-module-recovery --enable-module-extrakeys --prefix ${SECP256K1_BINARY_DIR} --with-pic --disable-shared --enable-static --disable-tests --disable-benchmark
COMMAND make -j16
COMMAND make install
COMMENT "Build secp256k1"
DEPENDS ${SECP256K1_SOURCE_DIR}
OUTPUT ${SECP256K1_LIBRARY}
)
if (NOT NIX)
set(SECP256K1_LIBRARY ${SECP256K1_BINARY_DIR}/lib/libsecp256k1.a)
add_custom_command(
WORKING_DIRECTORY ${SECP256K1_SOURCE_DIR}
COMMAND ./autogen.sh
COMMAND ./configure -q --disable-option-checking --enable-module-recovery --enable-module-extrakeys --prefix ${SECP256K1_BINARY_DIR} --with-pic --disable-shared --enable-static --disable-tests --disable-benchmark
COMMAND make -j16
COMMAND make install
COMMENT "Build secp256k1"
DEPENDS ${SECP256K1_SOURCE_DIR}
OUTPUT ${SECP256K1_LIBRARY}
)
endif()
endif()

else()
Expand Down
27 changes: 27 additions & 0 deletions CMake/FindSecp256k1.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# - Try to find Secp256k1
# Once done this will define
#
# SECP256K1_INCLUDE_DIR - the Secp256k1 include directory
# SECP256K1_LIBRARY - Link these to use Secp256k1

if (NOT SECP256K1_LIBRARY)
find_path(
SECP256K1_INCLUDE_DIR
NAMES microhttpd.h
DOC "microhttpd include dir"
)

find_library(
SECP256K1_LIBRARY
NAMES secp256k1 libsecp256k1
DOC "secp256k1 library"
)
endif()

if (SECP256K1_LIBRARY)
message(STATUS "Found Secp256k1: ${SECP256K1_LIBRARY}")
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Secp256k1 DEFAULT_MSG SECP256K1_INCLUDE_DIR SECP256K1_LIBRARY)
mark_as_advanced(SECP256K1_INCLUDE_DIR SECP256K1_LIBRARY)
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ if (TON_USE_JEMALLOC)
find_package(jemalloc REQUIRED)
endif()

if (NIX)
find_package(Secp256k1 REQUIRED)
endif()


set(MEMPROF "" CACHE STRING "Use one of \"ON\", \"FAST\" or \"SAFE\" to enable memory profiling. \
Works under macOS and Linux when compiled using glibc. \
In FAST mode stack is unwinded only using frame pointers, which may fail. \
Expand Down
1 change: 1 addition & 0 deletions assembly/wasm/fift-func-wasm-build-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ emcmake cmake -DUSE_EMSCRIPTEN=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAK
-DCMAKE_TOOLCHAIN_FILE=$EMSDK_DIR/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
-DCMAKE_CXX_FLAGS="-sUSE_ZLIB=1" \
-DSODIUM_INCLUDE_DIR=$SODIUM_DIR/src/libsodium/include \
-DSODIUM_USE_STATIC_LIBS=1 \
-DSODIUM_LIBRARY_RELEASE=$SODIUM_DIR/src/libsodium/.libs/libsodium.a \
..

Expand Down
2 changes: 1 addition & 1 deletion crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ if (NOT WIN32)
endif()
target_include_directories(ton_crypto SYSTEM PUBLIC $<BUILD_INTERFACE:${OPENSSL_INCLUDE_DIR}>)

add_dependencies(ton_crypto blst secp256k1)
add_dependencies(ton_crypto blst)
add_dependencies(ton_crypto_core secp256k1)

target_include_directories(ton_crypto PRIVATE ${BLST_INCLUDE_DIR})
Expand Down
2 changes: 1 addition & 1 deletion example/android/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Sets the minimum version of CMake required to build the native library.

cmake_minimum_required(VERSION 3.4.1 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

project(TON_ANDROID VERSION 0.5 LANGUAGES C CXX)

Expand Down

0 comments on commit 997753a

Please sign in to comment.