From f290abfb53e4275b9e923eff635be691be0499ba Mon Sep 17 00:00:00 2001 From: benyamin-codez <115509179+benyamin-codez@users.noreply.github.com> Date: Fri, 27 Dec 2024 21:21:18 +1100 Subject: [PATCH] [build] Pre-build x86 viosock libraries as needed Addendum to cec3f9c. 1. Refactored following review to a new file: prebuild_x86_libs.bat Split from PR #1212. Signed-off-by: benyamin-codez <115509179+benyamin-codez@users.noreply.github.com> --- build/build.bat | 39 ++++-------------------- build/prebuild_x86_libs.bat | 60 +++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 34 deletions(-) create mode 100644 build/prebuild_x86_libs.bat diff --git a/build/build.bat b/build/build.bat index d7f25b92d..b45fc678e 100644 --- a/build/build.bat +++ b/build/build.bat @@ -165,40 +165,11 @@ set TARGET_VS_CONFIG="%TARGET_PROJ_CONFIG% %BUILD_FLAVOR%|%BUILD_ARCH%" pushd %BUILD_DIR% call "%~dp0\SetVsEnv.bat" %TARGET_PROJ_CONFIG% -rem Check for x86 viosock libraries and build them if needed... -if "%BUILD_FILE%"=="virtio-win.sln" ( - set VIOSOCK_PREBUILD_X86_LIBS=1 -) -if "%BUILD_FILE%"=="viosock.sln" ( - set VIOSOCK_PREBUILD_X86_LIBS=1 -) -if "%VIOSOCK_PREBUILD_X86_LIBS%" EQU "1" ( - if %BUILD_ARCH%==x64 ( - if not exist "%BUILD_DIR%viosock\lib\x86\%TARGET%%BUILD_FLAVOR%\viosocklib.dll" ( - echo. - echo ATTENTION ^: Need to build x86 viosock libraries before building for amd64... - setlocal - set VIRTIO_WIN_NO_ARM=1 - if "%BUILD_FILE%"=="virtio-win.sln" ( - pushd "%BUILD_DIR%viosock\lib" - ) - if "%BUILD_FILE%"=="viosock.sln" ( - pushd "%BUILD_DIR%lib" - ) - call ..\..\build\build.bat viosocklib.vcxproj %TARGET% x86 - if ERRORLEVEL 1 ( - set BUILD_FAILED=1 - ) - popd - if "%BUILD_FAILED%" EQU "1" ( - goto :build_arch_done - ) - echo Successfully built the x86 viosock libraries. - echo. - echo Continuing with amd64 build... - endlocal - ) - ) +rem Check for any prerequisite x86 libraries and build them if needed... +call "%~dp0prebuild_x86_libs.bat" %BUILD_FILE% %BUILD_ARCH% "%BUILD_DIR%" %TARGET% %BUILD_FLAVOUR% +IF ERRORLEVEL 1 ( + set BUILD_FAILED=1 + goto :build_arch_done ) if /I "!TAG!"=="SDV" ( diff --git a/build/prebuild_x86_libs.bat b/build/prebuild_x86_libs.bat new file mode 100644 index 000000000..5f4e254df --- /dev/null +++ b/build/prebuild_x86_libs.bat @@ -0,0 +1,60 @@ +@echo off +setlocal +rem Check for x86 viosock libraries and build them if needed... +call :do_viosock %* +if ERRORLEVEL 1 ( + endlocal + exit /B 1 +) +endlocal +goto :eof + +:do_viosock +rem Lay up some variables +set BUILD_FILE=%~1 +set BUILD_ARCH=%~2 +set BUILD_DIR=%~3 +set TARGET=%~4 +set BUILD_FLAVOUR=%~5 +set VIOSOCK_PREBUILD_X86_LIBS= +set BUILD_FAILED= + +rem Which solutions need this? +if "%BUILD_FILE%"=="virtio-win.sln" ( + set VIOSOCK_PREBUILD_X86_LIBS=1 +) +if "%BUILD_FILE%"=="viosock.sln" ( + set VIOSOCK_PREBUILD_X86_LIBS=1 +) + +if "%VIOSOCK_PREBUILD_X86_LIBS%" EQU "1" ( + rem Only proceed if we are building for x64 + if %BUILD_ARCH%==x64 ( + rem Check for x86 viosock libraries and build them if needed... + if not exist "%BUILD_DIR%viosock\lib\x86\%TARGET%%BUILD_FLAVOR%\viosocklib.dll" ( + echo. + echo ATTENTION ^: Need to build x86 viosock libraries before building for amd64... + setlocal + set VIRTIO_WIN_NO_ARM=1 + if "%BUILD_FILE%"=="virtio-win.sln" ( + pushd "%BUILD_DIR%viosock\lib" + ) + if "%BUILD_FILE%"=="viosock.sln" ( + pushd "%BUILD_DIR%lib" + ) + call ..\..\build\build.bat viosocklib.vcxproj %TARGET% x86 + if ERRORLEVEL 1 ( + set BUILD_FAILED=1 + ) + popd + if "%BUILD_FAILED%" EQU "1" ( + exit /B 1 + ) + echo Successfully built the x86 viosock libraries. + echo. + echo Continuing with amd64 build... + endlocal + ) + ) +) +goto :eof