N2N and Godot runtime with embedded edge now building for Linux and Windows.

This commit is contained in:
Scott Duensing 2023-09-23 19:25:15 -05:00
parent f16608815f
commit 256c493e82
6 changed files with 151 additions and 19 deletions

2
.gitignore vendored
View file

@ -1,6 +1,8 @@
*~
output.log
bin/
n2n/CMakeLists.txt
n2n/include/config.h
modules/embedded/embeds/
hamncheese/export_presets.cfg
temp/

85
N2NCMakeLists.txt Normal file
View file

@ -0,0 +1,85 @@
cmake_minimum_required(VERSION 3.22)
project(n2n VERSION 3.1.1)
set(N2N_SOURCE
src/aes.c
src/auth.c
src/cc20.c
src/curve25519.c
src/edge_management.c
src/edge_utils.c
src/header_encryption.c
src/hexdump.c
src/json.c
src/management.c
src/minilzo.c
src/n2n.c
src/n2n_port_mapping.c
src/n2n_regex.c
src/network_traffic_filter.c
src/pearson.c
src/random_numbers.c
src/sn_management.c
src/sn_selection.c
src/sn_utils.c
src/speck.c
src/tf.c
src/transform_aes.c
src/transform_cc20.c
src/transform_lzo.c
src/transform_null.c
src/transform_speck.c
src/transform_tf.c
src/transform_zstd.c
src/tuntap_freebsd.c
src/tuntap_linux.c
src/tuntap_netbsd.c
src/tuntap_osx.c
src/wire.c
)
if(DEFINED WIN32)
set(WIN_IS_DUMB "lib")
endif()
set(N2N_LIBS
n2n
${CMAKE_SOURCE_DIR}/thirdparty/libnatpmp/build/libnatpmp.a
${CMAKE_SOURCE_DIR}/thirdparty/miniupnp/miniupnpc/build/${WIN_IS_DUMB}libminiupnpc.a
)
if(DEFINED WIN32)
set(N2N_SOURCE
${N2N_SOURCE}
src/win32/edge_utils_win32.c
src/win32/getopt1.c
src/win32/getopt.c
src/win32/wintap.c
)
set(N2N_LIBS
${N2N_LIBS}
netapi32
ws2_32
iphlpapi
)
endif()
include_directories(
include
${CMAKE_SOURCE_DIR}/thirdparty/libnatpmp/build
${CMAKE_SOURCE_DIR}/thirdparty/miniupnp/miniupnpc/build
)
add_definitions(
-O2
-DNDEBUG
)
add_library(n2n ${N2N_SOURCE})
add_executable(edge src/edge.c)
target_link_libraries(edge ${N2N_LIBS})
add_executable(supernode src/supernode.c)
target_link_libraries(supernode ${N2N_LIBS})

44
N2Nconfig.h Normal file
View file

@ -0,0 +1,44 @@
/* include/config.h. Generated from config.h.in by configure. */
/* include/config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the `cap' library (-lcap). */
/* #undef HAVE_LIBCAP */
/* Define to 1 if you have the `crypto' library (-lcrypto). */
/* #undef HAVE_LIBCRYPTO */
/* Define to 1 if you have the `miniupnpc' library (-lminiupnpc). */
#define HAVE_LIBMINIUPNPC 1
/* Define to 1 if you have the `natpmp' library (-lnatpmp). */
#define HAVE_LIBNATPMP 1
/* Define to 1 if you have the `pcap' library (-lpcap). */
/* #undef HAVE_LIBPCAP */
/* Define to 1 if you have the `pthread' library (-lpthread). */
//#define HAVE_LIBPTHREAD 1
/* Define to 1 if you have the `zstd' library (-lzstd). */
/* #undef HAVE_LIBZSTD */
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Last change date */
#define PACKAGE_BUILDDATE "Sat Sep 23 18:31:22 CDT 2023"
/* Define to the full name of this package. */
#define PACKAGE_NAME "edge"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "edge 3.1.1"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "edge"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "3.1.1"

View file

@ -67,6 +67,7 @@ LTO="lto=none" # Use "lto=full" for releases.
pushd bin
mkdir -p ../modules/embedded/embeds
createEmbeddedBinary x86_64-linux-gnu-edge ../modules/embedded/embeds/linux_x86_64.h EDGE_H
createEmbeddedBinary x86_64-w64-mingw32-edge.exe ../modules/embedded/embeds/windows_x86_64.h EDGE_H
popd
pushd godot
@ -85,6 +86,7 @@ scons compiledb=yes
# Build Templates.
scons platform=linuxbsd target=template_release arch=x86_64 ${TEMPLATE} ${LTO}
scons platform=windows target=template_release arch=x86_64 ${TEMPLATE} ${LTO}
popd

View file

@ -10,6 +10,7 @@ mkdir -p bin
function buildn2n() {
TRIPLE=$1
SUFFIX=$2
TOOLCHAIN=${BUILDROOT}/cmake/${TRIPLE}.cmake
pushd n2n/thirdparty/libnatpmp
@ -24,30 +25,28 @@ function buildn2n() {
pushd n2n/thirdparty/miniupnp/miniupnpc
[[ -d build ]] && rm -rf build
mkdir -p build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN} ..
make
popd
pushd n2n
./autogen.sh
CFLAGS="-I ${BUILDROOT}/n2n/thirdparty/libnatpmp -I ${BUILDROOT}/n2n/thirdparty/miniupnp/miniupnpc/include" \
LDFLAGS="-L ${BUILDROOT}/n2n/thirdparty/libnatpmp/build -L ${BUILDROOT}/n2n/thirdparty/miniupnp/miniupnpc/build" \
./configure \
--target=${TRIPLE} \
--host=${TRIPLE} \
--build=x86_64-linux \
--enable-pthread \
--enable-natpmp \
--enable-miniupnp
make edge
make supernode
upx -9 edge
upx -9 supernode
mv edge ../bin/${TRIPLE}-edge
mv supernode ../bin/${TRIPLE}-supernode
cd include
ln -f -s ../../N2Nconfig.h config.h
cd ..
ln -f -s ../N2NCMakeLists.txt CMakeLists.txt
[[ -d build ]] && rm -rf build
mkdir -p build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN} ..
make
upx -9 edge${SUFFIX}
upx -9 supernode${SUFFIX}
mv edge${SUFFIX} ../../bin/${TRIPLE}-edge${SUFFIX}
mv supernode${SUFFIX} ../../bin/${TRIPLE}-supernode${SUFFIX}
popd
}
buildn2n "x86_64-linux-gnu"
buildn2n "x86_64-w64-mingw32"
buildn2n "x86_64-w64-mingw32" ".exe"

View file

@ -16,8 +16,8 @@ extern "C" {
#endif
#elif _WIN32
#include "embeds/windows_x86_64.h"
unsigned char *data = x86_64_w64_mingw32_edge;
size_t length = (size_t)x86_64_w64_mingw32_edge_len;
unsigned char *data = x86_64_w64_mingw32_edge_exe;
size_t length = (size_t)x86_64_w64_mingw32_edge_exe_len;
#elif __APPLE__
#ifdef __arm__
#include "embeds/macos_arm64.h"