docker test update + makefile update
This commit is contained in:
4
Makefile
4
Makefile
@@ -1,5 +1,9 @@
|
|||||||
# Common makefile -- loads make rules for each platform
|
# Common makefile -- loads make rules for each platform
|
||||||
|
|
||||||
|
BUILD=build
|
||||||
|
INT=integrations
|
||||||
|
ZT1=zerotierone
|
||||||
|
|
||||||
OSTYPE=$(shell uname -s)
|
OSTYPE=$(shell uname -s)
|
||||||
|
|
||||||
ifeq ($(OSTYPE),Darwin)
|
ifeq ($(OSTYPE),Darwin)
|
||||||
|
|||||||
@@ -69,3 +69,8 @@ At this point, simply run your application as you normally would. It will be aut
|
|||||||
**Additional info**
|
**Additional info**
|
||||||
If you'd like to know the IP address your service can be reached at on this particular virtual network, use the following:
|
If you'd like to know the IP address your service can be reached at on this particular virtual network, use the following:
|
||||||
`zerotier-cli -D/var/lib/zerotier-one/nc_XXXXXXXXXXXXXXXX listnetworks`
|
`zerotier-cli -D/var/lib/zerotier-one/nc_XXXXXXXXXXXXXXXX listnetworks`
|
||||||
|
|
||||||
|
|
||||||
|
***
|
||||||
|
`docker exec -it 'container id' /bin/bash`
|
||||||
|
|
||||||
|
|||||||
5
integrations/docker/_remove_all.sh
Executable file
5
integrations/docker/_remove_all.sh
Executable file
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Delete all containers
|
||||||
|
docker rm $(docker ps -a -q)
|
||||||
|
# Delete all images
|
||||||
|
docker rmi $(docker images -q)
|
||||||
0
integrations/docker/docker_demo/docker_demo.name
Normal file
0
integrations/docker/docker_demo/docker_demo.name
Normal file
3
integrations/docker/docker_demo/hello.lua
Normal file
3
integrations/docker/docker_demo/hello.lua
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
local msg = "welcome to the machine!"
|
||||||
|
redis.call("SET", "msg", msg)
|
||||||
|
return redis.call("GET", "msg")
|
||||||
28
integrations/docker/docker_demo/monitor_dockerfile
Normal file
28
integrations/docker/docker_demo/monitor_dockerfile
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
# ZT SDK Test Monitor
|
||||||
|
FROM fedora:23
|
||||||
|
MAINTAINER https://www.zerotier.com/
|
||||||
|
|
||||||
|
RUN yum -y install redis-3.0.4-1.fc23.x86_64
|
||||||
|
|
||||||
|
EXPOSE 9993/udp
|
||||||
|
|
||||||
|
# Add ZT files
|
||||||
|
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||||
|
ADD monitor_identity.public /var/lib/zerotier-one/identity.public
|
||||||
|
ADD monitor_identity.secret /var/lib/zerotier-one/identity.secret
|
||||||
|
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||||
|
ADD *.conf /
|
||||||
|
ADD *.name /
|
||||||
|
|
||||||
|
# Install LWIP library used by service
|
||||||
|
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||||
|
|
||||||
|
ADD hello.lua /
|
||||||
|
|
||||||
|
ADD zerotier-one /
|
||||||
|
ADD zerotier-cli /
|
||||||
|
|
||||||
|
# Start ZeroTier-One
|
||||||
|
ADD monitor_entrypoint.sh /monitor_entrypoint.sh
|
||||||
|
RUN chmod -v +x /monitor_entrypoint.sh
|
||||||
|
CMD ["./monitor_entrypoint.sh"]
|
||||||
56
integrations/docker/docker_demo/monitor_entrypoint.sh
Normal file
56
integrations/docker/docker_demo/monitor_entrypoint.sh
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||||
|
|
||||||
|
|
||||||
|
# --- Test Parameters ---
|
||||||
|
test_namefile=$(ls *.name)
|
||||||
|
test_name="${test_namefile%.*}" # test network id
|
||||||
|
nwconf=$(ls *.conf) # blank test network config file
|
||||||
|
nwid="${nwconf%.*}" # test network id
|
||||||
|
sdk_wait_time=25 # wait for test container to come online
|
||||||
|
app_timeout_time=15 # app-specific timeout
|
||||||
|
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||||
|
file_base="$test_name".txt # test result output file
|
||||||
|
fail=FAIL. # appended to result file in event of failure
|
||||||
|
ok=OK. # appended to result file in event of success
|
||||||
|
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||||
|
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||||
|
|
||||||
|
|
||||||
|
# --- Network Config ---
|
||||||
|
echo '*** ZeroTier SDK Test Monitor'
|
||||||
|
chown -R daemon /var/lib/zerotier-one
|
||||||
|
chgrp -R daemon /var/lib/zerotier-one
|
||||||
|
su daemon -s /bin/bash -c '/zerotier-one -d -U -p9993 >>/tmp/zerotier-one.out 2>&1'
|
||||||
|
virtip4=""
|
||||||
|
while [ -z "$virtip4" ]; do
|
||||||
|
sleep 0.2
|
||||||
|
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||||
|
done
|
||||||
|
echo '*** Starting Test...'
|
||||||
|
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||||
|
echo '*** Sleeping for (' "$sdk_wait_time" 's ) while we wait for the container to come online...'
|
||||||
|
sleep "$sdk_wait_time"s
|
||||||
|
ncvirtip=$(<$address_file)
|
||||||
|
|
||||||
|
|
||||||
|
# --- Test section ---
|
||||||
|
echo '*** Running lua script against redis host at' $ncvirtip
|
||||||
|
redis-cli -h $ncvirtip EVAL "$(cat hello.lua)" 0 > redis_response.txt
|
||||||
|
response_string=$(<redis_response.txt)
|
||||||
|
|
||||||
|
if [[ $response_string == *"welcome to the machine!"* ]]
|
||||||
|
then
|
||||||
|
echo 'REDIS RESPONSE OK'
|
||||||
|
touch "$file_path$ok$test_name.txt"
|
||||||
|
printf 'Test: redis-server responded!\n' >> "$file_path$ok$test_name.txt"
|
||||||
|
else
|
||||||
|
echo 'REDIS RESPONSE FAIL'
|
||||||
|
touch "$file_path$fail$test_name.txt"
|
||||||
|
printf 'Test: redis server did NOT respond!\n' >> "$file_path$fail$test_name.txt"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
36
integrations/docker/docker_demo/sdk_dockerfile
Normal file
36
integrations/docker/docker_demo/sdk_dockerfile
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
# ZT SDK Test
|
||||||
|
FROM fedora:23
|
||||||
|
MAINTAINER https://www.zerotier.com/
|
||||||
|
|
||||||
|
# Install apps
|
||||||
|
RUN yum -y update
|
||||||
|
RUN yum -y install redis-3.0.4-1.fc23.x86_64
|
||||||
|
RUN yum clean all
|
||||||
|
|
||||||
|
# Add ZT files
|
||||||
|
RUN mkdir -p /var/lib/zerotier-one/networks.d
|
||||||
|
ADD sdk_identity.public /var/lib/zerotier-one/identity.public
|
||||||
|
ADD sdk_identity.secret /var/lib/zerotier-one/identity.secret
|
||||||
|
ADD *.conf /var/lib/zerotier-one/networks.d/
|
||||||
|
ADD *.conf /
|
||||||
|
ADD *.name /
|
||||||
|
|
||||||
|
EXPOSE 9993/udp 6379/udp
|
||||||
|
|
||||||
|
# Install LWIP library used by service
|
||||||
|
ADD liblwip.so /var/lib/zerotier-one/liblwip.so
|
||||||
|
|
||||||
|
# Install syscall intercept library
|
||||||
|
ADD libztintercept.so /
|
||||||
|
RUN cp libztintercept.so lib/libztintercept.so
|
||||||
|
RUN ln -sf /lib/libztintercept.so /lib/libzerotierintercept
|
||||||
|
|
||||||
|
ADD zerotier-cli /
|
||||||
|
Add zerotier-sdk-service /
|
||||||
|
|
||||||
|
# Install test scripts
|
||||||
|
ADD sdk_entrypoint.sh /sdk_entrypoint.sh
|
||||||
|
RUN chmod -v +x /sdk_entrypoint.sh
|
||||||
|
|
||||||
|
# Start ZeroTier-One
|
||||||
|
CMD ["./sdk_entrypoint.sh"]
|
||||||
38
integrations/docker/docker_demo/sdk_entrypoint.sh
Normal file
38
integrations/docker/docker_demo/sdk_entrypoint.sh
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/
|
||||||
|
|
||||||
|
|
||||||
|
# --- Test Parameters ---
|
||||||
|
test_namefile=$(ls *.name)
|
||||||
|
test_name="${test_namefile%.*}" # test network id
|
||||||
|
nwconf=$(ls *.conf) # blank test network config file
|
||||||
|
nwid="${nwconf%.*}" # test network id
|
||||||
|
file_path=/opt/results/ # test result output file path (fs shared between host and containers)
|
||||||
|
file_base="$test_name".txt # test result output file
|
||||||
|
tmp_ext=.tmp # temporary filetype used for sharing test data between containers
|
||||||
|
address_file="$file_path$test_name"_addr"$tmp_ext" # file shared between host and containers for sharing address (optional)
|
||||||
|
|
||||||
|
|
||||||
|
# --- Network Config ---
|
||||||
|
echo '*** ZeroTier SDK Test: ' "$test_name"
|
||||||
|
chown -R daemon /var/lib/zerotier-one
|
||||||
|
chgrp -R daemon /var/lib/zerotier-one
|
||||||
|
su daemon -s /bin/bash -c '/zerotier-sdk-service -d -U -p9993 >>/tmp/zerotier-sdk-service.out 2>&1'
|
||||||
|
virtip4=""
|
||||||
|
while [ -z "$virtip4" ]; do
|
||||||
|
sleep 0.2
|
||||||
|
virtip4=`/zerotier-cli listnetworks | grep -F $nwid | cut -d ' ' -f 9 | sed 's/,/\n/g' | grep -F '.' | cut -d / -f 1`
|
||||||
|
dev=`/zerotier-cli listnetworks | grep -F "" | cut -d ' ' -f 8 | cut -d "_" -f 2 | sed "s/^<dev>//" | tr '\n' '\0'`
|
||||||
|
done
|
||||||
|
echo '*** Up and running at' $virtip4 ' on network: ' $nwid
|
||||||
|
echo '*** Writing address to ' "$address_file"
|
||||||
|
echo $virtip4 > "$address_file"
|
||||||
|
|
||||||
|
# --- Test section ---
|
||||||
|
echo '*** Starting application...'
|
||||||
|
sleep 0.5
|
||||||
|
|
||||||
|
export ZT_NC_NETWORK=/var/lib/zerotier-one/nc_"$dev"
|
||||||
|
export LD_PRELOAD=./libztintercept.so
|
||||||
|
/usr/bin/redis-server --port 6379
|
||||||
8
integrations/docker/docker_demo/start.sh
Executable file
8
integrations/docker/docker_demo/start.sh
Executable file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Runs test image and monitor image as daemons
|
||||||
|
test_name=${PWD##*/}
|
||||||
|
echo 'Starting containers for: ' "$test_name"
|
||||||
|
touch "$test_name".name
|
||||||
|
test_container=$(docker run -d -it -v $PWD/_results:/opt/results --device=/dev/net/tun "$test_name":latest)
|
||||||
|
monitor_container=$(docker run -d -it -v $PWD/_results:/opt/results --device=/dev/net/tun "$test_name"_monitor:latest)
|
||||||
3
integrations/docker/docker_demo/stop.sh
Executable file
3
integrations/docker/docker_demo/stop.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
docker stop $(docker ps -a -q)
|
||||||
|
docker rm $test_container
|
||||||
|
docker rm $monitor_container
|
||||||
@@ -63,69 +63,84 @@ ifeq ($(SDK_DEBUG_LOG_TO_FILE),1)
|
|||||||
DEFS+=-DSDK_DEBUG_LOG_TO_FILE
|
DEFS+=-DSDK_DEBUG_LOG_TO_FILE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all: linux_shared_lib check
|
all: remove_only_intermediates linux_shared_lib check
|
||||||
|
|
||||||
remove_only_intermediates:
|
remove_only_intermediates:
|
||||||
-find . -type f \( -name '*.o' -o -name '*.so' \) -delete
|
-find . -type f \( -name '*.o' -o -name '*.so' \) -delete
|
||||||
|
|
||||||
linux_shared_lib: remove_only_intermediates $(OBJS)
|
# Build a dynamically-loadable library
|
||||||
mkdir -p build/linux_shared_lib
|
linux_shared_lib: $(OBJS)
|
||||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(DEFS) -DSDK -DZT_ONE_NO_ROOT_CHECK -Iext/lwip/src/include -Iext/lwip/src/include/ipv4 -Iext/lwip/src/include/ipv6 -Izerotierone/osdep -Izerotierone/node -Isrc -o build/zerotier-sdk-service $(OBJS) zerotierone/service/OneService.cpp src/SDK_EthernetTap.cpp src/SDK_Proxy.cpp zerotierone/one.cpp -x c src/SDK_RPC.c $(LDLIBS) -ldl
|
mkdir -p $(BUILD)/linux_shared_lib
|
||||||
|
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(DEFS) -DSDK -DZT_ONE_NO_ROOT_CHECK -Iext/lwip/src/include -Iext/lwip/src/include/ipv4 -Iext/lwip/src/include/ipv6 -I$(ZT1)/osdep -I$(ZT1)/node -Isrc -o $(BUILD)/zerotier-sdk-service $(OBJS) $(ZT1)/service/OneService.cpp src/SDK_EthernetTap.cpp src/SDK_Proxy.cpp $(ZT1)/one.cpp -x c src/SDK_RPC.c $(LDLIBS) -ldl
|
||||||
# Build liblwip.so which must be placed in ZT home for zerotier-netcon-service to work
|
# Build liblwip.so which must be placed in ZT home for zerotier-netcon-service to work
|
||||||
make -f make-liblwip.mk $(LWIP_FLAGS)
|
make -f make-liblwip.mk $(LWIP_FLAGS)
|
||||||
# Use gcc not clang to build standalone intercept library since gcc is typically used for libc and we want to ensure maximal ABI compatibility
|
# Use gcc not clang to build standalone intercept library since gcc is typically used for libc and we want to ensure maximal ABI compatibility
|
||||||
cd src ; gcc $(DEFS) -O2 -Wall -std=c99 -fPIC -DVERBOSE -D_GNU_SOURCE -DSDK_INTERCEPT -I. -I../zerotierone/node -nostdlib -shared -o libztintercept.so SDK_Sockets.c SDK_Intercept.c SDK_Debug.c SDK_RPC.c -ldl
|
cd src ; gcc $(DEFS) -O2 -Wall -std=c99 -fPIC -DVERBOSE -D_GNU_SOURCE -DSDK_INTERCEPT -I. -I../$(ZT1)/node -nostdlib -shared -o ../$(BUILD)/libztintercept.so SDK_Sockets.c SDK_Intercept.c SDK_Debug.c SDK_RPC.c -ldl
|
||||||
cp src/libztintercept.so build/linux_shared_lib/libztintercept.so
|
ln -sf zerotier-sdk-service $(BUILD)/zerotier-cli
|
||||||
ln -sf zerotier-sdk-service zerotier-cli
|
ln -sf zerotier-sdk-service $(BUILD)/zerotier-idtool
|
||||||
ln -sf zerotier-sdk-service zerotier-idtool
|
|
||||||
|
|
||||||
# Builds the docker demo images
|
# Build vanilla ZeroTier One binary
|
||||||
docker_demo: linux_shared_lib
|
one: $(OBJS) $(ZT1)/service/OneService.o $(ZT1)/one.o $(ZT1)/osdep/LinuxEthernetTap.o
|
||||||
# Copy ZT SDK service, dynamic hook library, and lwIP stack library to build directory
|
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $(BUILD)/zerotier-one $(OBJS) $(ZT1)/service/OneService.o $(ZT1)/one.o $(ZT1)/osdep/LinuxEthernetTap.o $(LDLIBS)
|
||||||
cp build/linux_shared_lib/libztintercept.so integrations/docker/docker_demo/libztintercept.so
|
$(STRIP) $(BUILD)/zerotier-one
|
||||||
cp build/zerotier-sdk-service integrations/docker/docker_demo/zerotier-sdk-service.so
|
cp $(BUILD)/zerotier-one $(INT)/docker/docker_demo/zerotier-one
|
||||||
cp build/lwip/liblwip.so integrations/docker/docker_demo/liblwip.so
|
|
||||||
touch integrations/docker/docker_demo/docker_demo.name
|
|
||||||
|
# Build the docker demo images
|
||||||
|
docker_demo: one linux_shared_lib
|
||||||
|
# Intercept library
|
||||||
|
cp $(BUILD)/linux_shared_lib/libztintercept.so $(INT)/docker/docker_demo/libztintercept.so
|
||||||
|
# SDK service
|
||||||
|
cp $(BUILD)/zerotier-sdk-service $(INT)/docker/docker_demo/zerotier-sdk-service
|
||||||
|
# lwIP network stack library
|
||||||
|
cp $(BUILD)/lwip/liblwip.so $(INT)/docker/docker_demo/liblwip.so
|
||||||
|
# CLI interface for ZeroTier
|
||||||
|
cp $(BUILD)/zerotier-cli $(INT)/docker/docker_demo/zerotier-cli
|
||||||
|
touch $(INT)/docker/docker_demo/docker_demo.name
|
||||||
# Server image
|
# Server image
|
||||||
cd integrations/docker/docker_demo; docker build --tag="docker_demo" -f sdk_dockerfile .
|
# This image will contain the server application and everything required to
|
||||||
|
# run the ZeroTier SDK service
|
||||||
|
cd $(INT)/docker/docker_demo; docker build --tag="docker_demo" -f sdk_dockerfile .
|
||||||
# Client image
|
# Client image
|
||||||
cd integrations/docker/docker_demo; docker build --tag="docker_demo_monitor" -f monitor_dockerfile .
|
# This image is merely a test image designed to interact with the server image
|
||||||
|
# in order to verify it's working properly
|
||||||
|
cd $(INT)/docker/docker_demo; docker build --tag="docker_demo_monitor" -f monitor_dockerfile .
|
||||||
|
|
||||||
|
|
||||||
# Check for the presence of built frameworks/bundles/libaries
|
# Check for the presence of built frameworks/bundles/libaries
|
||||||
check:
|
check:
|
||||||
./check.sh build/lwip/liblwip.so
|
./check.sh $(BUILD)/lwip/liblwip.so
|
||||||
./check.sh build/linux_shared_lib/libztintercept.so
|
./check.sh $(BUILD)/linux_shared_lib/libztintercept.so
|
||||||
|
|
||||||
./check.sh build/
|
./check.sh $(BUILD)/
|
||||||
./check.sh build/android_jni_lib/arm64-v8a/libZeroTierJNI.so
|
./check.sh $(BUILD)/android_jni_lib/arm64-v8a/libZeroTierJNI.so
|
||||||
./check.sh build/android_jni_lib/armeabi/libZeroTierJNI.so
|
./check.sh $(BUILD)/android_jni_lib/armeabi/libZeroTierJNI.so
|
||||||
./check.sh build/android_jni_lib/armeabi-v7a/libZeroTierJNI.so
|
./check.sh $(BUILD)/android_jni_lib/armeabi-v7a/libZeroTierJNI.so
|
||||||
./check.sh build/android_jni_lib/mips/libZeroTierJNI.so
|
./check.sh $(BUILD)/android_jni_lib/mips/libZeroTierJNI.so
|
||||||
./check.sh build/android_jni_lib/mips64/libZeroTierJNI.so
|
./check.sh $(BUILD)/android_jni_lib/mips64/libZeroTierJNI.so
|
||||||
./check.sh build/android_jni_lib/x86/libZeroTierJNI.so
|
./check.sh $(BUILD)/android_jni_lib/x86/libZeroTierJNI.so
|
||||||
./check.sh build/android_jni_lib/x86_64/libZeroTierJNI.so
|
./check.sh $(BUILD)/android_jni_lib/x86_64/libZeroTierJNI.so
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
TEST_OBJDIR := build/tests
|
TEST_OBJDIR := $(BUILD)/tests
|
||||||
TEST_SOURCES := $(wildcard tests/*.c)
|
TEST_SOURCES := $(wildcard tests/*.c)
|
||||||
TEST_TARGETS := $(addprefix build/tests/$(OSTYPE).,$(notdir $(TEST_SOURCES:.c=.out)))
|
TEST_TARGETS := $(addprefix $(BUILD)/tests/$(OSTYPE).,$(notdir $(TEST_SOURCES:.c=.out)))
|
||||||
|
|
||||||
build/tests/$(OSTYPE).%.out: tests/%.c
|
$(BUILD)/tests/$(OSTYPE).%.out: tests/%.c
|
||||||
-$(CC) $(CC_FLAGS) -o $@ $<
|
-$(CC) $(CC_FLAGS) -o $@ $<
|
||||||
|
|
||||||
$(TEST_OBJDIR):
|
$(TEST_OBJDIR):
|
||||||
mkdir -p $(TEST_OBJDIR)
|
mkdir -p $(TEST_OBJDIR)
|
||||||
|
|
||||||
tests: $(TEST_OBJDIR) $(TEST_TARGETS)
|
tests: $(TEST_OBJDIR) $(TEST_TARGETS)
|
||||||
mkdir -p build/tests;
|
mkdir -p $(BUILD)/tests;
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf zerotier-cli zerotier-idtool
|
-rm -rf zerotier-one zerotier-cli zerotier-idtool
|
||||||
rm -rf build/*
|
-rm -rf $(BUILD)/*
|
||||||
find . -type f \( -name '*.o' -o -name '*.so' -o -name '*.o.d' -o -name '*.out' -o -name '*.log' \) -delete
|
-find . -type f \( -name '*.o' -o -name '*.so' -o -name '*.o.d' -o -name '*.out' -o -name '*.log' \) -delete
|
||||||
# Remove junk generated by Android builds
|
# Remove junk generated by Android builds
|
||||||
cd integrations/Android/proj; ./gradlew clean
|
-cd $(INT)/android/android_jni_lib/proj; ./gradlew clean
|
||||||
rm -rf integrations/Android/proj/.gradle
|
-rm -rf $(INT)/android/android_jni_lib/proj/.gradle
|
||||||
rm -rf integrations/Android/proj/.idea
|
-rm -rf $(INT)/android/android_jni_lib/proj/.idea
|
||||||
rm -rf integrations/Android/proj/build
|
-rm -rf $(INT)/android/android_jni_lib/proj/build
|
||||||
|
|||||||
92
make-mac.mk
92
make-mac.mk
@@ -54,93 +54,93 @@ all: osx_app_framework ios_app_framework osx_unity3d_bundle ios_unity3d_bundle a
|
|||||||
# TODO: CHECK if XCODE TOOLS are installed
|
# TODO: CHECK if XCODE TOOLS are installed
|
||||||
# Build frameworks for application development
|
# Build frameworks for application development
|
||||||
osx_app_framework:
|
osx_app_framework:
|
||||||
cd integrations/apple/ZeroTierSDK_Apple; xcodebuild -scheme ZeroTierSDK_OSX build SYMROOT="../../../build/osx_app_framework"
|
cd $(INT)/apple/ZeroTierSDK_Apple; xcodebuild -scheme ZeroTierSDK_OSX build SYMROOT="../../../$(BUILD)/osx_app_framework"
|
||||||
cp docs/osx_zt_sdk.md build/osx_app_framework/README.md
|
cp docs/osx_zt_sdk.md $(BUILD)/osx_app_framework/README.md
|
||||||
ios_app_framework:
|
ios_app_framework:
|
||||||
cd integrations/apple/ZeroTierSDK_Apple; xcodebuild -scheme ZeroTierSDK_iOS build SYMROOT="../../../build/ios_app_framework"
|
cd $(INT)/apple/ZeroTierSDK_Apple; xcodebuild -scheme ZeroTierSDK_iOS build SYMROOT="../../../$(BUILD)/ios_app_framework"
|
||||||
cp docs/ios_zt_sdk.md build/ios_app_framework/README.md
|
cp docs/ios_zt_sdk.md $(BUILD)/ios_app_framework/README.md
|
||||||
# Build bundles for Unity integrations
|
# Build bundles for Unity integrations
|
||||||
osx_unity3d_bundle:
|
osx_unity3d_bundle:
|
||||||
cd integrations/apple/ZeroTierSDK_Apple; xcodebuild -scheme ZeroTierSDK_Unity3D_OSX build SYMROOT="../../../build/osx_unity3d_bundle"
|
cd $(INT)/apple/ZeroTierSDK_Apple; xcodebuild -scheme ZeroTierSDK_Unity3D_OSX build SYMROOT="../../../$(BUILD)/osx_unity3d_bundle"
|
||||||
cp docs/osx_unity3d_zt_sdk.md build/osx_unity3d_bundle/README.md
|
cp docs/osx_unity3d_zt_sdk.md $(BUILD)/osx_unity3d_bundle/README.md
|
||||||
ios_unity3d_bundle:
|
ios_unity3d_bundle:
|
||||||
cd integrations/apple/ZeroTierSDK_Apple; xcodebuild -scheme ZeroTierSDK_Unity3D_iOS build SYMROOT="../../../build/ios_unity3d_bundle"
|
cd $(INT)/apple/ZeroTierSDK_Apple; xcodebuild -scheme ZeroTierSDK_Unity3D_iOS build SYMROOT="../../../$(BUILD)/ios_unity3d_bundle"
|
||||||
cp docs/ios_unity3d_zt_sdk.md build/ios_unity3d_bundle/README.md
|
cp docs/ios_unity3d_zt_sdk.md $(BUILD)/ios_unity3d_bundle/README.md
|
||||||
# TODO: CHECK if ANDROID/GRADLE TOOLS are installed
|
# TODO: CHECK if ANDROID/GRADLE TOOLS are installed
|
||||||
# Build library for Android Unity integrations
|
# Build library for Android Unity integrations
|
||||||
# Build JNI library for Android app integration
|
# Build JNI library for Android app integration
|
||||||
android_jni_lib:
|
android_jni_lib:
|
||||||
cd integrations/android/android_jni_lib/proj; ./gradlew assembleDebug
|
cd $(INT)/android/android_jni_lib/proj; ./gradlew assembleDebug
|
||||||
# copy binary into example android project dir
|
# copy binary into example android project dir
|
||||||
cp integrations/android/android_jni_lib/java/libs/* build
|
cp $(INT)/android/android_jni_lib/java/libs/* build
|
||||||
mv integrations/android/android_jni_lib/java/libs/* build
|
mv $(INT)/android/android_jni_lib/java/libs/* build
|
||||||
cd build; for res_f in *; do mv "$res_f" "android_jni_lib_$res_f"; done
|
cd build; for res_f in *; do mv "$res_f" "android_jni_lib_$res_f"; done
|
||||||
#cp docs/android_zt_sdk.md build/README.md
|
#cp docs/android_zt_sdk.md $(BUILD)/README.md
|
||||||
|
|
||||||
remove_only_intermediates:
|
remove_only_intermediates:
|
||||||
-find . -type f \( -name '*.o' -o -name '*.so' \) -delete
|
-find . -type f \( -name '*.o' -o -name '*.so' \) -delete
|
||||||
|
|
||||||
osx_shared_lib: remove_only_intermediates $(OBJS)
|
osx_shared_lib: remove_only_intermediates $(OBJS)
|
||||||
mkdir -p build/osx_shared_lib
|
mkdir -p $(BUILD)/osx_shared_lib
|
||||||
# Need to selectively rebuild one.cpp and OneService.cpp with ZT_SERVICE_NETCON and ZT_ONE_NO_ROOT_CHECK defined, and also NetconEthernetTap
|
# Need to selectively rebuild one.cpp and OneService.cpp with ZT_SERVICE_NETCON and ZT_ONE_NO_ROOT_CHECK defined, and also NetconEthernetTap
|
||||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) -DSDK -DZT_ONE_NO_ROOT_CHECK -Iext/lwip/src/include -Iext/lwip/src/include/ipv4 -Iext/lwip/src/include/ipv6 -Izerotierone/osdep -Izerotierone/node -Isrc -o build/zerotier-sdk-service $(OBJS) zerotierone/service/OneService.cpp src/SDK_EthernetTap.cpp src/SDK_Proxy.cpp zerotierone/one.cpp -x c src/SDK_RPC.c $(LDLIBS) -ldl
|
$(CXX) $(CXXFLAGS) $(LDFLAGS) -DSDK -DZT_ONE_NO_ROOT_CHECK -Iext/lwip/src/include -Iext/lwip/src/include/ipv4 -Iext/lwip/src/include/ipv6 -Izerotierone/osdep -Izerotierone/node -Isrc -o $(BUILD)/zerotier-sdk-service $(OBJS) zerotierone/service/OneService.cpp src/SDK_EthernetTap.cpp src/SDK_Proxy.cpp zerotierone/one.cpp -x c src/SDK_RPC.c $(LDLIBS) -ldl
|
||||||
# Build liblwip.so which must be placed in ZT home for zerotier-sdk-service to work
|
# Build liblwip.so which must be placed in ZT home for zerotier-sdk-service to work
|
||||||
make -f make-liblwip.mk
|
make -f make-liblwip.mk
|
||||||
# Use gcc not clang to build standalone intercept library since gcc is typically used for libc and we want to ensure maximal ABI compatibility
|
# Use gcc not clang to build standalone intercept library since gcc is typically used for libc and we want to ensure maximal ABI compatibility
|
||||||
cd src ; gcc $(DEFS) -O2 -Wall -std=c99 -fPIC -fno-common -dynamiclib -flat_namespace -DVERBOSE -D_GNU_SOURCE -DNETCON_INTERCEPT -I. -I../zerotierone/node -nostdlib -shared -o libztintercept.so SDK_Sockets.c SDK_Intercept.c SDK_Debug.c SDK_RPC.c -ldl
|
cd src ; gcc $(DEFS) -O2 -Wall -std=c99 -fPIC -fno-common -dynamiclib -flat_namespace -DVERBOSE -D_GNU_SOURCE -DNETCON_INTERCEPT -I. -I../zerotierone/node -nostdlib -shared -o $(BUILD)/libztintercept.so SDK_Sockets.c SDK_Intercept.c SDK_Debug.c SDK_RPC.c -ldl
|
||||||
cp src/libztintercept.so build/osx_shared_lib/libztintercept.so
|
|
||||||
ln -sf zerotier-sdk-service zerotier-cli
|
ln -sf zerotier-sdk-service zerotier-cli
|
||||||
ln -sf zerotier-sdk-service zerotier-idtool
|
ln -sf zerotier-sdk-service zerotier-idtool
|
||||||
cp docs/osx_zt_sdk.md build/osx_shared_lib/README.md
|
cp docs/osx_zt_sdk.md $(BUILD)/osx_shared_lib/README.md
|
||||||
|
|
||||||
|
|
||||||
prep:
|
prep:
|
||||||
cp integrations/android/android_jni_lib/java/libs/* build
|
cp $(INT)/android/android_jni_lib/java/libs/* build
|
||||||
|
|
||||||
# Check for the presence of built frameworks/bundles/libaries
|
# Check for the presence of built frameworks/bundles/libaries
|
||||||
check:
|
check:
|
||||||
./check.sh build/lwip/liblwip.so
|
./check.sh $(BUILD)/lwip/liblwip.so
|
||||||
|
|
||||||
./check.sh build/osx_shared_lib/libztintercept.so
|
./check.sh $(BUILD)/osx_shared_lib/libztintercept.so
|
||||||
./check.sh build/osx_unity3d_bundle/Debug/ZeroTierSDK_Unity3D_OSX.bundle
|
./check.sh $(BUILD)/osx_unity3d_bundle/Debug/ZeroTierSDK_Unity3D_OSX.bundle
|
||||||
./check.sh build/osx_app_framework/Debug/ZeroTierSDK_OSX.framework
|
./check.sh $(BUILD)/osx_app_framework/Debug/ZeroTierSDK_OSX.framework
|
||||||
|
|
||||||
./check.sh build/ios_app_framework/Debug-iphoneos/ZeroTierSDK_iOS.framework
|
./check.sh $(BUILD)/ios_app_framework/Debug-iphoneos/ZeroTierSDK_iOS.framework
|
||||||
./check.sh build/ios_unity3d_bundle/Debug-iphoneos/ZeroTierSDK_Unity3D_iOS.bundle
|
./check.sh $(BUILD)/ios_unity3d_bundle/Debug-iphoneos/ZeroTierSDK_Unity3D_iOS.bundle
|
||||||
|
|
||||||
./check.sh build/
|
./check.sh $(BUILD)/
|
||||||
./check.sh build/android_jni_lib/arm64-v8a/libZeroTierJNI.so
|
./check.sh $(BUILD)/android_jni_lib/arm64-v8a/libZeroTierJNI.so
|
||||||
./check.sh build/android_jni_lib/armeabi/libZeroTierJNI.so
|
./check.sh $(BUILD)/android_jni_lib/armeabi/libZeroTierJNI.so
|
||||||
./check.sh build/android_jni_lib/armeabi-v7a/libZeroTierJNI.so
|
./check.sh $(BUILD)/android_jni_lib/armeabi-v7a/libZeroTierJNI.so
|
||||||
./check.sh build/android_jni_lib/mips/libZeroTierJNI.so
|
./check.sh $(BUILD)/android_jni_lib/mips/libZeroTierJNI.so
|
||||||
./check.sh build/android_jni_lib/mips64/libZeroTierJNI.so
|
./check.sh $(BUILD)/android_jni_lib/mips64/libZeroTierJNI.so
|
||||||
./check.sh build/android_jni_lib/x86/libZeroTierJNI.so
|
./check.sh $(BUILD)/android_jni_lib/x86/libZeroTierJNI.so
|
||||||
./check.sh build/android_jni_lib/x86_64/libZeroTierJNI.so
|
./check.sh $(BUILD)/android_jni_lib/x86_64/libZeroTierJNI.so
|
||||||
|
|
||||||
# Tests
|
# Tests
|
||||||
TEST_OBJDIR := build/tests
|
TEST_OBJDIR := $(BUILD)/tests
|
||||||
TEST_SOURCES := $(wildcard tests/*.c)
|
TEST_SOURCES := $(wildcard tests/*.c)
|
||||||
TEST_TARGETS := $(addprefix build/tests/$(OSTYPE).,$(notdir $(TEST_SOURCES:.c=.out)))
|
TEST_TARGETS := $(addprefix $(BUILD)/tests/$(OSTYPE).,$(notdir $(TEST_SOURCES:.c=.out)))
|
||||||
|
|
||||||
build/tests/$(OSTYPE).%.out: tests/%.c
|
$(BUILD)/tests/$(OSTYPE).%.out: tests/%.c
|
||||||
-$(CC) $(CC_FLAGS) -o $@ $<
|
-$(CC) $(CC_FLAGS) -o $@ $<
|
||||||
|
|
||||||
$(TEST_OBJDIR):
|
$(TEST_OBJDIR):
|
||||||
mkdir -p $(TEST_OBJDIR)
|
mkdir -p $(TEST_OBJDIR)
|
||||||
|
|
||||||
tests: $(TEST_OBJDIR) $(TEST_TARGETS)
|
tests: $(TEST_OBJDIR) $(TEST_TARGETS)
|
||||||
mkdir -p build/tests;
|
mkdir -p $(BUILD)/tests;
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf zerotier-cli zerotier-idtool
|
-rm -rf zerotier-cli zerotier-idtool
|
||||||
rm -rf build/*
|
-rm -rf $(BUILD)/*
|
||||||
find . -type f \( -name '*.o' -o -name '*.so' -o -name '*.o.d' -o -name '*.out' -o -name '*.log' \) -delete
|
-find . -type f \( -name '*.o' -o -name '*.so' -o -name '*.o.d' -o -name '*.out' -o -name '*.log' \) -delete
|
||||||
# android JNI lib project
|
# android JNI lib project
|
||||||
cd integrations/android/android_jni_lib/proj; ./gradlew clean
|
-cd $(INT)/android/android_jni_lib/proj; ./gradlew clean
|
||||||
rm -rf integrations/android/android_jni_lib/proj/.gradle
|
-rm -rf $(INT)/android/android_jni_lib/proj/.gradle
|
||||||
rm -rf integrations/android/android_jni_lib/proj/.idea
|
-rm -rf $(INT)/android/android_jni_lib/proj/.idea
|
||||||
rm -rf integrations/android/android_jni_lib/proj/build
|
-rm -rf $(INT)/android/android_jni_lib/proj/build
|
||||||
|
|
||||||
# example android app project
|
# example android app project
|
||||||
cd integrations/android/example_app; ./gradlew clean
|
-cd $(INT)/android/example_app; ./gradlew clean
|
||||||
rm -rf integrations/android/example_app/.idea
|
-rm -rf $(INT)/android/example_app/.idea
|
||||||
rm -rf integrations/android/example_app/.gradle
|
-rm -rf $(INT)/android/example_app/.gradle
|
||||||
|
|||||||
Reference in New Issue
Block a user