-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Project restructuring. Java code is now for example purposes. Made bi…
…ndings folder for all Makefile and code related to langage bindings
- Loading branch information
Showing
18 changed files
with
460 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
SHELL := /bin/sh | ||
|
||
include ../config.mk | ||
|
||
CC = gcc | ||
CFLAGS = -O2 -fPIC | ||
LFLAGS = $(OS_LFLAGS) -shared | ||
|
||
JAVA_HOME = $(shell java -XshowSettings:properties -version 2>&1 > /dev/null | grep 'java.home' | sed 's/\s*java.home = //' | sed 's/\/jre//') | ||
JAVA_INCLUDES = -I$(JAVA_HOME)/include/$(OS) -I$(JAVA_HOME)/include | ||
CLASS_PATH = . | ||
vpath %.class $(CLASS_PATH) | ||
|
||
DNAME = p2pd | ||
CNAME = p2pc | ||
|
||
.PHONY : java-daemon java-client go-bindings clean | ||
|
||
java-daemon: lib$(DNAME).$(EXT) $(DNAME).class | ||
|
||
java-client: lib$(CNAME).$(EXT) $(CNAME).class | ||
|
||
go-bindings: java-$(DNAME).o java-$(CNAME).o go-p2p.a | ||
$(CC) $(LFLAGS) -o libp2p.$(EXT) $^ | ||
|
||
lib%.$(EXT): java-%.o go-%.a | ||
$(CC) $(LFLAGS) -o $@ $^ | ||
|
||
java-%.o: go-%.a | ||
$(CC) $(CFLAGS) -c java/java-$*.c $(JAVA_INCLUDES) -o $@ | ||
|
||
go-p2p.a: | ||
go build -o $@ -buildmode=c-archive main.go | ||
|
||
go-%.a: | ||
go build -o $@ -buildmode=c-archive ../$*/main.go | ||
|
||
%.class: | ||
cd java/examples && javac $*.java && mv $@ ../../$@ | ||
|
||
clean: | ||
rm -f *.o \ | ||
&& rm -f *.a \ | ||
&& rm -f *.$(EXT) \ | ||
&& rm -f *.class \ | ||
&& rm -f *.h |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
|
||
tmux new-session -d -s foo 'p2pd' | ||
tmux split-window -v -t 0 'cd ../../ && java p2pd --sock=/tmp/p2pd2.sock' | ||
tmux split-window -h 'sleep 1 && cd ../../ && java p2pc --pathc=/tmp/p2c2.sock --pathd=/tmp/p2pd2.sock --command=ListenForMessage' | ||
tmux split-window -v -t 1 '/bin/bash' | ||
tmux select-layout tile | ||
tmux rename-window 'the dude abides' | ||
tmux attach-session -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <jni.h> | ||
|
||
#ifndef _Included_p2pc | ||
#define _Included_p2pc | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
JNIEXPORT void JNICALL Java_p2pc_startClient (JNIEnv *, jclass, jstring); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <jni.h> | ||
|
||
#ifndef _Included_p2pd | ||
#define _Included_p2pd | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
JNIEXPORT void JNICALL Java_p2pd_startDaemon (JNIEnv *, jclass, jstring); | ||
|
||
JNIEXPORT void JNICALL Java_p2pd_stopDaemon (JNIEnv *, jclass); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
import "C" | ||
import ( | ||
p2pd "github.com/libp2p/go-libp2p-daemon" | ||
p2pc "github.com/libp2p/go-libp2p-daemon/p2pclient" | ||
) | ||
|
||
func main() { | ||
} | ||
|
||
//export startClient | ||
func startClient(args *C.char) { | ||
argsGoString := C.GoString(args) | ||
config := p2pc.ProcessArgs(&argsGoString) | ||
p2pc.Start(config) | ||
} | ||
|
||
//export startDaemon | ||
func startDaemon(args *C.char) { | ||
argsGoString := C.GoString(args) | ||
config := p2pd.ProcessArgs(&argsGoString) | ||
p2pd.Start(config) | ||
} | ||
|
||
//export stopDaemon | ||
func stopDaemon() { | ||
p2pd.Stop() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
OS = $(shell uname -s | tr '[:upper:]' '[:lower:]') | ||
|
||
ifeq ($(OS), linux) | ||
EXT = so | ||
OS_LFLAGS = | ||
else ifeq ($(OS), darwin) | ||
EXT = dylib | ||
OS_LFLAGS = -mmacosx-version-min=$(shell defaults read loginwindow SystemVersionStampAsString) -framework CoreFoundation -framework Security | ||
endif | ||
|
||
DDIR = p2pd | ||
CDIR = p2pc | ||
BDIR = bindings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.