Skip to content

Commit

Permalink
build.bat: fix a pair of edge cases.
Browse files Browse the repository at this point in the history
- don't expand PATH in comment to avoid hitting the line length limit;
- disambiguate link.exe invocation in case of interference from msys;
  • Loading branch information
dot-asm committed Aug 15, 2024
1 parent 52cc60d commit 415d4f0
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@echo off
SETLOCAL
set PATH=%windir%\system32;%PATH% &:: override msys if there is one on %PATH%
set PATH=%windir%\system32;%PATH% &:: override msys if it's on the PATH
set TOP=%~dp0
cl /nologo /c /O2 /Zi /Fdblst.pdb /W4 /MT /Zl %TOP%src\server.c || EXIT /B
cl 2>&1 | find "for ARM64" > nul:
Expand All @@ -18,7 +18,7 @@ IF ERRORLEVEL 1 (
SETLOCAL ENABLEDELAYEDEXPANSION
set static=/out:blst.lib
set shared=
set arm64ec=
set arm64x=
FOR %%O IN (%*) DO (
set opt=%%O
IF "!opt!" == "-shared" (
Expand All @@ -31,8 +31,15 @@ FOR %%O IN (%*) DO (
)
IF [%shared%] NEQ [] (
cl /nologo /c /O2 /Oi- /MD %TOP%build\win64\dll.c || EXIT /B
set ld=
FOR /F "usebackq delims=" %%F IN (`where link`) DO (
IF "!ld!" == "" (
"%%F" 2>&1 | find "Linker" > nul:
IF !ERRORLEVEL! EQU 0 set ld="%%F"
)
)
IF [%arm64x%] NEQ [yes] (
link /nologo /debug /dll /entry:DllMain /incremental:no %shared% ^
!ld! /nologo /debug /dll /entry:DllMain /incremental:no %shared% ^
/def:%TOP%build\win64\blst.def *.obj kernel32.lib && del *.obj
) ELSE (
lib /nologo /out:blst_arm64.lib *.obj && del *.obj || EXIT /B
Expand All @@ -41,7 +48,7 @@ IF [%shared%] NEQ [] (
armasm64 -nologo -machine arm64ec -nowarn %%F || EXIT /B
)
cl /nologo /arm64EC /c /O2 /Oi- /MD %TOP%build\win64\dll.c || EXIT /B
link /nologo /machine:arm64x /dll /noentry %shared% ^
!ld! /nologo /machine:arm64x /dll /noentry %shared% ^
/def:%TOP%build\win64\blst.def *.obj ^
/defArm64Native:%TOP%build\win64\blst.def blst_arm64.lib ^
kernel32.lib && del *.obj blst_arm64.lib
Expand Down

0 comments on commit 415d4f0

Please sign in to comment.