Browse Source

Get it to build from go build

pull/1669/head
idk 3 years ago
parent
commit
7bc2e74683
No known key found for this signature in database
GPG Key ID: D75C03B39B5E14E1
  1. 25
      Makefile
  2. 8
      libi2pd/Destination.h
  3. 8
      libi2pd/Identity.h
  4. 10
      libi2pd/api.go
  5. 6
      libi2pd/api.swigcxx
  6. 9
      libi2pd/capi.cpp
  7. 11
      libi2pd/capi.h

25
Makefile

@ -1,6 +1,8 @@ @@ -1,6 +1,8 @@
SYS := $(shell $(CXX) -dumpmachine)
SHLIB := libi2pd.so
ARLIB := libi2pd.a
SHLIB_LANG := libi2pdlang.so
ARLIB_LANG := libi2pdlang.a
SHLIB_CLIENT := libi2pdclient.so
ARLIB_CLIENT := libi2pdclient.a
I2PD := i2pd
@ -26,6 +28,12 @@ else @@ -26,6 +28,12 @@ else
LD_DEBUG = -s
endif
ifeq ($(USE_STATIC),yes)
NEEDED_CXXFLAGS+= -static
else
endif
ifneq (, $(findstring darwin, $(SYS)))
DAEMON_SRC += $(DAEMON_SRC_DIR)/UnixDaemon.cpp
ifeq ($(HOMEBREW),1)
@ -71,6 +79,7 @@ mk_obj_dir: @@ -71,6 +79,7 @@ mk_obj_dir:
api: mk_obj_dir $(SHLIB) $(ARLIB)
client: mk_obj_dir $(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
## **without** overwriting the CXXFLAGS which we need in order to build.
@ -98,12 +107,21 @@ ifneq ($(USE_STATIC),yes) @@ -98,12 +107,21 @@ ifneq ($(USE_STATIC),yes)
$(CXX) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS) $(SHLIB)
endif
$(SHLIB_LANG): $(LANG_OBJS)
ifneq ($(USE_STATIC),yes)
$(CXX) $(LDFLAGS) -shared -o $@ $^ $(LDLIBS)
endif
$(ARLIB): $(LIB_OBJS)
$(AR) -r $@ $^
$(ARLIB_CLIENT): $(LIB_CLIENT_OBJS)
$(AR) -r $@ $^
$(ARLIB_LANG): $(LANG_OBJS)
$(AR) -r $@ $^
clean:
$(RM) -r obj
$(RM) -r docs/generated
@ -151,9 +169,10 @@ flags: @@ -151,9 +169,10 @@ flags:
##TODO: delete this before a PR
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
$(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 -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

8
libi2pd/Destination.h

@ -28,10 +28,6 @@ @@ -28,10 +28,6 @@
#include "Datagram.h"
#include "util.h"
#ifdef __cplusplus
extern "C" {
#endif
namespace i2p
{
namespace client
@ -316,8 +312,4 @@ namespace client @@ -316,8 +312,4 @@ namespace client
}
}
#ifdef __cplusplus
}
#endif
#endif

8
libi2pd/Identity.h

@ -20,10 +20,6 @@ @@ -20,10 +20,6 @@
#include "Signature.h"
#include "CryptoKey.h"
#ifdef __cplusplus
extern "C" {
#endif
namespace i2p
{
namespace data
@ -248,8 +244,4 @@ namespace data @@ -248,8 +244,4 @@ namespace data
}
}
#ifdef __cplusplus
}
#endif
#endif

10
libi2pd/api.go

@ -0,0 +1,10 @@ @@ -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"

6
libi2pd/api.swigcxx

@ -2,14 +2,14 @@ @@ -2,14 +2,14 @@
// e.g. map std::string to Go string
%{
#include "api.h"
#include "capi.h"
//#include "Streaming.h"
#include "Destination.h"
//#include "Destination.h"
//#include "Identity.h"
//#include "Tag.h"
%}
%include "api.h"
%include "capi.h"
//%include "Streaming.h"
//%include "Destination.h"
//%include "Identity.h"

9
libi2pd/capi.cpp

@ -13,9 +13,9 @@ @@ -13,9 +13,9 @@
extern "C" {
#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 ()
@ -25,8 +25,9 @@ void C_TerminateI2P () @@ -25,8 +25,9 @@ void C_TerminateI2P ()
void C_StartI2P ()//std::ostream *logStream)
{
// std::shared_ptr<std::ostream> cppLogStream(logStream);
return i2p::api::StartI2P(nullptr);
std::shared_ptr<std::ostream> logStream;
//cppLogStream(&out);
return i2p::api::StartI2P(logStream);
}
void C_StopI2P ()

11
libi2pd/capi.h

@ -9,16 +9,17 @@ @@ -9,16 +9,17 @@
#ifndef CAPI_H__
#define CAPI_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "Identity.h"
#include "Destination.h"
#include "Streaming.h"
#ifdef __cplusplus
extern "C" {
#endif
// 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_StartI2P (); //std::ostream *logStream = nullptr);
// write system log to logStream, if not specified to <appName>.log in application's folder

Loading…
Cancel
Save