From b5c49ebd35e490d33259d123086e502d4612e18e Mon Sep 17 00:00:00 2001 From: Joseph Henry Date: Fri, 10 May 2019 12:24:00 -0700 Subject: [PATCH] Tweaked Makefile patch target for compatibility with older versions of git. Differentiated bdist and sdist in dist.sh --- CMakeLists.txt | 5 +-- Makefile | 22 ++++++++----- dist.sh | 83 +++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 92 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 549318a..ea3a2fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -511,6 +511,7 @@ set (PUBLIC_ZT_HEADERS set_target_properties(${STATIC_LIB_NAME} PROPERTIES PUBLIC_HEADER "${PUBLIC_ZT_HEADERS}") install (TARGETS ${STATIC_LIB_NAME} - LIBRARY DESTINATION "lib" - PUBLIC_HEADER DESTINATION "include" + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + PUBLIC_HEADER DESTINATION include ) diff --git a/Makefile b/Makefile index fbe95fb..ff90a2e 100644 --- a/Makefile +++ b/Makefile @@ -17,14 +17,14 @@ list: # Pull all submodules update: - git submodule update --init - git submodule status + @git submodule update --init + @git submodule status # Patch submodules (issue update first) patch: - -git -C ext/lwip apply ../lwip.patch - -git -C ext/lwip-contrib apply ../lwip-contrib.patch - -git -C ext/ZeroTierOne apply ../ZeroTierOne.patch + -cd ext/lwip; git apply ../lwip.patch; + -cd ext/lwip-contrib; git apply ../lwip-contrib.patch; + -cd ext/ZeroTierOne; git apply ../ZeroTierOne.patch; # Target-specific clean clean_ios: @@ -98,7 +98,13 @@ all: host host_jar macos ios android wrap: $(DIST_BUILD_SCRIPT) wrap -# [For distribution process only] Marge and package everything into a tarball -dist: +# Binary distribution +bdist: $(DIST_BUILD_SCRIPT) merge - $(DIST_BUILD_SCRIPT) dist + $(DIST_BUILD_SCRIPT) bdist + +# Source distribution +sdist: update patch + $(DIST_BUILD_SCRIPT) sdist + +dist: bdist sdist diff --git a/dist.sh b/dist.sh index 19a24ea..0bb7ba0 100755 --- a/dist.sh +++ b/dist.sh @@ -292,6 +292,7 @@ clean() prep_android_example() { echo "Executing task: " ${FUNCNAME[ 0 ]} "(" $1 ")" + mkdir -p examples/android/ExampleAndroidApp/app/libs/ cp -f lib/$1/android-armeabi-v7a/libzt-$1.aar \ examples/android/ExampleAndroidApp/app/libs/libzt.aar } @@ -448,6 +449,19 @@ wrap() tar --exclude=$PROD_FILENAME -zcvf $PROD_FILENAME -C $ARCH_WRAP_DIR . } +# Renames and copies licenses for libzt and each of its dependencies +package_licenses() +{ + CURR_DIR=$1 + DEST_DIR=$2 + mkdir -p $DEST_DIR + cp $CURR_DIR/ext/lwip/COPYING $DEST_DIR/LWIP-LICENSE.BSD + cp $CURR_DIR/ext/concurrentqueue/LICENSE.md $DEST_DIR/CONCURRENTQUEUE-LICENSE.BSD + cp $CURR_DIR/LICENSE.GPL-3 $DEST_DIR/ZEROTIER-LICENSE.GPL-3 + cp $CURR_DIR/include/net/ROUTE_H-LICENSE.APSL $DEST_DIR/ROUTE_H-LICENSE.APSL + cp $CURR_DIR/include/net/ROUTE_H-LICENSE $DEST_DIR/ROUTE_H-LICENSE +} + # Copies binaries, documentation, licenses, etc into a products # dir and then tarballs everything together package_everything() @@ -457,14 +471,8 @@ package_everything() PROD_NAME=$LIBZT_VERSION-$(date '+%Y%m%d_%H-%M')-$1 PROD_DIR=$(pwd)/products/$PROD_NAME/ # Make products directory - LICENSE_DIR=$PROD_DIR/licenses - mkdir -p $LICENSE_DIR # Licenses - cp $(pwd)/ext/lwip/COPYING $LICENSE_DIR/LWIP-LICENSE.BSD - cp $(pwd)/ext/concurrentqueue/LICENSE.md $LICENSE_DIR/CONCURRENTQUEUE-LICENSE.BSD - cp $(pwd)/LICENSE.GPL-3 $LICENSE_DIR/ZEROTIER-LICENSE.GPL-3 - cp $(pwd)/include/net/ROUTE_H-LICENSE.APSL $LICENSE_DIR/ROUTE_H-LICENSE.APSL - cp $(pwd)/include/net/ROUTE_H-LICENSE $LICENSE_DIR/ROUTE_H-LICENSE + package_licenses $(pwd) $PROD_DIR/licenses # Documentation mkdir -p $PROD_DIR/doc # Copy the errno header from lwIP for customer reference @@ -523,8 +531,67 @@ package_everything() done } +# Generates a source-only tarball +sdist() +{ + VERSION=$(git describe --abbrev=0) + TARBALL_DIR="libzt-${VERSION}" + TARBALL_NAME=libzt-${VERSION}-source.tar.gz + PROD_DIR=$(pwd)/products/ + mkdir -p $PROD_DIR + # + mkdir ${TARBALL_DIR} + # primary sources + cp -rf src ${TARBALL_DIR}/src + cp -rf include ${TARBALL_DIR}/include + # important build scripts + cp Makefile ${TARBALL_DIR} + cp CMakeLists.txt ${TARBALL_DIR} + cp *.md ${TARBALL_DIR} + cp *.sh ${TARBALL_DIR} + cp *.bat ${TARBALL_DIR} + # submodules/dependencies + # lwIP + mkdir ${TARBALL_DIR}/ext + mkdir -p ${TARBALL_DIR}/ext/lwip/src + cp -rf ext/lwip/src/api ${TARBALL_DIR}/ext/lwip/src + cp -rf ext/lwip/src/core ${TARBALL_DIR}/ext/lwip/src + cp -rf ext/lwip/src/include ${TARBALL_DIR}/ext/lwip/src + cp -rf ext/lwip/src/netif ${TARBALL_DIR}/ext/lwip/src + # lwIP ports + mkdir -p ${TARBALL_DIR}/ext/lwip-contrib/ports + cp -rf ext/lwip-contrib/ports/unix ${TARBALL_DIR}/ext/lwip-contrib/ports + cp -rf ext/lwip-contrib/ports/win32 ${TARBALL_DIR}/ext/lwip-contrib/ports + # ZeroTierOne + mkdir ${TARBALL_DIR}/ext/ZeroTierOne + cp -rf ext/ZeroTierOne/*.h ${TARBALL_DIR}/ext/ZeroTierOne + cp -rf ext/ZeroTierOne/controller ${TARBALL_DIR}/ext/ZeroTierOne + cp -rf ext/ZeroTierOne/ext ${TARBALL_DIR}/ext/ZeroTierOne + cp -rf ext/ZeroTierOne/include ${TARBALL_DIR}/ext/ZeroTierOne + cp -rf ext/ZeroTierOne/node ${TARBALL_DIR}/ext/ZeroTierOne + cp -rf ext/ZeroTierOne/osdep ${TARBALL_DIR}/ext/ZeroTierOne + # + # Perform selective removal + rm -rf ${TARBALL_DIR}/ext/ZeroTierOne/ext/bin + rm -rf ${TARBALL_DIR}/ext/ZeroTierOne/ext/tap-mac + rm -rf ${TARBALL_DIR}/ext/ZeroTierOne/ext/librethinkdbxx + rm -rf ${TARBALL_DIR}/ext/ZeroTierOne/ext/installfiles + rm -rf ${TARBALL_DIR}/ext/ZeroTierOne/ext/curl-* + rm -rf ${TARBALL_DIR}/ext/ZeroTierOne/ext/http-parser + # + mkdir ${TARBALL_DIR}/ext/concurrentqueue + cp -rf ext/concurrentqueue/*.h ${TARBALL_DIR}/ext/concurrentqueue + # Licenses + package_licenses $(pwd) $TARBALL_DIR/licenses + # Tarball everything and display the results + tar -cvf ${TARBALL_NAME} ${TARBALL_DIR} + tree ${TARBALL_DIR} + rm -rf ${TARBALL_DIR} + mv ${TARBALL_NAME} ${PROD_DIR} +} + # Package both debug and release -dist() +bdist() { echo "Executing task: " ${FUNCNAME[ 0 ]} "(" $1 ")" package_everything "debug"