mirror of
https://github.com/logos-messaging/logos-delivery.git
synced 2026-08-06 20:03:11 +00:00
Rename liblmapi to liblogosdelivery
This commit is contained in:
parent
ec77e5dd3a
commit
5904538256
30
Makefile
30
Makefile
@ -433,11 +433,11 @@ docker-liteprotocoltester-push:
|
||||
################
|
||||
## C Bindings ##
|
||||
################
|
||||
.PHONY: cbindings cwaku_example libwaku liblmapi liblmapi_example
|
||||
.PHONY: cbindings cwaku_example libwaku liblmapi liblogosdelivery liblogosdelivery_example
|
||||
|
||||
STATIC ?= 0
|
||||
LIBWAKU_BUILD_COMMAND ?= libwakuDynamic
|
||||
LMAPI_BUILD_COMMAND ?= liblmapiDynamic
|
||||
LIBLOGOSDELIVERY_BUILD_COMMAND ?= liblogosdeliveryDynamic
|
||||
|
||||
ifeq ($(detected_OS),Windows)
|
||||
LIB_EXT_DYNAMIC = dll
|
||||
@ -454,37 +454,37 @@ LIB_EXT := $(LIB_EXT_DYNAMIC)
|
||||
ifeq ($(STATIC), 1)
|
||||
LIB_EXT = $(LIB_EXT_STATIC)
|
||||
LIBWAKU_BUILD_COMMAND = libwakuStatic
|
||||
LMAPI_BUILD_COMMAND = liblmapiStatic
|
||||
LIBLOGOSDELIVERY_BUILD_COMMAND = liblogosdeliveryStatic
|
||||
endif
|
||||
|
||||
libwaku: | build deps librln
|
||||
echo -e $(BUILD_MSG) "build/$@.$(LIB_EXT)" && $(ENV_SCRIPT) nim $(LIBWAKU_BUILD_COMMAND) $(NIM_PARAMS) waku.nims $@.$(LIB_EXT)
|
||||
|
||||
liblmapi: | build deps librln
|
||||
echo -e $(BUILD_MSG) "build/$@.$(LIB_EXT)" && $(ENV_SCRIPT) nim $(LMAPI_BUILD_COMMAND) $(NIM_PARAMS) waku.nims $@.$(LIB_EXT)
|
||||
liblogosdelivery: | build deps librln
|
||||
echo -e $(BUILD_MSG) "build/$@.$(LIB_EXT)" && $(ENV_SCRIPT) nim $(LIBLOGOSDELIVERY_BUILD_COMMAND) $(NIM_PARAMS) waku.nims $@.$(LIB_EXT)
|
||||
|
||||
liblmapi_example: | build liblmapi
|
||||
logosdelivery_example: | build liblogosdelivery
|
||||
@echo -e $(BUILD_MSG) "build/$@"
|
||||
ifeq ($(detected_OS),Darwin)
|
||||
gcc -o build/$@ \
|
||||
liblmapi/examples/liblmapi_example.c \
|
||||
-I./liblmapi \
|
||||
liblogosdelivery/examples/logosdelivery_example.c \
|
||||
-I./liblogosdelivery \
|
||||
-L./build \
|
||||
-llmapi \
|
||||
-llogosdelivery \
|
||||
-Wl,-rpath,./build
|
||||
else ifeq ($(detected_OS),Linux)
|
||||
gcc -o build/$@ \
|
||||
liblmapi/examples/liblmapi_example.c \
|
||||
-I./liblmapi \
|
||||
liblogosdelivery/examples/logosdelivery_example.c \
|
||||
-I./liblogosdelivery \
|
||||
-L./build \
|
||||
-llmapi \
|
||||
-llogosdelivery \
|
||||
-Wl,-rpath,'$$ORIGIN'
|
||||
else ifeq ($(detected_OS),Windows)
|
||||
gcc -o build/$@.exe \
|
||||
liblmapi/examples/liblmapi_example.c \
|
||||
-I./liblmapi \
|
||||
liblogosdelivery/examples/logosdelivery_example.c \
|
||||
-I./liblogosdelivery \
|
||||
-L./build \
|
||||
-llmapi \
|
||||
-llogosdelivery \
|
||||
-lws2_32
|
||||
endif
|
||||
|
||||
|
||||
@ -33,19 +33,19 @@ Compile the C example that demonstrates all library features:
|
||||
|
||||
```bash
|
||||
# Using Make (recommended)
|
||||
make liblmapi_example
|
||||
make liblogosdelivery_example
|
||||
|
||||
# Or manually on macOS:
|
||||
gcc -o build/liblmapi_example \
|
||||
liblmapi/examples/liblmapi_example.c \
|
||||
gcc -o build/liblogosdelivery_example \
|
||||
liblmapi/examples/liblogosdelivery_example.c \
|
||||
-I./liblmapi \
|
||||
-L./build \
|
||||
-llmapi \
|
||||
-Wl,-rpath,./build
|
||||
|
||||
# Or manually on Linux:
|
||||
gcc -o build/liblmapi_example \
|
||||
liblmapi/examples/liblmapi_example.c \
|
||||
gcc -o build/liblogosdelivery_example \
|
||||
liblmapi/examples/liblogosdelivery_example.c \
|
||||
-I./liblmapi \
|
||||
-L./build \
|
||||
-llmapi \
|
||||
@ -55,7 +55,7 @@ gcc -o build/liblmapi_example \
|
||||
## Running Examples
|
||||
|
||||
```bash
|
||||
./build/liblmapi_example
|
||||
./build/liblogosdelivery_example
|
||||
```
|
||||
|
||||
The example will:
|
||||
@ -75,7 +75,7 @@ After building, you'll have:
|
||||
build/
|
||||
├── liblmapi.dylib # Dynamic library (34MB)
|
||||
├── liblmapi.dylib.dSYM/ # Debug symbols
|
||||
└── liblmapi_example # Compiled example (34KB)
|
||||
└── liblogosdelivery_example # Compiled example (34KB)
|
||||
```
|
||||
|
||||
## Library Headers
|
||||
@ -92,13 +92,13 @@ If you get "library not found" errors when running the example:
|
||||
**macOS:**
|
||||
```bash
|
||||
export DYLD_LIBRARY_PATH=/path/to/build:$DYLD_LIBRARY_PATH
|
||||
./build/liblmapi_example
|
||||
./build/liblogosdelivery_example
|
||||
```
|
||||
|
||||
**Linux:**
|
||||
```bash
|
||||
export LD_LIBRARY_PATH=/path/to/build:$LD_LIBRARY_PATH
|
||||
./build/liblmapi_example
|
||||
./build/liblogosdelivery_example
|
||||
```
|
||||
|
||||
### Compilation fails
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
## Overview
|
||||
|
||||
The LMAPI library emits three types of message delivery events that clients can listen to by registering an event callback using `lmapi_set_event_callback()`.
|
||||
The LMAPI library emits three types of message delivery events that clients can listen to by registering an event callback using `logosdelivery_set_event_callback()`.
|
||||
|
||||
## Event Types
|
||||
|
||||
@ -86,8 +86,8 @@ void event_callback(int ret, const char *msg, size_t len, void *userData) {
|
||||
### 2. Register the Callback
|
||||
|
||||
```c
|
||||
void *ctx = lmapi_create_node(config, callback, userData);
|
||||
lmapi_set_event_callback(ctx, event_callback, NULL);
|
||||
void *ctx = logosdelivery_create_node(config, callback, userData);
|
||||
logosdelivery_set_event_callback(ctx, event_callback, NULL);
|
||||
```
|
||||
|
||||
### 3. Start the Node
|
||||
@ -95,7 +95,7 @@ lmapi_set_event_callback(ctx, event_callback, NULL);
|
||||
Once the node is started, events will be delivered to your callback:
|
||||
|
||||
```c
|
||||
lmapi_start_node(ctx, callback, userData);
|
||||
logosdelivery_start_node(ctx, callback, userData);
|
||||
```
|
||||
|
||||
## Event Flow
|
||||
@ -129,7 +129,7 @@ For a failed message send:
|
||||
|
||||
## Example Implementation
|
||||
|
||||
See `examples/liblmapi_example.c` for a complete working example that:
|
||||
See `examples/liblogosdelivery_example.c` for a complete working example that:
|
||||
- Registers an event callback
|
||||
- Sends a message
|
||||
- Receives and prints all three event types
|
||||
@ -10,11 +10,11 @@ This library wraps the high-level API functions from `waku/api/api.nim` and expo
|
||||
|
||||
### Node Lifecycle
|
||||
|
||||
#### `lmapi_create_node`
|
||||
#### `logosdelivery_create_node`
|
||||
Creates a new instance of the node from the given configuration JSON.
|
||||
|
||||
```c
|
||||
void *lmapi_create_node(
|
||||
void *logosdelivery_create_node(
|
||||
const char *configJson,
|
||||
FFICallBack callback,
|
||||
void *userData
|
||||
@ -44,33 +44,33 @@ void *lmapi_create_node(
|
||||
}
|
||||
```
|
||||
|
||||
#### `lmapi_start_node`
|
||||
#### `logosdelivery_start_node`
|
||||
Starts the node.
|
||||
|
||||
```c
|
||||
int lmapi_start_node(
|
||||
int logosdelivery_start_node(
|
||||
void *ctx,
|
||||
FFICallBack callback,
|
||||
void *userData
|
||||
);
|
||||
```
|
||||
|
||||
#### `lmapi_stop_node`
|
||||
#### `logosdelivery_stop_node`
|
||||
Stops the node.
|
||||
|
||||
```c
|
||||
int lmapi_stop_node(
|
||||
int logosdelivery_stop_node(
|
||||
void *ctx,
|
||||
FFICallBack callback,
|
||||
void *userData
|
||||
);
|
||||
```
|
||||
|
||||
#### `lmapi_destroy`
|
||||
#### `logosdelivery_destroy`
|
||||
Destroys a node instance and frees resources.
|
||||
|
||||
```c
|
||||
int lmapi_destroy(
|
||||
int logosdelivery_destroy(
|
||||
void *ctx,
|
||||
FFICallBack callback,
|
||||
void *userData
|
||||
@ -79,11 +79,11 @@ int lmapi_destroy(
|
||||
|
||||
### Messaging
|
||||
|
||||
#### `lmapi_subscribe`
|
||||
#### `logosdelivery_subscribe`
|
||||
Subscribe to a content topic to receive messages.
|
||||
|
||||
```c
|
||||
int lmapi_subscribe(
|
||||
int logosdelivery_subscribe(
|
||||
void *ctx,
|
||||
FFICallBack callback,
|
||||
void *userData,
|
||||
@ -92,16 +92,16 @@ int lmapi_subscribe(
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
- `ctx`: Context pointer from `lmapi_create_node`
|
||||
- `ctx`: Context pointer from `logosdelivery_create_node`
|
||||
- `callback`: Callback function to receive the result
|
||||
- `userData`: User data passed to the callback
|
||||
- `contentTopic`: Content topic string (e.g., "/myapp/1/chat/proto")
|
||||
|
||||
#### `lmapi_unsubscribe`
|
||||
#### `logosdelivery_unsubscribe`
|
||||
Unsubscribe from a content topic.
|
||||
|
||||
```c
|
||||
int lmapi_unsubscribe(
|
||||
int logosdelivery_unsubscribe(
|
||||
void *ctx,
|
||||
FFICallBack callback,
|
||||
void *userData,
|
||||
@ -109,11 +109,11 @@ int lmapi_unsubscribe(
|
||||
);
|
||||
```
|
||||
|
||||
#### `lmapi_send`
|
||||
#### `logosdelivery_send`
|
||||
Send a message.
|
||||
|
||||
```c
|
||||
int lmapi_send(
|
||||
int logosdelivery_send(
|
||||
void *ctx,
|
||||
FFICallBack callback,
|
||||
void *userData,
|
||||
@ -139,11 +139,11 @@ Note: The `payload` field should be base64-encoded.
|
||||
|
||||
### Events
|
||||
|
||||
#### `lmapi_set_event_callback`
|
||||
#### `logosdelivery_set_event_callback`
|
||||
Sets a callback that will be invoked whenever an event occurs (e.g., message received).
|
||||
|
||||
```c
|
||||
void lmapi_set_event_callback(
|
||||
void logosdelivery_set_event_callback(
|
||||
void *ctx,
|
||||
FFICallBack callback,
|
||||
void *userData
|
||||
@ -212,16 +212,16 @@ int main() {
|
||||
"}";
|
||||
|
||||
// Create node
|
||||
void *ctx = lmapi_create_node(config, callback, NULL);
|
||||
void *ctx = logosdelivery_create_node(config, callback, NULL);
|
||||
if (ctx == NULL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Start node
|
||||
lmapi_start_node(ctx, callback, NULL);
|
||||
logosdelivery_start_node(ctx, callback, NULL);
|
||||
|
||||
// Subscribe to a topic
|
||||
lmapi_subscribe(ctx, callback, NULL, "/myapp/1/chat/proto");
|
||||
logosdelivery_subscribe(ctx, callback, NULL, "/myapp/1/chat/proto");
|
||||
|
||||
// Send a message
|
||||
const char *msg = "{"
|
||||
@ -229,11 +229,11 @@ int main() {
|
||||
"\"payload\": \"SGVsbG8gV29ybGQ=\","
|
||||
"\"ephemeral\": false"
|
||||
"}";
|
||||
lmapi_send(ctx, callback, NULL, msg);
|
||||
logosdelivery_send(ctx, callback, NULL, msg);
|
||||
|
||||
// Clean up
|
||||
lmapi_stop_node(ctx, callback, NULL);
|
||||
lmapi_destroy(ctx, callback, NULL);
|
||||
logosdelivery_stop_node(ctx, callback, NULL);
|
||||
logosdelivery_destroy(ctx, callback, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1,9 +1,9 @@
|
||||
import ffi
|
||||
import waku/factory/waku
|
||||
|
||||
declareLibrary("lmapi")
|
||||
declareLibrary("logosdelivery")
|
||||
|
||||
proc lmapi_set_event_callback(
|
||||
proc logosdelivery_set_event_callback(
|
||||
ctx: ptr FFIContext[Waku], callback: FFICallBack, userData: pointer
|
||||
) {.dynlib, exportc, cdecl.} =
|
||||
ctx[].eventCallback = cast[pointer](callback)
|
||||
@ -19,20 +19,20 @@ This directory contains example programs demonstrating the usage of the Logos Me
|
||||
#### On Linux/macOS:
|
||||
```bash
|
||||
# Shared library
|
||||
gcc -o liblmapi_example liblmapi_example.c -I.. -L../../build -llmapi -Wl,-rpath,../../build
|
||||
gcc -o liblogosdelivery_example liblogosdelivery_example.c -I.. -L../../build -llmapi -Wl,-rpath,../../build
|
||||
|
||||
# Static library (if built with STATIC=1)
|
||||
gcc -o liblmapi_example liblmapi_example.c -I.. ../../build/liblmapi.a -lpthread -lm -ldl
|
||||
gcc -o liblogosdelivery_example liblogosdelivery_example.c -I.. ../../build/liblmapi.a -lpthread -lm -ldl
|
||||
```
|
||||
|
||||
#### On macOS:
|
||||
```bash
|
||||
gcc -o liblmapi_example liblmapi_example.c -I.. -L../../build -llmapi
|
||||
gcc -o liblogosdelivery_example liblogosdelivery_example.c -I.. -L../../build -llmapi
|
||||
```
|
||||
|
||||
#### On Windows (MinGW):
|
||||
```bash
|
||||
gcc -o liblmapi_example.exe liblmapi_example.c -I.. -L../../build -llmapi -lws2_32
|
||||
gcc -o liblogosdelivery_example.exe liblogosdelivery_example.c -I.. -L../../build -llmapi -lws2_32
|
||||
```
|
||||
|
||||
## Running the Examples
|
||||
@ -40,7 +40,7 @@ gcc -o liblmapi_example.exe liblmapi_example.c -I.. -L../../build -llmapi -lws2_
|
||||
### liblmapi Example
|
||||
|
||||
```bash
|
||||
./liblmapi_example
|
||||
./liblogosdelivery_example
|
||||
```
|
||||
|
||||
This example demonstrates:
|
||||
@ -1,4 +1,4 @@
|
||||
#include "../liblmapi.h"
|
||||
#include "../logosdelivery.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
@ -105,7 +105,8 @@ int main() {
|
||||
// Configuration JSON for creating a node
|
||||
const char *config = "{"
|
||||
"\"logLevel\": \"TRACE\","
|
||||
"\"mode\": \"Edge\","
|
||||
// "\"mode\": \"Edge\","
|
||||
"\"mode\": \"Core\","
|
||||
"\"clusterId\": 42,"
|
||||
"\"numShards\": 8,"
|
||||
// "\"shards\": [0,1,2,3,4,5,6,7],"
|
||||
@ -118,7 +119,7 @@ int main() {
|
||||
"}";
|
||||
|
||||
printf("1. Creating node...\n");
|
||||
void *ctx = lmapi_create_node(config, simple_callback, (void *)"create_node");
|
||||
void *ctx = logosdelivery_create_node(config, simple_callback, (void *)"create_node");
|
||||
if (ctx == NULL) {
|
||||
printf("Failed to create node\n");
|
||||
return 1;
|
||||
@ -128,18 +129,18 @@ int main() {
|
||||
sleep(1);
|
||||
|
||||
printf("\n2. Setting up event callback...\n");
|
||||
lmapi_set_event_callback(ctx, event_callback, NULL);
|
||||
logosdelivery_set_event_callback(ctx, event_callback, NULL);
|
||||
printf("Event callback registered for message events\n");
|
||||
|
||||
printf("\n3. Starting node...\n");
|
||||
lmapi_start_node(ctx, simple_callback, (void *)"start_node");
|
||||
logosdelivery_start_node(ctx, simple_callback, (void *)"start_node");
|
||||
|
||||
// Wait for node to start
|
||||
sleep(2);
|
||||
|
||||
printf("\n4. Subscribing to content topic...\n");
|
||||
const char *contentTopic = "/example/1/chat/proto";
|
||||
lmapi_subscribe(ctx, simple_callback, (void *)"subscribe", contentTopic);
|
||||
logosdelivery_subscribe(ctx, simple_callback, (void *)"subscribe", contentTopic);
|
||||
|
||||
// Wait for subscription
|
||||
sleep(1);
|
||||
@ -152,24 +153,24 @@ int main() {
|
||||
"\"payload\": \"SGVsbG8sIExvZ29zIE1lc3NhZ2luZyE=\","
|
||||
"\"ephemeral\": false"
|
||||
"}";
|
||||
lmapi_send(ctx, simple_callback, (void *)"send", message);
|
||||
logosdelivery_send(ctx, simple_callback, (void *)"send", message);
|
||||
|
||||
// Wait for message events to arrive
|
||||
printf("Waiting for message delivery events...\n");
|
||||
sleep(60);
|
||||
|
||||
printf("\n6. Unsubscribing from content topic...\n");
|
||||
lmapi_unsubscribe(ctx, simple_callback, (void *)"unsubscribe", contentTopic);
|
||||
logosdelivery_unsubscribe(ctx, simple_callback, (void *)"unsubscribe", contentTopic);
|
||||
|
||||
sleep(1);
|
||||
|
||||
printf("\n7. Stopping node...\n");
|
||||
lmapi_stop_node(ctx, simple_callback, (void *)"stop_node");
|
||||
logosdelivery_stop_node(ctx, simple_callback, (void *)"stop_node");
|
||||
|
||||
sleep(1);
|
||||
|
||||
printf("\n8. Destroying context...\n");
|
||||
lmapi_destroy(ctx, simple_callback, (void *)"destroy");
|
||||
logosdelivery_destroy(ctx, simple_callback, (void *)"destroy");
|
||||
|
||||
printf("\n=== Example completed ===\n");
|
||||
return 0;
|
||||
@ -1,8 +1,9 @@
|
||||
|
||||
// Generated manually and inspired by libwaku.h
|
||||
// Header file for Logos Messaging API (LMAPI) library
|
||||
#ifndef __liblmapi__
|
||||
#define __liblmapi__
|
||||
#pragma once
|
||||
#ifndef __liblogosdelivery__
|
||||
#define __liblogosdelivery__
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
@ -22,35 +23,35 @@ extern "C"
|
||||
// Creates a new instance of the node from the given configuration JSON.
|
||||
// Returns a pointer to the Context needed by the rest of the API functions.
|
||||
// Configuration should be in JSON format following the NodeConfig structure.
|
||||
void *lmapi_create_node(
|
||||
void *logosdelivery_create_node(
|
||||
const char *configJson,
|
||||
FFICallBack callback,
|
||||
void *userData);
|
||||
|
||||
// Starts the node.
|
||||
int lmapi_start_node(void *ctx,
|
||||
int logosdelivery_start_node(void *ctx,
|
||||
FFICallBack callback,
|
||||
void *userData);
|
||||
|
||||
// Stops the node.
|
||||
int lmapi_stop_node(void *ctx,
|
||||
int logosdelivery_stop_node(void *ctx,
|
||||
FFICallBack callback,
|
||||
void *userData);
|
||||
|
||||
// Destroys an instance of a node created with lmapi_create_node
|
||||
int lmapi_destroy(void *ctx,
|
||||
// Destroys an instance of a node created with logosdelivery_create_node
|
||||
int logosdelivery_destroy(void *ctx,
|
||||
FFICallBack callback,
|
||||
void *userData);
|
||||
|
||||
// Subscribe to a content topic.
|
||||
// contentTopic: string representing the content topic (e.g., "/myapp/1/chat/proto")
|
||||
int lmapi_subscribe(void *ctx,
|
||||
int logosdelivery_subscribe(void *ctx,
|
||||
FFICallBack callback,
|
||||
void *userData,
|
||||
const char *contentTopic);
|
||||
|
||||
// Unsubscribe from a content topic.
|
||||
int lmapi_unsubscribe(void *ctx,
|
||||
int logosdelivery_unsubscribe(void *ctx,
|
||||
FFICallBack callback,
|
||||
void *userData,
|
||||
const char *contentTopic);
|
||||
@ -63,14 +64,14 @@ extern "C"
|
||||
// "ephemeral": false
|
||||
// }
|
||||
// Returns a request ID that can be used to track the message delivery.
|
||||
int lmapi_send(void *ctx,
|
||||
int logosdelivery_send(void *ctx,
|
||||
FFICallBack callback,
|
||||
void *userData,
|
||||
const char *messageJson);
|
||||
|
||||
// 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 lmapi_set_event_callback(void *ctx,
|
||||
void logosdelivery_set_event_callback(void *ctx,
|
||||
FFICallBack callback,
|
||||
void *userData);
|
||||
|
||||
@ -78,4 +79,4 @@ extern "C"
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __liblmapi__ */
|
||||
#endif /* __liblogosdelivery__ */
|
||||
@ -4,19 +4,19 @@ import waku/factory/waku, waku/node/waku_node, ./declare_lib
|
||||
|
||||
################################################################################
|
||||
## Include different APIs, i.e. all procs with {.ffi.} pragma
|
||||
include ./lmapi/node_api, ./lmapi/messaging_api
|
||||
include ./logos_delivery_api/node_api, ./logos_delivery_api/messaging_api
|
||||
|
||||
################################################################################
|
||||
### Exported procs
|
||||
|
||||
proc lmapi_destroy(
|
||||
proc logosdelivery_destroy(
|
||||
ctx: ptr FFIContext[Waku], callback: FFICallBack, userData: pointer
|
||||
): cint {.dynlib, exportc, cdecl.} =
|
||||
initializeLibrary()
|
||||
checkParams(ctx, callback, userData)
|
||||
|
||||
ffi.destroyFFIContext(ctx).isOkOr:
|
||||
let msg = "liblmapi error: " & $error
|
||||
let msg = "liblogosdelivery error: " & $error
|
||||
callback(RET_ERR, unsafeAddr msg[0], cast[csize_t](len(msg)), userData)
|
||||
return RET_ERR
|
||||
|
||||
@ -7,7 +7,7 @@ import
|
||||
waku/api/[api, types],
|
||||
../declare_lib
|
||||
|
||||
proc lmapi_subscribe(
|
||||
proc logosdelivery_subscribe(
|
||||
ctx: ptr FFIContext[Waku],
|
||||
callback: FFICallBack,
|
||||
userData: pointer,
|
||||
@ -22,7 +22,7 @@ proc lmapi_subscribe(
|
||||
|
||||
return ok("")
|
||||
|
||||
proc lmapi_unsubscribe(
|
||||
proc logosdelivery_unsubscribe(
|
||||
ctx: ptr FFIContext[Waku],
|
||||
callback: FFICallBack,
|
||||
userData: pointer,
|
||||
@ -37,7 +37,7 @@ proc lmapi_unsubscribe(
|
||||
|
||||
return ok("")
|
||||
|
||||
proc lmapi_send(
|
||||
proc logosdelivery_send(
|
||||
ctx: ptr FFIContext[Waku],
|
||||
callback: FFICallBack,
|
||||
userData: pointer,
|
||||
@ -79,13 +79,13 @@ registerReqFFI(CreateNodeRequest, ctx: ptr FFIContext[Waku]):
|
||||
|
||||
return ok("")
|
||||
|
||||
proc lmapi_create_node(
|
||||
proc logosdelivery_create_node(
|
||||
configJson: cstring, callback: FFICallback, userData: pointer
|
||||
): pointer {.dynlib, exportc, cdecl.} =
|
||||
initializeLibrary()
|
||||
|
||||
if isNil(callback):
|
||||
echo "error: missing callback in lmapi_create_node"
|
||||
echo "error: missing callback in logosdelivery_create_node"
|
||||
return nil
|
||||
|
||||
var ctx = ffi.createFFIContext[Waku]().valueOr:
|
||||
@ -104,7 +104,7 @@ proc lmapi_create_node(
|
||||
|
||||
return ctx
|
||||
|
||||
proc lmapi_start_node(
|
||||
proc logosdelivery_start_node(
|
||||
ctx: ptr FFIContext[Waku], callback: FFICallBack, userData: pointer
|
||||
) {.ffi.} =
|
||||
# setting up outgoing event listeners
|
||||
@ -141,7 +141,7 @@ proc lmapi_start_node(
|
||||
return err("failed to start: " & errMsg)
|
||||
return ok("")
|
||||
|
||||
proc lmapi_stop_node(
|
||||
proc logosdelivery_stop_node(
|
||||
ctx: ptr FFIContext[Waku], callback: FFICallBack, userData: pointer
|
||||
) {.ffi.} =
|
||||
MessageErrorEvent.dropAllListeners(ctx.myLib[].brokerCtx)
|
||||
247
nix/submodules.json
Normal file
247
nix/submodules.json
Normal file
@ -0,0 +1,247 @@
|
||||
[
|
||||
{
|
||||
"path": "vendor/db_connector",
|
||||
"url": "https://github.com/nim-lang/db_connector.git",
|
||||
"rev": "74aef399e5c232f95c9fc5c987cebac846f09d62"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/dnsclient.nim",
|
||||
"url": "https://github.com/ba0f3/dnsclient.nim.git",
|
||||
"rev": "23214235d4784d24aceed99bbfe153379ea557c8"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-bearssl",
|
||||
"url": "https://github.com/status-im/nim-bearssl.git",
|
||||
"rev": "11e798b62b8e6beabe958e048e9e24c7e0f9ee63"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-chronicles",
|
||||
"url": "https://github.com/status-im/nim-chronicles.git",
|
||||
"rev": "54f5b726025e8c7385e3a6529d3aa27454c6e6ff"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-chronos",
|
||||
"url": "https://github.com/status-im/nim-chronos.git",
|
||||
"rev": "85af4db764ecd3573c4704139560df3943216cf1"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-confutils",
|
||||
"url": "https://github.com/status-im/nim-confutils.git",
|
||||
"rev": "e214b3992a31acece6a9aada7d0a1ad37c928f3b"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-dnsdisc",
|
||||
"url": "https://github.com/status-im/nim-dnsdisc.git",
|
||||
"rev": "b71d029f4da4ec56974d54c04518bada00e1b623"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-eth",
|
||||
"url": "https://github.com/status-im/nim-eth.git",
|
||||
"rev": "d9135e6c3c5d6d819afdfb566aa8d958756b73a8"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-faststreams",
|
||||
"url": "https://github.com/status-im/nim-faststreams.git",
|
||||
"rev": "c3ac3f639ed1d62f59d3077d376a29c63ac9750c"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-ffi",
|
||||
"url": "https://github.com/logos-messaging/nim-ffi",
|
||||
"rev": "06111de155253b34e47ed2aaed1d61d08d62cc1b"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-http-utils",
|
||||
"url": "https://github.com/status-im/nim-http-utils.git",
|
||||
"rev": "79cbab1460f4c0cdde2084589d017c43a3d7b4f1"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-json-rpc",
|
||||
"url": "https://github.com/status-im/nim-json-rpc.git",
|
||||
"rev": "9665c265035f49f5ff94bbffdeadde68e19d6221"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-json-serialization",
|
||||
"url": "https://github.com/status-im/nim-json-serialization.git",
|
||||
"rev": "b65fd6a7e64c864dabe40e7dfd6c7d07db0014ac"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-jwt",
|
||||
"url": "https://github.com/vacp2p/nim-jwt.git",
|
||||
"rev": "18f8378de52b241f321c1f9ea905456e89b95c6f"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-libbacktrace",
|
||||
"url": "https://github.com/status-im/nim-libbacktrace.git",
|
||||
"rev": "d8bd4ce5c46bb6d2f984f6b3f3d7380897d95ecb"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-libp2p",
|
||||
"url": "https://github.com/vacp2p/nim-libp2p.git",
|
||||
"rev": "eb7e6ff89889e41b57515f891ba82986c54809fb"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-lsquic",
|
||||
"url": "https://github.com/vacp2p/nim-lsquic",
|
||||
"rev": "f3fe33462601ea34eb2e8e9c357c92e61f8d121b"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-metrics",
|
||||
"url": "https://github.com/status-im/nim-metrics.git",
|
||||
"rev": "ecf64c6078d1276d3b7d9b3d931fbdb70004db11"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-minilru",
|
||||
"url": "https://github.com/status-im/nim-minilru.git",
|
||||
"rev": "0c4b2bce959591f0a862e9b541ba43c6d0cf3476"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-nat-traversal",
|
||||
"url": "https://github.com/status-im/nim-nat-traversal.git",
|
||||
"rev": "860e18c37667b5dd005b94c63264560c35d88004"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-presto",
|
||||
"url": "https://github.com/status-im/nim-presto.git",
|
||||
"rev": "92b1c7ff141e6920e1f8a98a14c35c1fa098e3be"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-regex",
|
||||
"url": "https://github.com/nitely/nim-regex.git",
|
||||
"rev": "4593305ed1e49731fc75af1dc572dd2559aad19c"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-results",
|
||||
"url": "https://github.com/arnetheduck/nim-results.git",
|
||||
"rev": "df8113dda4c2d74d460a8fa98252b0b771bf1f27"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-secp256k1",
|
||||
"url": "https://github.com/status-im/nim-secp256k1.git",
|
||||
"rev": "9dd3df62124aae79d564da636bb22627c53c7676"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-serialization",
|
||||
"url": "https://github.com/status-im/nim-serialization.git",
|
||||
"rev": "6f525d5447d97256750ca7856faead03e562ed20"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-sqlite3-abi",
|
||||
"url": "https://github.com/arnetheduck/nim-sqlite3-abi.git",
|
||||
"rev": "bdf01cf4236fb40788f0733466cdf6708783cbac"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-stew",
|
||||
"url": "https://github.com/status-im/nim-stew.git",
|
||||
"rev": "e5740014961438610d336cd81706582dbf2c96f0"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-stint",
|
||||
"url": "https://github.com/status-im/nim-stint.git",
|
||||
"rev": "470b7892561b5179ab20bd389a69217d6213fe58"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-taskpools",
|
||||
"url": "https://github.com/status-im/nim-taskpools.git",
|
||||
"rev": "9e8ccc754631ac55ac2fd495e167e74e86293edb"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-testutils",
|
||||
"url": "https://github.com/status-im/nim-testutils.git",
|
||||
"rev": "94d68e796c045d5b37cabc6be32d7bfa168f8857"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-toml-serialization",
|
||||
"url": "https://github.com/status-im/nim-toml-serialization.git",
|
||||
"rev": "fea85b27f0badcf617033ca1bc05444b5fd8aa7a"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-unicodedb",
|
||||
"url": "https://github.com/nitely/nim-unicodedb.git",
|
||||
"rev": "66f2458710dc641dd4640368f9483c8a0ec70561"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-unittest2",
|
||||
"url": "https://github.com/status-im/nim-unittest2.git",
|
||||
"rev": "8b51e99b4a57fcfb31689230e75595f024543024"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-web3",
|
||||
"url": "https://github.com/status-im/nim-web3.git",
|
||||
"rev": "81ee8ce479d86acb73be7c4f365328e238d9b4a3"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-websock",
|
||||
"url": "https://github.com/status-im/nim-websock.git",
|
||||
"rev": "ebe308a79a7b440a11dfbe74f352be86a3883508"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nim-zlib",
|
||||
"url": "https://github.com/status-im/nim-zlib.git",
|
||||
"rev": "daa8723fd32299d4ca621c837430c29a5a11e19a"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nimbus-build-system",
|
||||
"url": "https://github.com/status-im/nimbus-build-system.git",
|
||||
"rev": "e6c2c9da39c2d368d9cf420ac22692e99715d22c"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nimcrypto",
|
||||
"url": "https://github.com/cheatfate/nimcrypto.git",
|
||||
"rev": "721fb99ee099b632eb86dfad1f0d96ee87583774"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/nph",
|
||||
"url": "https://github.com/arnetheduck/nph.git",
|
||||
"rev": "c6e03162dc2820d3088660f644818d7040e95791"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/waku-rlnv2-contract",
|
||||
"url": "https://github.com/logos-messaging/waku-rlnv2-contract.git",
|
||||
"rev": "8a338f354481e8a3f3d64a72e38fad4c62e32dcd"
|
||||
}
|
||||
,
|
||||
{
|
||||
"path": "vendor/zerokit",
|
||||
"url": "https://github.com/vacp2p/zerokit.git",
|
||||
"rev": "70c79fbc989d4f87d9352b2f4bddcb60ebe55b19"
|
||||
}
|
||||
]
|
||||
82
scripts/generate_nix_submodules.sh
Executable file
82
scripts/generate_nix_submodules.sh
Executable file
@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Generates nix/submodules.json from .gitmodules and git ls-tree.
|
||||
# This allows Nix to fetch all git submodules without requiring
|
||||
# locally initialized submodules or the '?submodules=1' URI flag.
|
||||
#
|
||||
# Usage: ./scripts/generate_nix_submodules.sh
|
||||
#
|
||||
# Run this script after:
|
||||
# - Adding/removing submodules
|
||||
# - Updating submodule commits (e.g. after 'make update')
|
||||
# - Any change to .gitmodules
|
||||
#
|
||||
# Compatible with macOS bash 3.x (no associative arrays).
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
OUTPUT="${REPO_ROOT}/nix/submodules.json"
|
||||
|
||||
cd "$REPO_ROOT"
|
||||
|
||||
TMP_URLS=$(mktemp)
|
||||
TMP_REVS=$(mktemp)
|
||||
trap 'rm -f "$TMP_URLS" "$TMP_REVS"' EXIT
|
||||
|
||||
# Parse .gitmodules: extract (path, url) pairs
|
||||
current_path=""
|
||||
while IFS= read -r line; do
|
||||
case "$line" in
|
||||
*"path = "*)
|
||||
current_path="${line#*path = }"
|
||||
;;
|
||||
*"url = "*)
|
||||
if [ -n "$current_path" ]; then
|
||||
url="${line#*url = }"
|
||||
url="${url%/}"
|
||||
printf '%s\t%s\n' "$current_path" "$url" >> "$TMP_URLS"
|
||||
current_path=""
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done < .gitmodules
|
||||
|
||||
# Get pinned commit hashes from git tree
|
||||
git ls-tree HEAD vendor/ | while IFS= read -r tree_line; do
|
||||
mode=$(echo "$tree_line" | awk '{print $1}')
|
||||
type=$(echo "$tree_line" | awk '{print $2}')
|
||||
hash=$(echo "$tree_line" | awk '{print $3}')
|
||||
path=$(echo "$tree_line" | awk '{print $4}')
|
||||
if [ "$type" = "commit" ]; then
|
||||
path="${path%/}"
|
||||
printf '%s\t%s\n' "$path" "$hash" >> "$TMP_REVS"
|
||||
fi
|
||||
done
|
||||
|
||||
# Generate JSON by joining urls and revs on path
|
||||
printf '[\n' > "$OUTPUT"
|
||||
first=true
|
||||
|
||||
sort "$TMP_URLS" | while IFS="$(printf '\t')" read -r path url; do
|
||||
rev=$(grep "^${path} " "$TMP_REVS" | cut -f2 || true)
|
||||
|
||||
if [ -z "$rev" ]; then
|
||||
echo "WARNING: No commit hash found for submodule '$path', skipping" >&2
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$first" = true ]; then
|
||||
first=false
|
||||
else
|
||||
printf ' ,\n' >> "$OUTPUT"
|
||||
fi
|
||||
|
||||
printf ' {\n "path": "%s",\n "url": "%s",\n "rev": "%s"\n }\n' \
|
||||
"$path" "$url" "$rev" >> "$OUTPUT"
|
||||
done
|
||||
|
||||
printf ']\n' >> "$OUTPUT"
|
||||
|
||||
count=$(grep -c '"path"' "$OUTPUT" || echo 0)
|
||||
echo "Generated $OUTPUT with $count submodule entries"
|
||||
@ -401,10 +401,10 @@ task libWakuIOS, "Build the mobile bindings for iOS":
|
||||
let extraParams = "-d:chronicles_log_level=ERROR"
|
||||
buildMobileIOS srcDir, extraParams
|
||||
|
||||
task liblmapiStatic, "Build the liblmapi (Logos Messaging API) static library":
|
||||
task liblogosdeliveryStatic, "Build the liblogosdelivery (Logos Messaging Delivery API) static library":
|
||||
let lib_name = paramStr(paramCount())
|
||||
buildLibrary lib_name, "liblmapi/", chroniclesParams, "static", "liblmapi.nim", "liblmapi"
|
||||
buildLibrary lib_name, "liblogosdelivery/", chroniclesParams, "static", "liblogosdelivery.nim", "liblogosdelivery"
|
||||
|
||||
task liblmapiDynamic, "Build the liblmapi (Logos Messaging API) dynamic library":
|
||||
task liblogosdeliveryDynamic, "Build the liblogosdelivery (Logos Messaging Delivery API) dynamic library":
|
||||
let lib_name = paramStr(paramCount())
|
||||
buildLibrary lib_name, "liblmapi/", chroniclesParams, "dynamic", "liblmapi.nim", "liblmapi"
|
||||
buildLibrary lib_name, "liblogosdelivery/", chroniclesParams, "dynamic", "liblogosdelivery.nim", "liblogosdelivery"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user