Add new PowerShell script to replace batch file for Windows builds
This commit is contained in:
5
Makefile
5
Makefile
@@ -1,9 +1,4 @@
|
|||||||
ifeq ($(OS),Windows_NT)
|
|
||||||
DIST_BUILD_SCRIPT := dist.bat
|
|
||||||
CLEAN_SCRIPT := clean.bat
|
|
||||||
else
|
|
||||||
DIST_BUILD_SCRIPT := ./dist.sh
|
DIST_BUILD_SCRIPT := ./dist.sh
|
||||||
endif
|
|
||||||
|
|
||||||
#EXECUTABLES = cmake
|
#EXECUTABLES = cmake
|
||||||
#build_reqs := $(foreach exec,$(EXECUTABLES),\
|
#build_reqs := $(foreach exec,$(EXECUTABLES),\
|
||||||
|
|||||||
17
README.md
17
README.md
@@ -8,17 +8,22 @@ Downloads: [download.zerotier.com/dist/sdk](https://download.zerotier.com/dist/s
|
|||||||
|
|
||||||
<div style="page-break-after: always;"></div>
|
<div style="page-break-after: always;"></div>
|
||||||
|
|
||||||
## Building from source
|
## Building on Linux, macOS
|
||||||
|
*Requires [CMake](https://cmake.org/download/), [Clang](https://releases.llvm.org/download.html) is recommended*
|
||||||
|
```
|
||||||
|
make update && make patch && make host_release CC=clang CXX=clang++
|
||||||
|
```
|
||||||
|
|
||||||
To build both `release` and `debug` libraries for only your host's architecture use `make host`. Or optionally `make host_release` for release only. To build everything including things like iOS frameworks, Android packages, etc, use `make all`. Possible build targets can be seen by using `make list`. Resultant libraries will be placed in `./lib`, test and example programs will be placed in `./bin`:
|
## Building on Windows
|
||||||
|
*Requires [CMake](https://cmake.org/download/) and [PowerShell](https://github.com/powershell/powershell)*
|
||||||
|
|
||||||
```
|
```
|
||||||
make update; make patch; make host
|
. ./dist.ps1
|
||||||
# OR
|
Build-Library -BuildType "Release" -Arch "Win32|x64|ARM|ARM64" -LanguageBinding "none|csharp"
|
||||||
brew install cmake
|
|
||||||
make clean; make update && make patch && make host_release CC=clang CXX=clang++
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
*Note: To build both `release` and `debug` libraries for only your host's architecture use `make host`. Or optionally `make host_release` for release only. To build everything including things like iOS frameworks, Android packages, etc, use `make all`. Possible build targets can be seen by using `make list`. Resultant libraries will be placed in `./lib`, test and example programs will be placed in `./bin`*
|
||||||
|
|
||||||
Typical build output:
|
Typical build output:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
115
dist.bat
115
dist.bat
@@ -1,115 +0,0 @@
|
|||||||
REM build temp directories
|
|
||||||
set Win32ReleaseBuildDir=tmp\release\win32
|
|
||||||
set Win64ReleaseBuildDir=tmp\release\win64
|
|
||||||
set Win32DebugBuildDir=tmp\debug\win32
|
|
||||||
set Win64DebugBuildDir=tmp\debug\win64
|
|
||||||
|
|
||||||
mkdir %Win32ReleaseBuildDir%
|
|
||||||
mkdir %Win64ReleaseBuildDir%
|
|
||||||
mkdir %Win32DebugBuildDir%
|
|
||||||
mkdir %Win64DebugBuildDir%
|
|
||||||
|
|
||||||
REM final output directories
|
|
||||||
set WinReleaseOutputDir=lib\release
|
|
||||||
set WinDebugOutputDir=lib\debug
|
|
||||||
|
|
||||||
mkdir %WinReleaseOutputDir%\win-x86
|
|
||||||
mkdir %WinReleaseOutputDir%\win-x86_64
|
|
||||||
mkdir %WinDebugOutputDir%\win-x86
|
|
||||||
mkdir %WinDebugOutputDir%\win-x86_64
|
|
||||||
|
|
||||||
mkdir %WinReleaseOutputDir%
|
|
||||||
mkdir %WinDebugOutputDir%
|
|
||||||
|
|
||||||
pushd %Win32ReleaseBuildDir%
|
|
||||||
cmake -G "Visual Studio 16 2019" ../../../
|
|
||||||
cmake --build . --config Release
|
|
||||||
popd
|
|
||||||
copy %Win32ReleaseBuildDir%\Release\zt.lib %WinReleaseOutputDir%\win-x86\libzt32.lib
|
|
||||||
copy %Win32ReleaseBuildDir%\Release\zt-shared.dll %WinReleaseOutputDir%\win-x86\libzt32.dll
|
|
||||||
|
|
||||||
pushd %Win32DebugBuildDir%
|
|
||||||
cmake -G "Visual Studio 16 2019" ../../../
|
|
||||||
cmake --build . --config Debug
|
|
||||||
popd
|
|
||||||
copy %Win32DebugBuildDir%\Debug\zt.lib %WinDebugOutputDir%\win-x86\libzt32d.lib
|
|
||||||
copy %Win32DebugBuildDir%\Debug\zt-shared.dll %WinDebugOutputDir%\win-x86\libzt32d.dll
|
|
||||||
|
|
||||||
pushd %Win64ReleaseBuildDir%
|
|
||||||
cmake -G "Visual Studio 16 2019" -A x64 ../../../
|
|
||||||
cmake --build . --config Release
|
|
||||||
popd
|
|
||||||
copy %Win64ReleaseBuildDir%\Release\zt.lib %WinReleaseOutputDir%\win-x86_64\libzt64.lib
|
|
||||||
copy %Win64ReleaseBuildDir%\Release\zt-shared.dll %WinReleaseOutputDir%\win-x86_64\libzt64.dll
|
|
||||||
|
|
||||||
pushd %Win64DebugBuildDir%
|
|
||||||
cmake -G "Visual Studio 16 2019" -A x64 ../../../
|
|
||||||
cmake --build . --config Debug
|
|
||||||
popd
|
|
||||||
copy %Win64DebugBuildDir%\Debug\zt.lib %WinDebugOutputDir%\win-x86_64\libzt64d.lib
|
|
||||||
copy %Win64DebugBuildDir%\Debug\zt-shared.dll %WinDebugOutputDir%\win-x86_64\libzt64d.dll
|
|
||||||
|
|
||||||
REM Copy example binaries
|
|
||||||
|
|
||||||
mkdir bin\debug\win-x86\
|
|
||||||
copy %Win32DebugBuildDir%\Debug\*.exe bin\debug\win-x86\
|
|
||||||
mkdir bin\debug\win-x86_64\
|
|
||||||
copy %Win64DebugBuildDir%\Debug\*.exe bin\debug\win-x86_64\
|
|
||||||
|
|
||||||
mkdir bin\release\win-x86\
|
|
||||||
copy %Win32ReleaseBuildDir%\Release\*.exe bin\release\win-x86\
|
|
||||||
mkdir bin\release\win-x86_64\
|
|
||||||
copy %Win64ReleaseBuildDir%\Release\*.exe bin\release\win-x86_64\
|
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
rd /S /Q bin
|
|
||||||
|
|
||||||
# Build with JNI
|
|
||||||
|
|
||||||
mkdir WinBuild32 & pushd WinBuild32
|
|
||||||
cmake -D JNI:BOOL=ON -G "Visual Studio 16 2019" ../
|
|
||||||
popd
|
|
||||||
mkdir WinBuild64 & pushd WinBuild64
|
|
||||||
cmake -D JNI:BOOL=ON -G "Visual Studio 16 2019" -A x64 ../
|
|
||||||
popd
|
|
||||||
|
|
||||||
cmake --build WinBuild32 --config Release
|
|
||||||
cmake --build WinBuild32 --config Debug
|
|
||||||
|
|
||||||
REM Build JAR file
|
|
||||||
REM release variant
|
|
||||||
cd packages\java
|
|
||||||
del com/zerotier/libzt/*.class
|
|
||||||
move ..\..\%ReleaseWinBuildDir%\zt-shared.dll zt.dll
|
|
||||||
javac com/zerotier/libzt/*.java
|
|
||||||
jar cf zt.jar zt.dll com/zerotier/libzt/*.class
|
|
||||||
move zt.jar ..\..\%PrebuiltReleaseWin32Dir%
|
|
||||||
REM debug variant
|
|
||||||
del com/zerotier/libzt/*.class
|
|
||||||
move ..\..\%DebugWinBuildDir%\zt-shared.dll zt.dll
|
|
||||||
javac com/zerotier/libzt/*.java
|
|
||||||
jar cf zt.jar zt.dll com/zerotier/libzt/*.class
|
|
||||||
move zt.jar ..\..\%PrebuiltDebugWin32Dir%
|
|
||||||
popd
|
|
||||||
popd
|
|
||||||
|
|
||||||
cmake --build WinBuild64 --config Release
|
|
||||||
cmake --build WinBuild64 --config Debug
|
|
||||||
|
|
||||||
REM Build JAR file
|
|
||||||
REM release variant
|
|
||||||
cd packages\java
|
|
||||||
del com/zerotier/libzt/*.class
|
|
||||||
move ..\..\%ReleaseWinBuildDir%\zt-shared.dll zt.dll
|
|
||||||
javac com/zerotier/libzt/*.java
|
|
||||||
jar cf zt.jar zt.dll com/zerotier/libzt/*.class
|
|
||||||
move zt.jar ..\..\%PrebuiltReleaseWin64Dir%
|
|
||||||
REM debug variant
|
|
||||||
del com/zerotier/libzt/*.class
|
|
||||||
move ..\..\%DebugWinBuildDir%\zt-shared.dll zt.dll
|
|
||||||
javac com/zerotier/libzt/*.java
|
|
||||||
jar cf zt.jar zt.dll com/zerotier/libzt/*.class
|
|
||||||
move zt.jar ..\..\%PrebuiltDebugWin64Dir%
|
|
||||||
popd
|
|
||||||
popd
|
|
||||||
72
dist.ps1
Normal file
72
dist.ps1
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
function Clean
|
||||||
|
{
|
||||||
|
Remove-Item tmp -Recurse -Force -Confirm:$false -ErrorAction:'silentlycontinue'
|
||||||
|
Remove-Item lib -Recurse -Force -Confirm:$false -ErrorAction:'silentlycontinue'
|
||||||
|
Remove-Item bin -Recurse -Force -Confirm:$false -ErrorAction:'silentlycontinue'
|
||||||
|
}
|
||||||
|
|
||||||
|
function Build-Library([string]$BuildType, [string]$Arch, [string]$LanguageBinding)
|
||||||
|
{
|
||||||
|
$OptionalLanguageBinding=""
|
||||||
|
|
||||||
|
if ($LanguageBinding -eq "csharp") {
|
||||||
|
$OptionalLanguageBinding="-DZTS_PINVOKE:BOOL=ON"
|
||||||
|
$LanguageBindingPostfix="-pinvoke"
|
||||||
|
}
|
||||||
|
if ($LanguageBinding -eq "java") {
|
||||||
|
#$OptionalLanguageBinding="-DSDK_JNI=ON -DSDK_JNI=1"
|
||||||
|
#$LanguageBindingPostfix="-jni"
|
||||||
|
}
|
||||||
|
|
||||||
|
$archAlias = ""
|
||||||
|
$bitCount = ""
|
||||||
|
|
||||||
|
if ($Arch -eq "Win32") {
|
||||||
|
$bitCount="32"
|
||||||
|
$archAlias="win-x86"
|
||||||
|
}
|
||||||
|
if ($Arch -eq "x64") {
|
||||||
|
$bitCount="64"
|
||||||
|
$archAlias="win-x64"
|
||||||
|
}
|
||||||
|
if ($Arch -eq "ARM32") {
|
||||||
|
$bitCount="32"
|
||||||
|
$archAlias="win-arm"
|
||||||
|
}
|
||||||
|
if ($Arch -eq "ARM64") {
|
||||||
|
$bitCount="64"
|
||||||
|
$archAlias="win-arm64"
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($archAlias -eq "" -or $bitCount -eq "") {
|
||||||
|
echo "No valid architecture specified. Breaking."
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
# Directory for CMake to build and store intermediate files
|
||||||
|
$env:BuildDir="tmp\$BuildType\"+$Arch+$LanguageBindingPostfix
|
||||||
|
md $env:BuildDir
|
||||||
|
# Directory where we plan to store the resultant libraries
|
||||||
|
$env:OutputDir="lib\"+$BuildType.ToLower()
|
||||||
|
md $env:OutputDir\$archAlias$LanguageBindingPostfix
|
||||||
|
Push-Location -Path $env:BuildDir
|
||||||
|
cmake ${OptionalLanguageBinding} -G "Visual Studio 16 2019" -A $Arch ../../../
|
||||||
|
cmake --build . --config $BuildType
|
||||||
|
Pop-Location
|
||||||
|
Copy-Item $env:BuildDir\$BuildType\zt.lib $env:OutputDir\$archAlias$LanguageBindingPostfix\libzt$bitCount.lib
|
||||||
|
Copy-Item $env:BuildDir\$BuildType\zt-shared.dll $env:OutputDir\$archAlias$LanguageBindingPostfix\libzt$bitCount.dll
|
||||||
|
}
|
||||||
|
|
||||||
|
function Build-All
|
||||||
|
{
|
||||||
|
# Win32
|
||||||
|
Build-Library -BuildType "Release" -Arch "Win32" -LanguageBinding ""
|
||||||
|
Build-Library -BuildType "Release" -Arch "Win32" -LanguageBinding "pinvoke"
|
||||||
|
Build-Library -BuildType "Debug" -Arch "Win32" -LanguageBinding ""
|
||||||
|
Build-Library -BuildType "Debug" -Arch "Win32" -LanguageBinding "pinvoke"
|
||||||
|
# x64
|
||||||
|
Build-Library -BuildType "Release" -Arch "x64" -LanguageBinding ""
|
||||||
|
Build-Library -BuildType "Release" -Arch "x64" -LanguageBinding "pinvoke"
|
||||||
|
Build-Library -BuildType "Debug" -Arch "x64" -LanguageBinding ""
|
||||||
|
Build-Library -BuildType "Debug" -Arch "x64" -LanguageBinding "pinvoke"
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user