mirror of
https://github.com/amnezia-vpn/euphoria-windows.git
synced 2026-05-17 08:15:59 +03:00
62 lines
2.1 KiB
Batchfile
62 lines
2.1 KiB
Batchfile
@echo off
|
|
rem SPDX-License-Identifier: MIT
|
|
rem Copyright (C) 2019-2021 WireGuard LLC. All Rights Reserved.
|
|
|
|
setlocal
|
|
set BUILDDIR=%~dp0
|
|
set PATH=%BUILDDIR%.deps\llvm-mingw\bin;%BUILDDIR%.deps\go\bin;%PATH%
|
|
set PATHEXT=.exe
|
|
cd /d %BUILDDIR% || exit /b 1
|
|
|
|
if exist .deps\prepared goto :build
|
|
:installdeps
|
|
rmdir /s /q .deps 2> NUL
|
|
mkdir .deps || goto :error
|
|
cd .deps || goto :error
|
|
call :download go.zip https://go.dev/dl/go1.18.8.windows-amd64.zip 980788761e75ed33ffc4f2a7a3ff07cd90949bd023eb1a8d855ef0b5de9cbcba || goto :error
|
|
rem Mirror of https://github.com/mstorsjo/llvm-mingw/releases/download/20201020/llvm-mingw-20201020-msvcrt-x86_64.zip
|
|
call :download llvm-mingw-msvcrt.zip https://download.wireguard.com/windows-toolchain/distfiles/llvm-mingw-20201020-msvcrt-x86_64.zip 2e46593245090df96d15e360e092f0b62b97e93866e0162dca7f93b16722b844 || goto :error
|
|
call :download wintun.zip https://www.wintun.net/builds/wintun-0.12.zip eba90e26686ed86595ae0a6d4d3f4f022924b1758f5148a32a91c60cc6e604df || goto :error
|
|
copy /y NUL prepared > NUL || goto :error
|
|
cd .. || goto :error
|
|
|
|
:build
|
|
set GOOS=windows
|
|
set GOARM=7
|
|
set GOPATH=%BUILDDIR%.deps\gopath
|
|
set GOROOT=%BUILDDIR%.deps\go
|
|
set CGO_ENABLED=1
|
|
set CGO_CFLAGS=-O3 -Wall -Wno-unused-function -Wno-switch -std=gnu11 -DWINVER=0x0601
|
|
set CGO_LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat -Wl,--export-all-symbols
|
|
set CGO_LDFLAGS=%CGO_LDFLAGS% -Wl,--high-entropy-va
|
|
call :build_plat x64 x86_64 amd64 || goto :error
|
|
|
|
:success
|
|
echo [+] Success
|
|
exit /b 0
|
|
|
|
:download
|
|
echo [+] Downloading %1
|
|
curl -#fLo %1 %2 || exit /b 1
|
|
echo [+] Verifying %1
|
|
for /f %%a in ('CertUtil -hashfile %1 SHA256 ^| findstr /r "^[0-9a-f]*$"') do if not "%%a"=="%~3" exit /b 1
|
|
echo [+] Extracting %1
|
|
tar -xf %1 %~4 || exit /b 1
|
|
echo [+] Cleaning up %1
|
|
del %1 || exit /b 1
|
|
goto :eof
|
|
|
|
:build_plat
|
|
set CC=%~2-w64-mingw32-gcc
|
|
set GOARCH=%~3
|
|
mkdir %1 >NUL 2>&1
|
|
echo [+] Building library %1
|
|
go build -buildmode c-shared -ldflags="-w -s" -trimpath -v -o "%~1/tunnel.dll" || exit /b 1
|
|
del "%~1\tunnel.h"
|
|
goto :eof
|
|
|
|
:error
|
|
echo [-] Failed with error #%errorlevel%.
|
|
cmd /c exit %errorlevel%
|
|
|