updated unit tests, makefile targets
This commit is contained in:
188
make-mac.mk
188
make-mac.mk
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Makefile for ZeroTier SDK on OSX
|
||||
# Makefile for ZeroTier SDK on macOS
|
||||
#
|
||||
# Targets
|
||||
# all: build every target possible on host system, plus tests
|
||||
@@ -7,6 +7,30 @@
|
||||
# tests: build only test applications for host system
|
||||
# clean: removes all built files, objects, other trash
|
||||
|
||||
# Build everything
|
||||
all: one osx ios android lwip pico check
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# ----------------------------------- Config -----------------------------------
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# Automagically pick clang or gcc, with preference for clang
|
||||
# This is only done if we have not overridden these with an environment or CLI variable
|
||||
ifeq ($(origin CC),default)
|
||||
CC=$(shell if [ -e /usr/bin/clang ]; then echo clang; else echo gcc; fi)
|
||||
endif
|
||||
ifeq ($(origin CXX),default)
|
||||
CXX=$(shell if [ -e /usr/bin/clang++ ]; then echo clang++; else echo g++; fi)
|
||||
endif
|
||||
|
||||
INCLUDES=
|
||||
DEFS=
|
||||
ARCH_FLAGS=-arch x86_64
|
||||
CFLAGS=
|
||||
CXXFLAGS=$(CFLAGS) -fno-rtti
|
||||
|
||||
include objects.mk
|
||||
|
||||
# Target output filenames
|
||||
SHARED_LIB_NAME = libztosx.so
|
||||
INTERCEPT_NAME = libztintercept.so
|
||||
@@ -18,7 +42,7 @@ LWIP_LIB_NAME = liblwip.so
|
||||
PICO_LIB_NAME = libpicotcp.so
|
||||
#
|
||||
SHARED_LIB = $(BUILD)/$(SHARED_LIB_NAME)
|
||||
INTERCEPT = $(BUILD)/$(INTERCEPT_NAME)
|
||||
SDK_INTERCEPT = $(BUILD)/$(INTERCEPT_NAME)
|
||||
SDK_SERVICE = $(BUILD)/$(SDK_SERVICE_NAME)
|
||||
ONE_SERVICE = $(BUILD)/$(ONE_SERVICE_NAME)
|
||||
ONE_CLI = $(BUILD)/$(ONE_CLI_NAME)
|
||||
@@ -41,25 +65,23 @@ SDK_INTERCEPT_C_FILES:=src/sockets.c \
|
||||
src/intercept.c \
|
||||
src/rpc.c
|
||||
|
||||
INCLUDES+= -Iext \
|
||||
-I$(ZT1)/osdep \
|
||||
-I$(ZT1)/node \
|
||||
-I$(ZT1)/service \
|
||||
-I../$(ZT1)/osdep \
|
||||
-I../$(ZT1)/node \
|
||||
-I../$(ZT1)/service \
|
||||
-I. \
|
||||
-Isrc \
|
||||
-Isrc/stack_drivers
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# --------------------------------- ZT Config ----------------------------------
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
ZTFLAGS:=-DSDK -DZT_ONE_NO_ROOT_CHECK
|
||||
|
||||
# Automagically pick clang or gcc, with preference for clang
|
||||
# This is only done if we have not overridden these with an environment or CLI variable
|
||||
ifeq ($(origin CC),default)
|
||||
CC=$(shell if [ -e /usr/bin/clang ]; then echo clang; else echo gcc; fi)
|
||||
endif
|
||||
ifeq ($(origin CXX),default)
|
||||
CXX=$(shell if [ -e /usr/bin/clang++ ]; then echo clang++; else echo g++; fi)
|
||||
endif
|
||||
|
||||
INCLUDES=
|
||||
DEFS=
|
||||
LIBS=
|
||||
ARCH_FLAGS=-arch x86_64
|
||||
CFLAGS=
|
||||
|
||||
include objects.mk
|
||||
|
||||
# Disable codesign since open source users will not have ZeroTier's certs
|
||||
CODESIGN=echo
|
||||
PRODUCTSIGN=echo
|
||||
@@ -80,58 +102,48 @@ else
|
||||
STRIP=strip
|
||||
endif
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# -------------------------------- SDK Config ----------------------------------
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# Debug output for the SDK
|
||||
# Specific levels can be controlled in src/debug.h
|
||||
ifeq ($(SDK_DEBUG),1)
|
||||
DEFS+=-DSDK_DEBUG -g
|
||||
endif
|
||||
|
||||
CXXFLAGS=$(CFLAGS) -fno-rtti
|
||||
|
||||
INCLUDES+= -Iext \
|
||||
-I$(ZT1)/osdep \
|
||||
-I$(ZT1)/node \
|
||||
-I$(ZT1)/service \
|
||||
-I../$(ZT1)/osdep \
|
||||
-I../$(ZT1)/node \
|
||||
-I../$(ZT1)/service \
|
||||
-I. \
|
||||
-Isrc \
|
||||
-Isrc/stack_drivers \
|
||||
-I$(LWIP_DIR)/src/include \
|
||||
-I$(LWIP_DIR)/src/include/ipv4 \
|
||||
-I$(LWIP_DIR)/src/include/ipv6 \
|
||||
-I$(PICOTCP_DIR)/include \
|
||||
-I$(PICOTCP_DIR)/build/include \
|
||||
-Isrc/stack_drivers/lwip \
|
||||
-Isrc/stack_drivers/picotcp \
|
||||
-Isrc/stack_drivers/jip
|
||||
|
||||
|
||||
# Stack selection / parameters
|
||||
|
||||
# lwIP debug
|
||||
ifeq ($(SDK_LWIP_DEBUG),1)
|
||||
LWIP_FLAGS+=SDK_LWIP_DEBUG=1
|
||||
endif
|
||||
# ------------------------------------------------------------------------------
|
||||
# ------------------------ Network Stack Configuration -------------------------
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# lwIP
|
||||
ifeq ($(SDK_LWIP),1)
|
||||
STACK_FLAGS+=-DSDK_LWIP
|
||||
INCLUDES+= -I$(LWIP_DIR)/src/include \
|
||||
-I$(LWIP_DIR)/src/include/ipv4 \
|
||||
-I$(LWIP_DIR)/src/include/ipv6 \
|
||||
-Isrc/stack_drivers/lwip
|
||||
|
||||
ifeq ($(SDK_LWIP_DEBUG),1)
|
||||
LWIP_FLAGS+=SDK_LWIP_DEBUG=1
|
||||
endif
|
||||
endif
|
||||
|
||||
# picoTCP
|
||||
ifeq ($(SDK_PICOTCP),1)
|
||||
STACK_FLAGS+=-DSDK_PICOTCP
|
||||
INCLUDES+= -I$(PICOTCP_DIR)/include \
|
||||
-I$(PICOTCP_DIR)/build/include \
|
||||
-Isrc/stack_drivers/picotcp
|
||||
endif
|
||||
|
||||
# jip
|
||||
ifeq ($(SDK_JIP),1)
|
||||
STACK_FLAGS+=-DSDK_JIP
|
||||
INCLUDES+= -Isrc/stack_drivers/jip
|
||||
endif
|
||||
|
||||
|
||||
|
||||
# TCP protocol version
|
||||
ifeq ($(SDK_IPV4),1)
|
||||
LWIP_FLAGS+=SDK_IPV4=1
|
||||
@@ -143,14 +155,6 @@ ifeq ($(SDK_IPV6),1)
|
||||
STACK_FLAGS+=-DSDK_IPV6
|
||||
endif
|
||||
|
||||
|
||||
# ------ MISC TARGETS ------
|
||||
# Build everything
|
||||
all: one osx ios android lwip check
|
||||
|
||||
|
||||
|
||||
# --- EXTERNAL LIBRARIES ---
|
||||
lwip:
|
||||
-make -f make-liblwip.mk $(LWIP_FLAGS)
|
||||
|
||||
@@ -163,25 +167,28 @@ pico:
|
||||
jip:
|
||||
-make -f make-jip.mk $(JIP_FLAGS)
|
||||
|
||||
# ------- IOS / OSX --------
|
||||
# ------------------------------------------------------------------------------
|
||||
# -------------------------------- IOS / macOS ---------------------------------
|
||||
# ------------------------------------------------------------------------------
|
||||
# Build all Apple targets
|
||||
apple: one osx ios
|
||||
|
||||
|
||||
# Build vanilla ZeroTier One binary
|
||||
one: $(OBJS) $(ZT1)/service/OneService.o $(ZT1)/one.o $(ZT1)/osdep/OSXEthernetTap.o
|
||||
mkdir -p $(BUILD)
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $(BUILD)/zerotier-one $(OBJS) $(ZT1)/service/OneService.o $(ZT1)/one.o $(ZT1)/osdep/OSXEthernetTap.o $(LDLIBS)
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $(BUILD)/zerotier-one $(OBJS) $(ZT1)/service/OneService.o $(ZT1)/one.o $(ZT1)/osdep/OSXEthernetTap.o
|
||||
$(STRIP) $(ONE_SERVICE)
|
||||
cp $(ONE_SERVICE) $(INT)/docker/docker_demo/$(ONE_SERVICE_NAME)
|
||||
|
||||
# Build all iOS targets
|
||||
ios: ios_app_framework ios_unity3d_bundle
|
||||
|
||||
|
||||
# Build all OSX targets
|
||||
osx: osx_app_framework osx_unity3d_bundle osx_shared_lib osx_sdk_service osx_intercept
|
||||
|
||||
# ---------------------------------------
|
||||
# ----------- App Frameworks ------------
|
||||
# ---------------------------------------
|
||||
|
||||
# TODO: CHECK if XCODE TOOLS are installed
|
||||
# Build frameworks for application development
|
||||
@@ -189,11 +196,15 @@ osx_app_framework:
|
||||
cd $(INT)/apple/ZeroTierSDK_Apple; xcodebuild -configuration Release -scheme ZeroTierSDK_OSX build SYMROOT="../../../$(BUILD)/osx_app_framework"
|
||||
cd $(INT)/apple/ZeroTierSDK_Apple; xcodebuild -configuration Debug -scheme ZeroTierSDK_OSX build SYMROOT="../../../$(BUILD)/osx_app_framework"
|
||||
cp docs/osx.md $(BUILD)/osx_app_framework/README.md
|
||||
|
||||
ios_app_framework:
|
||||
cd $(INT)/apple/ZeroTierSDK_Apple; xcodebuild -configuration Release -scheme ZeroTierSDK_iOS build SYMROOT="../../../$(BUILD)/ios_app_framework"
|
||||
cd $(INT)/apple/ZeroTierSDK_Apple; xcodebuild -configuration Debug -scheme ZeroTierSDK_iOS build SYMROOT="../../../$(BUILD)/ios_app_framework"
|
||||
cp docs/ios.md $(BUILD)/ios_app_framework/README.md
|
||||
|
||||
# ---------------------------------------
|
||||
# ------------ Unity Bundles ------------
|
||||
# ---------------------------------------
|
||||
|
||||
# Build bundles for Unity integrations
|
||||
osx_unity3d_bundle:
|
||||
@@ -203,59 +214,55 @@ osx_unity3d_bundle:
|
||||
chmod 755 $(BUILD)/osx_unity3d_bundle/Debug/ZeroTierSDK_Unity3D_OSX.bundle
|
||||
cp -p -R $(BUILD)/osx_unity3d_bundle/Debug/ZeroTierSDK_Unity3D_OSX.bundle $(INT)/Unity3D/Assets/Plugins
|
||||
|
||||
|
||||
ios_unity3d_bundle:
|
||||
cd $(INT)/apple/ZeroTierSDK_Apple; xcodebuild -configuration Release -scheme ZeroTierSDK_Unity3D_iOS build SYMROOT="../../../$(BUILD)/ios_unity3d_bundle"
|
||||
cd $(INT)/apple/ZeroTierSDK_Apple; xcodebuild -configuration Debug -scheme ZeroTierSDK_Unity3D_iOS build SYMROOT="../../../$(BUILD)/ios_unity3d_bundle"
|
||||
cp docs/ios_unity3d.md $(BUILD)/ios_unity3d_bundle/README.md
|
||||
|
||||
#
|
||||
simple_app: tests osx_service_and_intercept
|
||||
mkdir -p build/simple_app
|
||||
mkdir -p build/tests/zerotier
|
||||
$(CXX) -Isrc $(SHARED_LIB) integrations/simple_app/app.cpp -o $(BUILD)/simple_app/app
|
||||
cp $(LWIP_LIB) $(BUILD)/tests/zerotier/$(LWIP_LIB_NAME)
|
||||
|
||||
|
||||
remove_only_intermediates:
|
||||
-find . -type f \( -name '*.o' -o -name '*.so' \) -delete
|
||||
|
||||
# ---------------------------------------
|
||||
# --------------- Intercept -------------
|
||||
# ---------------------------------------
|
||||
|
||||
osx_intercept:
|
||||
# Use gcc not clang to build standalone intercept library since gcc is typically used for libc and we want to ensure maximal ABI compatibility
|
||||
gcc $(DEFS) $(INCLUDES) -g -O2 -Wall -std=c99 -fPIC -DVERBOSE -D_GNU_SOURCE -DSDK_INTERCEPT -nostdlib -nostdlib -shared -o $(INTERCEPT) $(SDK_INTERCEPT_C_FILES) -ldl
|
||||
gcc $(DEFS) $(INCLUDES) -g -O2 -Wall -std=c99 -fPIC -DVERBOSE -D_GNU_SOURCE -DSDK_INTERCEPT -nostdlib -nostdlib -shared -o $(SDK_INTERCEPT) $(SDK_INTERCEPT_C_FILES) -ldl
|
||||
|
||||
# ---------------------------------------
|
||||
# ----- Service Library Combinations ----
|
||||
# ---------------------------------------
|
||||
|
||||
# Build only the SDK service
|
||||
ifeq ($(SDK_LWIP),1)
|
||||
osx_sdk_service: lwip $(OBJS)
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(STACK_FLAGS) $(DEFS) $(INCLUDES) $(ZTFLAGS) -DSDK_SERVICE -o $(SDK_SERVICE) $(OBJS) $(LWIP_DRIVER_FILES) $(SDK_SERVICE_CPP_FILES) $(SDK_SERVICE_C_FILES) $(LDLIBS) -ldl
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(STACK_FLAGS) $(DEFS) $(INCLUDES) $(ZTFLAGS) -DSDK_SERVICE -o $(SDK_SERVICE) $(OBJS) $(LWIP_DRIVER_FILES) $(SDK_SERVICE_CPP_FILES) $(SDK_SERVICE_C_FILES) -ldl
|
||||
else
|
||||
osx_sdk_service: pico $(OBJS)
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(STACK_FLAGS) $(DEFS) $(INCLUDES) $(ZTFLAGS) -DSDK_SERVICE -o $(SDK_SERVICE) $(OBJS) $(PICO_DRIVER_FILES) $(SDK_SERVICE_CPP_FILES) $(SDK_SERVICE_C_FILES) $(LDLIBS) -ldl
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(STACK_FLAGS) $(DEFS) $(INCLUDES) $(ZTFLAGS) -DSDK_SERVICE -o $(SDK_SERVICE) $(OBJS) $(PICO_DRIVER_FILES) $(SDK_SERVICE_CPP_FILES) $(SDK_SERVICE_C_FILES) -ldl
|
||||
endif
|
||||
ln -sf $(SDK_SERVICE_NAME) $(BUILD)/zerotier-cli
|
||||
ln -sf $(SDK_SERVICE_NAME) $(BUILD)/zerotier-idtool
|
||||
|
||||
|
||||
# Build both intercept library and SDK service (separate)
|
||||
osx_service_and_intercept: osx_intercept osx_sdk_service
|
||||
|
||||
# Builds a single shared library which contains everything
|
||||
osx_shared_lib: pico $(OBJS)
|
||||
osx_static_lib: pico $(OBJS)
|
||||
$(CXX) $(CXXFLAGS) $(STACK_FLAGS) $(DEFS) $(INCLUDES) $(ZTFLAGS) -DSDK_SERVICE -DSDK -DSDK_BUNDLED $(PICO_DRIVER_FILES) $(SDK_INTERCEPT_C_FILES) $(SDK_SERVICE_CPP_FILES) src/service.cpp -c
|
||||
libtool -static -o build/libzt.a zerotierone/node/IncomingPacket.o picotcp.o proxy.o tap.o one.o OneService.o service.o sockets.o rpc.o intercept.o OneService.o $(OBJS)
|
||||
libtool -static -o build/libzt.a picotcp.o proxy.o tap.o one.o OneService.o service.o sockets.o rpc.o intercept.o OneService.o $(OBJS)
|
||||
|
||||
# Builds zts_* library tests
|
||||
osx_shared_lib_tests:
|
||||
osx_static_lib_tests:
|
||||
mkdir -p $(TEST_OBJDIR)
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(INCLUDES) $(STACK_FLAGS) $(DEFS) -DSDK_SERVICE -DSDK -DSDK_BUNDLED -Isrc tests/shared_test/zts.tcpserver4.c -o $(TEST_OBJDIR)/$(OSTYPE).zts.tcpserver4.out -Lbuild -lzt -ldl
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(INCLUDES) $(STACK_FLAGS) $(DEFS) -DSDK_SERVICE -DSDK -DSDK_BUNDLED -Isrc tests/shared_test/zts.tcpclient4.c -o $(TEST_OBJDIR)/$(OSTYPE).zts.tcpclient4.out -Lbuild -lzt -ldl
|
||||
|
||||
osx_dynamic_lib:
|
||||
|
||||
osx_dynamic_lib_tests:
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# ---------------------------------- Android -----------------------------------
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# -------- ANDROID ---------
|
||||
# Build all Android targets
|
||||
# Chip architectures can be specified in integrations/android/android_jni_lib/java/jni/Application.mk
|
||||
android: android_jni_lib
|
||||
@@ -271,15 +278,15 @@ android_jni_lib:
|
||||
mv -f $(INT)/android/android_jni_lib/java/libs/* $(BUILD)/android_jni_lib
|
||||
cp -R $(BUILD)/android_jni_lib/* $(INT)/android/example_app/app/src/main/jniLibs
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# ---------------------------------- Testing -----------------------------------
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
# -------- TESTING ---------
|
||||
# Check for the presence of built frameworks/bundles/libaries
|
||||
check:
|
||||
-./check.sh $(LWIP_LIB)
|
||||
-./check.sh $(PICO_LIB)
|
||||
-./check.sh $(INTERCEPT)
|
||||
-./check.sh $(SDK_INTERCEPT)
|
||||
-./check.sh $(ONE_SERVICE)
|
||||
-./check.sh $(SDK_SERVICE)
|
||||
-./check.sh $(SHARED_LIB)
|
||||
@@ -312,17 +319,12 @@ tests: $(TEST_OBJDIR) $(TEST_TARGETS)
|
||||
mkdir -p build/tests/zerotier
|
||||
|
||||
test_suite: tests lwip osx_service_and_intercept
|
||||
cp tests/api_test/test.sh $(BUILD)/tests/test.sh
|
||||
cp tests/api_test/servers.sh $(BUILD)/tests/servers.sh
|
||||
cp tests/api_test/clients.sh $(BUILD)/tests/clients.sh
|
||||
cp tests/cleanup.sh $(BUILD)/tests/cleanup.sh
|
||||
cp $(LWIP_LIB) $(BUILD)/tests/zerotier/$(LWIP_LIB_NAME)
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# ------------------------------ Administrative --------------------------------
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# ----- ADMINISTRATIVE -----
|
||||
JAVAC := $(shell which javac)
|
||||
|
||||
clean_unity:
|
||||
|
||||
clean_android:
|
||||
# android JNI lib project
|
||||
|
||||
Reference in New Issue
Block a user