diff --git a/Makefile b/Makefile index 40c1d7e99..792774dbc 100644 --- a/Makefile +++ b/Makefile @@ -199,7 +199,7 @@ test-libp2p-daemon: | vendor/go/bin/p2pd deps libnimbus.so: | build deps nat-libs echo -e $(BUILD_MSG) "build/$@" && \ - $(ENV_SCRIPT) nim c --app:lib --noMain -d:"chronicles_sinks=textlines" --debuginfo --opt:speed --lineTrace:off $(NIM_PARAMS) -o:build/$@.0 wrappers/wrapper.nim && \ + $(ENV_SCRIPT) nim c --app:lib --noMain --nimcache:nimcache/libnimbus $(NIM_PARAMS) -o:build/$@.0 wrappers/libnimbus.nim && \ rm -f build/$@ && \ ln -s $@.0 build/$@ @@ -207,11 +207,12 @@ wrappers: | build deps nat-libs libnimbus.so go-checks echo -e $(BUILD_MSG) "build/C_wrapper_example" && \ $(CC) wrappers/wrapper_example.c -Wl,-rpath,'$$ORIGIN' -Lbuild -lnimbus -lm -g -o build/C_wrapper_example echo -e $(BUILD_MSG) "build/go_wrapper_example" && \ - go build -o build/go_wrapper_example wrappers/wrapper_example.go + go build -linkshared -o build/go_wrapper_example wrappers/wrapper_example.go libnimbus.a: | build deps nat-libs echo -e $(BUILD_MSG) "build/$@" && \ - $(ENV_SCRIPT) nim c --app:staticlib --noMain $(NIM_PARAMS) -o:build/$@ wrappers/wrapper.nim + rm -f build/$@ && \ + $(ENV_SCRIPT) nim c --app:staticlib --noMain --nimcache:nimcache/libnimbus $(NIM_PARAMS) -o:build/$@ wrappers/libnimbus.nim wrappers-static: | build deps nat-libs libnimbus.a go-checks echo -e $(BUILD_MSG) "build/C_wrapper_example_static" && \ diff --git a/nim.cfg b/nim.cfg index 52b2c9fdf..8b04f4b94 100644 --- a/nim.cfg +++ b/nim.cfg @@ -17,7 +17,3 @@ --excessiveStackTrace:on -d:metrics # enable metric collection -# Required to make up for the compiler's inability to invalidate the C file -# (and object) cache on different command line arguments. ---forceBuild - diff --git a/wrappers/wrapper.h b/wrappers/libnimbus.h similarity index 84% rename from wrappers/wrapper.h rename to wrappers/libnimbus.h index 4f84bfffb..94840f6f7 100644 --- a/wrappers/wrapper.h +++ b/wrappers/libnimbus.h @@ -1,6 +1,13 @@ +#ifndef __LIBNIMBUS_H__ +#define __LIBNIMBUS_H__ + #include #include +#ifdef __cplusplus +extern "C" { +#endif + typedef struct { uint8_t* decoded; size_t decodedLen; @@ -30,3 +37,10 @@ void nimbus_poll(); void nimbus_post(const char* channel, const char* payload); void nimbus_subscribe(const char* channel, received_msg_handler msg); + +#ifdef __cplusplus +} +#endif + +#endif //__LIBNIMBUS_H__ + diff --git a/wrappers/wrapper.nim b/wrappers/libnimbus.nim similarity index 82% rename from wrappers/wrapper.nim rename to wrappers/libnimbus.nim index 6b7c83df7..e5c157e7a 100644 --- a/wrappers/wrapper.nim +++ b/wrappers/libnimbus.nim @@ -28,22 +28,6 @@ proc `$`*(digest: SymKey): string = for c in digest: result &= hexChar(c.byte) const - # Can't import config.nim from here.. - # TODO: refactor in nimbus, then move this. - MainnetBootnodes = [ - # Ethereum Foundation Go Bootnodes - "enode://d860a01f9722d78051619d1e2351aba3f43f943f6f00718d1b9baa4101932a1f5011f16bb2b1bb35db20d6fe28fa0bf09636d26a87d31de9ec6203eeedb1f666@18.138.108.67:30303", # bootnode-aws-ap-southeast-1-001 - "enode://22a8232c3abc76a16ae9d6c3b164f98775fe226f0917b0ca871128a74a8e9630b458460865bab457221f1d448dd9791d24c4e5d88786180ac185df813a68d4de@3.209.45.79:30303", # bootnode-aws-us-east-1-001 - "enode://ca6de62fce278f96aea6ec5a2daadb877e51651247cb96ee310a318def462913b653963c155a0ef6c7d50048bba6e6cea881130857413d9f50a621546b590758@34.255.23.113:30303", # bootnode-aws-eu-west-1-001 - "enode://279944d8dcd428dffaa7436f25ca0ca43ae19e7bcf94a8fb7d1641651f92d121e972ac2e8f381414b80cc8e5555811c2ec6e1a99bb009b3f53c4c69923e11bd8@35.158.244.151:30303", # bootnode-aws-eu-central-1-001 - "enode://8499da03c47d637b20eee24eec3c356c9a2e6148d6fe25ca195c7949ab8ec2c03e3556126b0d7ed644675e78c4318b08691b7b57de10e5f0d40d05b09238fa0a@52.187.207.27:30303", # bootnode-azure-australiaeast-001 - "enode://103858bdb88756c71f15e9b5e09b56dc1be52f0a5021d46301dbbfb7e130029cc9d0d6f73f693bc29b665770fff7da4d34f3c6379fe12721b5d7a0bcb5ca1fc1@191.234.162.198:30303", # bootnode-azure-brazilsouth-001 - "enode://715171f50508aba88aecd1250af392a45a330af91d7b90701c436b618c86aaa1589c9184561907bebbb56439b8f8787bc01f49a7c77276c58c1b09822d75e8e8@52.231.165.108:30303", # bootnode-azure-koreasouth-001 - "enode://5d6d7cd20d6da4bb83a1d28cadb5d409b64edf314c0335df658c1a54e32c7c4a7ab7823d57c39b6a757556e68ff1df17c748b698544a55cb488b52479a92b60f@104.42.217.25:30303", # bootnode-azure-westus-001 - # Ethereum Foundation C++ Bootnodes - "enode://979b7fa28feeb35a4741660a16076f1943202cb72b6af70d327f053e248bab9ba81760f39d0701ef1d8f89cc1fbd2cacba0710a12cd5314d5e0c9021aa3637f9@5.1.83.226:30303" # DE - ] - # Whisper nodes taken from: # curl -s https://raw.githubusercontent.com/status-im/status-react/develop/resources/config/fleets.json | jq '"\"" + .fleets["eth.beta"].whisper[] + "\","' -r WhisperNodes* = [ diff --git a/wrappers/wrapper_example.c b/wrappers/wrapper_example.c index 5d3f0cf6f..728005bb2 100644 --- a/wrappers/wrapper_example.c +++ b/wrappers/wrapper_example.c @@ -4,7 +4,7 @@ #include #include -#include "wrapper.h" +#include "libnimbus.h" void NimMain(); diff --git a/wrappers/wrapper_example.go b/wrappers/wrapper_example.go index 0c5b363d5..9b392cee7 100644 --- a/wrappers/wrapper_example.go +++ b/wrappers/wrapper_example.go @@ -7,7 +7,7 @@ import ( ) // #cgo LDFLAGS: -Wl,-rpath,'$ORIGIN' -L${SRCDIR}/../build -lnimbus -lm -// #include "wrapper.h" +// #include "libnimbus.h" import "C" // Arrange that main.main runs on main thread.