This PR adds UniValue over a git subtree. Main repository is currently https://github.com/jgarzik/univalue.
Edit: You need to re-do ./autogen.sh and ./configure after this is merged
This PR adds UniValue over a git subtree. Main repository is currently https://github.com/jgarzik/univalue.
Edit: You need to re-do ./autogen.sh and ./configure after this is merged
Wouldn’t dynamic library and or pkg-config require broad support in various distributions over their package management?
Personally I would recommend static linking of the JSON stack. It’s a critical library and an a hacked JSON stack could lead to coin stealing.
@sipa: Recently we have coupled UniValue with utilstrencodings.cpp/h
(see https://github.com/bitcoin/bitcoin/commit/c02309204b8195476945f7066e8d96c60246db08#diff-0f1b401041a14398229cf7e31b6db7eeR13).
To re-acchive independence from other sources, i have added the depending numparse functions in UniValue (see https://github.com/jgarzik/univalue/commit/d0ec6ad70f2a1590138adbcbb78ab8f0c1f8a47e and https://github.com/jgarzik/univalue/commit/4b288b380a364737c7488b6cc9bb552f98d7f890). Not sure if this was a good step. I think copy and namespace the numparse function to UniValue could have made more sense. But also not sure if it would be a good idea either (duplicate code in bitcoin).
For bitcoin-core, we compile univalue without the number parse functions because we have them already over utilstrencodings.cpp/h
. This is why univalue gets compiled with --with-numfunc=no
.
But without the number parse functions, univalue itself cannot run the tests because the number parse functions are essential.
Maybe there is a way to tell the UniValue subtrees make check
to link with utilstrencodings.o
. But this would somehow break the independence of the subtree.
FWIW, the numberparse code is very nicely C/C++ standard and not tied to Univalue or bitcoin at all.
For the univalue tests, we could create an optional libtest for this case, if no better solution appears.
UniValue doesn’t depend on any code. It now just have an option (--with-numfunc=no
) to avoid linking numfunc.o
(consuming application of libunivalue can provide own number parse functions [3 functions as Jeff mentioned above] to avoid duplicated code).
I think it would make sense to just namespace the ParseInt32
, ParseInt64
and ParseDouble
into UniValue::
and compile/link them always.
Will do a PR upstream.
Updated this PR:
make check
does now also covers the UniValue make check
#include "univalue/univalue.h"
with #include <univalue.h>
(was necessary because UniValues uses now univalue/lib/* as folder structure).I think it’s recommended to build a *.la (libtool) library to gain more flexibility.
Travis complains about missing -fPIC recompile support: https://travis-ci.org/bitcoin/bitcoin/jobs/79127433#L1480
Secp256k1 also uses libtool and fPIC: https://github.com/bitcoin/bitcoin/blob/master/configure.ac#L920
Updated. Now runs unit tests (univalue’s make check) and also passes Win32/64 travis.
UniValue has now a stable ABI and versioning.
Because it’s not available over package management systems, i think adding it over “/depends” makes no sense yet.
Adding it over a git subtree would split off discussions and PR for UniValue. If other projects start using UniValue, Bitcoin-Core could also benefit from maintenance and new features/optimizations.
I hadn’t used subtrees before, was confused as to the intention. I had the impression we were just copying the code in.
After some further research, concept ACK :+1:
git-subtree-dir: src/univalue
git-subtree-split: 87d90455ff5e87dedc304353aa23ace47ffb6c1c
similar to secp256k1 include and compile univalue over a subtree
Note: As usual after large build system changes, if you get:
0Making all in src
1make[1]: Entering directory `/store/orion/projects/bitcoin/bitcoin/src'
2make[2]: Entering directory `/store/orion/projects/bitcoin/bitcoin/src'
3make[3]: Entering directory `/store/orion/projects/bitcoin/bitcoin/src/univalue'
4make[3]: *** No targets specified and no makefile found. Stop.
5make[3]: Leaving directory `/store/orion/projects/bitcoin/bitcoin/src/univalue'
6make[2]: *** [univalue/lib/libunivalue.la] Error 2
7make[2]: Leaving directory `/store/orion/projects/bitcoin/bitcoin/src'
8make[1]: *** [all-recursive] Error 1
9make[1]: Leaving directory `/store/orion/projects/bitcoin/bitcoin/src'
10make: *** [all-recursive] Error 1
You need to re-do ./autogen.sh
and ./configure
. The automatic triggering of those is not enough.
Edit: ACK