HomePhabricator

[CMAKE] Add support to build secp256k1 JNI binding and tests

Authored by Fabien on Aug 9 2019, 08:52.

Description

[CMAKE] Add support to build secp256k1 JNI binding and tests

Summary:
This allow for building the secp256k1 JNI binding from CMake, as well as
running the java test as part of the check-all command.
The JNI binding is disabled by default and require the ECDH module to be
enabled. If the JNI binding is to be built, a shared secp256k1_jni library
is also built.

Test Plan:
On Linux:

mkdir buildcmake && cd buildcmake

The default check-all behavior is unaffected:

cmake -GNinja ..
ninja check-all

Check in the output that the java tests are not run.

ls ./src/secp256k1 | grep ".so" # Should return nothing

JNI requires the ECDH module:

rm -rf *
rm -rf *

Should return a CMake error:

The secp256k1 JNI support requires ECDH.  Try again with
  -DSECP256K1_ENABLE_MODULE_ECDH=ON.

The check-all target runs the java tests when JNI is enabled:

rm -rf *
cmake -GNinja .. -DSECP256K1_ENABLE_JNI=ON \
  -DSECP256K1_ENABLE_MODULE_ECDH=ON
ninja check-all

Check in the output that the java tests are run.

ls ./src/secp256k1 | grep ".so" # Should return libsecp256k1_jni.so

It also works when built as standalone:

cd ../src/secp256k1
mkdir buildcmake && cd buildcmake
cmake -GNinja .. -DSECP256K1_ENABLE_JNI=ON \
  -DSECP256K1_ENABLE_MODULE_ECDH=ON
ninja secp256k1-check-java

Check in the output that the java tests are run.

ls . | grep ".so" # Should return libsecp256k1_jni.so

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D3871

Details

Committed
FabienSep 16 2019, 09:00
Pushed
FabienSep 16 2019, 09:00
Reviewer
Restricted Project
Differential Revision
D3871: [CMAKE] Add support to build secp256k1 JNI binding and tests
Parents
rABC9b97fa8bb7c4: Move InactivityCheck logic to private method.
Branches
Unknown
Tags
Unknown