Skip to content

Commit 28d6547

Browse files
committed
Optionally compile the examples in autotools, compile+run in travis
1 parent a9f796f commit 28d6547

File tree

5 files changed

+32
-2
lines changed

5 files changed

+32
-2
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ tests
1010
exhaustive_tests
1111
gen_context
1212
valgrind_ctime_test
13+
keygen_example
14+
ecdh_example
1315
*.exe
1416
*.so
1517
*.a
1618
!.gitignore
19+
*.log
20+
*.trs
1721

1822
Makefile
1923
configure

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ compiler:
1717
- gcc
1818
env:
1919
global:
20-
- FIELD=auto BIGNUM=auto SCALAR=auto ENDOMORPHISM=no STATICPRECOMPUTATION=yes ECMULTGENPRECISION=auto ASM=no BUILD=check EXTRAFLAGS= HOST= ECDH=no RECOVERY=no EXPERIMENTAL=no CTIMETEST=yes BENCH=yes ITERS=2
20+
- FIELD=auto BIGNUM=auto SCALAR=auto ENDOMORPHISM=no STATICPRECOMPUTATION=yes ECMULTGENPRECISION=auto ASM=no BUILD=check EXTRAFLAGS= HOST= ECDH=no RECOVERY=no EXPERIMENTAL=no CTIMETEST=yes BENCH=yes ITERS=2 EXAMPLES=yes
2121
matrix:
2222
- SCALAR=32bit RECOVERY=yes
2323
- SCALAR=32bit FIELD=32bit ECDH=yes EXPERIMENTAL=yes

Makefile.am

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ noinst_HEADERS += contrib/lax_der_parsing.h
4848
noinst_HEADERS += contrib/lax_der_parsing.c
4949
noinst_HEADERS += contrib/lax_der_privatekey_parsing.h
5050
noinst_HEADERS += contrib/lax_der_privatekey_parsing.c
51+
noinst_HEADERS += examples/random.h
5152

5253
if USE_EXTERNAL_ASM
5354
COMMON_LIB = libsecp256k1_common.la
@@ -121,6 +122,23 @@ exhaustive_tests_LDFLAGS = -static
121122
TESTS += exhaustive_tests
122123
endif
123124

125+
if USE_EXAMPLES
126+
noinst_PROGRAMS += keygen_example
127+
keygen_example_SOURCES = examples/keygen.c
128+
keygen_example_CPPFLAGS = -I$(top_srcdir)/include $(SECP_INCLUDES)
129+
keygen_example_LDADD = libsecp256k1.la $(SECP_LIBS)
130+
keygen_example_LDFLAGS = -static
131+
TESTS += keygen_example
132+
if ENABLE_MODULE_ECDH
133+
noinst_PROGRAMS += ecdh_example
134+
ecdh_example_SOURCES = examples/ecdh.c
135+
ecdh_example_CPPFLAGS = -I$(top_srcdir)/include $(SECP_INCLUDES)
136+
ecdh_example_LDADD = libsecp256k1.la $(SECP_LIBS)
137+
ecdh_example_LDFLAGS = -static
138+
TESTS += ecdh_example
139+
endif
140+
endif
141+
124142
if USE_ECMULT_STATIC_PRECOMPUTATION
125143
CPPFLAGS_FOR_BUILD +=-I$(top_srcdir) -I$(builddir)/src
126144

configure.ac

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ AC_ARG_ENABLE(exhaustive_tests,
116116
[use_exhaustive_tests=$enableval],
117117
[use_exhaustive_tests=yes])
118118

119+
AC_ARG_ENABLE(examples,
120+
AS_HELP_STRING([--enable-examples],[compile the examples [default=no]]),
121+
[use_examples=$enableval],
122+
[use_examples=no])
123+
119124
AC_ARG_ENABLE(endomorphism,
120125
AS_HELP_STRING([--enable-endomorphism],[enable endomorphism [default=no]]),
121126
[use_endomorphism=$enableval],
@@ -527,6 +532,7 @@ AC_SUBST(SECP_TEST_INCLUDES)
527532
AM_CONDITIONAL([ENABLE_COVERAGE], [test x"$enable_coverage" = x"yes"])
528533
AM_CONDITIONAL([USE_TESTS], [test x"$use_tests" != x"no"])
529534
AM_CONDITIONAL([USE_EXHAUSTIVE_TESTS], [test x"$use_exhaustive_tests" != x"no"])
535+
AM_CONDITIONAL([USE_EXAMPLES], [test x"$use_examples" != x"no"])
530536
AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" = x"yes"])
531537
AM_CONDITIONAL([USE_ECMULT_STATIC_PRECOMPUTATION], [test x"$set_precomp" = x"yes"])
532538
AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"])
@@ -548,6 +554,7 @@ echo " with ecmult precomp = $set_precomp"
548554
echo " with external callbacks = $use_external_default_callbacks"
549555
echo " with benchmarks = $use_benchmark"
550556
echo " with coverage = $enable_coverage"
557+
echo " with examples = $use_examples"
551558
echo " module ecdh = $enable_module_ecdh"
552559
echo " module recovery = $enable_module_recovery"
553560
echo

contrib/travis.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ fi
2020
--enable-experimental="$EXPERIMENTAL" --enable-endomorphism="$ENDOMORPHISM" \
2121
--with-field="$FIELD" --with-bignum="$BIGNUM" --with-asm="$ASM" --with-scalar="$SCALAR" \
2222
--enable-ecmult-static-precomputation="$STATICPRECOMPUTATION" --with-ecmult-gen-precision="$ECMULTGENPRECISION" \
23-
--enable-module-ecdh="$ECDH" --enable-module-recovery="$RECOVERY" "$EXTRAFLAGS" "$USE_HOST"
23+
--enable-module-ecdh="$ECDH" --enable-module-recovery="$RECOVERY" --enable-examples="$EXAMPLES" \
24+
"$EXTRAFLAGS" "$USE_HOST"
2425

2526
if [ -n "$BUILD" ]
2627
then

0 commit comments

Comments
 (0)