Warning, /graphics/krita/build-tools/windows/build-msvc.cmd is written in an unsupported language. File is not indexed.
0001 @echo off
0002
0003 setlocal enabledelayedexpansion
0004 goto begin
0005
0006
0007 :: Subroutines
0008
0009 :find_on_path out_variable file_name
0010 set %1=%~f$PATH:2
0011 goto :EOF
0012
0013
0014 :get_dir_path out_variable file_path
0015 set %1=%~dp2
0016 goto :EOF
0017
0018
0019 :get_full_path out_variable file_path
0020 setlocal
0021 set FULL_PATH=%~f2
0022 if not exist "%FULL_PATH%" (
0023 set FULL_PATH=
0024 ) else (
0025 if exist "%FULL_PATH%\" (
0026 set FULL_PATH=
0027 )
0028 )
0029 endlocal & set "%1=%FULL_PATH%"
0030 goto :EOF
0031
0032
0033 :get_full_path_dir out_variable file_path
0034 setlocal
0035 set FULL_PATH=%~dp2
0036 if not exist "%FULL_PATH%" (
0037 set FULL_PATH=
0038 )
0039 endlocal & set "%1=%FULL_PATH%"
0040 goto :EOF
0041
0042
0043 :prompt_for_string out_variable prompt
0044 set /p %1=%~2^>
0045 goto :EOF
0046
0047
0048 :prompt_for_positive_integer out_variable prompt
0049 setlocal
0050 call :prompt_for_string USER_INPUT "%~2"
0051 if "%USER_INPUT%" == "" set USER_INPUT=0
0052 set /a RESULT=%USER_INPUT%
0053 if not %RESULT% GTR 0 (
0054 set RESULT=
0055 )
0056 endlocal & set "%1=%RESULT%"
0057 goto :EOF
0058
0059
0060 :prompt_for_file out_variable prompt
0061 setlocal
0062 :prompt_for_file__retry
0063 call :prompt_for_string USER_INPUT "%~2"
0064 if "%USER_INPUT%" == "" (
0065 endlocal
0066 set %1=
0067 goto :EOF
0068 )
0069 call :get_full_path RESULT "%USER_INPUT%"
0070 if "%RESULT%" == "" (
0071 echo Input does not point to valid file!
0072 set USER_INPUT=
0073 goto prompt_for_file__retry
0074 )
0075 endlocal & set "%1=%RESULT%"
0076 goto :EOF
0077
0078
0079 :prompt_for_dir out_variable prompt
0080 setlocal
0081 :prompt_for_dir__retry
0082 call :prompt_for_string USER_INPUT "%~2"
0083 if "%USER_INPUT%" == "" (
0084 endlocal
0085 set %1=
0086 goto :EOF
0087 )
0088 call :get_full_path_dir RESULT "%USER_INPUT%\"
0089 if "%RESULT%" == "" (
0090 echo Input does not point to valid dir!
0091 set USER_INPUT=
0092 goto prompt_for_dir__retry
0093 )
0094 endlocal & set "%1=%RESULT%"
0095 goto :EOF
0096
0097
0098 :has_target out_variable folder
0099 setlocal
0100 set RESULT=
0101 if exist "%~2" (
0102 set RESULT=1
0103 )
0104 endlocal & set "%1=%RESULT%"
0105 goto :EOF
0106
0107 :usage
0108 echo Usage:
0109 echo %~n0 [--no-interactive] [ OPTIONS ... ]
0110 echo.
0111 echo Basic options:
0112 echo --no-interactive Run without interactive prompts
0113 echo When not specified, the script will prompt
0114 echo for some of the parameters.
0115 echo --jobs ^<count^> Set parallel jobs count when building
0116 echo Defaults to no. of logical cores
0117 echo --skip-deps Skips (re)building of deps
0118 echo --skip-krita Skips (re)building of Krita
0119 echo --cmd Launch a cmd prompt instead of building.
0120 echo The environment is set up like the build
0121 echo environment with some helper command macros.
0122 echo --dev Activate developer options, like 'CodeBlocks'
0123 echo generator and BUILD_TESTING
0124 echo.
0125 echo Path options:
0126 echo --src-dir ^<dir_path^> Specify Krita source dir
0127 echo If unspecified, this will be determined from
0128 echo the script location.
0129 echo --download-dir ^<dir_path^> Specify deps download dir
0130 echo Can be omitted if --skip-deps is used
0131 echo --deps-build-dir ^<dir_path^> Specify deps build dir
0132 echo Can be omitted if --skip-deps is used
0133 echo --deps-install-dir ^<dir_path^> Specify deps install dir
0134 echo --krita-build-dir ^<dir_path^> Specify Krita build dir
0135 echo Can be omitted if --skip-krita is used
0136 echo --krita-install-dir ^<dir_path^> Specify Krita install dir
0137 echo Can be omitted if --skip-krita is used
0138 echo.
0139 goto :EOF
0140 :usage_and_exit
0141 call :usage
0142 exit /b
0143 :usage_and_fail
0144 call :usage
0145 exit /b 100
0146
0147
0148 :: ----------------------------
0149 :begin
0150
0151 echo Krita build script for Windows
0152 echo.
0153
0154
0155 :: command-line args parsing
0156 set ARG_NO_INTERACTIVE=
0157 set ARG_JOBS=
0158 set ARG_SKIP_DEPS=
0159 set ARG_SKIP_KRITA=
0160 set ARG_SRC_DIR=
0161 set ARG_DOWNLOAD_DIR=
0162 set ARG_DEPS_BUILD_DIR=
0163 set ARG_DEPS_INSTALL_DIR=
0164 set ARG_KRITA_BUILD_DIR=
0165 set ARG_KRITA_INSTALL_DIR=
0166 set ARG_PLUGINS_BUILD_DIR=
0167 set ARG_CMD=
0168 set ARG_DEV=
0169 :args_parsing_loop
0170 set CURRENT_MATCHED=
0171 if not "%1" == "" (
0172 if "%1" == "--no-interactive" (
0173 set ARG_NO_INTERACTIVE=1
0174 set CURRENT_MATCHED=1
0175 )
0176 if "%1" == "--jobs" (
0177 if not "%ARG_JOBS%" == "" (
0178 echo ERROR: Arg --jobs specified more than once 1>&2
0179 echo.
0180 goto usage_and_fail
0181 )
0182 set /a "ARG_JOBS=%2"
0183 if not !ARG_JOBS! GTR 0 (
0184 echo ERROR: Arg --jobs is not a positive integer 1>&2
0185 echo.
0186 goto usage_and_fail
0187 )
0188 shift /2
0189 set CURRENT_MATCHED=1
0190 )
0191 if "%1" == "--skip-deps" (
0192 set ARG_SKIP_DEPS=1
0193 set CURRENT_MATCHED=1
0194 )
0195 if "%1" == "--skip-krita" (
0196 set ARG_SKIP_KRITA=1
0197 set CURRENT_MATCHED=1
0198 )
0199 if "%1" == "--dev" (
0200 set ARG_DEV=1
0201 set CURRENT_MATCHED=1
0202 )
0203 if "%1" == "--src-dir" (
0204 if not "%ARG_SRC_DIR%" == "" (
0205 echo ERROR: Arg --src-dir specified more than once 1>&2
0206 echo.
0207 goto usage_and_fail
0208 )
0209 if not exist "%~f2\" (
0210 echo ERROR: Arg --src-dir does not point to a directory 1>&2
0211 echo.
0212 goto usage_and_fail
0213 )
0214 call :get_dir_path ARG_SRC_DIR "%~f2\"
0215 shift /2
0216 set CURRENT_MATCHED=1
0217 )
0218 if "%1" == "--download-dir" (
0219 if not "%ARG_DOWNLOAD_DIR%" == "" (
0220 echo ERROR: Arg --download-dir specified more than once 1>&2
0221 echo.
0222 goto usage_and_fail
0223 )
0224 if "%~f2" == "" (
0225 echo ERROR: Arg --download-dir does not point to a valid path 1>&2
0226 echo.
0227 goto usage_and_fail
0228 )
0229 call :get_dir_path ARG_DOWNLOAD_DIR "%~f2\"
0230 shift /2
0231 set CURRENT_MATCHED=1
0232 )
0233 if "%1" == "--deps-build-dir" (
0234 if not "%ARG_DEPS_BUILD_DIR%" == "" (
0235 echo ERROR: Arg --deps-build-dir specified more than once 1>&2
0236 echo.
0237 goto usage_and_fail
0238 )
0239 if "%~f2" == "" (
0240 echo ERROR: Arg --deps-build-dir does not point to a valid path 1>&2
0241 echo.
0242 goto usage_and_fail
0243 )
0244 call :get_dir_path ARG_DEPS_BUILD_DIR "%~f2\"
0245 shift /2
0246 set CURRENT_MATCHED=1
0247 )
0248 if "%1" == "--deps-install-dir" (
0249 if not "%ARG_DEPS_INSTALL_DIR%" == "" (
0250 echo ERROR: Arg --deps-install-dir specified more than once 1>&2
0251 echo.
0252 goto usage_and_fail
0253 )
0254 if "%~f2" == "" (
0255 echo ERROR: Arg --deps-install-dir does not point to a valid path 1>&2
0256 echo.
0257 goto usage_and_fail
0258 )
0259 call :get_dir_path ARG_DEPS_INSTALL_DIR "%~f2\"
0260 shift /2
0261 set CURRENT_MATCHED=1
0262 )
0263 if "%1" == "--krita-build-dir" (
0264 if not "%ARG_KRITA_BUILD_DIR%" == "" (
0265 echo ERROR: Arg --krita-build-dir specified more than once 1>&2
0266 echo.
0267 goto usage_and_fail
0268 )
0269 if "%~f2" == "" (
0270 echo ERROR: Arg --krita-build-dir does not point to a valid path 1>&2
0271 echo.
0272 goto usage_and_fail
0273 )
0274 call :get_dir_path ARG_KRITA_BUILD_DIR "%~f2\"
0275 shift /2
0276 set CURRENT_MATCHED=1
0277 )
0278 if "%1" == "--krita-install-dir" (
0279 if not "%ARG_KRITA_INSTALL_DIR%" == "" (
0280 echo ERROR: Arg --krita-install-dir specified more than once 1>&2
0281 echo.
0282 goto usage_and_fail
0283 )
0284 if "%~f2" == "" (
0285 echo ERROR: Arg --krita-install-dir does not point to a valid path 1>&2
0286 echo.
0287 goto usage_and_fail
0288 )
0289 call :get_dir_path ARG_KRITA_INSTALL_DIR "%~f2\"
0290 shift /2
0291 set CURRENT_MATCHED=1
0292 )
0293 if "%1" == "--plugins-build-dir" (
0294 if not "%ARG_PLUGINS_BUILD_DIR%" == "" (
0295 echo ERROR: Arg --plugins-build-dir specified more than once 1>&2
0296 echo.
0297 goto usage_and_fail
0298 )
0299 if "%~f2" == "" (
0300 echo ERROR: Arg --plugins-build-dir does not point to a valid path 1>&2
0301 echo.
0302 goto usage_and_fail
0303 )
0304 call :get_dir_path ARG_PLUGINS_BUILD_DIR "%~f2\"
0305 shift /2
0306 set CURRENT_MATCHED=1
0307 )
0308 if "%1" == "--cmd" (
0309 set ARG_CMD=1
0310 set CURRENT_MATCHED=1
0311 )
0312 if "%1" == "--help" (
0313 goto usage_and_exit
0314 )
0315 if not "!CURRENT_MATCHED!" == "1" (
0316 echo ERROR: Unknown option %1 1>&2
0317 echo.
0318 goto usage_and_fail
0319 )
0320 shift /1
0321 goto args_parsing_loop
0322 )
0323
0324 if "%ARG_NO_INTERACTIVE%" == "1" (
0325 echo Non-interactive mode
0326 ) else (
0327 echo Interactive mode
0328 :: Trick to pause on exit
0329 call :real_begin
0330 pause
0331 exit /b !ERRORLEVEL!
0332 )
0333 :real_begin
0334 echo.
0335
0336
0337 if "%ARG_SKIP_DEPS%" == "1" (
0338 if "%ARG_SKIP_KRITA%" == "1" (
0339 echo Both deps and Krita will be skipped.
0340 ) else (
0341 echo Building of deps will be skipped.
0342 )
0343 ) else (
0344 if "%ARG_SKIP_KRITA%" == "1" (
0345 echo Building of Krita will be skipped.
0346 ) else (
0347 echo Both deps and Krita will be built.
0348 )
0349 )
0350
0351
0352 :: Check environment config
0353
0354 if "%CMAKE_EXE%" == "" (
0355 call :find_on_path CMAKE_EXE cmake.exe
0356 if "!CMAKE_EXE!" == "" (
0357 if not "%ARG_NO_INTERACTIVE%" == "1" (
0358 call :prompt_for_file CMAKE_EXE "Provide path to cmake.exe"
0359 )
0360 if "!CMAKE_EXE!" == "" (
0361 echo ERROR: CMake not found! 1>&2
0362 exit /b 102
0363 )
0364 call :get_dir_path CMAKE_BIN_DIR "!CMAKE_EXE!"
0365 ) else (
0366 echo Found CMake on PATH: !CMAKE_EXE!
0367 if not "%ARG_NO_INTERACTIVE%" == "1" (
0368 choice /c ny /n /m "Is this correct? [y/n] "
0369 if errorlevel 3 exit 255
0370 if not errorlevel 2 (
0371 call :prompt_for_file CMAKE_EXE "Provide path to cmake.exe"
0372 if "!CMAKE_EXE!" == "" (
0373 echo ERROR: CMake not found! 1>&2
0374 exit /b 102
0375 )
0376 call :get_dir_path CMAKE_BIN_DIR "!CMAKE_EXE!"
0377 )
0378 )
0379 call :get_dir_path CMAKE_BIN_DIR "!CMAKE_EXE!"
0380 )
0381 )
0382 echo CMake: %CMAKE_BIN_DIR%
0383
0384 if "%SEVENZIP_EXE%" == "" (
0385 call :find_on_path SEVENZIP_EXE 7z.exe
0386 if "!SEVENZIP_EXE!" == "" (
0387 set "SEVENZIP_EXE=%ProgramFiles%\7-Zip\7z.exe"
0388 if "!SEVENZIP_EXE!" == "" (
0389 set "SEVENZIP_EXE=%ProgramFiles(x86)%\7-Zip\7z.exe"
0390 )
0391 if "!SEVENZIP_EXE!" == "" (
0392 echo 7-Zip not found
0393 )
0394 )
0395 )
0396 if "%SEVENZIP_EXE%" == "" (
0397 echo 7-Zip: %SEVENZIP_EXE%
0398 )
0399
0400 if "%PYTHON_BIN_DIR%" == "" (
0401 call :find_on_path PYTHON_BIN_DIR_PYTHON_EXE python.exe
0402 if "!PYTHON_BIN_DIR_PYTHON_EXE!" == "" (
0403 if not "%ARG_NO_INTERACTIVE%" == "1" (
0404 call :prompt_for_file PYTHON_BIN_DIR_PYTHON_EXE "Provide path to python.exe of Python 3.6.2"
0405 )
0406 if "!PYTHON_BIN_DIR_PYTHON_EXE!" == "" (
0407 echo ERROR: Python not found! 1>&2
0408 exit /b 102
0409 )
0410 call :get_dir_path PYTHON_BIN_DIR "!PYTHON_BIN_DIR_PYTHON_EXE!"
0411 ) else (
0412 call :get_dir_path PYTHON_BIN_DIR "!PYTHON_BIN_DIR_PYTHON_EXE!"
0413 echo Found Python on PATH: !PYTHON_BIN_DIR!
0414 if not "%ARG_NO_INTERACTIVE%" == "1" (
0415 choice /c ny /n /m "Is this correct? [y/n] "
0416 if errorlevel 3 exit 255
0417 if not errorlevel 2 (
0418 call :prompt_for_file PYTHON_BIN_DIR_PYTHON_EXE "Provide path to python.exe of Python 3.6.2"
0419 if "!PYTHON_BIN_DIR_PYTHON_EXE!" == "" (
0420 echo ERROR: Python not found! 1>&2
0421 exit /b 102
0422 )
0423 call :get_dir_path PYTHON_BIN_DIR "!PYTHON_BIN_DIR_PYTHON_EXE!"
0424 )
0425 )
0426 )
0427 )
0428 echo Python: %PYTHON_BIN_DIR%
0429
0430 @REM Translation tools
0431
0432 if "%KRITA_GIT_DIR%" == "" (
0433 call :find_on_path KRITA_GIT_EXE_DIR git.exe
0434 if NOT "!KRITA_GIT_EXE_DIR!" == "" (
0435 call :get_dir_path KRITA_GIT_DIR "!KRITA_GIT_EXE_DIR!"
0436 echo Found Git on PATH: !KRITA_GIT_DIR!
0437 )
0438 ) else echo Git found on %KRITA_GIT_DIR%
0439
0440 if "%KRITA_NINJA_DIR%" == "" (
0441 call :find_on_path KRITA_NINJA_EXE_DIR ninja.exe
0442 if NOT "!KRITA_NINJA_EXE_DIR!" == "" (
0443 call :get_dir_path KRITA_NINJA_DIR "!KRITA_NINJA_EXE_DIR!"
0444 echo Found Ninja on PATH: !KRITA_NINJA_DIR!
0445 )
0446 ) else echo Ninja found on %KRITA_NINJA_DIR%
0447
0448 if "%SVN_DIR%" == "" (
0449 call :find_on_path SVN_EXE_DIR svn.exe
0450 if NOT "!SVN_EXE_DIR!" == "" (
0451 call :get_dir_path SVN_DIR "!SVN_EXE_DIR!"
0452 echo Found SVN on PATH: !SVN_DIR!
0453 )
0454 ) else echo SVN found on %SVN_DIR%
0455
0456 if "%PERL_DIR%" == "" (
0457 call :find_on_path PERL_EXE_DIR perl.exe
0458 if NOT "!PERL_EXE_DIR!" == "" (
0459 call :get_dir_path PERL_DIR "!PERL_EXE_DIR!"
0460 echo Found Perl on PATH: !PERL_DIR!
0461 )
0462 ) else echo Perl found on %PERL_DIR%
0463
0464 if "%ARG_SKIP_DEPS%" == "1" goto skip_windows_sdk_dir_check
0465
0466 if "%WindowsSdkDir%" == "" if not "%ProgramFiles(x86)%" == "" set "WindowsSdkDir=%ProgramFiles(x86)%\Windows Kits\10"
0467 if "%WindowsSdkDir%" == "" set "WindowsSdkDir=%ProgramFiles(x86)%\Windows Kits\10"
0468 if exist "%WindowsSdkDir%\" (
0469 pushd "%WindowsSdkDir%"
0470 if exist "bin\x64\fxc.exe" (
0471 set HAVE_FXC_EXE=1
0472 if "%WindowsSdkVerBinPath%" == "" set "WindowsSdkVerBinPath=%WindowsSdkDir%"
0473 ) else (
0474 for /f "delims=" %%a in ('dir /a:d /b "bin\10.*"') do (
0475 if exist "bin\%%a\x64\fxc.exe" (
0476 set HAVE_FXC_EXE=1
0477 if "%WindowsSdkVerBinPath%" == "" set "WindowsSdkVerBinPath=%WindowsSdkDir%\bin\%%a\"
0478 )
0479 )
0480 )
0481 popd
0482 )
0483 set QT_ENABLE_DYNAMIC_OPENGL=ON
0484 if not "%HAVE_FXC_EXE%" == "1" (
0485 set WindowsSdkDir=
0486 echo Windows SDK 10 with fxc.exe not found
0487 echo Qt will *not* be built with ANGLE ^(dynamic OpenGL^) support.
0488 if not "%ARG_NO_INTERACTIVE%" == "1" (
0489 choice /c ny /n /m "Is this ok? [y/n] "
0490 if errorlevel 3 exit 255
0491 if not errorlevel 2 (
0492 exit /b 102
0493 )
0494 )
0495 set QT_ENABLE_DYNAMIC_OPENGL=OFF
0496 ) else echo Windows SDK 10 with fxc.exe found on %WindowsSdkDir%
0497
0498 :skip_windows_sdk_dir_check
0499
0500 if not "%ARG_JOBS%" == "" (
0501 set "PARALLEL_JOBS=%ARG_JOBS%"
0502 set "UseMultiToolTask=true"
0503 set "EnforceProcessCountAcrossBuilds=true"
0504 )
0505 if "%PARALLEL_JOBS%" == "" (
0506 echo Number of logical CPU cores detected: %NUMBER_OF_PROCESSORS%
0507 echo Enabling %NUMBER_OF_PROCESSORS% parallel jobs
0508 set PARALLEL_JOBS=%NUMBER_OF_PROCESSORS%
0509 if not "%ARG_NO_INTERACTIVE%" == "1" (
0510 choice /c ny /n /m "Is this correct? [y/n] "
0511 if errorlevel 3 exit 255
0512 if not errorlevel 2 (
0513 call :prompt_for_positive_integer PARALLEL_JOBS "Provide no. of parallel jobs"
0514 if "!PARALLEL_JOBS!" == "" (
0515 echo ERROR: Invalid job count! 1>&2
0516 exit /b 102
0517 )
0518 )
0519 )
0520 set "UseMultiToolTask=true"
0521 set "EnforceProcessCountAcrossBuilds=true"
0522 )
0523 set "MultiProcMaxCount=%PARALLEL_JOBS%"
0524 echo Parallel jobs count: %PARALLEL_JOBS% (MultiProcMaxCount=%MultiProcMaxCount%)
0525
0526 if not "%ARG_SRC_DIR%" == "" (
0527 set "KRITA_SRC_DIR=%ARG_SRC_DIR%"
0528 )
0529 if "%KRITA_SRC_DIR%" == "" (
0530 :: Check whether this looks like to be in the source tree
0531 set "_temp=%~dp0"
0532 if "!_temp:~-21!" == "\build-tools\windows\" (
0533 if exist "!_temp:~0,-21!\CMakeLists.txt" (
0534 if exist "!_temp:~0,-21!\3rdparty\CMakeLists.txt" (
0535 set "KRITA_SRC_DIR=!_temp:~0,-21!\"
0536 echo Script is running inside Krita src dir
0537 )
0538 )
0539 )
0540 )
0541 if "%KRITA_SRC_DIR%" == "" (
0542 if not "%ARG_NO_INTERACTIVE%" == "1" (
0543 call :prompt_for_dir KRITA_SRC_DIR "Provide path of Krita src dir"
0544 )
0545 if "!KRITA_SRC_DIR!" == "" (
0546 echo ERROR: Krita src dir not found! 1>&2
0547 exit /b 102
0548 )
0549 )
0550 echo Krita src: %KRITA_SRC_DIR%
0551
0552 if "%ARG_SKIP_DEPS%" == "1" goto skip_deps_args_check
0553
0554 if not "%ARG_DOWNLOAD_DIR%" == "" (
0555 set "DEPS_DOWNLOAD_DIR=%ARG_DOWNLOAD_DIR%"
0556 )
0557 if "%DEPS_DOWNLOAD_DIR%" == "" (
0558 set DEPS_DOWNLOAD_DIR=%CD%\d\
0559 echo Using default deps download dir: !DEPS_DOWNLOAD_DIR!
0560 if not "%ARG_NO_INTERACTIVE%" == "1" (
0561 choice /c ny /n /m "Is this ok? [y/n] "
0562 if errorlevel 3 exit 255
0563 if not errorlevel 2 (
0564 call :prompt_for_dir DEPS_DOWNLOAD_DIR "Provide path of depps download dir"
0565 )
0566 )
0567 if "!DEPS_DOWNLOAD_DIR!" == "" (
0568 echo ERROR: Deps download dir not set! 1>&2
0569 exit /b 102
0570 )
0571 )
0572 echo Deps download dir: %DEPS_DOWNLOAD_DIR%
0573
0574 if not "%ARG_DEPS_BUILD_DIR%" == "" (
0575 set "DEPS_BUILD_DIR=%ARG_DEPS_BUILD_DIR%"
0576 )
0577 if "%DEPS_BUILD_DIR%" == "" (
0578 set DEPS_BUILD_DIR=%CD%\b_deps\
0579 echo Using default deps build dir: !DEPS_BUILD_DIR!
0580 if not "%ARG_NO_INTERACTIVE%" == "1" (
0581 choice /c ny /n /m "Is this ok? [y/n] "
0582 if errorlevel 3 exit 255
0583 if not errorlevel 2 (
0584 call :prompt_for_dir DEPS_BUILD_DIR "Provide path of deps build dir"
0585 )
0586 )
0587 if "!DEPS_BUILD_DIR!" == "" (
0588 echo ERROR: Deps build dir not set! 1>&2
0589 exit /b 102
0590 )
0591 )
0592 echo Deps build dir: %DEPS_BUILD_DIR%
0593
0594 :skip_deps_args_check
0595
0596 if not "%ARG_DEPS_INSTALL_DIR%" == "" (
0597 set "DEPS_INSTALL_DIR=%ARG_DEPS_INSTALL_DIR%"
0598 )
0599 if "%DEPS_INSTALL_DIR%" == "" (
0600 set DEPS_INSTALL_DIR=%CD%\i_deps\
0601 echo Using default deps install dir: !DEPS_INSTALL_DIR!
0602 if not "%ARG_NO_INTERACTIVE%" == "1" (
0603 choice /c ny /n /m "Is this ok? [y/n] "
0604 if errorlevel 3 exit 255
0605 if not errorlevel 2 (
0606 call :prompt_for_dir DEPS_INSTALL_DIR "Provide path of deps install dir"
0607 )
0608 )
0609 if "!DEPS_INSTALL_DIR!" == "" (
0610 echo ERROR: Deps install dir not set! 1>&2
0611 exit /b 102
0612 )
0613 )
0614 echo Deps install dir: %DEPS_INSTALL_DIR%
0615
0616 if "%ARG_SKIP_KRITA%" == "1" goto skip_krita_args_check
0617
0618 if not "%ARG_KRITA_BUILD_DIR%" == "" (
0619 set "KRITA_BUILD_DIR=%ARG_KRITA_BUILD_DIR%"
0620 )
0621 if "%KRITA_BUILD_DIR%" == "" (
0622 set KRITA_BUILD_DIR=%CD%\b\
0623 echo Using default Krita build dir: !KRITA_BUILD_DIR!
0624 if not "%ARG_NO_INTERACTIVE%" == "1" (
0625 choice /c ny /n /m "Is this ok? [y/n] "
0626 if errorlevel 3 exit 255
0627 if not errorlevel 2 (
0628 call :prompt_for_dir KRITA_BUILD_DIR "Provide path of Krita build dir"
0629 )
0630 )
0631 if "!KRITA_BUILD_DIR!" == "" (
0632 echo ERROR: Krita build dir not set! 1>&2
0633 exit /b 102
0634 )
0635 )
0636 echo Krita build dir: %KRITA_BUILD_DIR%
0637
0638 @REM Plugins also need the download dir
0639 if not "%ARG_DOWNLOAD_DIR%" == "" (
0640 set "PLUGINS_DOWNLOAD_DIR=%ARG_DOWNLOAD_DIR%"
0641 )
0642 if "%PLUGINS_DOWNLOAD_DIR%" == "" (
0643 set PLUGINS_DOWNLOAD_DIR=%CD%\d\
0644 echo Using default deps download dir: !PLUGINS_DOWNLOAD_DIR!
0645 if not "%ARG_NO_INTERACTIVE%" == "1" (
0646 choice /c ny /n /m "Is this ok? [y/n] "
0647 if errorlevel 3 exit 255
0648 if not errorlevel 2 (
0649 call :prompt_for_dir PLUGINS_DOWNLOAD_DIR "Provide path of plugins download dir"
0650 )
0651 )
0652 if "!PLUGINS_DOWNLOAD_DIR!" == "" (
0653 echo ERROR: Plugins download dir not set! 1>&2
0654 exit /b 102
0655 )
0656 )
0657 echo Plugins download dir: %PLUGINS_DOWNLOAD_DIR%
0658
0659 if not "%ARG_PLUGINS_BUILD_DIR%" == "" (
0660 set "PLUGINS_BUILD_DIR=%ARG_PLUGINS_BUILD_DIR%"
0661 )
0662 if "%PLUGINS_BUILD_DIR%" == "" (
0663 set PLUGINS_BUILD_DIR=%CD%\b_plugins\
0664 echo Using default plugins build dir: !PLUGINS_BUILD_DIR!
0665 if not "%ARG_NO_INTERACTIVE%" == "1" (
0666 choice /c ny /n /m "Is this ok? [y/n] "
0667 if errorlevel 3 exit 255
0668 if not errorlevel 2 (
0669 call :prompt_for_dir PLUGINS_BUILD_DIR "Provide path of plugins build dir"
0670 )
0671 )
0672 if "!PLUGINS_BUILD_DIR!" == "" (
0673 echo ERROR: Plugins build dir not set! 1>&2
0674 exit /b 102
0675 )
0676 )
0677 echo Plugins build dir: %PLUGINS_BUILD_DIR%
0678
0679 if not "%ARG_KRITA_INSTALL_DIR%" == "" (
0680 set "KRITA_INSTALL_DIR=%ARG_KRITA_INSTALL_DIR%"
0681 )
0682 if "%KRITA_INSTALL_DIR%" == "" (
0683 set KRITA_INSTALL_DIR=%CD%\i\
0684 echo Using default Krita install dir: !KRITA_INSTALL_DIR!
0685 if not "%ARG_NO_INTERACTIVE%" == "1" (
0686 choice /c ny /n /m "Is this ok? [y/n] "
0687 if errorlevel 3 exit 255
0688 if not errorlevel 2 (
0689 call :prompt_for_dir KRITA_INSTALL_DIR "Provide path of Krita install dir"
0690 )
0691 )
0692 if "!KRITA_INSTALL_DIR!" == "" (
0693 echo ERROR: Krita install dir not set! 1>&2
0694 exit /b 102
0695 )
0696 )
0697 echo Krita install dir: %KRITA_INSTALL_DIR%
0698
0699 :skip_krita_args_check
0700
0701 echo.
0702
0703
0704 if not "%ARG_NO_INTERACTIVE%" == "1" (
0705 choice /c ny /n /m "Is the above ok? [y/n] "
0706 if errorlevel 3 exit 255
0707 if not errorlevel 2 (
0708 exit /b 1
0709 )
0710 echo.
0711 )
0712
0713 :: Initialize clean PATH
0714 set PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
0715 :: Set PATH for calling Python scripts
0716 set PATH=%PYTHON_BIN_DIR%;%PATH%
0717 :: Set PATH for external tools (Meson/Ninja)
0718 if NOT "%KRITA_GIT_DIR%" == "" (
0719 set PATH=%PATH%;%KRITA_GIT_DIR%
0720 )
0721 if NOT "%KRITA_NINJA_DIR%" == "" (
0722 if NOT "%KRITA_NINJA_DIR%" == "%MINGW_BIN_DIR%" (
0723 set PATH=%PATH%;%KRITA_NINJA_DIR%
0724 )
0725 )
0726 if NOT "%SVN_DIR%" == "" (
0727 set PATH=%PATH%;%SVN_DIR%
0728 )
0729 if NOT "%CMAKE_BIN_DIR%" == "" (
0730 set PATH=%PATH%;%CMAKE_BIN_DIR%
0731 )
0732
0733 echo Creating dirs...
0734 if NOT "%ARG_SKIP_DEPS%" == "1" (
0735 mkdir %DEPS_DOWNLOAD_DIR%
0736 if errorlevel 1 (
0737 if not exist "%DEPS_DOWNLOAD_DIR%\" (
0738 echo ERROR: Cannot create deps download dir! 1>&2
0739 exit /b 103
0740 )
0741 )
0742 mkdir %DEPS_BUILD_DIR%
0743 if errorlevel 1 (
0744 if not exist "%DEPS_BUILD_DIR%\" (
0745 echo ERROR: Cannot create deps build dir! 1>&2
0746 exit /b 103
0747 )
0748 )
0749 mkdir %DEPS_INSTALL_DIR%
0750 if errorlevel 1 (
0751 if not exist "%DEPS_INSTALL_DIR%\" (
0752 echo ERROR: Cannot create deps install dir! 1>&2
0753 exit /b 103
0754 )
0755 )
0756 )
0757 if NOT "%ARG_SKIP_KRITA%" == "1" (
0758 mkdir %KRITA_BUILD_DIR%
0759 if errorlevel 1 (
0760 if not exist "%KRITA_BUILD_DIR%\" (
0761 echo ERROR: Cannot create Krita build dir! 1>&2
0762 exit /b 103
0763 )
0764 )
0765 mkdir %PLUGINS_DOWNLOAD_DIR%
0766 if errorlevel 1 (
0767 if not exist "%PLUGINS_DOWNLOAD_DIR%\" (
0768 echo ERROR: Cannot create plugins download dir! 1>&2
0769 exit /b 103
0770 )
0771 )
0772 mkdir %PLUGINS_BUILD_DIR%
0773 if errorlevel 1 (
0774 if not exist "%PLUGINS_BUILD_DIR%\" (
0775 echo ERROR: Cannot create plugins build dir! 1>&2
0776 exit /b 103
0777 )
0778 )
0779 mkdir %KRITA_INSTALL_DIR%
0780 if errorlevel 1 (
0781 if not exist "%KRITA_INSTALL_DIR%\" (
0782 echo ERROR: Cannot create Krita install dir! 1>&2
0783 exit /b 103
0784 )
0785 )
0786 )
0787
0788 echo.
0789
0790
0791 set CMAKE_BUILD_TYPE=RelWithDebInfo
0792 set QT_ENABLE_DEBUG_INFO=OFF
0793
0794 set KRITA_GENERATOR=Visual Studio 17 2022
0795 set KRITA_BUILD_TESTING=OFF
0796 set KRITA_INSTALL_BENCHMARKS=OFF
0797
0798 if "%ARG_DEV%" == "1" (
0799 set KRITA_BUILD_TESTING=ON
0800 set KRITA_INSTALL_BENCHMARKS=ON
0801 )
0802
0803 if "%KRITA_BRANDING%" == "" (
0804 rem Check Jenkins job name
0805 if "%JOB_NAME%" == "Krita_Nightly_Windows_Build" (
0806 set KRITA_BRANDING=Next
0807 ) else (
0808 if "%JOB_NAME%" == "Krita_Stable_Windows_Build" (
0809 set KRITA_BRANDING=Plus
0810 )
0811 )
0812 )
0813
0814 :: Paths for CMake
0815 set "BUILDDIR_DOWNLOAD_CMAKE=%DEPS_DOWNLOAD_DIR:\=/%"
0816 set "BUILDDIR_DOWNLOAD_CMAKE=%BUILDDIR_DOWNLOAD_CMAKE: =\ %"
0817 set "BUILDDIR_PLUGINS_DOWNLOAD_CMAKE=%PLUGINS_DOWNLOAD_DIR:\=/%"
0818 set "BUILDDIR_PLUGINS_DOWNLOAD_CMAKE=%BUILDDIR_PLUGINS_DOWNLOAD_CMAKE: =\ %"
0819 set "BUILDDIR_DEPS_INSTALL_CMAKE=%DEPS_INSTALL_DIR:\=/%"
0820 set "BUILDDIR_DEPS_INSTALL_CMAKE=%BUILDDIR_DEPS_INSTALL_CMAKE: =\ %"
0821 set "BUILDDIR_KRITA_INSTALL_CMAKE=%KRITA_INSTALL_DIR:\=/%"
0822 set "BUILDDIR_KRITA_INSTALL_CMAKE=%BUILDDIR_KRITA_INSTALL_CMAKE: =\ %"
0823 set "BUILDDIR_PLUGINS_INSTALL_CMAKE=%KRITA_INSTALL_DIR:\=/%"
0824 set "BUILDDIR_PLUGINS_INSTALL_CMAKE=%BUILDDIR_KRITA_INSTALL_CMAKE: =\ %"
0825
0826 if not "%PERL_DIR%" == "" (
0827 :: Safety measure for Strawberry Perl injecting pkg-config in the PATH
0828 call :find_on_path STRAWBERRY_PERL_PKG_CONFIG_EXE_DIR pkg-config.bat
0829 if exist "%PERL_DIR%\pkg-config.bat" (
0830 echo Found unpatched Strawberry Perl, ignoring due to its pkg-config introducing external binaries.
0831 set "PATH=%PATH%;%DEPS_INSTALL_DIR%\Strawberry\perl\bin"
0832 ) else (
0833 echo Found patched Strawberry Perl, it is safe to use.
0834 set "PERL_EXECUTABLE=%PERL_DIR%\perl.exe"
0835 set "PERL_EXECUTABLE=!PERL_EXECUTABLE:\=/!"
0836 set "PERL_EXECUTABLE=!PERL_EXECUTABLE: =\ !"
0837 set "PATH=%PATH%;%PERL_DIR%"
0838 )
0839 ) else (
0840 set "PATH=%PATH%;%DEPS_INSTALL_DIR%\Strawberry\perl\bin"
0841 )
0842
0843 set PATH=%DEPS_INSTALL_DIR%\bin;%PATH%
0844
0845 if not "%GETTEXT_SEARCH_PATH%" == "" (
0846 set PATH=!PATH!;!GETTEXT_SEARCH_PATH!
0847 )
0848
0849 :: Prepare the CMake command lines
0850 set CMDLINE_CMAKE_DEPS="%CMAKE_EXE%" "%KRITA_SRC_DIR%\3rdparty" ^
0851 -DSUBMAKE_JOBS=%PARALLEL_JOBS% ^
0852 -DQT_ENABLE_DEBUG_INFO=%QT_ENABLE_DEBUG_INFO% ^
0853 -DQT_ENABLE_DYNAMIC_OPENGL=%QT_ENABLE_DYNAMIC_OPENGL% ^
0854 -DPERL_EXECUTABLE=%PERL_EXECUTABLE% ^
0855 -DEXTERNALS_DOWNLOAD_DIR=%BUILDDIR_DOWNLOAD_CMAKE% ^
0856 -DINSTALL_ROOT=%BUILDDIR_DEPS_INSTALL_CMAKE% ^
0857 -G "%KRITA_GENERATOR%" ^
0858 -A "x64" ^
0859 -T "host=x64" ^
0860 -DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%
0861
0862 set CMDLINE_CMAKE_KRITA="%CMAKE_EXE%" "%KRITA_SRC_DIR%\." ^
0863 -DBoost_DEBUG=OFF ^
0864 -DBOOST_INCLUDEDIR=%BUILDDIR_DEPS_INSTALL_CMAKE%/include ^
0865 -DBOOST_ROOT=%BUILDDIR_DEPS_INSTALL_CMAKE% ^
0866 -DBOOST_LIBRARYDIR=%BUILDDIR_DEPS_INSTALL_CMAKE%/lib ^
0867 -DCMAKE_PREFIX_PATH=%BUILDDIR_DEPS_INSTALL_CMAKE% ^
0868 -DCMAKE_INSTALL_PREFIX=%BUILDDIR_KRITA_INSTALL_CMAKE% ^
0869 -DBUILD_TESTING=%KRITA_BUILD_TESTING% ^
0870 -DINSTALL_BENCHMARKS=%KRITA_INSTALL_BENCHMARKS% ^
0871 -DHAVE_MEMORY_LEAK_TRACKER=OFF ^
0872 -DFOUNDATION_BUILD=ON ^
0873 -DUSE_QT_TABLET_WINDOWS=ON ^
0874 -DHIDE_SAFE_ASSERTS=ON ^
0875 -DBRANDING=%KRITA_BRANDING% ^
0876 -Wno-dev ^
0877 -G "%KRITA_GENERATOR%" ^
0878 -A "x64" ^
0879 -T "host=x64" ^
0880 -DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%
0881
0882 set CMDLINE_CMAKE_PLUGINS="%CMAKE_EXE%" "%KRITA_SRC_DIR%\3rdparty_plugins" ^
0883 -DSUBMAKE_JOBS=%PARALLEL_JOBS% ^
0884 -DQT_ENABLE_DEBUG_INFO=%QT_ENABLE_DEBUG_INFO% ^
0885 -DQT_ENABLE_DYNAMIC_OPENGL=%QT_ENABLE_DYNAMIC_OPENGL% ^
0886 -DEXTERNALS_DOWNLOAD_DIR=%BUILDDIR_PLUGINS_DOWNLOAD_CMAKE% ^
0887 -DINSTALL_ROOT=%BUILDDIR_PLUGINS_INSTALL_CMAKE% ^
0888 -G "%KRITA_GENERATOR%" ^
0889 -A "x64" ^
0890 -T "host=x64" ^
0891 -DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%
0892
0893 :: Launch CMD prompt if requested
0894 if "%ARG_CMD%" == "1" (
0895 doskey cmake-deps=cmd /c "pushd %DEPS_BUILD_DIR% && %CMDLINE_CMAKE_DEPS%"
0896 doskey cmake-krita=cmd /c "pushd %KRITA_BUILD_DIR% && %CMDLINE_CMAKE_KRITA%"
0897 doskey make-deps=cmd /c "pushd %DEPS_BUILD_DIR% && "%CMAKE_EXE%" --build . --config %CMAKE_BUILD_TYPE% --target $* --parallel %PARALLEL_JOBS%"
0898 doskey make-krita=cmd /c "pushd %KRITA_BUILD_DIR% && "%CMAKE_EXE%" --build . --config %CMAKE_BUILD_TYPE% --target install --parallel %PARALLEL_JOBS%"
0899 doskey make-plugins=cmd /c "pushd %PLUGINS_BUILD_DIR% && "%CMAKE_EXE%" --build . --config %CMAKE_BUILD_TYPE% --target $* --parallel %PARALLEL_JOBS%"
0900 echo.
0901 title Krita build - %KRITA_SRC_DIR% ^(deps: %DEPS_BUILD_DIR%, krita: %KRITA_BUILD_DIR%, plugins: %PLUGINS_BUILD_DIR%^)
0902 echo You're now in the build environment.
0903 echo The following macros are available:
0904 echo cmake-deps
0905 echo -- Run CMake for the deps.
0906 echo make-deps ^<deps target^>
0907 echo -- Run build for the specified deps target. The target name should
0908 echo include the `ext_` prefix, e.g. `ext_qt`.
0909 echo make-plugins ^<deps target^>
0910 echo -- Build the specified plugin target. The target name should
0911 echo include the `ext_` prefix, e.g. `ext_gmic`.
0912 echo cmake-krita
0913 echo -- Run CMake for Krita.
0914 echo make-krita
0915 echo -- Run build for Krita's `install` target.
0916 echo.
0917 echo For more info, type `doskey /macros` to view the macro commands.
0918 cmd /k
0919 exit
0920 )
0921
0922
0923 if "%ARG_SKIP_DEPS%" == "1" goto skip_build_deps
0924
0925 pushd %DEPS_BUILD_DIR%
0926 if errorlevel 1 (
0927 echo ERROR: Cannot enter deps build dir! 1>&2
0928 exit /b 104
0929 )
0930
0931 echo Running CMake for deps...
0932
0933 @echo on
0934 %CMDLINE_CMAKE_DEPS%
0935 @if errorlevel 1 (
0936 @echo ERROR: CMake configure failed! 1>&2
0937 @exit /b 104
0938 )
0939 @echo off
0940 echo.
0941
0942 set EXT_TARGETS=patch zlib gettext openssl boost exiv2 fftw3 eigen3 jpeg lcms2
0943 set EXT_TARGETS=%EXT_TARGETS% ocio openexr png icoutils tiff gsl
0944 set EXT_TARGETS=%EXT_TARGETS% giflib qt libraw kwindowsystem drmingw
0945 set EXT_TARGETS=%EXT_TARGETS% python sip pyqt
0946 set EXT_TARGETS=%EXT_TARGETS% lzma quazip openjpeg libde265 libx265 libheif
0947 set EXT_TARGETS=%EXT_TARGETS% seexpr mypaint webp jpegxl xsimd
0948 set EXT_TARGETS=%EXT_TARGETS% freetype fontconfig poppler fribidi unibreak
0949 set EXT_TARGETS=%EXT_TARGETS% ffmpeg lager
0950
0951 for %%a in (%EXT_TARGETS%) do (
0952 set TEST_HAS_TARGET=
0953 call :has_target TEST_HAS_TARGET_SELF "ext_%%a\"
0954 call :has_target TEST_HAS_KF5_TARGET "ext_frameworks\ext_%%a-prefix\"
0955 call :has_target TEST_HAS_HEIF_TARGET "ext_heif\ext_%%a-prefix\"
0956 if "!TEST_HAS_TARGET_SELF!" == "1" set TEST_HAS_TARGET=1
0957 if "!TEST_HAS_KF5_TARGET!" == "1" set TEST_HAS_TARGET=1
0958 if "!TEST_HAS_HEIF_TARGET!" == "1" set TEST_HAS_TARGET=1
0959
0960 if defined TEST_HAS_TARGET (
0961 echo Building ext_%%a...
0962 "%CMAKE_EXE%" --build . --config %CMAKE_BUILD_TYPE% --target ext_%%a --parallel %PARALLEL_JOBS% -- /p:CL_MPCount=2
0963 if errorlevel 1 (
0964 echo ERROR: Building of ext_%%a failed! 1>&2
0965 exit /b 105
0966 )
0967 ) else (
0968 echo Skipping ext_%%a, using OS package...
0969 )
0970 )
0971 echo.
0972
0973 echo Deploying debug symbols for all dependencies...
0974
0975 python "%KRITA_SRC_DIR%\packaging\windows\deploy-deps-debug-symbols.py" ^
0976 --no-interactive ^
0977 --deps-install-dir="%DEPS_INSTALL_DIR%\" ^
0978 --deps-build-dir="%DEPS_BUILD_DIR%\"
0979
0980 echo.
0981
0982 echo ******** Built deps ********
0983 popd
0984
0985 :skip_build_deps
0986
0987 if "%ARG_SKIP_KRITA%" == "1" goto skip_build_krita
0988
0989 pushd %KRITA_BUILD_DIR%
0990 if errorlevel 1 (
0991 echo ERROR: Cannot enter Krita build dir! 1>&2
0992 exit /b 104
0993 )
0994
0995 echo Running CMake for Krita...
0996
0997 @echo on
0998 %CMDLINE_CMAKE_KRITA%
0999 @if errorlevel 1 (
1000 @echo ERROR: CMake configure failed! 1>&2
1001 @exit /b 104
1002 )
1003 @echo off
1004 echo.
1005
1006 echo Building Krita...
1007 "%CMAKE_EXE%" --build . --config %CMAKE_BUILD_TYPE% --target install --parallel %PARALLEL_JOBS%
1008 if errorlevel 1 (
1009 echo ERROR: Building of Krita failed! 1>&2
1010 exit /b 105
1011 )
1012 echo.
1013
1014 echo Deploying debug symbols for Krita...
1015
1016 python "%KRITA_SRC_DIR%\packaging\windows\deploy-krita-debug-symbols.py" ^
1017 --no-interactive ^
1018 --krita-install-dir="%KRITA_INSTALL_DIR%\" ^
1019 --krita-build-dir="%KRITA_BUILD_DIR%\"
1020
1021 echo.
1022
1023 echo ******** Built Krita ********
1024 popd
1025
1026 pushd %PLUGINS_BUILD_DIR%
1027 if errorlevel 1 (
1028 echo ERROR: Cannot enter plugins build dir! 1>&2
1029 exit /b 104
1030 )
1031
1032 echo Running CMake for plugins...
1033
1034 @echo on
1035 %CMDLINE_CMAKE_PLUGINS%
1036 @if errorlevel 1 (
1037 @echo ERROR: CMake configure failed! 1>&2
1038 @exit /b 104
1039 )
1040 @echo off
1041 echo.
1042
1043 set EXT_TARGETS=gmic
1044
1045 for %%a in (%EXT_TARGETS%) do (
1046 echo Building ext_%%a...
1047 "%CMAKE_EXE%" --build . --config %CMAKE_BUILD_TYPE% --target ext_%%a
1048 if errorlevel 1 (
1049 echo ERROR: Building of ext_%%a failed! 1>&2
1050 exit /b 105
1051 )
1052 )
1053 echo.
1054
1055 echo Deploying debug symbols for plugins...
1056 python "%KRITA_SRC_DIR%\packaging\windows\deploy-deps-debug-symbols.py" ^
1057 --no-interactive ^
1058 --deps-install-dir="%KRITA_INSTALL_DIR%\" ^
1059 --deps-build-dir="%PLUGINS_BUILD_DIR%\"
1060 echo.
1061
1062 echo ******** Built plugins ********
1063 popd
1064
1065 :skip_build_krita
1066
1067 echo Krita build completed!