Misc existing (some nim-waku duplicates)

This commit is contained in:
Oskar Thoren 2021-06-13 20:53:50 +08:00
parent 69b38671ca
commit 1ff392ef87
No known key found for this signature in database
GPG Key ID: B2ECCFD3BC2EF77E
4 changed files with 50 additions and 0 deletions

View File

@ -5,6 +5,7 @@ build:
all: build
# TODO Integrate with nim-waku wrapper
# TODO Assume we have libwaku.so already
# libraries for dynamic linking of non-Nim objects
EXTRA_LIBS_DYNAMIC := -L"$(CURDIR)/build" -lwaku -lm

9
nwaku/libwaku.h Normal file
View File

@ -0,0 +1,9 @@
#include <stdint.h>
#include <stddef.h>
// Initialize Nim
void NimMain();
char* info(const char* wakuNode);
void echo();

5
nwaku/scratch.go Normal file
View File

@ -0,0 +1,5 @@
package
import (
"fmt"
)

35
nwaku/wrapper2.go Normal file
View File

@ -0,0 +1,35 @@
package main
// TODO Update package name here
import (
"fmt"
"runtime"
)
/*
#include <stdlib.h>
// Passing "-lwaku" to the Go linker through "-extldflags" is not enough. We need it in here, for some reason.
#cgo LDFLAGS: -Wl,-rpath,'$ORIGIN' -L${SRCDIR}/../build -lwaku
#include "libwaku.h"
*/
import "C"
// Arrange that main.main runs on main thread.
func init() {
runtime.LockOSThread()
}
// Wrapper that uses C library instead
// Just call info here?
func Start() {
C.NimMain()
var str = C.info("hello there")
fmt.Println("String", str)
}
func main() {
fmt.Println("Hi main")
Start()
}