Page MenuHomePhabricator

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

Authored by Fabien on Wed, Aug 14, 12:00.

Details

Reviewers
deadalnix
Group Reviewers
Restricted Project
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 Java tests are to be built, a shared secp256k1 library
is also built.

Depends on D3870.

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.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.so

Diff Detail

Repository
rABC Bitcoin ABC
Branch
cmake_jni
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 7142
Build 12329: Bitcoin ABC Teamcity Staging
Build 12328: arc lint + arc unit