mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 21:37:17 +01:00
Get it to build from go build
This commit is contained in:
parent
5013ce5649
commit
7bc2e74683
25
Makefile
25
Makefile
|
@ -1,6 +1,8 @@
|
||||||
SYS := $(shell $(CXX) -dumpmachine)
|
SYS := $(shell $(CXX) -dumpmachine)
|
||||||
SHLIB := libi2pd.so
|
SHLIB := libi2pd.so
|
||||||
ARLIB := libi2pd.a
|
ARLIB := libi2pd.a
|
||||||
|
SHLIB_LANG := libi2pdlang.so
|
||||||
|
ARLIB_LANG := libi2pdlang.a
|
||||||
SHLIB_CLIENT := libi2pdclient.so
|
SHLIB_CLIENT := libi2pdclient.so
|
||||||
ARLIB_CLIENT := libi2pdclient.a
|
ARLIB_CLIENT := libi2pdclient.a
|
||||||
I2PD := i2pd
|
I2PD := i2pd
|
||||||
|
@ -26,6 +28,12 @@ else
|
||||||
LD_DEBUG = -s
|
LD_DEBUG = -s
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(USE_STATIC),yes)
|
||||||
|
NEEDED_CXXFLAGS+= -static
|
||||||
|
else
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq (, $(findstring darwin, $(SYS)))
|
ifneq (, $(findstring darwin, $(SYS)))
|
||||||
DAEMON_SRC += $(DAEMON_SRC_DIR)/UnixDaemon.cpp
|
DAEMON_SRC += $(DAEMON_SRC_DIR)/UnixDaemon.cpp
|
||||||
ifeq ($(HOMEBREW),1)
|
ifeq ($(HOMEBREW),1)
|
||||||
|
@ -71,6 +79,7 @@ mk_obj_dir:
|
||||||
api: mk_obj_dir $(SHLIB) $(ARLIB)
|
api: mk_obj_dir $(SHLIB) $(ARLIB)
|
||||||
client: mk_obj_dir $(SHLIB_CLIENT) $(ARLIB_CLIENT)
|
client: mk_obj_dir $(SHLIB_CLIENT) $(ARLIB_CLIENT)
|
||||||
api_client: mk_obj_dir $(SHLIB) $(ARLIB) $(SHLIB_CLIENT) $(ARLIB_CLIENT)
|
api_client: mk_obj_dir $(SHLIB) $(ARLIB) $(SHLIB_CLIENT) $(ARLIB_CLIENT)
|
||||||
|
langs: mk_obj_dir $(LANG_OBJS) $(SHLIB_LANG) $(ARLIB_LANG)
|
||||||
|
|
||||||
## NOTE: The NEEDED_CXXFLAGS are here so that CXXFLAGS can be specified at build time
|
## NOTE: The NEEDED_CXXFLAGS are here so that CXXFLAGS can be specified at build time
|
||||||
## **without** overwriting the CXXFLAGS which we need in order to build.
|
## **without** overwriting the CXXFLAGS which we need in order to build.
|
||||||
|
@ -98,12 +107,21 @@ ifneq ($(USE_STATIC),yes)
|
||||||
$(CXX) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS) $(SHLIB)
|
$(CXX) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS) $(SHLIB)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
$(SHLIB_LANG): $(LANG_OBJS)
|
||||||
|
ifneq ($(USE_STATIC),yes)
|
||||||
|
$(CXX) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS)
|
||||||
|
endif
|
||||||
|
|
||||||
$(ARLIB): $(LIB_OBJS)
|
$(ARLIB): $(LIB_OBJS)
|
||||||
$(AR) -r $@ $^
|
$(AR) -r $@ $^
|
||||||
|
|
||||||
$(ARLIB_CLIENT): $(LIB_CLIENT_OBJS)
|
$(ARLIB_CLIENT): $(LIB_CLIENT_OBJS)
|
||||||
$(AR) -r $@ $^
|
$(AR) -r $@ $^
|
||||||
|
|
||||||
|
$(ARLIB_LANG): $(LANG_OBJS)
|
||||||
|
$(AR) -r $@ $^
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) -r obj
|
$(RM) -r obj
|
||||||
$(RM) -r docs/generated
|
$(RM) -r docs/generated
|
||||||
|
@ -151,9 +169,10 @@ flags:
|
||||||
|
|
||||||
##TODO: delete this before a PR
|
##TODO: delete this before a PR
|
||||||
testc: api api_client
|
testc: api api_client
|
||||||
# g++ -Ii18n -c test.c -o test.o
|
g++ -Ii18n -c _test.c -o test.o
|
||||||
# gcc -llibi2pd.so -c _test.c -o test.o
|
# gcc -llibi2pd.so -c _test.c -o test.o
|
||||||
$(CC) -g -Wall -o test.o _test.c libi2pd.a
|
# $(CXX) $(LDFLAGS) $(LDLIBS) -static -Ii18n -Ilibi2pd -Ilibi2pd_client -g -Wall -o test.o _test.c libi2pd.a libi2pdclient.a #obj/libi2pd/*.o obj/i18n/*.o #libi2pd.so
|
||||||
|
# $(CXX) $(LDFLAGS) $(LDLIBS) -static -Ii18n -g -Wall -o test.o _test.c libi2pd.a libi2pdclient.a #obj/libi2pd/*.o obj/i18n/*.o #libi2pd.so
|
||||||
# gcc -o i2pd _test.c libi2pd.a -lstdc++ -llibi2pd -Llibi2pd
|
# gcc -o i2pd _test.c libi2pd.a -lstdc++ -llibi2pd -Llibi2pd
|
||||||
# gcc -Ii18n -I/usr/include/c++/10 -I/usr/include/x86_64-linux-gnu/c++/10 -llibi2pd.a -c test.c -o test.o
|
# gcc -Ii18n -I/usr/include/c++/10 -I/usr/include/x86_64-linux-gnu/c++/10 -llibi2pd.a -c test.c -o test.o
|
||||||
# g++ test.o libi2pd.so libi2pdclient.so -o test.main
|
g++ test.o libi2pd.a libi2pdclient.a libi2pdlang.a -o test.main
|
|
@ -28,10 +28,6 @@
|
||||||
#include "Datagram.h"
|
#include "Datagram.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
namespace client
|
namespace client
|
||||||
|
@ -316,8 +312,4 @@ namespace client
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -20,10 +20,6 @@
|
||||||
#include "Signature.h"
|
#include "Signature.h"
|
||||||
#include "CryptoKey.h"
|
#include "CryptoKey.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace i2p
|
namespace i2p
|
||||||
{
|
{
|
||||||
namespace data
|
namespace data
|
||||||
|
@ -248,8 +244,4 @@ namespace data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
10
libi2pd/api.go
Normal file
10
libi2pd/api.go
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
package api
|
||||||
|
|
||||||
|
/*
|
||||||
|
//void Go_InitI2P (int argc, char argv[], const char * appName){
|
||||||
|
|
||||||
|
//}
|
||||||
|
#cgo CPPFLAGS: -I${SRCDIR}/../i18n -I${SRCDIR}/../libi2pd_client -g -Wall -Wextra -Wno-unused-parameter -pedantic -Wno-psabi -fPIC -D__AES__ -maes
|
||||||
|
#cgo LDFLAGS: -latomic -lcrypto -lssl -lz -lboost_system -lboost_date_time -lboost_filesystem -lboost_program_options -lpthread -lstdc++
|
||||||
|
*/
|
||||||
|
import "C"
|
|
@ -2,14 +2,14 @@
|
||||||
// e.g. map std::string to Go string
|
// e.g. map std::string to Go string
|
||||||
|
|
||||||
%{
|
%{
|
||||||
#include "api.h"
|
#include "capi.h"
|
||||||
//#include "Streaming.h"
|
//#include "Streaming.h"
|
||||||
#include "Destination.h"
|
//#include "Destination.h"
|
||||||
//#include "Identity.h"
|
//#include "Identity.h"
|
||||||
//#include "Tag.h"
|
//#include "Tag.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%include "api.h"
|
%include "capi.h"
|
||||||
//%include "Streaming.h"
|
//%include "Streaming.h"
|
||||||
//%include "Destination.h"
|
//%include "Destination.h"
|
||||||
//%include "Identity.h"
|
//%include "Identity.h"
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void C_InitI2P (int argc, char* argv[], const char * appName)
|
void C_InitI2P (int argc, char argv[], const char * appName)
|
||||||
{
|
{
|
||||||
return i2p::api::InitI2P(argc, argv, appName);
|
return i2p::api::InitI2P(argc, &argv, appName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void C_TerminateI2P ()
|
void C_TerminateI2P ()
|
||||||
|
@ -25,8 +25,9 @@ void C_TerminateI2P ()
|
||||||
|
|
||||||
void C_StartI2P ()//std::ostream *logStream)
|
void C_StartI2P ()//std::ostream *logStream)
|
||||||
{
|
{
|
||||||
// std::shared_ptr<std::ostream> cppLogStream(logStream);
|
std::shared_ptr<std::ostream> logStream;
|
||||||
return i2p::api::StartI2P(nullptr);
|
//cppLogStream(&out);
|
||||||
|
return i2p::api::StartI2P(logStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
void C_StopI2P ()
|
void C_StopI2P ()
|
||||||
|
|
|
@ -9,16 +9,17 @@
|
||||||
#ifndef CAPI_H__
|
#ifndef CAPI_H__
|
||||||
#define CAPI_H__
|
#define CAPI_H__
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Identity.h"
|
#include "Identity.h"
|
||||||
#include "Destination.h"
|
#include "Destination.h"
|
||||||
#include "Streaming.h"
|
#include "Streaming.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
// initialization start and stop
|
// initialization start and stop
|
||||||
void C_InitI2P (int argc, char* argv[], const char * appName);
|
void C_InitI2P (int argc, char argv[], const char * appName);
|
||||||
|
//void C_InitI2P (int argc, char** argv, const char * appName);
|
||||||
void C_TerminateI2P ();
|
void C_TerminateI2P ();
|
||||||
void C_StartI2P (); //std::ostream *logStream = nullptr);
|
void C_StartI2P (); //std::ostream *logStream = nullptr);
|
||||||
// write system log to logStream, if not specified to <appName>.log in application's folder
|
// write system log to logStream, if not specified to <appName>.log in application's folder
|
||||||
|
|
Loading…
Reference in a new issue