Skip to content

Commit

Permalink
adjust nix, wasm and android builds
Browse files Browse the repository at this point in the history
  • Loading branch information
neodix42 committed Nov 25, 2024
1 parent 555ecb7 commit 91c0e1d
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 17 deletions.
32 changes: 16 additions & 16 deletions CMake/BuildSECP256K1.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)

if (NOT SECP256K1_LIBRARY)

set(SECP256K1_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third-party/secp256k1)
Expand All @@ -10,13 +8,13 @@ if (NOT SECP256K1_LIBRARY)

if (MSVC)
set(SECP256K1_BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third-party/secp256k1)
set(SECP256K1_LIBRARY ${SECP256K1_SOURCE_DIR}/build/src/Release/libsecp256k1.lib)
set(SECP256K1_LIBRARY ${SECP256K1_SOURCE_DIR}/build/lib/Release/libsecp256k1.lib)
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 @@ -34,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)
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ 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
4 changes: 4 additions & 0 deletions assembly/android/build-android-tonlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ while getopts 'a' flag; do
esac
done

export CC=$(which clang-16)
export CXX=$(which clang++-16)
export CCACHE_DISABLE=1

if [ ! -d android-ndk-r25b ]; then
rm android-ndk-r25b-linux.zip
echo "Downloading https://dl.google.com/android/repository/android-ndk-r25b-linux.zip"
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 @@ -181,6 +181,7 @@ emcmake cmake -DUSE_EMSCRIPTEN=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAK
-DSECP256K1_LIBRARY=$SECP256K1_DIR/.libs/libsecp256k1.a \
-DSODIUM_FOUND=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 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 91c0e1d

Please sign in to comment.