2018-08-23 13:53:23 +02:00
|
|
|
@echo off
|
|
|
|
|
2018-08-21 17:27:26 +02:00
|
|
|
REM Default build is 64-bit
|
|
|
|
REM 32-bit compilation is available using "32" as a second parameter when you run msvc_build.bat
|
|
|
|
REM How to use:
|
|
|
|
REM BUILD 64-bit:
|
|
|
|
REM "msvc_build.bat debug" builds 64-bit Debug version of MuseScore without optimizations
|
|
|
|
REM "msvc_build.bat relwithdebinfo" builds optimized 64-bit version of MuseScore with almost all debug symbols
|
|
|
|
REM "msvc_build.bat release" builds fully optimized 64-bit version of MuseScore without command line output
|
|
|
|
REM
|
|
|
|
REM BUILD 32-bit:
|
|
|
|
REM "msvc_build.bat debug 32" builds 32-bit Debug version of MuseScore
|
|
|
|
REM "msvc_build.bat relwithdebinfo 32" builds 32-bit RelWithDebInfo version of MuseScore
|
|
|
|
REM "msvc_build.bat release 32" builds 32-bit Release version of MuseScore
|
|
|
|
REM
|
|
|
|
REM INSTALL 64-bit:
|
|
|
|
REM "msvc_build.bat install" put all required files of 64-bit Release build to install folder (msvc.install_x64)
|
|
|
|
REM "msvc_build.bat installdebug" put all required files of 64-bit Debug build to install folder (msvc.install_x64)
|
2020-11-09 05:16:50 +01:00
|
|
|
REM "msvc_build.bat installrelwithdebinfo" put all required files of 64-bit RelWithDebInfo build to install folder (msvc.install_x64)
|
2018-08-21 17:27:26 +02:00
|
|
|
REM
|
|
|
|
REM INSTALL 32-bit:
|
2020-11-09 05:16:50 +01:00
|
|
|
REM "msvc_build.bat install 32" put all required files of 32-bit Release build to install folder (msvc.install_x86)
|
|
|
|
REM "msvc_build.bat installdebug 32" put all required files of 32-bit Debug build to install folder (msvc.install_x86)
|
2018-08-21 17:27:26 +02:00
|
|
|
REM "msvc_build.bat installrelwithdebinfo 32" put all required files of 32-bit RelWithDebInfo build to install folder (msvc.install_x86)
|
|
|
|
REM
|
|
|
|
REM PACKAGE:
|
|
|
|
REM "msvc_build.bat package" pack the installer for already built and installed 64-bit Release build (msvc.build_x64/MuseScore-*.msi)
|
|
|
|
REM "msvc_build.bat package 32" pack the installer for already built and installed 32-bit Release build (msvc.build_x86/MuseScore-*.msi)
|
|
|
|
REM
|
|
|
|
REM CLEAN:
|
|
|
|
REM "msvc_build.bat clean" remove all files in msvc.* folders and the folders itself
|
2020-10-14 17:15:56 +02:00
|
|
|
REM
|
|
|
|
REM Windows Portable build is triggered by defining BUILD_WIN_PORTABLE environment variable to "ON" before launching this script, e.g.
|
|
|
|
REM SET BUILD_WIN_PORTABLE=ON
|
2018-08-21 17:27:26 +02:00
|
|
|
|
2020-11-09 05:16:50 +01:00
|
|
|
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
|
2020-04-14 18:54:23 +02:00
|
|
|
|
2020-09-07 11:03:49 +02:00
|
|
|
IF "%GENERATOR_NAME%"=="" (
|
|
|
|
CALL :FIND_GENERATOR
|
2020-11-09 05:16:50 +01:00
|
|
|
)
|
2020-04-14 18:54:23 +02:00
|
|
|
|
|
|
|
IF "%GENERATOR_NAME%"=="" (
|
|
|
|
ECHO "No supported version of Microsoft Visual Studio (2017 or 2019) found."
|
|
|
|
GOTO :END
|
|
|
|
)
|
|
|
|
|
2018-08-21 17:27:26 +02:00
|
|
|
REM BUILD_64 and BUILD_FOR_WINSTORE are used in CMakeLists.txt
|
2019-02-22 08:49:59 +01:00
|
|
|
SET BUILD_FOR_WINSTORE=OFF
|
2019-05-03 21:12:32 +02:00
|
|
|
SET "BUILD_FOLDER=msvc.build"
|
|
|
|
SET "INSTALL_FOLDER=msvc.install"
|
2018-07-10 14:57:05 +02:00
|
|
|
|
2019-08-31 17:54:00 +02:00
|
|
|
IF "%2"=="32" (
|
2020-04-14 18:54:23 +02:00
|
|
|
SET PLATFORM_NAME=Win32
|
2019-08-31 17:54:00 +02:00
|
|
|
SET "ARCH=x86"
|
|
|
|
SET BUILD_64=OFF
|
|
|
|
) ELSE (
|
|
|
|
IF NOT "%2"=="" (
|
|
|
|
IF NOT "%2"=="64" (
|
|
|
|
echo Invalid second argument
|
|
|
|
GOTO :END
|
|
|
|
) ELSE (
|
2020-04-14 18:54:23 +02:00
|
|
|
SET PLATFORM_NAME=x64
|
2019-08-31 17:54:00 +02:00
|
|
|
SET "ARCH=x64"
|
|
|
|
SET BUILD_64=ON
|
|
|
|
)
|
|
|
|
) ELSE (
|
2020-04-14 18:54:23 +02:00
|
|
|
SET PLATFORM_NAME=x64
|
2019-08-31 17:54:00 +02:00
|
|
|
SET "ARCH=x64"
|
|
|
|
SET BUILD_64=ON
|
|
|
|
)
|
2020-10-29 09:35:30 +01:00
|
|
|
)
|
2018-07-10 14:57:05 +02:00
|
|
|
|
2018-08-21 17:27:26 +02:00
|
|
|
IF NOT "%3"=="" (
|
2018-10-27 08:13:15 +02:00
|
|
|
SET BUILD_NUMBER="%3"
|
|
|
|
SET BUILD_AUTOUPDATE="ON"
|
2020-11-09 05:16:50 +01:00
|
|
|
)
|
2020-10-14 17:15:56 +02:00
|
|
|
|
2020-10-29 09:35:30 +01:00
|
|
|
ECHO "BUILD_WIN_PORTABLE: %BUILD_WIN_PORTABLE%"
|
2020-10-14 17:15:56 +02:00
|
|
|
IF "%BUILD_WIN_PORTABLE%"=="ON" (
|
2020-10-29 09:35:30 +01:00
|
|
|
SET "INSTALL_FOLDER=MuseScorePortable\App\MuseScore"
|
|
|
|
SET "BUILD_AUTOUPDATE=OFF"
|
|
|
|
SET "WIN_PORTABLE_OPT=-DBUILD_PORTABLEAPPS=ON"
|
2020-11-09 05:16:50 +01:00
|
|
|
)
|
2020-10-29 09:35:30 +01:00
|
|
|
|
2020-11-09 05:16:50 +01:00
|
|
|
ECHO "INSTALL_FOLDER: %INSTALL_FOLDER%"
|
|
|
|
ECHO "WIN_PORTABLE_OPT: %WIN_PORTABLE_OPT%"
|
2018-07-10 14:57:05 +02:00
|
|
|
|
2018-10-25 13:27:39 +02:00
|
|
|
IF /I "%1"=="release" (
|
2018-08-21 17:27:26 +02:00
|
|
|
SET CONFIGURATION_STR="release"
|
|
|
|
GOTO :BUILD
|
|
|
|
)
|
|
|
|
|
2018-10-25 13:27:39 +02:00
|
|
|
IF /I "%1"=="debug" (
|
2018-08-21 17:27:26 +02:00
|
|
|
SET CONFIGURATION_STR="debug"
|
|
|
|
GOTO :BUILD
|
|
|
|
)
|
2018-08-08 10:47:01 +02:00
|
|
|
|
2018-10-25 13:27:39 +02:00
|
|
|
IF /I "%1"=="relwithdebinfo" (
|
2018-08-21 17:27:26 +02:00
|
|
|
SET CONFIGURATION_STR="relwithdebinfo"
|
|
|
|
GOTO :BUILD
|
2020-11-09 05:16:50 +01:00
|
|
|
)
|
2018-08-08 14:52:21 +02:00
|
|
|
|
2018-10-25 13:27:39 +02:00
|
|
|
IF /I "%1"=="install" (
|
2019-05-03 21:12:32 +02:00
|
|
|
SET "BUILD_FOLDER=%BUILD_FOLDER%_%ARCH%"
|
2018-08-21 17:27:26 +02:00
|
|
|
SET CONFIGURATION_STR="release"
|
|
|
|
GOTO :INSTALL
|
2020-11-09 05:16:50 +01:00
|
|
|
)
|
2018-07-10 14:57:05 +02:00
|
|
|
|
2018-10-25 13:27:39 +02:00
|
|
|
IF /I "%1"=="installdebug" (
|
2019-05-03 21:12:32 +02:00
|
|
|
SET "BUILD_FOLDER=%BUILD_FOLDER%_%ARCH%"
|
2018-08-21 17:27:26 +02:00
|
|
|
SET CONFIGURATION_STR="debug"
|
|
|
|
GOTO :INSTALL
|
2020-11-09 05:16:50 +01:00
|
|
|
)
|
2018-08-08 14:52:21 +02:00
|
|
|
|
2018-10-25 13:27:39 +02:00
|
|
|
IF /I "%1"=="installrelwithdebinfo" (
|
2019-05-03 21:12:32 +02:00
|
|
|
SET "BUILD_FOLDER=%BUILD_FOLDER%_%ARCH%"
|
2018-08-21 17:27:26 +02:00
|
|
|
SET CONFIGURATION_STR="relwithdebinfo"
|
|
|
|
GOTO :INSTALL
|
2020-11-09 05:16:50 +01:00
|
|
|
)
|
2018-08-08 14:52:21 +02:00
|
|
|
|
2018-10-25 13:27:39 +02:00
|
|
|
IF /I "%1"=="package" (
|
2019-05-03 21:12:32 +02:00
|
|
|
cd "%BUILD_FOLDER%_%ARCH%"
|
2019-04-11 19:17:07 +02:00
|
|
|
cmake --build . --config RelWithDebInfo --target package
|
2018-08-21 17:27:26 +02:00
|
|
|
GOTO :END
|
2020-11-09 05:16:50 +01:00
|
|
|
)
|
2018-07-10 14:57:05 +02:00
|
|
|
|
2020-11-17 09:06:50 +01:00
|
|
|
IF /I "%1"=="revision" (
|
|
|
|
echo revisionStep
|
|
|
|
git rev-parse --short=7 HEAD > local_build_revision.env
|
|
|
|
GOTO :END
|
|
|
|
)
|
|
|
|
|
2018-10-25 13:27:39 +02:00
|
|
|
IF /I "%1"=="clean" (
|
2018-08-21 17:27:26 +02:00
|
|
|
for /d %%G in ("msvc.*") do rd /s /q "%%~G"
|
2020-10-14 17:15:56 +02:00
|
|
|
for /d %%G in ("MuseScorePortable") do rd /s /q "%%~G"
|
2018-08-21 17:27:26 +02:00
|
|
|
GOTO :END
|
2020-11-09 05:16:50 +01:00
|
|
|
) ELSE (
|
2019-05-03 21:12:32 +02:00
|
|
|
echo No valid parameters are set
|
2018-08-21 17:27:26 +02:00
|
|
|
GOTO :END
|
2020-11-09 05:16:50 +01:00
|
|
|
)
|
2018-08-21 17:27:26 +02:00
|
|
|
|
2020-04-14 18:54:23 +02:00
|
|
|
:FIND_GENERATOR
|
|
|
|
|
|
|
|
REM Usage: CALL :FIND_GENERATOR
|
|
|
|
REM Detects the highest supported VS version installed and sets GENERATOR_NAME to the appropriate CMake generator name.
|
|
|
|
|
|
|
|
REM vswhere.exe is a helper utility that is automatically installed with VS2017 and later (and always at a fixed location).
|
|
|
|
SET VSWHERE="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
|
2020-11-09 05:16:50 +01:00
|
|
|
IF NOT EXIST %VSWHERE% EXIT /B !ERRORLEVEL!
|
2020-04-14 18:54:23 +02:00
|
|
|
|
|
|
|
REM Try Visual Studio 2019 first.
|
|
|
|
CALL :FIND_GENERATOR_VERSION %VSWHERE% 16 2019
|
|
|
|
|
|
|
|
REM Fall back to Visual Studio 2017.
|
|
|
|
IF "%GENERATOR_NAME%"=="" CALL :FIND_GENERATOR_VERSION %VSWHERE% 15 2017
|
|
|
|
|
2020-11-09 05:16:50 +01:00
|
|
|
EXIT /B !ERRORLEVEL!
|
2020-04-14 18:54:23 +02:00
|
|
|
|
|
|
|
:FIND_GENERATOR_VERSION
|
|
|
|
|
|
|
|
REM Usage: CALL :FIND_GENERATOR_VERSION "[path\]vswhere.exe" major_version_number year
|
|
|
|
REM Checks if the specified VS version is installed, and if so, sets GENERATOR_NAME to the appropriate CMake generator name.
|
|
|
|
|
|
|
|
FOR /F "usebackq delims=. tokens=1" %%I IN (`%1 -version [%2^,^) -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationVersion -format value`) DO (
|
|
|
|
IF "%%I"=="%2" SET GENERATOR_NAME=Visual Studio %2 %3
|
|
|
|
)
|
|
|
|
|
2020-11-09 05:16:50 +01:00
|
|
|
EXIT /B !ERRORLEVEL!
|
2020-04-14 18:54:23 +02:00
|
|
|
|
2018-08-21 17:27:26 +02:00
|
|
|
:BUILD
|
2020-04-14 18:54:23 +02:00
|
|
|
echo Generator is: %GENERATOR_NAME%
|
|
|
|
echo Platform is: %PLATFORM_NAME%
|
2019-05-03 21:12:32 +02:00
|
|
|
SET "BUILD_FOLDER=%BUILD_FOLDER%_%ARCH%"
|
|
|
|
echo Build folder is: %BUILD_FOLDER%
|
2020-10-14 17:15:56 +02:00
|
|
|
IF NOT "%BUILD_WIN_PORTABLE%"=="ON" (
|
|
|
|
SET "INSTALL_FOLDER=%INSTALL_FOLDER%_%ARCH%"
|
2020-11-09 05:16:50 +01:00
|
|
|
)
|
2019-05-03 21:12:32 +02:00
|
|
|
echo Install folder is: %INSTALL_FOLDER%
|
2020-11-09 05:16:50 +01:00
|
|
|
if not exist "%BUILD_FOLDER%\" mkdir "%BUILD_FOLDER%"
|
|
|
|
if not exist "%INSTALL_FOLDER%\" mkdir "%INSTALL_FOLDER%"
|
2019-02-15 13:26:32 +01:00
|
|
|
|
2020-01-18 23:07:47 +01:00
|
|
|
IF NOT "%MSCORE_STABLE_BUILD%" == "" (
|
2020-12-10 14:38:48 +01:00
|
|
|
IF NOT "%CRASH_LOG_SERVER_URL%" == "" (
|
2020-01-18 23:07:47 +01:00
|
|
|
IF "%BUILD_FOR_WINSTORE%" == "OFF" (
|
|
|
|
SET CRASH_REPORT_URL_OPT=-DCRASH_REPORT_URL=%CRASH_LOG_SERVER_URL% -DBUILD_CRASH_REPORTER=ON
|
2019-07-09 14:25:58 +02:00
|
|
|
)
|
2020-11-09 05:16:50 +01:00
|
|
|
)
|
2019-02-15 13:26:32 +01:00
|
|
|
|
2020-01-18 23:07:47 +01:00
|
|
|
IF NOT "%TELEMETRY_TRACK_ID%" == "" (
|
|
|
|
SET TELEMETRY_TRACK_ID_OPT=-DTELEMETRY_TRACK_ID=%TELEMETRY_TRACK_ID%
|
2019-12-20 15:22:27 +01:00
|
|
|
)
|
2020-11-09 05:16:50 +01:00
|
|
|
)
|
2019-12-20 15:22:27 +01:00
|
|
|
|
2020-10-29 09:35:30 +01:00
|
|
|
IF "%MUSESCORE_BUILD_CONFIG%" == "" (
|
|
|
|
SET MUSESCORE_BUILD_CONFIG="dev"
|
2020-11-09 05:16:50 +01:00
|
|
|
)
|
2020-10-29 09:35:30 +01:00
|
|
|
|
2020-10-23 15:49:08 +02:00
|
|
|
IF NOT "%BUILD_VST%" == "" (
|
|
|
|
SET BUILD_VST_OPT=-DBUILD_VST=%BUILD_VST%
|
|
|
|
SET VST3_SDK_PATH_OPT=-DVST3_SDK_PATH=%VST3_SDK_PATH%
|
|
|
|
)
|
|
|
|
|
2020-10-14 17:15:56 +02:00
|
|
|
SET "INSTALL_FOLDER=%INSTALL_FOLDER:\=/%"
|
2019-02-15 13:26:32 +01:00
|
|
|
REM -DCMAKE_BUILD_NUMBER=%BUILD_NUMBER% -DCMAKE_BUILD_AUTOUPDATE=%BUILD_AUTOUPDATE% %CRASH_REPORT_URL_OPT% are used for CI only
|
2020-10-29 09:35:30 +01:00
|
|
|
cd "%BUILD_FOLDER%"
|
2020-11-09 05:16:50 +01:00
|
|
|
IF EXIST "CMakeCache.txt" (
|
|
|
|
echo Using existing CMake configuration to save time.
|
|
|
|
echo To force reconfiguration, delete CMakeCache.txt or run "msvc_build.bat clean".
|
|
|
|
echo You only need to do this if you want to use different build options to before.
|
|
|
|
REM Note: If a CMakeLists.txt file was edited then the build system will detect it
|
|
|
|
REM and run CMake again automatically with the same options as before.
|
|
|
|
) ELSE (
|
|
|
|
echo Building CMake configuration...
|
2020-12-03 08:58:32 +01:00
|
|
|
cmake -G "%GENERATOR_NAME%" -A "%PLATFORM_NAME%" -DCMAKE_INSTALL_PREFIX=../%INSTALL_FOLDER% -DCMAKE_BUILD_TYPE=%CONFIGURATION_STR% -DMUSESCORE_BUILD_CONFIG=%MUSESCORE_BUILD_CONFIG% -DMUSESCORE_REVISION=%MUSESCORE_REVISION% -DBUILD_FOR_WINSTORE=%BUILD_FOR_WINSTORE% -DBUILD_64=%BUILD_64% -DCMAKE_BUILD_NUMBER=%BUILD_NUMBER% -DBUILD_AUTOUPDATE=%BUILD_AUTOUPDATE% %BUILD_VST_OPT% %VST3_SDK_PATH_OPT% %CRASH_REPORT_URL_OPT% %TELEMETRY_TRACK_ID_OPT% %WIN_PORTABLE_OPT% ..
|
2020-11-09 05:16:50 +01:00
|
|
|
IF !ERRORLEVEL! NEQ 0 (
|
|
|
|
set OLD_ERRORLEVEL=!ERRORLEVEL!
|
|
|
|
del /f "CMakeCache.txt"
|
|
|
|
exit /b !OLD_ERRORLEVEL!
|
|
|
|
)
|
|
|
|
)
|
2019-05-03 21:12:32 +02:00
|
|
|
echo Building MuseScore...
|
2020-10-29 09:35:30 +01:00
|
|
|
cmake --build . --config %CONFIGURATION_STR% --target mscore
|
2018-08-21 17:27:26 +02:00
|
|
|
GOTO :END
|
|
|
|
|
|
|
|
:INSTALL
|
2019-05-03 21:12:32 +02:00
|
|
|
cd "%BUILD_FOLDER%"
|
|
|
|
echo Installing MuseScore files...
|
2018-08-23 14:29:00 +02:00
|
|
|
cmake --build . --config %CONFIGURATION_STR% --target install
|
2018-08-21 17:27:26 +02:00
|
|
|
GOTO :END
|
|
|
|
|
2020-04-14 18:54:23 +02:00
|
|
|
:END
|
2020-11-09 05:16:50 +01:00
|
|
|
exit /b !ERRORLEVEL!
|