1
0
mirror of https://git.zx2c4.com/wireguard-windows synced 2024-11-10 16:59:18 +00:00
wireguard-windows/embeddable-dll-service/build.bat
Simon Rozman b279eab97a build: make code signing method configurable
Existing code signing was hard-coded to use a locally installed
certificate (hardware security dongles included). However, signtool.exe
is extensible to allow any kind of digest signing plugin with /dlib and
/dmdf switches. This is used for cloud-based code signing (e.g.
Microsoft Trusted Signing).

Signed-off-by: Simon Rozman <simon@rozman.si>
2024-10-17 14:27:00 +02:00

49 lines
1.3 KiB
Batchfile

@echo off
rem SPDX-License-Identifier: MIT
rem Copyright (C) 2019-2022 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
call ..\build.bat || 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
call :build_plat x86 i686 386 || goto :error
call :build_plat amd64 x86_64 amd64 || goto :error
call :build_plat arm64 aarch64 arm64 || goto :error
:sign
if exist ..\sign.bat call ..\sign.bat
if "%SigningProvider%"=="" goto :success
if "%TimestampServer%"=="" goto :success
echo [+] Signing
signtool sign %SigningProvider% /fd sha256 /tr "%TimestampServer%" /td sha256 /d "WireGuard Tunnel" x86\tunnel.dll amd64\tunnel.dll arm64\tunnel.dll || goto :error
:success
echo [+] Success
exit /b 0
: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%