Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ test_amalgamation:
- touch config.h
- gcc -Wall -W -Wextra -Werror -I. -I./src -I./src/ccan -I./src/secp256k1/include src/ctest/amalgamation_compile_test.c
- gcc -DBUILD_ELEMENTS -Wall -W -Wextra -Werror -I. -I./src -I./src/ccan -I./src/secp256k1/include src/ctest/amalgamation_compile_test.c
- gcc -DBUILD_ELEMENTS -DBUILD_MINIMAL -Wall -W -Wextra -Werror -I. -I./src -I./src/ccan -I./src/secp256k1/include src/ctest/amalgamation_compile_test.c
- clang -Wall -W -Wextra -Werror -I. -I./src -I./src/ccan -I./src/secp256k1/include src/ctest/amalgamation_compile_test.c
- clang -DBUILD_ELEMENTS -Wall -W -Wextra -Werror -I. -I./src -I./src/ccan -I./src/secp256k1/include src/ctest/amalgamation_compile_test.c
- clang -DBUILD_ELEMENTS -DBUILD_MINIMAL -Wall -W -Wextra -Werror -I. -I./src -I./src/ccan -I./src/secp256k1/include src/ctest/amalgamation_compile_test.c

test_mingw_static_build:
stage: test
Expand Down
6 changes: 6 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ if test "x$standard_secp" = "xyes"; then
fi

if test "x$minimal" = "xyes"; then
if test "x$elements" = "xno"; then
AC_MSG_FAILURE([ERROR: Minimal mode requires Elements support to be enabled])
fi
AX_CHECK_COMPILE_FLAG([-DBUILD_MINIMAL=1], [AM_CFLAGS="$AM_CFLAGS -DBUILD_MINIMAL=1"])
fi

Expand Down Expand Up @@ -271,6 +274,9 @@ AC_ARG_WITH([system-secp256k1],
AM_CONDITIONAL([LINK_SYSTEM_SECP256K1], [test "x$with_system_secp256k1" != xno])
AM_COND_IF([LINK_SYSTEM_SECP256K1], [
dnl Use the secp installed system-wide (after checking it for suitability)
if test "x$minimal" = "xyes"; then
AC_MSG_ERROR([Minimal mode cannot be used with --with-system-secp256k1])
fi
saved_LIBS=$LIBS
m4_ifdef([PKG_CHECK_MODULES],
[PKG_CHECK_MODULES([libsecp256k1], [$with_system_secp256k1])],
Expand Down
11 changes: 11 additions & 0 deletions src/amalgamation/combined.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifndef WALLY_NO_AMALGAMATION
/*
* secp2556k1-zkp configuration
*/
Expand Down Expand Up @@ -38,6 +39,7 @@
* config.h (which must be provided by the amalgamation user)
* is included.
*/
#define BUILD_AMALGAMATION 1
#include "src/internal.h"

/* The amalgamation user can provide their own defines and skip
Expand Down Expand Up @@ -121,3 +123,12 @@ void wally_silence_unused_warnings(void)
assert_bip38_assumptions();
assert_tx_assumptions();
}

/* Undefine our internal macros */
#undef BYTES_VALID
#undef BYTES_INVALID
#undef BYTES_INVALID_N
#undef OUTPUT_CHECK
#undef OUTPUT_ALLOC

#endif /* WALLY_NO_AMALGAMATION */
2 changes: 2 additions & 0 deletions src/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ bool mem_is_zero(const void *mem, size_t len);
/* Fetch our internal operations function pointers */
const struct wally_operations *wally_ops(void);

#ifndef BUILD_AMALGAMATION
#define malloc(size) __use_wally_malloc_internally__
#define calloc(size) __use_wally_calloc_internally__
#define free(ptr) __use_wally_free_internally__
#ifdef strdup
#undef strdup
#endif
#define strdup(ptr) __use_wally_strdup_internally__
#endif

#define NUM_ELEMS(a) (sizeof(a) / sizeof(a[0]))

Expand Down