mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 18:43:02 +01:00
Rework windows build process
All code detecting the version of Visual Studio to use is now in setenvvar.bat. run_all.bat has a new feature - TESTENV which will print out the environment that will be used for the build and then quit.
This commit is contained in:
parent
1fcace0767
commit
371cd3a01d
@ -103,19 +103,11 @@ copy %FB_ROOT_PATH%\src\extlib\*.sql %FB_OUTPUT_DIR%\plugins\udr > nul
|
||||
@copy %FB_INSTALL_SCRIPTS%\uninstall_service.bat %FB_OUTPUT_DIR% >nul
|
||||
|
||||
:: MSVC runtime
|
||||
if defined VS150COMNTOOLS (
|
||||
@copy "%VS150COMNTOOLS%\..\..\VC\redist\%FB_VC_CRT_DIR%\Microsoft.VC141.CRT\vcruntime140.dll" %FB_OUTPUT_DIR% >nul
|
||||
@copy "%VS150COMNTOOLS%\..\..\VC\redist\%FB_VC_CRT_DIR%\Microsoft.VC141.CRT\msvcp140.dll" %FB_OUTPUT_DIR% >nul
|
||||
) else (
|
||||
if defined VS140COMNTOOLS (
|
||||
@copy "%VS140COMNTOOLS%\..\..\VC\redist\%FB_VC_CRT_DIR%\Microsoft.VC140.CRT\vcruntime140.dll" %FB_OUTPUT_DIR% >nul
|
||||
@copy "%VS140COMNTOOLS%\..\..\VC\redist\%FB_VC_CRT_DIR%\Microsoft.VC140.CRT\msvcp140.dll" %FB_OUTPUT_DIR% >nul
|
||||
) else (
|
||||
if defined VS120COMNTOOLS (
|
||||
@copy "%VS120COMNTOOLS%\..\..\VC\redist\%FB_VC_CRT_DIR%\Microsoft.VC120.CRT\msvcr120.dll" %FB_OUTPUT_DIR% >nul
|
||||
@copy "%VS120COMNTOOLS%\..\..\VC\redist\%FB_VC_CRT_DIR%\Microsoft.VC120.CRT\msvcp120.dll" %FB_OUTPUT_DIR% >nul
|
||||
)
|
||||
@copy "%VCToolsRedistDir%\..\..\VC\redist\%VSCMD_ARG_TGT_ARCH%\Microsoft.VC%MSVC_RUNTIME_LIBRARY_VERSION%.CRT\vcruntime140.dll" %FB_OUTPUT_DIR% >nul
|
||||
@if exist "%VCToolsRedistDir%\..\..\VC\redist\%VSCMD_ARG_TGT_ARCH%\Microsoft.VC%MSVC_RUNTIME_LIBRARY_VERSION%.CRT\vcruntime140_1.dll" (
|
||||
copy "%VCToolsRedistDir%\..\..\VC\redist\%VSCMD_ARG_TGT_ARCH%\Microsoft.VC%MSVC_RUNTIME_LIBRARY_VERSION%.CRT\vcruntime140_1.dll" %FB_OUTPUT_DIR% >nul
|
||||
)
|
||||
@copy "%VCToolsRedistDir%\..\..\VC\redist\%VSCMD_ARG_TGT_ARCH%\Microsoft.VC%MSVC_RUNTIME_LIBRARY_VERSION%.CRT\msvcp140.dll" %FB_OUTPUT_DIR% >nul
|
||||
)
|
||||
|
||||
@goto :EOF
|
||||
|
@ -9,6 +9,7 @@ set FBBUILD_BUILDTYPE=release
|
||||
set FBBUILD_INCLUDE_PDB=
|
||||
set FBBUILD_MAKE_KITS_ONLY=
|
||||
set FBBUILD_BUILD_ONLY=0
|
||||
set FBBUILD_TEST_ONLY=
|
||||
|
||||
::Check if on-line help is required
|
||||
for %%v in ( %1 %2 %3 %4 %5 %6 %7 %8 %9 ) do (
|
||||
@ -26,9 +27,13 @@ for %%v in ( %* ) do (
|
||||
( if /I "%%v"=="PDB" (set FBBUILD_INCLUDE_PDB=1) )
|
||||
( if /I "%%v"=="REPACK" (set FBBUILD_MAKE_KITS_ONLY=1) )
|
||||
( if /I "%%v"=="JUSTBUILD" (set FBBUILD_BUILD_ONLY=1) )
|
||||
( if /I "%%v"=="TESTENV" (set FBBUILD_TEST_ONLY=1) )
|
||||
)
|
||||
|
||||
call :SETVCENV
|
||||
if "%ERRLEV%"=="1" goto :END
|
||||
|
||||
if defined FBBUILD_TEST_ONLY ( goto TEST_ENV & goto :EOF )
|
||||
|
||||
if defined FBBUILD_MAKE_KITS_ONLY (goto :MAKE_KITS & goto :EOF)
|
||||
|
||||
@ -51,10 +56,12 @@ if "%FBBUILD_BUILD_ONLY%"=="1" goto :END
|
||||
:: Package everything up
|
||||
pushd ..\install\arch-specific\win32
|
||||
call BuildExecutableInstall ISX ZIP EMB %FBBUILD_BUILDTYPE%
|
||||
if "%ERRLEV%"=="1" ( @echo Oops - some sort of error & popd & goto :END)
|
||||
if "%ERRLEV%"=="1" (
|
||||
@echo Oops - some sort of error during packaging & popd & goto :END
|
||||
)
|
||||
if defined FBBUILD_INCLUDE_PDB (
|
||||
set /A FBBUILD_PACKAGE_NUMBER-=1
|
||||
call BuildExecutableInstall ISX ZIP EMB %FBBUILD_BUILDTYPE% PDB
|
||||
set /A FBBUILD_PACKAGE_NUMBER-=1
|
||||
call BuildExecutableInstall ISX ZIP EMB %FBBUILD_BUILDTYPE% PDB
|
||||
)
|
||||
popd
|
||||
|
||||
@ -80,6 +87,9 @@ goto :END
|
||||
@echo.
|
||||
@echo JUSTBUILD - Just build - don't create packages.
|
||||
@echo.
|
||||
@echo TESTENV - Sanity check - is Visual Studio available?.
|
||||
@echo - print the build variables that will be used
|
||||
@echo.
|
||||
@goto :EOF
|
||||
::---------
|
||||
|
||||
@ -88,22 +98,25 @@ goto :END
|
||||
::===============================
|
||||
:: Set up the compiler environment
|
||||
|
||||
if DEFINED VS170COMNTOOLS (
|
||||
@devenv /? >nul 2>nul
|
||||
@ if errorlevel 9009 (call "%VS170COMNTOOLS%\..\..\VC\Auxiliary\Build\vcvarsall.bat" %PROCESSOR_ARCHITECTURE%) else ( echo The file: & @echo "%VS170COMNTOOLS%\..\..\VC\Auxiliary\Build\vcvarsall.bat" %PROCESSOR_ARCHITECTURE% & echo has already been executed.)
|
||||
) else (
|
||||
if DEFINED VS160COMNTOOLS (
|
||||
@devenv /? >nul 2>nul
|
||||
@if errorlevel 9009 (call "%VS160COMNTOOLS%\..\..\VC\Auxiliary\Build\vcvarsall.bat" %PROCESSOR_ARCHITECTURE%) else ( echo The file: & @echo "%VS160COMNTOOLS%\..\..\VC\Auxiliary\Build\vcvarsall.bat" %PROCESSOR_ARCHITECTURE% & echo has already been executed.)
|
||||
) else (
|
||||
if DEFINED VS150COMNTOOLS (
|
||||
@devenv /? >nul 2>nul
|
||||
@if errorlevel 9009 (call "%VS150COMNTOOLS%\..\..\VC\Auxiliary\Build\vcvarsall.bat" %PROCESSOR_ARCHITECTURE%) else ( echo The file: & @echo "%VS150COMNTOOLS%\..\..\VC\Auxiliary\Build\vcvarsall.bat" %PROCESSOR_ARCHITECTURE% & echo has already been executed.)
|
||||
) else (
|
||||
@goto :HELP
|
||||
)
|
||||
)
|
||||
)
|
||||
@call setenvvar.bat
|
||||
if "%ERRLEV%"=="1" goto :END
|
||||
|
||||
|
||||
goto :END
|
||||
::---------
|
||||
|
||||
|
||||
:TEST_ENV
|
||||
::===============================
|
||||
:: Show variables
|
||||
call :SETVCENV
|
||||
if "%ERRLEV%"=="1" goto :END
|
||||
echo.
|
||||
set FB
|
||||
set MS
|
||||
set VC
|
||||
set VS
|
||||
echo.
|
||||
goto :END
|
||||
::---------
|
||||
|
||||
|
@ -3,7 +3,6 @@ set FB_DBG=
|
||||
set FB_CONFIG=release
|
||||
set FB_CLEAN=
|
||||
set FB_ICU=
|
||||
set FB_VC_CRT_ARCH=%FB_PROCESSOR_ARCHITECTURE%
|
||||
|
||||
for %%v in ( %* ) do (
|
||||
( if /I "%%v"=="DEBUG" ( (set FB_DBG=TRUE) && (set FB_CONFIG=debug) ) )
|
||||
@ -12,22 +11,6 @@ for %%v in ( %* ) do (
|
||||
( if /I "%%v"=="RELEASE" ( (set FB_DBG=) && (set FB_CONFIG=release) ) )
|
||||
)
|
||||
|
||||
if %FB_VC_CRT_ARCH% == AMD64 ( set FB_VC_CRT_ARCH=x64)
|
||||
|
||||
if defined VS150COMNTOOLS (
|
||||
if exist "%VS150COMNTOOLS%\..\..\VC\redist\MSVC" (
|
||||
for /D %%d in ( "%VS150COMNTOOLS%\..\..\VC\redist\MSVC\*" ) do (
|
||||
set FB_VC_CRT_VER=MSVC\%%~nxd
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if defined FB_VC_CRT_VER (
|
||||
set FB_VC_CRT_DIR=%FB_VC_CRT_VER%\%FB_VC_CRT_ARCH%
|
||||
) else (
|
||||
set FB_VC_CRT_DIR=%FB_VC_CRT_ARCH%
|
||||
)
|
||||
|
||||
set FB_OBJ_DIR=%FB_TARGET_PLATFORM%\%FB_CONFIG%
|
||||
set FB_BIN_DIR=%FB_ROOT_PATH%\temp\%FB_OBJ_DIR%\firebird\
|
||||
|
||||
|
@ -3,39 +3,101 @@
|
||||
:: FB_LONG_ROOT_PATH long format path of the main directory
|
||||
:: FB_DB_PATH unix format path of the main directory
|
||||
:: (This is used by gpre and preprocess.bat)
|
||||
:: VS_VER VisualStudio version (msvc12|msvc14|msvc15)
|
||||
:: VS_VER VisualStudio version (msvc15)
|
||||
|
||||
@echo off
|
||||
|
||||
::set FB_PROCESSOR_ARCHITECTURE=AMD64
|
||||
|
||||
:: Default target CPU architecture is the native environment
|
||||
if NOT DEFINED FB_PROCESSOR_ARCHITECTURE (
|
||||
set FB_PROCESSOR_ARCHITECTURE=%PROCESSOR_ARCHITECTURE%
|
||||
@if NOT DEFINED FB_PROCESSOR_ARCHITECTURE (
|
||||
set FB_PROCESSOR_ARCHITECTURE=%PROCESSOR_ARCHITECTURE%
|
||||
)
|
||||
|
||||
|
||||
::=================
|
||||
:SET_MSVC_VER
|
||||
|
||||
if DEFINED VS170COMNTOOLS (
|
||||
@set MSVC_VERSION=15
|
||||
@set MSVC_CMAKE_GENERATOR=Visual Studio 17 2022
|
||||
) else (
|
||||
if DEFINED VS160COMNTOOLS (
|
||||
@set MSVC_VERSION=15
|
||||
@set MSVC_CMAKE_GENERATOR=Visual Studio 16 2019
|
||||
) else (
|
||||
if DEFINED VS150COMNTOOLS (
|
||||
@set MSVC_VERSION=15
|
||||
@set MSVC_CMAKE_GENERATOR=Visual Studio 15
|
||||
) else (
|
||||
@goto :HELP
|
||||
)
|
||||
)
|
||||
:: NOTE: We introduce a new variable here - FB_VSCOMNTOOLS
|
||||
:: This is intended to remove multiple tests for Visual Studio installs.
|
||||
:: If FB_VSCOMNTOOLS is not already defined it will dynamically pick the
|
||||
:: newest version of Visual Studio. If a specific version of Visual
|
||||
:: is required then FB_VSCOMNTOOLS should be set in the environment prior
|
||||
:: to running the build process.
|
||||
:: NOTE 2: Do not change the assignment to FB_VSCOMNTOOLS after vcvarsall
|
||||
:: has been executed. This change is not be detected (but it could be).
|
||||
:: For now, if you wish to try a different version of Visual Studio you
|
||||
:: should open a new command prompt and start afresh.
|
||||
::
|
||||
|
||||
@if not DEFINED FB_VSCOMNTOOLS (
|
||||
if DEFINED VS170COMNTOOLS (
|
||||
set "FB_VSCOMNTOOLS=%VS170COMNTOOLS%"
|
||||
) else (
|
||||
if DEFINED VS160COMNTOOLS (
|
||||
set "FB_VSCOMNTOOLS=%VS160COMNTOOLS%"
|
||||
) else (
|
||||
if DEFINED VS150COMNTOOLS (
|
||||
set "FB_VSCOMNTOOLS=%VS150COMNTOOLS%"
|
||||
) else (
|
||||
goto :HELP
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
set VS_VER=msvc%MSVC_VERSION%
|
||||
:: Now set some firebird build specific variables that depend upon the
|
||||
:: version of Visual Studio that is being used for the build.
|
||||
@if DEFINED FB_VSCOMNTOOLS (
|
||||
if "%FB_VSCOMNTOOLS%" == "%VS170COMNTOOLS%" (
|
||||
set MSVC_VERSION=15
|
||||
set MSVC_CMAKE_GENERATOR=Visual Studio 17 2022
|
||||
)
|
||||
if "%FB_VSCOMNTOOLS%" == "%VS160COMNTOOLS%" (
|
||||
set MSVC_VERSION=15
|
||||
set MSVC_CMAKE_GENERATOR=Visual Studio 16 2019
|
||||
)
|
||||
if "%FB_VSCOMNTOOLS%" == "%VS150COMNTOOLS%" (
|
||||
set MSVC_VERSION=15
|
||||
set MSVC_CMAKE_GENERATOR=Visual Studio 15
|
||||
)
|
||||
) else (
|
||||
goto :HELP
|
||||
)
|
||||
|
||||
:: Run vsvarsall just once during the build...
|
||||
@if DEFINED FB_VSCOMNTOOLS (
|
||||
@devenv /? >nul 2>nul
|
||||
@if errorlevel 9009 (
|
||||
call "%FB_VSCOMNTOOLS%\..\..\VC\Auxiliary\Build\vcvarsall.bat" %PROCESSOR_ARCHITECTURE%
|
||||
) else (
|
||||
@echo The file:
|
||||
@echo "%FB_VSCOMNTOOLS%\..\..\VC\Auxiliary\Build\vcvarsall.bat" %PROCESSOR_ARCHITECTURE%
|
||||
@echo has already been executed.
|
||||
)
|
||||
)
|
||||
|
||||
:: VS_VER is used to locate the correct set of Visual Studio project files.
|
||||
:: They are stored in builds\win32\$VS_VER%. Currently (2022-06-16) only one set exists.
|
||||
@set VS_VER=msvc%MSVC_VERSION%
|
||||
|
||||
|
||||
:: We need to deploy runtime dlls with 140 in the file name. But these files are
|
||||
:: stored in a directory name dependant upon the precise minor version of the
|
||||
:: runtime. So we need to extract two values:
|
||||
:: MAJOR runtime version
|
||||
:: MINOR runtime version
|
||||
:: which we then use to determine the location of the various runtime files reqd.
|
||||
:: For now, MSVC_RUNTIME_LIBRARY_VERSION indicates the VS specific location.
|
||||
:: MSVC_RUNTIME_FILE_VERSION represents the version string in the runtime file name.
|
||||
:: If anyone can come up with better naming conventions please do not hesitate to
|
||||
:: suggest them.
|
||||
:: This has been tested on VS 2017, 2019 and 2022
|
||||
:: Note that VCToolsVersion is only defined after vcvarsall.bat been run.
|
||||
@if defined VCToolsVersion (
|
||||
set MSVC_RUNTIME_MAJOR_VERSION=%VCToolsVersion:~0,2%
|
||||
set MSVC_RUNTIME_MINOR_VERSION=%VCToolsVersion:~3,1%
|
||||
set MSVC_RUNTIME_LIBRARY_VERSION=%MSVC_RUNTIME_MAJOR_VERSION%%MSVC_RUNTIME_MINOR_VERSION%
|
||||
set MSVC_RUNTIME_FILE_VERSION=%MSVC_RUNTIME_MAJOR_VERSION%0
|
||||
)
|
||||
@echo.
|
||||
|
||||
|
||||
@ -74,18 +136,22 @@ goto :END
|
||||
:HELP
|
||||
@echo.
|
||||
@echo ERROR:
|
||||
@echo A working version of Visual Studio cannot be found
|
||||
@echo on your current path.
|
||||
@echo A working version of Visual Studio cannot be found.
|
||||
@echo.
|
||||
@echo You need MS Visual Studio 12 or newer to build Firebird
|
||||
@echo MS Visual Studio 2017 (MSVC 15) or newer is required to build Firebird
|
||||
@echo from these batch files.
|
||||
@echo.
|
||||
@echo A properly installed version of Visual Studio will set
|
||||
@echo an environment variable such as %%VS150COMNTOOLS%%.
|
||||
@echo We use that variable to run the appropriate batch file
|
||||
@echo An environment variable such as %%VS150COMNTOOLS%% needs to be set.
|
||||
@echo This variable is not set automatically by the Visual Studio installer.
|
||||
@echo It must be set manually for your installation. For example:
|
||||
@echo.
|
||||
@echo "set VS150COMNTOOLS=C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\Common7\\Tools"
|
||||
@echo.
|
||||
@echo We use that variable to run the appropriate Visual Studio batch file
|
||||
@echo to set up the build environment.
|
||||
@echo.
|
||||
:: set errorlevel
|
||||
@set ERRLEV=1
|
||||
@exit /B 1
|
||||
|
||||
:END
|
||||
@ -93,9 +159,7 @@ goto :END
|
||||
@echo Setting Environment Variables thus...
|
||||
@echo.
|
||||
@echo vs_ver=%VS_VER%
|
||||
if defined VS_VER_EXPRESS (
|
||||
@echo vs_ver_express=%VS_VER_EXPRESS%
|
||||
)
|
||||
@echo FB_VSCOMNTOOLS=%FB_VSCOMNTOOLS%
|
||||
@echo platform=%FB_TARGET_PLATFORM%
|
||||
@echo msvc_version=%MSVC_VERSION%
|
||||
@echo db_path=%FB_DB_PATH%
|
||||
|
Loading…
Reference in New Issue
Block a user