mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-07-07 08:49:26 +00:00
feat: unify libs into a single liblogosdelivery (#3949)
This commit is contained in:
parent
1460aa54cf
commit
5c60792842
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@ -40,7 +40,6 @@ jobs:
|
||||
- 'flake.nix'
|
||||
- 'flake.lock'
|
||||
- 'library/**'
|
||||
- 'liblogosdelivery/**'
|
||||
v2:
|
||||
- 'logos_delivery/**'
|
||||
- 'apps/**'
|
||||
|
||||
3
.github/workflows/release-assets.yml
vendored
3
.github/workflows/release-assets.yml
vendored
@ -159,7 +159,8 @@ jobs:
|
||||
mkdir -p pkg/DEBIAN pkg/usr/local/lib pkg/usr/local/include
|
||||
cp build/liblogosdelivery.so pkg/usr/local/lib/
|
||||
cp build/liblogosdelivery.a pkg/usr/local/lib/
|
||||
cp liblogosdelivery/liblogosdelivery.h pkg/usr/local/include/
|
||||
cp library/liblogosdelivery.h pkg/usr/local/include/
|
||||
cp library/liblogosdelivery_kernel.h pkg/usr/local/include/
|
||||
|
||||
echo "Package: logosdelivery" >> pkg/DEBIAN/control
|
||||
echo "Version: ${VERSION}" >> pkg/DEBIAN/control
|
||||
|
||||
10
.github/workflows/windows-build.yml
vendored
10
.github/workflows/windows-build.yml
vendored
@ -120,10 +120,10 @@ jobs:
|
||||
export PATH="$GITHUB_WORKSPACE/.nim_runtime/bin:$HOME/.nimble/bin:$PATH"
|
||||
make wakunode2 V=3 -j${{ env.NPROC }}
|
||||
|
||||
- name: Building libwaku.dll
|
||||
- name: Building liblogosdelivery.dll
|
||||
run: |
|
||||
export PATH="$GITHUB_WORKSPACE/.nim_runtime/bin:$HOME/.nimble/bin:$PATH"
|
||||
make libwaku STATIC=0 V=1 -j
|
||||
make liblogosdelivery STATIC=0 V=1 -j
|
||||
|
||||
- name: Check Executable
|
||||
run: |
|
||||
@ -133,9 +133,9 @@ jobs:
|
||||
echo "Build failed: wakunode2.exe not found"
|
||||
exit 1
|
||||
fi
|
||||
if [ -f "./build/libwaku.dll" ]; then
|
||||
echo "libwaku.dll build successful"
|
||||
if [ -f "./build/liblogosdelivery.dll" ]; then
|
||||
echo "liblogosdelivery.dll build successful"
|
||||
else
|
||||
echo "Build failed: libwaku.dll not found"
|
||||
echo "Build failed: liblogosdelivery.dll not found"
|
||||
exit 1
|
||||
fi
|
||||
151
Makefile
151
Makefile
@ -54,7 +54,7 @@ endif
|
||||
.PHONY: all test clean examples deps nimble install-nim install-nimble
|
||||
|
||||
# default target
|
||||
all: | wakunode2 libwaku liblogosdelivery
|
||||
all: | wakunode2 liblogosdelivery
|
||||
|
||||
examples: | example2 chat2 chat2bridge
|
||||
|
||||
@ -417,7 +417,7 @@ docker-liteprotocoltester-push:
|
||||
################
|
||||
## C Bindings ##
|
||||
################
|
||||
.PHONY: cbindings cwaku_example libwaku liblogosdelivery liblogosdelivery_example
|
||||
.PHONY: cbindings cwaku_example liblogosdelivery liblogosdelivery_example
|
||||
|
||||
detected_OS ?= Linux
|
||||
ifeq ($(OS),Windows_NT)
|
||||
@ -441,59 +441,58 @@ else ifeq ($(detected_OS),Linux)
|
||||
BUILD_COMMAND := $(BUILD_COMMAND)Linux
|
||||
endif
|
||||
|
||||
# Windows: build with nim directly (see wakunode2). Flags mirror logos_delivery.nimble.
|
||||
libwaku: | build-deps librln
|
||||
ifeq ($(detected_OS),Windows)
|
||||
nim c --out:build/libwaku.dll --threads:on --app:lib --opt:speed --noMain --mm:refc --header -d:metrics --nimMainPrefix:libwaku --skipParentCfg:off -d:discv5_protocol_id=d5waku --cpu:amd64 $(NIM_PARAMS) library/libwaku.nim
|
||||
else
|
||||
$(NIMBLE) --verbose libwaku$(BUILD_COMMAND) logos_delivery.nimble
|
||||
endif
|
||||
|
||||
# Windows: build with nim directly (see wakunode2) — `nimble <task>` re-clones
|
||||
# git deps every build and they intermittently hang on the MSYS2 runner. Flags
|
||||
# mirror logos_delivery.nimble's dynamic-windows task.
|
||||
liblogosdelivery: | build-deps librln
|
||||
ifeq ($(detected_OS),Windows)
|
||||
nim c --out:build/liblogosdelivery.dll --threads:on --app:lib --opt:speed --noMain --mm:refc --header -d:metrics --nimMainPrefix:liblogosdelivery --skipParentCfg:off -d:discv5_protocol_id=d5waku --cpu:amd64 $(NIM_PARAMS) library/liblogosdelivery.nim
|
||||
else
|
||||
$(NIMBLE) --verbose liblogosdelivery$(BUILD_COMMAND) logos_delivery.nimble
|
||||
endif
|
||||
|
||||
logosdelivery_example: | build liblogosdelivery
|
||||
@echo -e $(BUILD_MSG) "build/$@"
|
||||
ifeq ($(detected_OS),Darwin)
|
||||
gcc -o build/$@ \
|
||||
liblogosdelivery/examples/logosdelivery_example.c \
|
||||
liblogosdelivery/examples/json_utils.c \
|
||||
-I./liblogosdelivery \
|
||||
library/examples/logosdelivery_example.c \
|
||||
library/examples/json_utils.c \
|
||||
-I./library \
|
||||
-L./build \
|
||||
-llogosdelivery \
|
||||
-Wl,-rpath,./build
|
||||
else ifeq ($(detected_OS),Linux)
|
||||
gcc -o build/$@ \
|
||||
liblogosdelivery/examples/logosdelivery_example.c \
|
||||
liblogosdelivery/examples/json_utils.c \
|
||||
-I./liblogosdelivery \
|
||||
library/examples/logosdelivery_example.c \
|
||||
library/examples/json_utils.c \
|
||||
-I./library \
|
||||
-L./build \
|
||||
-llogosdelivery \
|
||||
-Wl,-rpath,'$$ORIGIN'
|
||||
else ifeq ($(detected_OS),Windows)
|
||||
gcc -o build/$@.exe \
|
||||
liblogosdelivery/examples/logosdelivery_example.c \
|
||||
liblogosdelivery/examples/json_utils.c \
|
||||
-I./liblogosdelivery \
|
||||
library/examples/logosdelivery_example.c \
|
||||
library/examples/json_utils.c \
|
||||
-I./library \
|
||||
-L./build \
|
||||
-llogosdelivery \
|
||||
-lws2_32
|
||||
endif
|
||||
|
||||
cwaku_example: | build libwaku
|
||||
cwaku_example: | build liblogosdelivery
|
||||
echo -e $(BUILD_MSG) "build/$@" && \
|
||||
cc -o "build/$@" \
|
||||
./examples/cbindings/waku_example.c \
|
||||
./examples/cbindings/base64.c \
|
||||
-lwaku -Lbuild/ \
|
||||
-llogosdelivery -Lbuild/ \
|
||||
-pthread -ldl -lm
|
||||
|
||||
cppwaku_example: | build libwaku
|
||||
cppwaku_example: | build liblogosdelivery
|
||||
echo -e $(BUILD_MSG) "build/$@" && \
|
||||
g++ -o "build/$@" \
|
||||
./examples/cpp/waku.cpp \
|
||||
./examples/cpp/base64.cpp \
|
||||
-lwaku -Lbuild/ \
|
||||
-llogosdelivery -Lbuild/ \
|
||||
-pthread -ldl -lm
|
||||
|
||||
nodejswaku: | build deps
|
||||
@ -503,12 +502,12 @@ nodejswaku: | build deps
|
||||
#####################
|
||||
## Mobile Bindings ##
|
||||
#####################
|
||||
.PHONY: libwaku-android \
|
||||
libwaku-android-precheck \
|
||||
libwaku-android-arm64 \
|
||||
libwaku-android-amd64 \
|
||||
libwaku-android-x86 \
|
||||
libwaku-android-arm
|
||||
.PHONY: liblogosdelivery-android \
|
||||
liblogosdelivery-android-precheck \
|
||||
liblogosdelivery-android-arm64 \
|
||||
liblogosdelivery-android-amd64 \
|
||||
liblogosdelivery-android-x86 \
|
||||
liblogosdelivery-android-arm
|
||||
|
||||
ANDROID_TARGET ?= 30
|
||||
ifeq ($(detected_OS),Darwin)
|
||||
@ -517,56 +516,56 @@ else
|
||||
ANDROID_TOOLCHAIN_DIR := $(ANDROID_NDK_HOME)/toolchains/llvm/prebuilt/linux-x86_64
|
||||
endif
|
||||
|
||||
libwaku-android-precheck:
|
||||
liblogosdelivery-android-precheck:
|
||||
ifndef ANDROID_NDK_HOME
|
||||
$(error ANDROID_NDK_HOME is not set)
|
||||
endif
|
||||
|
||||
build-libwaku-for-android-arch:
|
||||
build-liblogosdelivery-for-android-arch:
|
||||
ifneq ($(findstring /nix/store,$(LIBRLN_FILE)),)
|
||||
mkdir -p $(CURDIR)/build/android/$(ABIDIR)/
|
||||
CPU=$(CPU) ABIDIR=$(ABIDIR) ANDROID_ARCH=$(ANDROID_ARCH) ANDROID_COMPILER=$(ANDROID_COMPILER) ANDROID_TOOLCHAIN_DIR=$(ANDROID_TOOLCHAIN_DIR) $(NIMBLE) libWakuAndroid
|
||||
CPU=$(CPU) ABIDIR=$(ABIDIR) ANDROID_ARCH=$(ANDROID_ARCH) ANDROID_COMPILER=$(ANDROID_COMPILER) ANDROID_TOOLCHAIN_DIR=$(ANDROID_TOOLCHAIN_DIR) $(NIMBLE) libLogosDeliveryAndroid
|
||||
else
|
||||
./scripts/build_rln_android.sh $(CURDIR)/build $(LIBRLN_BUILDDIR) $(LIBRLN_VERSION) $(CROSS_TARGET) $(ABIDIR)
|
||||
endif
|
||||
$(MAKE) rebuild-nat-libs-nimbledeps CC=$(ANDROID_TOOLCHAIN_DIR)/bin/$(ANDROID_COMPILER)
|
||||
|
||||
libwaku-android-arm64: ANDROID_ARCH=aarch64-linux-android
|
||||
libwaku-android-arm64: CPU=arm64
|
||||
libwaku-android-arm64: ABIDIR=arm64-v8a
|
||||
libwaku-android-arm64: | libwaku-android-precheck build deps
|
||||
$(MAKE) build-libwaku-for-android-arch ANDROID_ARCH=$(ANDROID_ARCH) CROSS_TARGET=$(ANDROID_ARCH) CPU=$(CPU) ABIDIR=$(ABIDIR) ANDROID_COMPILER=$(ANDROID_ARCH)$(ANDROID_TARGET)-clang
|
||||
liblogosdelivery-android-arm64: ANDROID_ARCH=aarch64-linux-android
|
||||
liblogosdelivery-android-arm64: CPU=arm64
|
||||
liblogosdelivery-android-arm64: ABIDIR=arm64-v8a
|
||||
liblogosdelivery-android-arm64: | liblogosdelivery-android-precheck build deps
|
||||
$(MAKE) build-liblogosdelivery-for-android-arch ANDROID_ARCH=$(ANDROID_ARCH) CROSS_TARGET=$(ANDROID_ARCH) CPU=$(CPU) ABIDIR=$(ABIDIR) ANDROID_COMPILER=$(ANDROID_ARCH)$(ANDROID_TARGET)-clang
|
||||
|
||||
libwaku-android-amd64: ANDROID_ARCH=x86_64-linux-android
|
||||
libwaku-android-amd64: CPU=amd64
|
||||
libwaku-android-amd64: ABIDIR=x86_64
|
||||
libwaku-android-amd64: | libwaku-android-precheck build deps
|
||||
$(MAKE) build-libwaku-for-android-arch ANDROID_ARCH=$(ANDROID_ARCH) CROSS_TARGET=$(ANDROID_ARCH) CPU=$(CPU) ABIDIR=$(ABIDIR) ANDROID_COMPILER=$(ANDROID_ARCH)$(ANDROID_TARGET)-clang
|
||||
liblogosdelivery-android-amd64: ANDROID_ARCH=x86_64-linux-android
|
||||
liblogosdelivery-android-amd64: CPU=amd64
|
||||
liblogosdelivery-android-amd64: ABIDIR=x86_64
|
||||
liblogosdelivery-android-amd64: | liblogosdelivery-android-precheck build deps
|
||||
$(MAKE) build-liblogosdelivery-for-android-arch ANDROID_ARCH=$(ANDROID_ARCH) CROSS_TARGET=$(ANDROID_ARCH) CPU=$(CPU) ABIDIR=$(ABIDIR) ANDROID_COMPILER=$(ANDROID_ARCH)$(ANDROID_TARGET)-clang
|
||||
|
||||
libwaku-android-x86: ANDROID_ARCH=i686-linux-android
|
||||
libwaku-android-x86: CPU=i386
|
||||
libwaku-android-x86: ABIDIR=x86
|
||||
libwaku-android-x86: | libwaku-android-precheck build deps
|
||||
$(MAKE) build-libwaku-for-android-arch ANDROID_ARCH=$(ANDROID_ARCH) CROSS_TARGET=$(ANDROID_ARCH) CPU=$(CPU) ABIDIR=$(ABIDIR) ANDROID_COMPILER=$(ANDROID_ARCH)$(ANDROID_TARGET)-clang
|
||||
liblogosdelivery-android-x86: ANDROID_ARCH=i686-linux-android
|
||||
liblogosdelivery-android-x86: CPU=i386
|
||||
liblogosdelivery-android-x86: ABIDIR=x86
|
||||
liblogosdelivery-android-x86: | liblogosdelivery-android-precheck build deps
|
||||
$(MAKE) build-liblogosdelivery-for-android-arch ANDROID_ARCH=$(ANDROID_ARCH) CROSS_TARGET=$(ANDROID_ARCH) CPU=$(CPU) ABIDIR=$(ABIDIR) ANDROID_COMPILER=$(ANDROID_ARCH)$(ANDROID_TARGET)-clang
|
||||
|
||||
libwaku-android-arm: ANDROID_ARCH=armv7a-linux-androideabi
|
||||
libwaku-android-arm: CPU=arm
|
||||
libwaku-android-arm: ABIDIR=armeabi-v7a
|
||||
libwaku-android-arm: | libwaku-android-precheck build deps
|
||||
$(MAKE) build-libwaku-for-android-arch ANDROID_ARCH=$(ANDROID_ARCH) CROSS_TARGET=armv7-linux-androideabi CPU=$(CPU) ABIDIR=$(ABIDIR) ANDROID_COMPILER=$(ANDROID_ARCH)$(ANDROID_TARGET)-clang
|
||||
liblogosdelivery-android-arm: ANDROID_ARCH=armv7a-linux-androideabi
|
||||
liblogosdelivery-android-arm: CPU=arm
|
||||
liblogosdelivery-android-arm: ABIDIR=armeabi-v7a
|
||||
liblogosdelivery-android-arm: | liblogosdelivery-android-precheck build deps
|
||||
$(MAKE) build-liblogosdelivery-for-android-arch ANDROID_ARCH=$(ANDROID_ARCH) CROSS_TARGET=armv7-linux-androideabi CPU=$(CPU) ABIDIR=$(ABIDIR) ANDROID_COMPILER=$(ANDROID_ARCH)$(ANDROID_TARGET)-clang
|
||||
|
||||
libwaku-android:
|
||||
$(MAKE) libwaku-android-amd64
|
||||
$(MAKE) libwaku-android-arm64
|
||||
$(MAKE) libwaku-android-x86
|
||||
liblogosdelivery-android:
|
||||
$(MAKE) liblogosdelivery-android-amd64
|
||||
$(MAKE) liblogosdelivery-android-arm64
|
||||
$(MAKE) liblogosdelivery-android-x86
|
||||
|
||||
#################
|
||||
## iOS Bindings #
|
||||
#################
|
||||
.PHONY: libwaku-ios-precheck \
|
||||
libwaku-ios-device \
|
||||
libwaku-ios-simulator \
|
||||
libwaku-ios
|
||||
.PHONY: liblogosdelivery-ios-precheck \
|
||||
liblogosdelivery-ios-device \
|
||||
liblogosdelivery-ios-simulator \
|
||||
liblogosdelivery-ios
|
||||
|
||||
IOS_DEPLOYMENT_TARGET ?= 18.0
|
||||
|
||||
@ -574,31 +573,31 @@ define get_ios_sdk_path
|
||||
$(shell xcrun --sdk $(1) --show-sdk-path 2>/dev/null)
|
||||
endef
|
||||
|
||||
libwaku-ios-precheck:
|
||||
liblogosdelivery-ios-precheck:
|
||||
ifeq ($(detected_OS),Darwin)
|
||||
@command -v xcrun >/dev/null 2>&1 || { echo "Error: Xcode command line tools not installed"; exit 1; }
|
||||
else
|
||||
$(error iOS builds are only supported on macOS)
|
||||
endif
|
||||
|
||||
build-libwaku-for-ios-arch:
|
||||
IOS_SDK=$(IOS_SDK) IOS_ARCH=$(IOS_ARCH) IOS_SDK_PATH=$(IOS_SDK_PATH) $(NIMBLE) libWakuIOS
|
||||
build-liblogosdelivery-for-ios-arch:
|
||||
IOS_SDK=$(IOS_SDK) IOS_ARCH=$(IOS_ARCH) IOS_SDK_PATH=$(IOS_SDK_PATH) $(NIMBLE) libLogosDeliveryIOS
|
||||
|
||||
libwaku-ios-device: IOS_ARCH=arm64
|
||||
libwaku-ios-device: IOS_SDK=iphoneos
|
||||
libwaku-ios-device: IOS_SDK_PATH=$(call get_ios_sdk_path,iphoneos)
|
||||
libwaku-ios-device: | libwaku-ios-precheck build deps
|
||||
$(MAKE) build-libwaku-for-ios-arch IOS_ARCH=$(IOS_ARCH) IOS_SDK=$(IOS_SDK) IOS_SDK_PATH=$(IOS_SDK_PATH)
|
||||
liblogosdelivery-ios-device: IOS_ARCH=arm64
|
||||
liblogosdelivery-ios-device: IOS_SDK=iphoneos
|
||||
liblogosdelivery-ios-device: IOS_SDK_PATH=$(call get_ios_sdk_path,iphoneos)
|
||||
liblogosdelivery-ios-device: | liblogosdelivery-ios-precheck build deps
|
||||
$(MAKE) build-liblogosdelivery-for-ios-arch IOS_ARCH=$(IOS_ARCH) IOS_SDK=$(IOS_SDK) IOS_SDK_PATH=$(IOS_SDK_PATH)
|
||||
|
||||
libwaku-ios-simulator: IOS_ARCH=arm64
|
||||
libwaku-ios-simulator: IOS_SDK=iphonesimulator
|
||||
libwaku-ios-simulator: IOS_SDK_PATH=$(call get_ios_sdk_path,iphonesimulator)
|
||||
libwaku-ios-simulator: | libwaku-ios-precheck build deps
|
||||
$(MAKE) build-libwaku-for-ios-arch IOS_ARCH=$(IOS_ARCH) IOS_SDK=$(IOS_SDK) IOS_SDK_PATH=$(IOS_SDK_PATH)
|
||||
liblogosdelivery-ios-simulator: IOS_ARCH=arm64
|
||||
liblogosdelivery-ios-simulator: IOS_SDK=iphonesimulator
|
||||
liblogosdelivery-ios-simulator: IOS_SDK_PATH=$(call get_ios_sdk_path,iphonesimulator)
|
||||
liblogosdelivery-ios-simulator: | liblogosdelivery-ios-precheck build deps
|
||||
$(MAKE) build-liblogosdelivery-for-ios-arch IOS_ARCH=$(IOS_ARCH) IOS_SDK=$(IOS_SDK) IOS_SDK_PATH=$(IOS_SDK_PATH)
|
||||
|
||||
libwaku-ios:
|
||||
$(MAKE) libwaku-ios-device
|
||||
$(MAKE) libwaku-ios-simulator
|
||||
liblogosdelivery-ios:
|
||||
$(MAKE) liblogosdelivery-ios-device
|
||||
$(MAKE) liblogosdelivery-ios-simulator
|
||||
|
||||
###################
|
||||
# Release Targets #
|
||||
|
||||
@ -6,7 +6,7 @@ This is a very simple example that shows how to invoke libwaku functions from a
|
||||
2. cd to nwaku root folder
|
||||
3. make cwaku_example -j8
|
||||
|
||||
This will create libwaku.so and cwaku_example binary within the build folder.
|
||||
This will create liblogosdelivery.so and cwaku_example binary within the build folder.
|
||||
|
||||
## Run
|
||||
1. Open terminal
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#include "base64.h"
|
||||
#include "../../library/libwaku.h"
|
||||
#include "../../library/liblogosdelivery_kernel.h"
|
||||
|
||||
// Shared synchronization variables
|
||||
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
@ -357,7 +357,7 @@ int main(int argc, char **argv)
|
||||
printf("Bind addr: %s:%u\n", cfgNode.host, cfgNode.port);
|
||||
printf("Waku Relay enabled: %s\n", cfgNode.relay == 1 ? "YES" : "NO");
|
||||
|
||||
set_event_callback(ctx, on_event_received, userData);
|
||||
logosdelivery_set_event_callback(ctx, on_event_received, userData);
|
||||
|
||||
waku_start(ctx, event_handler, userData);
|
||||
waitForCallback();
|
||||
|
||||
@ -6,7 +6,7 @@ This is a very simple example that shows how to invoke libwaku functions from a
|
||||
2. cd to nwaku root folder
|
||||
3. make cppwaku_example -j8
|
||||
|
||||
This will create libwaku.so and cppwaku_example binary within the build folder.
|
||||
This will create liblogosdelivery.so and cppwaku_example binary within the build folder.
|
||||
|
||||
## Run
|
||||
1. Open terminal
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
#include <sys/syscall.h>
|
||||
|
||||
#include "base64.h"
|
||||
#include "../../library/libwaku.h"
|
||||
#include "../../library/liblogosdelivery_kernel.h"
|
||||
|
||||
// Shared synchronization variables
|
||||
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
@ -312,7 +312,7 @@ int main(int argc, char **argv)
|
||||
|
||||
std::cout << "Custom pubsub topic: " << pubsubTopic << std::endl;
|
||||
|
||||
set_event_callback(ctx,
|
||||
logosdelivery_set_event_callback(ctx,
|
||||
cify([&](const char *msg, size_t len)
|
||||
{ event_handler(msg, len); }),
|
||||
nullptr);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
## Pre-requisite
|
||||
libwaku.so is needed to be compiled and present in build folder. To create it:
|
||||
liblogosdelivery.so is needed to be compiled and present in build folder. To create it:
|
||||
|
||||
- Run only the first time and after changing the current commit
|
||||
```code
|
||||
@ -8,7 +8,7 @@ make update
|
||||
```
|
||||
- Run the next every time you want to compile libwaku
|
||||
```code
|
||||
make POSTGRES=1 libwaku -j4
|
||||
make POSTGRES=1 liblogosdelivery -j4
|
||||
```
|
||||
|
||||
Also needed:
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
package main
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L../../build/ -lwaku
|
||||
#cgo LDFLAGS: -L../../build/ -llogosdelivery
|
||||
#cgo LDFLAGS: -L../../ -Wl,-rpath,../../
|
||||
|
||||
#include "../../library/libwaku.h"
|
||||
#include "../../library/liblogosdelivery_kernel.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -112,7 +112,7 @@ package main
|
||||
|
||||
// This technique is needed because cgo only allows to export Go functions and not methods.
|
||||
|
||||
set_event_callback(wakuCtx, (FFICallBack) globalEventCallback, wakuCtx);
|
||||
logosdelivery_set_event_callback(wakuCtx, (FFICallBack) globalEventCallback, wakuCtx);
|
||||
}
|
||||
|
||||
static void cGoWakuContentTopic(void* wakuCtx,
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
0671AF6DCB0D788B0C1E9C8B /* WakuExampleApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WakuExampleApp.swift; sourceTree = "<group>"; };
|
||||
31BE20DB2755A11000723420 /* libwaku.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = libwaku.h; sourceTree = "<group>"; };
|
||||
31BE20DB2755A11000723420 /* liblogosdelivery.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = liblogosdelivery.h; sourceTree = "<group>"; };
|
||||
5C5AAC91E0166D28BFA986DB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
|
||||
638A565C495A63CFF7396FBC /* WakuNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WakuNode.swift; sourceTree = "<group>"; };
|
||||
7D8744E36DADC11F38A1CC99 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
|
||||
@ -36,7 +36,7 @@
|
||||
children = (
|
||||
7D8744E36DADC11F38A1CC99 /* ContentView.swift */,
|
||||
5C5AAC91E0166D28BFA986DB /* Info.plist */,
|
||||
31BE20DB2755A11000723420 /* libwaku.h */,
|
||||
31BE20DB2755A11000723420 /* liblogosdelivery.h */,
|
||||
A8655016B3DF9B0877631CE5 /* WakuExample-Bridging-Header.h */,
|
||||
0671AF6DCB0D788B0C1E9C8B /* WakuExampleApp.swift */,
|
||||
638A565C495A63CFF7396FBC /* WakuNode.swift */,
|
||||
@ -132,7 +132,7 @@
|
||||
OTHER_LDFLAGS = (
|
||||
"-lc++",
|
||||
"-force_load",
|
||||
"$(PROJECT_DIR)/../../build/ios/iphoneos-arm64/libwaku.a",
|
||||
"$(PROJECT_DIR)/../../build/ios/iphoneos-arm64/liblogosdelivery.a",
|
||||
"-lsqlite3",
|
||||
"-lz",
|
||||
);
|
||||
@ -289,7 +289,7 @@
|
||||
OTHER_LDFLAGS = (
|
||||
"-lc++",
|
||||
"-force_load",
|
||||
"$(PROJECT_DIR)/../../build/ios/iphoneos-arm64/libwaku.a",
|
||||
"$(PROJECT_DIR)/../../build/ios/iphoneos-arm64/liblogosdelivery.a",
|
||||
"-lsqlite3",
|
||||
"-lz",
|
||||
);
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
#ifndef WakuExample_Bridging_Header_h
|
||||
#define WakuExample_Bridging_Header_h
|
||||
|
||||
#import "libwaku.h"
|
||||
#import "liblogosdelivery_kernel.h"
|
||||
|
||||
#endif /* WakuExample_Bridging_Header_h */
|
||||
|
||||
|
||||
@ -350,7 +350,7 @@ actor WakuActor {
|
||||
ctx = createResult.ctx
|
||||
|
||||
// Set event callback
|
||||
waku_set_event_callback(ctx, WakuActor.eventCallback, nil)
|
||||
logosdelivery_set_event_callback(ctx, WakuActor.eventCallback, nil)
|
||||
|
||||
// Start node
|
||||
let startResult = await callWakuSync { userData in
|
||||
|
||||
1
examples/ios/WakuExample/liblogosdelivery.h
Symbolic link
1
examples/ios/WakuExample/liblogosdelivery.h
Symbolic link
@ -0,0 +1 @@
|
||||
../../../library/liblogosdelivery.h
|
||||
1
examples/ios/WakuExample/liblogosdelivery_kernel.h
Symbolic link
1
examples/ios/WakuExample/liblogosdelivery_kernel.h
Symbolic link
@ -0,0 +1 @@
|
||||
../../../library/liblogosdelivery_kernel.h
|
||||
@ -1,253 +0,0 @@
|
||||
|
||||
// Generated manually and inspired by the one generated by the Nim Compiler.
|
||||
// In order to see the header file generated by Nim just run `make libwaku`
|
||||
// from the root repo folder and the header should be created in
|
||||
// nimcache/release/libwaku/libwaku.h
|
||||
#ifndef __libwaku__
|
||||
#define __libwaku__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// The possible returned values for the functions that return int
|
||||
#define RET_OK 0
|
||||
#define RET_ERR 1
|
||||
#define RET_MISSING_CALLBACK 2
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*WakuCallBack) (int callerRet, const char* msg, size_t len, void* userData);
|
||||
|
||||
// Creates a new instance of the waku node.
|
||||
// Sets up the waku node from the given configuration.
|
||||
// Returns a pointer to the Context needed by the rest of the API functions.
|
||||
void* waku_new(
|
||||
const char* configJson,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_start(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_stop(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
// Destroys an instance of a waku node created with waku_new
|
||||
int waku_destroy(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_version(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
// Sets a callback that will be invoked whenever an event occurs.
|
||||
// It is crucial that the passed callback is fast, non-blocking and potentially thread-safe.
|
||||
void waku_set_event_callback(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_content_topic(void* ctx,
|
||||
const char* appName,
|
||||
unsigned int appVersion,
|
||||
const char* contentTopicName,
|
||||
const char* encoding,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_pubsub_topic(void* ctx,
|
||||
const char* topicName,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_default_pubsub_topic(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_relay_publish(void* ctx,
|
||||
const char* pubSubTopic,
|
||||
const char* jsonWakuMessage,
|
||||
unsigned int timeoutMs,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_lightpush_publish(void* ctx,
|
||||
const char* pubSubTopic,
|
||||
const char* jsonWakuMessage,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_relay_subscribe(void* ctx,
|
||||
const char* pubSubTopic,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_relay_add_protected_shard(void* ctx,
|
||||
int clusterId,
|
||||
int shardId,
|
||||
char* publicKey,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_relay_unsubscribe(void* ctx,
|
||||
const char* pubSubTopic,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_filter_subscribe(void* ctx,
|
||||
const char* pubSubTopic,
|
||||
const char* contentTopics,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_filter_unsubscribe(void* ctx,
|
||||
const char* pubSubTopic,
|
||||
const char* contentTopics,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_filter_unsubscribe_all(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_relay_get_num_connected_peers(void* ctx,
|
||||
const char* pubSubTopic,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_relay_get_connected_peers(void* ctx,
|
||||
const char* pubSubTopic,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_relay_get_num_peers_in_mesh(void* ctx,
|
||||
const char* pubSubTopic,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_relay_get_peers_in_mesh(void* ctx,
|
||||
const char* pubSubTopic,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_store_query(void* ctx,
|
||||
const char* jsonQuery,
|
||||
const char* peerAddr,
|
||||
int timeoutMs,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_connect(void* ctx,
|
||||
const char* peerMultiAddr,
|
||||
unsigned int timeoutMs,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_disconnect_peer_by_id(void* ctx,
|
||||
const char* peerId,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_disconnect_all_peers(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_dial_peer(void* ctx,
|
||||
const char* peerMultiAddr,
|
||||
const char* protocol,
|
||||
int timeoutMs,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_dial_peer_by_id(void* ctx,
|
||||
const char* peerId,
|
||||
const char* protocol,
|
||||
int timeoutMs,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_get_peerids_from_peerstore(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_get_connected_peers_info(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_get_peerids_by_protocol(void* ctx,
|
||||
const char* protocol,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_listen_addresses(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_get_connected_peers(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
// Returns a list of multiaddress given a url to a DNS discoverable ENR tree
|
||||
// Parameters
|
||||
// char* entTreeUrl: URL containing a discoverable ENR tree
|
||||
// char* nameDnsServer: The nameserver to resolve the ENR tree url.
|
||||
// int timeoutMs: Timeout value in milliseconds to execute the call.
|
||||
int waku_dns_discovery(void* ctx,
|
||||
const char* entTreeUrl,
|
||||
const char* nameDnsServer,
|
||||
int timeoutMs,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
// Updates the bootnode list used for discovering new peers via DiscoveryV5
|
||||
// bootnodes - JSON array containing the bootnode ENRs i.e. `["enr:...", "enr:..."]`
|
||||
int waku_discv5_update_bootnodes(void* ctx,
|
||||
char* bootnodes,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_start_discv5(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_stop_discv5(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
// Retrieves the ENR information
|
||||
int waku_get_my_enr(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_get_my_peerid(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_get_metrics(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_peer_exchange_request(void* ctx,
|
||||
int numPeers,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_ping_peer(void* ctx,
|
||||
const char* peerAddr,
|
||||
int timeoutMs,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
int waku_is_online(void* ctx,
|
||||
WakuCallBack callback,
|
||||
void* userData);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __libwaku__ */
|
||||
@ -29,7 +29,7 @@ targets:
|
||||
- "$(PROJECT_DIR)/../../build/ios/iphonesimulator-arm64"
|
||||
OTHER_LDFLAGS:
|
||||
- "-lc++"
|
||||
- "-lwaku"
|
||||
- "-llogosdelivery"
|
||||
IPHONEOS_DEPLOYMENT_TARGET: "14.0"
|
||||
info:
|
||||
path: WakuExample/Info.plist
|
||||
|
||||
@ -1 +1,2 @@
|
||||
libwaku.h
|
||||
liblogosdelivery.h
|
||||
liblogosdelivery_kernel.h
|
||||
|
||||
@ -2,8 +2,8 @@ LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := waku
|
||||
LOCAL_SRC_FILES := ../jniLibs/$(TARGET_ARCH_ABI)/libwaku.so
|
||||
LOCAL_MODULE := logosdelivery
|
||||
LOCAL_SRC_FILES := ../jniLibs/$(TARGET_ARCH_ABI)/liblogosdelivery.so
|
||||
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
@ -12,6 +12,6 @@ include $(CLEAR_VARS)
|
||||
LOCAL_SRC_FILES := waku_ffi.c
|
||||
LOCAL_MODULE := waku_jni
|
||||
LOCAL_LDLIBS := -llog
|
||||
LOCAL_SHARED_LIBRARIES := waku
|
||||
LOCAL_SHARED_LIBRARIES := logosdelivery
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
@ -1,4 +1,4 @@
|
||||
#include "libwaku.h"
|
||||
#include "liblogosdelivery_kernel.h"
|
||||
#include <android/log.h>
|
||||
#include <jni.h>
|
||||
#include <stdbool.h>
|
||||
@ -321,5 +321,5 @@ void Java_com_mobile_WakuModule_wakuSetEventCallback(JNIEnv *env, jobject thiz,
|
||||
cb_env *c = (cb_env *)malloc(sizeof(cb_env));
|
||||
c->wakuPtr = wakuPtr;
|
||||
c->env = env;
|
||||
waku_set_event_callback((void *)wakuPtr, wk_callback, (void *)c);
|
||||
logosdelivery_set_event_callback((void *)wakuPtr, wk_callback, (void *)c);
|
||||
}
|
||||
|
||||
@ -6,17 +6,21 @@ const args = process.argv.slice(2);
|
||||
const forceFlagIndex = args.indexOf('--force');
|
||||
|
||||
const nwakuRootFolder = '../../';
|
||||
const libwakuHeaderSrc = 'library/libwaku.h';
|
||||
// Stable messaging header + the advanced kernel header it includes. Both must
|
||||
// be copied so the kernel header's `#include "liblogosdelivery.h"` resolves.
|
||||
const headers = [
|
||||
{src: 'library/liblogosdelivery.h', dst: 'android/app/src/main/jni/liblogosdelivery.h'},
|
||||
{src: 'library/liblogosdelivery_kernel.h', dst: 'android/app/src/main/jni/liblogosdelivery_kernel.h'},
|
||||
];
|
||||
|
||||
// Android --------------------------------------------------------------------------------------
|
||||
|
||||
const androidArchitectures = ['arm64-v8a', 'x86', 'x86_64']; // 'armeabi-v7a'
|
||||
const androidSrcFolder = 'build/android';
|
||||
const androidDstFolder = 'android/app/src/main/jniLibs';
|
||||
const androidFilesToCheck = ['libwaku.so', 'librln.so'];
|
||||
const androidLibDst = 'android/app/src/main/jni/libwaku.h';
|
||||
const androidFilesToCheck = ['liblogosdelivery.so', 'librln.so'];
|
||||
|
||||
const androidDstFiles = [androidLibDst];
|
||||
const androidDstFiles = headers.map(h => h.dst);
|
||||
androidArchitectures.forEach(architecture => {
|
||||
androidFilesToCheck.forEach(file => {
|
||||
androidDstFiles.push(`${androidDstFolder}/${architecture}/${file}`);
|
||||
@ -28,7 +32,7 @@ const filesExist = androidDstFiles.every(file => fs.existsSync(file));
|
||||
if (!filesExist || forceFlagIndex !== -1) {
|
||||
console.log('Running make to generate all architecture libraries...');
|
||||
const makeCommand = 'make';
|
||||
const makeProcess = spawn(makeCommand, ['libwaku-android'], {cwd: '../../'});
|
||||
const makeProcess = spawn(makeCommand, ['liblogosdelivery-android'], {cwd: '../../'});
|
||||
|
||||
makeProcess.stdout.on('data', data => process.stdout.write(data));
|
||||
makeProcess.stderr.on('data', data => process.stdout.write(data));
|
||||
@ -47,14 +51,16 @@ if (!filesExist || forceFlagIndex !== -1) {
|
||||
);
|
||||
});
|
||||
});
|
||||
console.log('Copying header...');
|
||||
fs.copyFile(
|
||||
`${nwakuRootFolder}/${libwakuHeaderSrc}`,
|
||||
androidLibDst,
|
||||
err => {
|
||||
if (err) throw err;
|
||||
},
|
||||
);
|
||||
console.log('Copying headers...');
|
||||
headers.forEach(header => {
|
||||
fs.copyFile(
|
||||
`${nwakuRootFolder}/${header.src}`,
|
||||
header.dst,
|
||||
err => {
|
||||
if (err) throw err;
|
||||
},
|
||||
);
|
||||
});
|
||||
} else {
|
||||
console.error(`make exited with ${code}`);
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
{
|
||||
"target_name": "waku",
|
||||
"sources": [ "waku_addon.c", "../cbindings/base64.c" ],
|
||||
"libraries": [ "-lwaku", "-L../../../build/" ]
|
||||
"libraries": [ "-llogosdelivery", "-L../../../build/" ]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "../cbindings/base64.h"
|
||||
#include "../../library/libwaku.h"
|
||||
#include "../../library/liblogosdelivery_kernel.h"
|
||||
|
||||
// Reference to the NodeJs function to be called when a waku event occurs.
|
||||
// static napi_ref ref_event_callback = NULL;
|
||||
@ -284,7 +284,7 @@ static napi_value WakuSetEventCallback(napi_env env, napi_callback_info info) {
|
||||
|
||||
// Inside 'event_handler', the event will be dispatched to the NodeJs
|
||||
// if there is a proper napi_function (ref_event_callback) being set.
|
||||
waku_set_event_callback(event_handler, userData);
|
||||
logosdelivery_set_event_callback(event_handler, userData);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -9,7 +9,7 @@ elif sys.platform == "win32":
|
||||
else:
|
||||
_lib_ext = "so"
|
||||
|
||||
_lib_path = f"build/libwaku.{_lib_ext}"
|
||||
_lib_path = f"build/liblogosdelivery.{_lib_ext}"
|
||||
|
||||
libwaku = object
|
||||
try:
|
||||
@ -19,7 +19,7 @@ except OSError as e:
|
||||
print(f"Exception: {e}")
|
||||
print(f"""
|
||||
The '{_lib_path}' library can be created with the next command from
|
||||
the repo's root folder: `make libwaku`.
|
||||
the repo's root folder: `make liblogosdelivery`.
|
||||
|
||||
And it should build the library in '{_lib_path}'.
|
||||
|
||||
@ -111,8 +111,8 @@ print("Waku Relay enabled: {}".format(args.relay))
|
||||
# Set the event callback
|
||||
callback = callback_type(handle_event) # This line is important so that the callback is not gc'ed
|
||||
|
||||
libwaku.set_event_callback.argtypes = [callback_type, ctypes.c_void_p]
|
||||
libwaku.set_event_callback(callback, ctypes.c_void_p(0))
|
||||
libwaku.logosdelivery_set_event_callback.argtypes = [callback_type, ctypes.c_void_p]
|
||||
libwaku.logosdelivery_set_event_callback(callback, ctypes.c_void_p(0))
|
||||
|
||||
# Start the node
|
||||
libwaku.waku_start.argtypes = [ctypes.c_void_p,
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
|
||||
CXX = g++
|
||||
CXXFLAGS = -g3 -fpermissive -fPIC `pkg-config --cflags Qt5Core Qt5Gui Qt5Qml Qt5Quick`
|
||||
LDFLAGS = `pkg-config --libs Qt5Core Qt5Gui Qt5Qml Qt5Quick` -lwaku -L../../build/
|
||||
LDFLAGS = `pkg-config --libs Qt5Core Qt5Gui Qt5Qml Qt5Quick` -llogosdelivery -L../../build/
|
||||
MOC = moc
|
||||
|
||||
TARGET = main-qt
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
|
||||
#include "../../library/libwaku.h"
|
||||
#include "../../library/liblogosdelivery_kernel.h"
|
||||
|
||||
class WakuHandler : public QObject {
|
||||
Q_OBJECT
|
||||
@ -27,7 +27,7 @@ public:
|
||||
void initialize(const QString& jsonConfig, WakuCallBack event_handler, void* userData) {
|
||||
ctx = waku_new(jsonConfig.toUtf8().constData(), WakuCallBack(event_handler), userData);
|
||||
|
||||
set_event_callback(ctx, on_event_received, userData);
|
||||
logosdelivery_set_event_callback(ctx, on_event_received, userData);
|
||||
qDebug() << "Waku context initialized, ready to start.";
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rustc-link-arg=-lwaku");
|
||||
println!("cargo:rustc-link-arg=-llogosdelivery");
|
||||
println!("cargo:rustc-link-arg=-L../../build/");
|
||||
}
|
||||
|
||||
@ -1,78 +0,0 @@
|
||||
import ffi
|
||||
import std/locks
|
||||
import logos_delivery/waku/factory/waku
|
||||
import logos_delivery/waku/waku_mix/logos_core_client as mix_rln_client
|
||||
|
||||
declareLibrary("logosdelivery")
|
||||
|
||||
var eventCallbackLock: Lock
|
||||
initLock(eventCallbackLock)
|
||||
|
||||
template requireInitializedNode*(
|
||||
ctx: ptr FFIContext[Waku], opName: string, onError: untyped
|
||||
) =
|
||||
if isNil(ctx):
|
||||
let errMsg {.inject.} = opName & " failed: invalid context"
|
||||
onError
|
||||
elif isNil(ctx.myLib) or isNil(ctx.myLib[]):
|
||||
let errMsg {.inject.} = opName & " failed: node is not initialized"
|
||||
onError
|
||||
|
||||
proc logosdelivery_set_event_callback(
|
||||
ctx: ptr FFIContext[Waku], callback: FFICallBack, userData: pointer
|
||||
) {.dynlib, exportc, cdecl.} =
|
||||
if isNil(ctx):
|
||||
echo "error: invalid context in logosdelivery_set_event_callback"
|
||||
return
|
||||
|
||||
# prevent race conditions that might happen due incorrect usage.
|
||||
eventCallbackLock.acquire()
|
||||
defer:
|
||||
eventCallbackLock.release()
|
||||
|
||||
ctx[].eventCallback = cast[pointer](callback)
|
||||
ctx[].eventUserData = userData
|
||||
|
||||
proc logosdelivery_init(): cint {.dynlib, exportc, cdecl.} =
|
||||
initializeLibrary()
|
||||
# Default log level is configured at compile time via chronicles_log_level;
|
||||
# the runtime setLogLevel resolution conflicts with std/termios's two-arg
|
||||
# template under ff8d518 — leave the compile-time default in effect.
|
||||
return RET_OK
|
||||
|
||||
proc logosdelivery_set_rln_fetcher(
|
||||
ctx: ptr FFIContext[Waku], fetcher: mix_rln_client.RlnFetcherFunc, fetcherData: pointer
|
||||
) {.dynlib, exportc, cdecl.} =
|
||||
if fetcher.isNil:
|
||||
echo "error: nil fetcher in logosdelivery_set_rln_fetcher"
|
||||
return
|
||||
mix_rln_client.setRlnFetcher(fetcher, fetcherData)
|
||||
|
||||
proc logosdelivery_set_rln_config(
|
||||
ctx: ptr FFIContext[Waku], configAccountId: cstring, leafIndex: cint
|
||||
): cint {.dynlib, exportc, cdecl.} =
|
||||
if configAccountId.isNil:
|
||||
return RET_ERR
|
||||
mix_rln_client.setRlnConfig($configAccountId, leafIndex.int)
|
||||
return RET_OK
|
||||
|
||||
proc logosdelivery_set_rln_identity(
|
||||
ctx: ptr FFIContext[Waku], idSecretHashHex: cstring
|
||||
) {.dynlib, exportc, cdecl.} =
|
||||
if idSecretHashHex.isNil:
|
||||
return
|
||||
mix_rln_client.setRlnIdentity($idSecretHashHex)
|
||||
|
||||
proc logosdelivery_push_roots(
|
||||
ctx: ptr FFIContext[Waku], rootsJson: cstring
|
||||
) {.dynlib, exportc, cdecl.} =
|
||||
if rootsJson.isNil:
|
||||
return
|
||||
mix_rln_client.pushRoots($rootsJson)
|
||||
|
||||
proc logosdelivery_push_proof(
|
||||
ctx: ptr FFIContext[Waku], proofJson: cstring
|
||||
) {.dynlib, exportc, cdecl.} =
|
||||
if proofJson.isNil:
|
||||
return
|
||||
mix_rln_client.pushProof($proofJson)
|
||||
@ -1,12 +0,0 @@
|
||||
import std/[atomics, options]
|
||||
import chronicles, chronos, chronos/threadsync, ffi
|
||||
import
|
||||
logos_delivery/waku/factory/waku, logos_delivery/waku/node/waku_node, ./declare_lib
|
||||
|
||||
################################################################################
|
||||
## Include different APIs, i.e. all procs with {.ffi.} pragma
|
||||
|
||||
include
|
||||
./logos_delivery_api/node_api,
|
||||
./logos_delivery_api/messaging_api,
|
||||
./logos_delivery_api/debug_api
|
||||
@ -1,29 +0,0 @@
|
||||
# Nim configuration for liblogosdelivery
|
||||
|
||||
# Ensure correct compiler configuration
|
||||
--gc:
|
||||
refc
|
||||
--threads:
|
||||
on
|
||||
|
||||
# Include paths
|
||||
--path:
|
||||
"../vendor/nim-ffi"
|
||||
--path:
|
||||
"../"
|
||||
--path:
|
||||
"../vendor/mix-rln-spam-protection-plugin/src"
|
||||
|
||||
# Optimization and debugging
|
||||
--opt:
|
||||
speed
|
||||
--debugger:
|
||||
native
|
||||
|
||||
# Export symbols for dynamic library
|
||||
--app:
|
||||
lib
|
||||
--noMain
|
||||
|
||||
# Enable FFI macro features when needed for debugging
|
||||
# --define:ffiDumpMacros
|
||||
@ -63,8 +63,12 @@ build/
|
||||
|
||||
## Library Headers
|
||||
|
||||
The main header file is:
|
||||
- `liblogosdelivery/liblogosdelivery.h` - C API declarations
|
||||
The C API is tiered across two headers (one library, two stability promises):
|
||||
- `library/liblogosdelivery.h` - stable, supported Messaging / Reliable
|
||||
Channels API. This is the front door for consumers.
|
||||
- `library/liblogosdelivery_kernel.h` - advanced, low-level kernel API
|
||||
(`waku_*`). "Use at your own risk", may change at any time. Including it is
|
||||
a deliberate opt-in; it pulls in `liblogosdelivery.h` for shared types.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
@ -119,5 +123,5 @@ your_program: your_program.c
|
||||
## API Documentation
|
||||
|
||||
See:
|
||||
- [liblogosdelivery.h](liblogosdelivery/liblogosdelivery.h) - API function declarations
|
||||
- [MESSAGE_EVENTS.md](liblogosdelivery/MESSAGE_EVENTS.md) - Message event handling guide
|
||||
- [liblogosdelivery.h](library/liblogosdelivery.h) - API function declarations
|
||||
- [MESSAGE_EVENTS.md](library/MESSAGE_EVENTS.md) - Message event handling guide
|
||||
@ -1,10 +1,33 @@
|
||||
import ffi
|
||||
import std/locks
|
||||
import logos_delivery/waku/factory/waku
|
||||
|
||||
declareLibrary("waku")
|
||||
declareLibrary("logosdelivery")
|
||||
|
||||
proc set_event_callback(
|
||||
var eventCallbackLock: Lock
|
||||
initLock(eventCallbackLock)
|
||||
|
||||
template requireInitializedNode*(
|
||||
ctx: ptr FFIContext[Waku], opName: string, onError: untyped
|
||||
) =
|
||||
if isNil(ctx):
|
||||
let errMsg {.inject.} = opName & " failed: invalid context"
|
||||
onError
|
||||
elif isNil(ctx.myLib) or isNil(ctx.myLib[]):
|
||||
let errMsg {.inject.} = opName & " failed: node is not initialized"
|
||||
onError
|
||||
|
||||
proc logosdelivery_set_event_callback(
|
||||
ctx: ptr FFIContext[Waku], callback: FFICallBack, userData: pointer
|
||||
) {.dynlib, exportc, cdecl.} =
|
||||
if isNil(ctx):
|
||||
echo "error: invalid context in logosdelivery_set_event_callback"
|
||||
return
|
||||
|
||||
# prevent race conditions that might happen due incorrect usage.
|
||||
eventCallbackLock.acquire()
|
||||
defer:
|
||||
eventCallbackLock.release()
|
||||
|
||||
ctx[].eventCallback = cast[pointer](callback)
|
||||
ctx[].eventUserData = userData
|
||||
|
||||
@ -58,12 +58,12 @@ proc createWaku(
|
||||
|
||||
return ok(wakuRes)
|
||||
|
||||
registerReqFFI(CreateNodeRequest, ctx: ptr FFIContext[Waku]):
|
||||
registerReqFFI(CreateNodeWithCallbacksRequest, ctx: ptr FFIContext[Waku]):
|
||||
proc(
|
||||
configJson: cstring, appCallbacks: AppCallbacks
|
||||
): Future[Result[string, string]] {.async.} =
|
||||
ctx.myLib[] = (await createWaku(configJson, cast[AppCallbacks](appCallbacks))).valueOr:
|
||||
error "CreateNodeRequest failed", error = error
|
||||
error "CreateNodeWithCallbacksRequest failed", error = error
|
||||
return err($error)
|
||||
|
||||
return ok("")
|
||||
|
||||
@ -4,7 +4,7 @@ import
|
||||
logos_delivery/waku/factory/waku,
|
||||
logos_delivery/waku/node/waku_node,
|
||||
logos_delivery/waku/node/peer_manager,
|
||||
../declare_lib
|
||||
library/declare_lib
|
||||
|
||||
type PeerInfo = object
|
||||
protocols: seq[string]
|
||||
|
||||
@ -105,6 +105,10 @@ extern "C"
|
||||
void logosdelivery_push_roots(void *ctx, const char *rootsJson);
|
||||
void logosdelivery_push_proof(void *ctx, const char *proofJson);
|
||||
|
||||
// NOTE: the low-level kernel API (waku_*) lives in the separate, advanced
|
||||
// header liblogosdelivery_kernel.h. It is intentionally not declared here so
|
||||
// this header only promises the stable Messaging / Reliable Channels surface.
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@ -1,22 +1,26 @@
|
||||
import std/[atomics, options, atomics, macros]
|
||||
import std/[atomics, options, macros]
|
||||
import chronicles, chronos, chronos/threadsync, ffi
|
||||
import
|
||||
logos_delivery/waku/waku_core/message/message,
|
||||
logos_delivery/waku/waku_core/topics/pubsub_topic,
|
||||
logos_delivery/waku/waku_relay,
|
||||
logos_delivery/waku/factory/waku,
|
||||
logos_delivery/waku/node/waku_node,
|
||||
logos_delivery/waku/node/health_monitor/health_status,
|
||||
../logos_delivery/waku/factory/app_callbacks,
|
||||
./events/json_message_event,
|
||||
./events/json_topic_health_change_event,
|
||||
./events/json_connection_change_event,
|
||||
./events/json_connection_status_change_event,
|
||||
../logos_delivery/waku/factory/app_callbacks,
|
||||
logos_delivery/waku/factory/waku,
|
||||
logos_delivery/waku/node/waku_node,
|
||||
logos_delivery/waku/node/health_monitor/health_status,
|
||||
./declare_lib
|
||||
|
||||
################################################################################
|
||||
## Include different APIs, i.e. all procs with {.ffi.} pragma
|
||||
|
||||
include
|
||||
./logos_delivery_api/node_api,
|
||||
./logos_delivery_api/messaging_api,
|
||||
./logos_delivery_api/debug_api,
|
||||
./kernel_api/peer_manager_api,
|
||||
./kernel_api/discovery_api,
|
||||
./kernel_api/node_lifecycle_api,
|
||||
@ -28,7 +32,7 @@ include
|
||||
./kernel_api/protocols/filter_api
|
||||
|
||||
################################################################################
|
||||
### Exported procs
|
||||
### Exported procs (former libwaku API)
|
||||
|
||||
proc waku_new(
|
||||
configJson: cstring, callback: FFICallback, userData: pointer
|
||||
@ -76,7 +80,10 @@ proc waku_new(
|
||||
)
|
||||
|
||||
ffi.sendRequestToFFIThread(
|
||||
ctx, CreateNodeRequest.ffiNewReq(callback, userData, configJson, appCallbacks)
|
||||
ctx,
|
||||
CreateNodeWithCallbacksRequest.ffiNewReq(
|
||||
callback, userData, configJson, appCallbacks
|
||||
),
|
||||
).isOkOr:
|
||||
let msg = "error in sendRequestToFFIThread: " & $error
|
||||
callback(RET_ERR, unsafeAddr msg[0], cast[csize_t](len(msg)), userData)
|
||||
@ -1,26 +1,31 @@
|
||||
|
||||
// Generated manually and inspired by the one generated by the Nim Compiler.
|
||||
// In order to see the header file generated by Nim just run `make libwaku`
|
||||
// from the root repo folder and the header should be created in
|
||||
// nimcache/release/libwaku/libwaku.h
|
||||
#ifndef __libwaku__
|
||||
#define __libwaku__
|
||||
// liblogosdelivery_kernel.h — Kernel / advanced API (low-level, per-protocol).
|
||||
//
|
||||
// ⚠️ USE AT YOUR OWN RISK — UNSUPPORTED, UNSTABLE SURFACE.
|
||||
//
|
||||
// These `waku_*` functions are the low-level kernel API. They are NOT part of
|
||||
// the stable, supported Messaging / Reliable Channels surface declared in
|
||||
// liblogosdelivery.h. They expose per-protocol internals (relay, filter,
|
||||
// lightpush, store, discovery, peer management) and may change or be removed
|
||||
// at ANY time, without notice or a deprecation cycle.
|
||||
//
|
||||
// Including this header is a deliberate opt-in into the advanced tier. If you
|
||||
// only need messaging, include liblogosdelivery.h and nothing here.
|
||||
//
|
||||
// See https://github.com/logos-messaging/logos-delivery/issues/3851 for the
|
||||
// tiering rationale.
|
||||
#pragma once
|
||||
#ifndef __liblogosdelivery_kernel__
|
||||
#define __liblogosdelivery_kernel__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
// The possible returned values for the functions that return int
|
||||
#define RET_OK 0
|
||||
#define RET_ERR 1
|
||||
#define RET_MISSING_CALLBACK 2
|
||||
// Shared FFICallBack typedef and RET_* return codes live in the stable header.
|
||||
#include "liblogosdelivery.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
typedef void (*FFICallBack)(int callerRet, const char *msg, size_t len, void *userData);
|
||||
|
||||
// Creates a new instance of the waku node.
|
||||
// Sets up the waku node from the given configuration.
|
||||
// Returns a pointer to the Context needed by the rest of the API functions.
|
||||
@ -46,11 +51,8 @@ extern "C"
|
||||
FFICallBack callback,
|
||||
void *userData);
|
||||
|
||||
// Sets a callback that will be invoked whenever an event occurs.
|
||||
// It is crucial that the passed callback is fast, non-blocking and potentially thread-safe.
|
||||
void set_event_callback(void *ctx,
|
||||
FFICallBack callback,
|
||||
void *userData);
|
||||
// NOTE: event callbacks are registered via logosdelivery_set_event_callback
|
||||
// (declared above) which the waku_* API shares.
|
||||
|
||||
int waku_content_topic(void *ctx,
|
||||
FFICallBack callback,
|
||||
@ -251,4 +253,4 @@ extern "C"
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __libwaku__ */
|
||||
#endif /* __liblogosdelivery_kernel__ */
|
||||
@ -1 +1,27 @@
|
||||
path = "../"
|
||||
# Nim configuration for liblogosdelivery
|
||||
|
||||
# Ensure correct compiler configuration
|
||||
--gc:
|
||||
refc
|
||||
--threads:
|
||||
on
|
||||
|
||||
# Include paths
|
||||
--path:
|
||||
"../vendor/nim-ffi"
|
||||
--path:
|
||||
"../"
|
||||
|
||||
# Optimization and debugging
|
||||
--opt:
|
||||
speed
|
||||
--debugger:
|
||||
native
|
||||
|
||||
# Export symbols for dynamic library
|
||||
--app:
|
||||
lib
|
||||
--noMain
|
||||
|
||||
# Enable FFI macro features when needed for debugging
|
||||
# --define:ffiDumpMacros
|
||||
|
||||
@ -117,7 +117,7 @@ proc buildBinary(name: string, srcDir = "./", params = "") =
|
||||
exec "nim c --out:build/" & name & " --mm:refc " & getMyCPU() & getNimParams() & " " & params & " " &
|
||||
srcDir & name & ".nim"
|
||||
|
||||
proc buildLibrary(lib_name: string, srcDir = "./", params = "", `type` = "static", srcFile = "libwaku.nim", mainPrefix = "libwaku") =
|
||||
proc buildLibrary(lib_name: string, srcDir = "./", params = "", `type` = "static", srcFile = "liblogosdelivery.nim", mainPrefix = "liblogosdelivery") =
|
||||
if not dirExists "build":
|
||||
mkDir "build"
|
||||
|
||||
@ -378,7 +378,7 @@ proc buildMobileIOS(srcDir = ".", params = "") =
|
||||
|
||||
echo "iOS library created: " & aFile
|
||||
|
||||
task libWakuIOS, "Build the mobile bindings for iOS":
|
||||
task libLogosDeliveryIOS, "Build the mobile bindings for iOS":
|
||||
let srcDir = "./library"
|
||||
let extraParams = "-d:chronicles_log_level=ERROR"
|
||||
buildMobileIOS srcDir, extraParams
|
||||
@ -495,45 +495,25 @@ let chroniclesParams =
|
||||
"""-d:chronicles_disabled_topics="eth,dnsdisc.client" """ & "--warning:Deprecated:off " &
|
||||
"--warning:UnusedImport:on " & "-d:chronicles_log_level=TRACE"
|
||||
|
||||
## Libwaku build tasks
|
||||
|
||||
task libwakuDynamicWindows, "Generate bindings":
|
||||
buildLibDynamicWindows("libwaku", "library")
|
||||
|
||||
task libwakuDynamicLinux, "Generate bindings":
|
||||
buildLibDynamicLinux("libwaku", "library")
|
||||
|
||||
task libwakuDynamicMac, "Generate bindings":
|
||||
buildLibDynamicMac("libwaku", "library")
|
||||
|
||||
task libwakuStaticWindows, "Generate bindings":
|
||||
buildLibStaticWindows("libwaku", "library")
|
||||
|
||||
task libwakuStaticLinux, "Generate bindings":
|
||||
buildLibStaticLinux("libwaku", "library")
|
||||
|
||||
task libwakuStaticMac, "Generate bindings":
|
||||
buildLibStaticMac("libwaku", "library")
|
||||
|
||||
## Liblogosdelivery build tasks
|
||||
|
||||
task liblogosdeliveryDynamicWindows, "Generate bindings":
|
||||
buildLibDynamicWindows("liblogosdelivery", "liblogosdelivery")
|
||||
buildLibDynamicWindows("liblogosdelivery", "library")
|
||||
|
||||
task liblogosdeliveryDynamicLinux, "Generate bindings":
|
||||
buildLibDynamicLinux("liblogosdelivery", "liblogosdelivery")
|
||||
buildLibDynamicLinux("liblogosdelivery", "library")
|
||||
|
||||
task liblogosdeliveryDynamicMac, "Generate bindings":
|
||||
buildLibDynamicMac("liblogosdelivery", "liblogosdelivery")
|
||||
buildLibDynamicMac("liblogosdelivery", "library")
|
||||
|
||||
task liblogosdeliveryStaticWindows, "Generate bindings":
|
||||
buildLibStaticWindows("liblogosdelivery", "liblogosdelivery")
|
||||
buildLibStaticWindows("liblogosdelivery", "library")
|
||||
|
||||
task liblogosdeliveryStaticLinux, "Generate bindings":
|
||||
buildLibStaticLinux("liblogosdelivery", "liblogosdelivery")
|
||||
buildLibStaticLinux("liblogosdelivery", "library")
|
||||
|
||||
task liblogosdeliveryStaticMac, "Generate bindings":
|
||||
buildLibStaticMac("liblogosdelivery", "liblogosdelivery")
|
||||
buildLibStaticMac("liblogosdelivery", "library")
|
||||
|
||||
### Formatting tasks
|
||||
|
||||
|
||||
@ -113,7 +113,7 @@ pkgs.stdenv.mkDerivation {
|
||||
echo "== Building liblogosdelivery (dynamic) =="
|
||||
${nimCompile {
|
||||
outFile = "build/liblogosdelivery.${libExt}";
|
||||
sourceFile = "liblogosdelivery/liblogosdelivery.nim";
|
||||
sourceFile = "library/liblogosdelivery.nim";
|
||||
extraArgs = [
|
||||
"--app:lib"
|
||||
"--opt:size"
|
||||
@ -126,7 +126,7 @@ pkgs.stdenv.mkDerivation {
|
||||
echo "== Building liblogosdelivery (static) =="
|
||||
${nimCompile {
|
||||
outFile = "build/liblogosdelivery.a";
|
||||
sourceFile = "liblogosdelivery/liblogosdelivery.nim";
|
||||
sourceFile = "library/liblogosdelivery.nim";
|
||||
extraArgs = [
|
||||
"--app:staticlib"
|
||||
"--opt:size"
|
||||
@ -147,7 +147,8 @@ pkgs.stdenv.mkDerivation {
|
||||
mkdir -p $out/lib $out/include
|
||||
cp build/liblogosdelivery.${libExt} $out/lib/ 2>/dev/null || true
|
||||
cp build/liblogosdelivery.a $out/lib/ 2>/dev/null || true
|
||||
cp liblogosdelivery/liblogosdelivery.h $out/include/ 2>/dev/null || true
|
||||
cp library/liblogosdelivery.h $out/include/ 2>/dev/null || true
|
||||
cp library/liblogosdelivery_kernel.h $out/include/ 2>/dev/null || true
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user