Warning, /graphics/krita/packaging/windows/package-complete.cmd is written in an unsupported language. File is not indexed.
0001 @echo off 0002 :: This batch script is meant to prepare a Krita package folder to be zipped or 0003 :: to be a base for the installer. 0004 0005 :: -------- 0006 0007 setlocal enabledelayedexpansion 0008 goto begin 0009 0010 0011 :: Subroutines 0012 0013 :find_on_path out_variable file_name 0014 set %1=%~f$PATH:2 0015 goto :EOF 0016 0017 0018 :get_dir_path out_variable file_path 0019 set %1=%~dp2 0020 goto :EOF 0021 0022 0023 :get_full_path out_variable file_path 0024 setlocal 0025 set FULL_PATH=%~f2 0026 if not exist "%FULL_PATH%" ( 0027 set FULL_PATH= 0028 ) else ( 0029 if exist "%FULL_PATH%\" ( 0030 set FULL_PATH= 0031 ) 0032 ) 0033 endlocal & set "%1=%FULL_PATH%" 0034 goto :EOF 0035 0036 0037 :get_full_path_dir out_variable file_path 0038 setlocal 0039 set FULL_PATH=%~dp2 0040 if not exist "%FULL_PATH%" ( 0041 set FULL_PATH= 0042 ) 0043 endlocal & set "%1=%FULL_PATH%" 0044 goto :EOF 0045 0046 0047 :prompt_for_string out_variable prompt 0048 set /p %1=%~2^> 0049 goto :EOF 0050 0051 0052 :prompt_for_positive_integer out_variable prompt 0053 setlocal 0054 call :prompt_for_string USER_INPUT "%~2" 0055 if "%USER_INPUT%" == "" set USER_INPUT=0 0056 set /a RESULT=%USER_INPUT% 0057 if not %RESULT% GTR 0 ( 0058 set RESULT= 0059 ) 0060 endlocal & set "%1=%RESULT%" 0061 goto :EOF 0062 0063 0064 :prompt_for_file out_variable prompt 0065 setlocal 0066 :prompt_for_file__retry 0067 call :prompt_for_string USER_INPUT "%~2" 0068 if "%USER_INPUT%" == "" ( 0069 endlocal 0070 set %1= 0071 goto :EOF 0072 ) 0073 call :get_full_path RESULT "%USER_INPUT%" 0074 if "%RESULT%" == "" ( 0075 echo Input does not point to valid file! 0076 set USER_INPUT= 0077 goto prompt_for_file__retry 0078 ) 0079 endlocal & set "%1=%RESULT%" 0080 goto :EOF 0081 0082 0083 :prompt_for_dir out_variable prompt 0084 setlocal 0085 :prompt_for_dir__retry 0086 call :prompt_for_string USER_INPUT "%~2" 0087 if "%USER_INPUT%" == "" ( 0088 endlocal 0089 set %1= 0090 goto :EOF 0091 ) 0092 call :get_full_path_dir RESULT "%USER_INPUT%\" 0093 if "%RESULT%" == "" ( 0094 echo Input does not point to valid dir! 0095 set USER_INPUT= 0096 goto prompt_for_dir__retry 0097 ) 0098 endlocal & set "%1=%RESULT%" 0099 goto :EOF 0100 0101 0102 :usage 0103 echo Usage: 0104 echo %~n0 [--no-interactive --package-name ^<name^>] [ OPTIONS ... ] 0105 echo. 0106 echo Basic options: 0107 echo --no-interactive Run without interactive prompts 0108 echo When not specified, the script will prompt 0109 echo for some of the parameters. 0110 echo --package-name ^<name^> Specify the package name 0111 echo. 0112 echo Path options: 0113 echo --src-dir ^<dir_path^> Specify Krita source dir 0114 echo If unspecified, this will be determined from 0115 echo the script location 0116 echo --deps-install-dir ^<dir_path^> Specify deps install dir 0117 echo --krita-install-dir ^<dir_path^> Specify Krita install dir 0118 echo. 0119 echo Special options: 0120 echo --pre-zip-hook ^<script_path^> Specify a script to be called before 0121 echo packaging the zip archive, can be used to 0122 echo sign the binaries 0123 echo. 0124 goto :EOF 0125 :usage_and_exit 0126 call :usage 0127 exit /b 0128 :usage_and_fail 0129 call :usage 0130 exit /b 100 0131 0132 0133 :: ---------------------------- 0134 :begin 0135 0136 echo Krita Windows packaging script 0137 echo. 0138 0139 0140 :: command-line args parsing 0141 set ARG_NO_INTERACTIVE= 0142 set ARG_PACKAGE_NAME= 0143 set ARG_SRC_DIR= 0144 set ARG_DEPS_INSTALL_DIR= 0145 set ARG_KRITA_INSTALL_DIR= 0146 set ARG_PRE_ZIP_HOOK= 0147 :args_parsing_loop 0148 set CURRENT_MATCHED= 0149 if not "%1" == "" ( 0150 if "%1" == "--no-interactive" ( 0151 set ARG_NO_INTERACTIVE=1 0152 set CURRENT_MATCHED=1 0153 ) 0154 if "%1" == "--package-name" ( 0155 if not "%ARG_PACKAGE_NAME%" == "" ( 0156 echo ERROR: Arg --package-name specified more than once 1>&2 0157 echo. 0158 goto usage_and_fail 0159 ) 0160 if "%~2" == "" ( 0161 echo ERROR: Arg --package-name is empty 1>&2 0162 echo. 0163 goto usage_and_fail 0164 ) 0165 set "ARG_PACKAGE_NAME=%~2" 0166 shift /2 0167 set CURRENT_MATCHED=1 0168 ) 0169 if "%1" == "--src-dir" ( 0170 if not "%ARG_SRC_DIR%" == "" ( 0171 echo ERROR: Arg --src-dir specified more than once 1>&2 0172 echo. 0173 goto usage_and_fail 0174 ) 0175 if not exist "%~f2\" ( 0176 echo ERROR: Arg --src-dir does not point to a directory 1>&2 0177 echo. 0178 goto usage_and_fail 0179 ) 0180 call :get_dir_path ARG_SRC_DIR "%~f2\" 0181 shift /2 0182 set CURRENT_MATCHED=1 0183 ) 0184 if "%1" == "--deps-install-dir" ( 0185 if not "%ARG_DEPS_INSTALL_DIR%" == "" ( 0186 echo ERROR: Arg --deps-install-dir specified more than once 1>&2 0187 echo. 0188 goto usage_and_fail 0189 ) 0190 if "%~f2" == "" ( 0191 echo ERROR: Arg --deps-install-dir does not point to a valid path 1>&2 0192 echo. 0193 goto usage_and_fail 0194 ) 0195 call :get_dir_path ARG_DEPS_INSTALL_DIR "%~f2\" 0196 shift /2 0197 set CURRENT_MATCHED=1 0198 ) 0199 if "%1" == "--krita-install-dir" ( 0200 if not "%ARG_KRITA_INSTALL_DIR%" == "" ( 0201 echo ERROR: Arg --krita-install-dir specified more than once 1>&2 0202 echo. 0203 goto usage_and_fail 0204 ) 0205 if "%~f2" == "" ( 0206 echo ERROR: Arg --krita-install-dir does not point to a valid path 1>&2 0207 echo. 0208 goto usage_and_fail 0209 ) 0210 call :get_dir_path ARG_KRITA_INSTALL_DIR "%~f2\" 0211 shift /2 0212 set CURRENT_MATCHED=1 0213 ) 0214 if "%1" == "--pre-zip-hook" ( 0215 if not "%ARG_PRE_ZIP_HOOK%" == "" ( 0216 echo ERROR: Arg --pre-zip-hook specified more than once 1>&2 0217 echo. 0218 goto usage_and_fail 0219 ) 0220 if "%~f2" == "" ( 0221 echo ERROR: Arg --pre-zip-hook does not point to a valid path 1>&2 0222 echo. 0223 goto usage_and_fail 0224 ) 0225 call :get_full_path ARG_PRE_ZIP_HOOK "%~f2" 0226 if "!ARG_PRE_ZIP_HOOK!" == "" ( 0227 echo ERROR: Arg --pre-zip-hook does not point to a valid file 1>&2 0228 echo. 0229 goto usage_and_fail 0230 ) 0231 shift /2 0232 set CURRENT_MATCHED=1 0233 ) 0234 if "%1" == "--help" ( 0235 goto usage_and_exit 0236 ) 0237 if not "!CURRENT_MATCHED!" == "1" ( 0238 echo ERROR: Unknown option %1 1>&2 0239 echo. 0240 goto usage_and_fail 0241 ) 0242 shift /1 0243 goto args_parsing_loop 0244 ) 0245 0246 if "%ARG_NO_INTERACTIVE%" == "1" ( 0247 if "%ARG_PACKAGE_NAME%" == "" ( 0248 echo ERROR: Required arg --package-name not specified! 1>&2 0249 echo. 0250 goto usage_and_fail 0251 ) 0252 ) 0253 0254 if "%ARG_NO_INTERACTIVE%" == "1" ( 0255 echo Non-interactive mode 0256 ) else ( 0257 echo Interactive mode 0258 :: Trick to pause on exit 0259 call :real_begin 0260 pause 0261 exit /b !ERRORLEVEL! 0262 ) 0263 :real_begin 0264 echo. 0265 0266 0267 if "%ARG_PACKAGE_NAME%" == "" ( 0268 call :prompt_for_string ARG_PACKAGE_NAME "Provide package name" 0269 if "ARG_PACKAGE_NAME" == "" ( 0270 echo ERROR: Package name not set! 1>&2 0271 exit /b 102 0272 ) 0273 ) 0274 0275 0276 :: Check environment config 0277 0278 if "%SEVENZIP_EXE%" == "" ( 0279 call :find_on_path SEVENZIP_EXE 7z.exe 0280 ) 0281 if "%SEVENZIP_EXE%" == "" ( 0282 call :find_on_path SEVENZIP_EXE 7za.exe 0283 ) 0284 if "!SEVENZIP_EXE!" == "" ( 0285 set "SEVENZIP_EXE=%ProgramFiles%\7-Zip\7z.exe" 0286 if not exist "!SEVENZIP_EXE!" ( 0287 set "SEVENZIP_EXE=%ProgramFiles(x86)%\7-Zip\7z.exe" 0288 ) 0289 if not exist "!SEVENZIP_EXE!" ( 0290 echo 7-Zip not found! 1>&2 0291 exit /b 102 0292 ) 0293 ) 0294 echo 7-Zip: %SEVENZIP_EXE% 0295 0296 if "%MINGW_BIN_DIR%" == "" ( 0297 call :find_on_path MINGW_BIN_DIR_MAKE_EXE mingw32-make.exe 0298 if "!MINGW_BIN_DIR_MAKE_EXE!" == "" ( 0299 if not "%ARG_NO_INTERACTIVE%" == "1" ( 0300 call :prompt_for_file MINGW_BIN_DIR_MAKE_EXE "Provide path to mingw32-make.exe of mingw-w64" 0301 ) 0302 if "!MINGW_BIN_DIR_MAKE_EXE!" == "" ( 0303 echo ERROR: mingw-w64 not found! 1>&2 0304 exit /b 102 0305 ) 0306 call :get_dir_path MINGW_BIN_DIR "!MINGW_BIN_DIR_MAKE_EXE!" 0307 ) else ( 0308 call :get_dir_path MINGW_BIN_DIR "!MINGW_BIN_DIR_MAKE_EXE!" 0309 echo Found mingw on PATH: !MINGW_BIN_DIR! 0310 if not "%ARG_NO_INTERACTIVE%" == "1" ( 0311 choice /c ny /n /m "Is this correct? [y/n] " 0312 if errorlevel 3 exit 255 0313 if not errorlevel 2 ( 0314 call :prompt_for_file MINGW_BIN_DIR_MAKE_EXE "Provide path to mingw32-make.exe of mingw-w64" 0315 if "!MINGW_BIN_DIR_MAKE_EXE!" == "" ( 0316 echo ERROR: mingw-w64 not found! 1>&2 0317 exit /b 102 0318 ) 0319 call :get_dir_path MINGW_BIN_DIR "!MINGW_BIN_DIR_MAKE_EXE!" 0320 ) 0321 ) 0322 ) 0323 ) 0324 echo mingw-w64: %MINGW_BIN_DIR% 0325 0326 :: Windows SDK is needed for windeployqt to get d3dcompiler_xx.dll 0327 if "%WindowsSdkDir%" == "" if not "%ProgramFiles(x86)%" == "" set "WindowsSdkDir=%ProgramFiles(x86)%\Windows Kits\10" 0328 if "%WindowsSdkDir%" == "" set "WindowsSdkDir=%ProgramFiles(x86)%\Windows Kits\10" 0329 if exist "%WindowsSdkDir%\" ( 0330 pushd "%WindowsSdkDir%" 0331 if exist "bin\x64\fxc.exe" ( 0332 set HAVE_FXC_EXE=1 0333 ) else ( 0334 for /f "delims=" %%a in ('dir /a:d /b "bin\10.*"') do ( 0335 if exist "bin\%%a\x64\fxc.exe" ( 0336 set HAVE_FXC_EXE=1 0337 ) 0338 ) 0339 ) 0340 popd 0341 ) 0342 if not "%HAVE_FXC_EXE%" == "1" ( 0343 set WindowsSdkDir= 0344 echo Windows SDK 10 with fxc.exe not found 0345 echo If Qt was built with ANGLE ^(dynamic OpenGL^) support, the package might not work properly on some systems! 0346 ) else echo Windows SDK 10 with fxc.exe found on %WindowsSdkDir% 0347 0348 if not "%ARG_SRC_DIR%" == "" ( 0349 set "KRITA_SRC_DIR=%ARG_SRC_DIR%" 0350 ) 0351 if "%KRITA_SRC_DIR%" == "" ( 0352 :: Check whether this looks like to be in the source tree 0353 set "_temp=%~dp0" 0354 if "!_temp:~-19!" == "\packaging\windows\" ( 0355 if exist "!_temp:~0,-19!\CMakeLists.txt" ( 0356 if exist "!_temp:~0,-19!\3rdparty\CMakeLists.txt" ( 0357 set "KRITA_SRC_DIR=!_temp:~0,-19!\" 0358 echo Script is running inside Krita src dir 0359 ) 0360 ) 0361 ) 0362 ) 0363 if "%KRITA_SRC_DIR%" == "" ( 0364 if not "%ARG_NO_INTERACTIVE%" == "1" ( 0365 call :prompt_for_dir KRITA_SRC_DIR "Provide path of Krita src dir" 0366 ) 0367 if "!KRITA_SRC_DIR!" == "" ( 0368 echo ERROR: Krita src dir not found! 1>&2 0369 exit /b 102 0370 ) 0371 ) 0372 echo Krita src: %KRITA_SRC_DIR% 0373 0374 if not "%ARG_DEPS_INSTALL_DIR%" == "" ( 0375 set "DEPS_INSTALL_DIR=%ARG_DEPS_INSTALL_DIR%" 0376 ) 0377 if "%DEPS_INSTALL_DIR%" == "" ( 0378 set DEPS_INSTALL_DIR=%CD%\i_deps\ 0379 echo Using default deps install dir: !DEPS_INSTALL_DIR! 0380 if not "%ARG_NO_INTERACTIVE%" == "1" ( 0381 choice /c ny /n /m "Is this ok? [y/n] " 0382 if errorlevel 3 exit 255 0383 if not errorlevel 2 ( 0384 call :prompt_for_dir DEPS_INSTALL_DIR "Provide path of deps install dir" 0385 ) 0386 ) 0387 if "!DEPS_INSTALL_DIR!" == "" ( 0388 echo ERROR: Deps install dir not set! 1>&2 0389 exit /b 102 0390 ) 0391 ) 0392 echo Deps install dir: %DEPS_INSTALL_DIR% 0393 0394 if not "%ARG_KRITA_INSTALL_DIR%" == "" ( 0395 set "KRITA_INSTALL_DIR=%ARG_KRITA_INSTALL_DIR%" 0396 ) 0397 if "%KRITA_INSTALL_DIR%" == "" ( 0398 set KRITA_INSTALL_DIR=%CD%\i\ 0399 echo Using default Krita install dir: !KRITA_INSTALL_DIR! 0400 if not "%ARG_NO_INTERACTIVE%" == "1" ( 0401 choice /c ny /n /m "Is this ok? [y/n] " 0402 if errorlevel 3 exit 255 0403 if not errorlevel 2 ( 0404 call :prompt_for_dir KRITA_INSTALL_DIR "Provide path of Krita install dir" 0405 ) 0406 ) 0407 if "!KRITA_INSTALL_DIR!" == "" ( 0408 echo ERROR: Krita install dir not set! 1>&2 0409 exit /b 102 0410 ) 0411 ) 0412 echo Krita install dir: %KRITA_INSTALL_DIR% 0413 0414 0415 :: Simple checking 0416 if not exist "%DEPS_INSTALL_DIR%\" ( 0417 echo ERROR: Cannot find the deps install folder! 1>&2 0418 exit /B 1 0419 ) 0420 if not exist "%KRITA_INSTALL_DIR%\" ( 0421 echo ERROR: Cannot find the krita install folder! 1>&2 0422 exit /B 1 0423 ) 0424 if not "%DEPS_INSTALL_DIR: =%" == "%DEPS_INSTALL_DIR%" ( 0425 echo ERROR: Deps install path contains space, which will not work properly! 1>&2 0426 exit /B 1 0427 ) 0428 if not "%KRITA_INSTALL_DIR: =%" == "%KRITA_INSTALL_DIR%" ( 0429 echo ERROR: Krita install path contains space, which will not work properly! 1>&2 0430 exit /B 1 0431 ) 0432 0433 set pkg_name=%ARG_PACKAGE_NAME% 0434 echo Package name is "%pkg_name%" 0435 0436 set pkg_root=%CD%\%pkg_name% 0437 echo Packaging dir is %pkg_root% 0438 echo. 0439 if exist %pkg_root% ( 0440 echo ERROR: Packaging dir already exists! Please remove or rename it first. 0441 exit /B 1 0442 ) 0443 if exist %pkg_root%.zip ( 0444 echo ERROR: Packaging zip already exists! Please remove or rename it first. 0445 exit /B 1 0446 ) 0447 if exist %pkg_root%-dbg.zip ( 0448 echo ERROR: Packaging debug zip already exists! Please remove or rename it first. 0449 exit /B 1 0450 ) 0451 0452 echo. 0453 0454 0455 if not "%ARG_NO_INTERACTIVE%" == "1" ( 0456 choice /c ny /n /m "Is the above ok? [y/n] " 0457 if errorlevel 3 exit 255 0458 if not errorlevel 2 ( 0459 exit /b 1 0460 ) 0461 echo. 0462 ) 0463 0464 0465 :: Initialize clean PATH 0466 set "PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\" 0467 set "PATH=%MINGW_BIN_DIR%;%DEPS_INSTALL_DIR%\bin;%PATH%" 0468 0469 0470 echo. 0471 echo Trying to guess GCC version... 0472 g++ --version > NUL 0473 if errorlevel 1 ( 0474 echo ERROR: g++ is not working. 0475 exit /B 1 0476 ) 0477 for /f "delims=" %%a in ('g++ --version ^| find "g++"') do set GCC_VERSION_LINE=%%a 0478 if "%GCC_VERSION_LINE%" == "" ( 0479 for /f "delims=" %%a in ('g++ --version ^| find "clang"') do set GCC_VERSION_LINE=%%a 0480 ) 0481 if "%GCC_VERSION_LINE%" == "" ( 0482 echo ERROR: Failed to get version of g++. 0483 exit /B 1 0484 ) 0485 echo -- %GCC_VERSION_LINE% 0486 set IS_TDM= 0487 set IS_MSYS= 0488 set IS_CLANG= 0489 if not "%GCC_VERSION_LINE:tdm64=%" == "%GCC_VERSION_LINE%" ( 0490 echo Compiler looks like TDM64-GCC 0491 set IS_TDM=1 0492 ) else if not "%GCC_VERSION_LINE:MSYS=%" == "%GCC_VERSION_LINE%" ( 0493 echo Compiler looks like MSYS GCC 0494 set IS_MSYS=1 0495 ) else if not "%GCC_VERSION_LINE:clang=%" == "%GCC_VERSION_LINE%" ( 0496 echo Compiler looks like Clang 0497 set IS_CLANG=1 0498 ) else ( 0499 echo Compiler looks like plain old MinGW64 0500 ) 0501 set IS_LLVM_MINGW= 0502 set IS_MSYS_CLANG= 0503 if not x%IS_CLANG% == x ( 0504 rem Look for the multiarch target binary dirs. Unfortunately there is 0505 rem no surefire way to detect a llvm-mingw toolchain. 0506 if exist "%MINGW_BIN_DIR%\..\i686-w64-mingw32\bin\" ( 0507 if exist "%MINGW_BIN_DIR%\..\x86_64-w64-mingw32\bin\" ( 0508 echo Toolchain looks like llvm-mingw 0509 set IS_LLVM_MINGW=1 0510 ) 0511 ) 0512 if "!IS_LLVM_MINGW!" == "" ( 0513 echo Toolchain does not look like llvm-mingw, assuming MSYS Clang 0514 set IS_MSYS_CLANG=1 0515 ) 0516 ) 0517 0518 echo. 0519 echo Trying to guess target architecture... 0520 set OBJDUMP= 0521 for %%a in (objdump llvm-objdump) do ( 0522 %%a --version > NUL 0523 if not errorlevel 1 ( 0524 set OBJDUMP=%%a 0525 ) 0526 ) 0527 if "%OBJDUMP%" == "" ( 0528 echo ERROR: objdump is not working. 0529 exit /B 1 0530 ) 0531 for /f "delims=, tokens=1" %%a in ('%OBJDUMP% -f %KRITA_INSTALL_DIR%\bin\krita.exe ^| find "i386"') do set TARGET_ARCH_LINE=%%a 0532 if "%TARGET_ARCH_LINE%" == "" ( 0533 echo "Possible LLVM objdump, trying to detect architecture..." 0534 for /f "delims=" %%a in ('%OBJDUMP% -f %KRITA_INSTALL_DIR%\bin\krita.exe ^| find "coff"') do set TARGET_ARCH_LINE=%%a 0535 ) 0536 echo -- %TARGET_ARCH_LINE% 0537 if "%TARGET_ARCH_LINE:x86-64=%" == "%TARGET_ARCH_LINE%" ( 0538 echo Target looks like x86 0539 set IS_X64= 0540 ) else ( 0541 echo Target looks like x64 0542 set IS_x64=1 0543 ) 0544 0545 echo. 0546 echo Testing for objcopy... 0547 objcopy --version > NUL 0548 if errorlevel 1 ( 0549 echo ERROR: objcopy is not working. 0550 exit /B 1 0551 ) 0552 0553 echo. 0554 echo Testing for strip... 0555 strip --version > NUL 0556 if errorlevel 1 ( 0557 echo ERROR: strip is not working. 0558 exit /B 1 0559 ) 0560 0561 echo. 0562 echo Creating base directories... 0563 mkdir %pkg_root% && ^ 0564 mkdir %pkg_root%\bin && ^ 0565 mkdir %pkg_root%\lib && ^ 0566 mkdir %pkg_root%\share 0567 if errorlevel 1 ( 0568 echo ERROR: Cannot create packaging dir tree! 0569 %PAUSE% 0570 exit /B 1 0571 ) 0572 0573 echo. 0574 echo Copying GCC libraries... 0575 set "STDLIBS_DIR=%MINGW_BIN_DIR%" 0576 if not x%IS_TDM% == x ( 0577 if x%is_x64% == x ( 0578 :: TDM-GCC x86 0579 set "STDLIBS=libgomp-1" 0580 ) else ( 0581 :: TDM-GCC x64 0582 set "STDLIBS=libgomp_64-1" 0583 ) 0584 ) else if not x%IS_MSYS% == x ( 0585 if x%is_x64% == x ( 0586 :: msys-mingw-w64 x86 0587 set "STDLIBS=libgcc_s_dw2-1 libgomp-1 libstdc++-6 libwinpthread-1 libatomic-1 libiconv-2 zlib1 libexpat-1 libintl-8 libssl-1_1 libcrypto-1_1" 0588 ) else ( 0589 :: msys-mingw-w64 x64 0590 set "STDLIBS=libgcc_s_seh-1 libgomp-1 libstdc++-6 libwinpthread-1 libatomic-1 libiconv-2 zlib1 libexpat-1 libintl-8 libssl-1_1-x64 libcrypto-1_1-x64" 0591 ) 0592 ) else if not x%IS_MSYS_CLANG% == x ( 0593 if x%is_x64% == x ( 0594 :: msys-mingw-w64-clang64 x86 0595 set "STDLIBS=libomp libssp-0 libunwind libc++ libwinpthread-1 libiconv-2 zlib1 libexpat-1 libintl-8 libssl-1_1 libcrypto-1_1" 0596 ) else ( 0597 :: msys-mingw-w64-clang64 x64 0598 set "STDLIBS=libomp libssp-0 libunwind libc++ libwinpthread-1 libiconv-2 zlib1 libexpat-1 libintl-8 libssl-1_1-x64 libcrypto-1_1-x64" 0599 ) 0600 ) else if not x%IS_LLVM_MINGW% == x ( 0601 :: llvm-mingw 0602 set "STDLIBS=libc++ libomp libssp-0 libunwind libwinpthread-1" 0603 rem The toolchain does not include all of the DLLs in the compiler bin dir, 0604 rem so we need to copy them from the cross target bin dir. 0605 if x%is_x64% == x ( 0606 set "STDLIBS_DIR=%MINGW_BIN_DIR%\..\i686-w64-mingw32\bin" 0607 ) else ( 0608 set "STDLIBS_DIR=%MINGW_BIN_DIR%\..\x86_64-w64-mingw32\bin" 0609 ) 0610 ) else ( 0611 if x%is_x64% == x ( 0612 :: mingw-w64 x86 0613 set "STDLIBS=libgcc_s_dw2-1 libgomp-1 libstdc++-6 libwinpthread-1" 0614 ) else ( 0615 :: mingw-w64 x64 0616 set "STDLIBS=libgcc_s_seh-1 libgomp-1 libstdc++-6 libwinpthread-1" 0617 ) 0618 ) 0619 0620 for %%L in (%STDLIBS%) do copy "%STDLIBS_DIR%\%%L.dll" %pkg_root%\bin 0621 0622 echo. 0623 echo Copying files... 0624 :: krita.exe 0625 copy %KRITA_INSTALL_DIR%\bin\krita.exe %pkg_root%\bin 0626 copy %KRITA_INSTALL_DIR%\bin\krita.com %pkg_root%\bin 0627 :: kritarunner.exe 0628 copy %KRITA_INSTALL_DIR%\bin\kritarunner.exe %pkg_root%\bin 0629 copy %KRITA_INSTALL_DIR%\bin\kritarunner.com %pkg_root%\bin 0630 0631 if exist %KRITA_INSTALL_DIR%\bin\FreehandStrokeBenchmark.exe ( 0632 :: FreehandStrokeBenchmark.exe 0633 copy %KRITA_INSTALL_DIR%\bin\FreehandStrokeBenchmark.exe %pkg_root%\bin 0634 xcopy /S /Y /I %DEPS_INSTALL_DIR%\bin\data %pkg_root%\bin\data 0635 ) 0636 0637 :: qt.conf -- to specify the location to Qt translations 0638 copy %KRITA_SRC_DIR%\packaging\windows\qt.conf %pkg_root%\bin 0639 :: DLLs from bin/ 0640 echo INFO: Copying all DLLs except Qt5* from bin/ 0641 setlocal enableextensions enabledelayedexpansion 0642 for /f "delims=" %%F in ('dir /b "%KRITA_INSTALL_DIR%\bin\*.dll"') do ( 0643 set file=%%F 0644 set file=!file:~0,3! 0645 if not x!file! == xQt5 copy %KRITA_INSTALL_DIR%\bin\%%F %pkg_root%\bin 0646 ) 0647 for /f "delims=" %%F in ('dir /b "%DEPS_INSTALL_DIR%\bin\*.dll"') do ( 0648 set file=%%F 0649 set file=!file:~0,3! 0650 if not x!file! == xQt5 copy %DEPS_INSTALL_DIR%\bin\%%F %pkg_root%\bin 0651 ) 0652 endlocal 0653 :: symsrv.yes for Dr. Mingw 0654 copy %DEPS_INSTALL_DIR%\bin\symsrv.yes %pkg_root%\bin 0655 :: DLLs from lib/ 0656 echo INFO: Copying all DLLs from lib/ (deps) 0657 copy %DEPS_INSTALL_DIR%\lib\*.dll %pkg_root%\bin 0658 :: Boost, there might be more than one leftover but we can't really do much 0659 copy %DEPS_INSTALL_DIR%\bin\libboost_system-*.dll %pkg_root%\bin 0660 :: KF5 plugins may be placed at different locations depending on how Qt is built 0661 xcopy /S /Y /I %DEPS_INSTALL_DIR%\lib\plugins\imageformats %pkg_root%\bin\imageformats 0662 xcopy /S /Y /I %DEPS_INSTALL_DIR%\plugins\imageformats %pkg_root%\bin\imageformats 0663 xcopy /S /Y /I %DEPS_INSTALL_DIR%\lib\plugins\kf5 %pkg_root%\bin\kf5 0664 xcopy /S /Y /I %DEPS_INSTALL_DIR%\plugins\kf5 %pkg_root%\bin\kf5 0665 0666 :: Copy the sql drivers explicitly 0667 xcopy /S /Y /I %DEPS_INSTALL_DIR%\plugins\sqldrivers %pkg_root%\bin\sqldrivers 0668 0669 :: Qt Translations 0670 :: it seems that windeployqt does these, but only *some* of these??? 0671 mkdir %pkg_root%\bin\translations 0672 setlocal enableextensions enabledelayedexpansion 0673 for /f "delims=" %%F in ('dir /b "%DEPS_INSTALL_DIR%\translations\qt_*.qm"') do ( 0674 :: Exclude qt_help_*.qm 0675 set temp=%%F 0676 set temp2=!temp:_help=! 0677 if x!temp2! == x!temp! copy %DEPS_INSTALL_DIR%\translations\!temp! %pkg_root%\bin\translations\!temp! 0678 ) 0679 endlocal 0680 :: Krita plugins 0681 xcopy /Y %KRITA_INSTALL_DIR%\lib\kritaplugins\*.dll %pkg_root%\lib\kritaplugins\ 0682 xcopy /Y /S /I %DEPS_INSTALL_DIR%\lib\krita-python-libs %pkg_root%\lib\krita-python-libs 0683 xcopy /Y /S /I %KRITA_INSTALL_DIR%\lib\krita-python-libs %pkg_root%\lib\krita-python-libs 0684 0685 :: Share 0686 xcopy /Y /S /I %KRITA_INSTALL_DIR%\share\color %pkg_root%\share\color 0687 xcopy /Y /S /I %KRITA_INSTALL_DIR%\share\color-schemes %pkg_root%\share\color-schemes 0688 xcopy /Y /S /I %KRITA_INSTALL_DIR%\share\icons %pkg_root%\share\icons 0689 xcopy /Y /S /I %KRITA_INSTALL_DIR%\share\krita %pkg_root%\share\krita 0690 xcopy /Y /S /I %KRITA_INSTALL_DIR%\share\kritaplugins %pkg_root%\share\kritaplugins 0691 xcopy /Y /S /I %DEPS_INSTALL_DIR%\share\kf5 %pkg_root%\share\kf5 0692 xcopy /Y /S /I %DEPS_INSTALL_DIR%\share\mime %pkg_root%\share\mime 0693 :: Python libs 0694 xcopy /Y /S /I %DEPS_INSTALL_DIR%\share\krita\pykrita %pkg_root%\share\krita\pykrita 0695 robocopy %DEPS_INSTALL_DIR%\lib\site-packages %pkg_root%\lib\site-packages /S /E ^ 0696 /XF "setuptools.pth" "easy-install.pth" ^ 0697 /XD "packaging*" "pip*" "ply*" "pyparsing*" "PyQt_builder*" "sip*" "toml*" 0698 :: Not useful on Windows it seems 0699 rem xcopy /Y /S /I %KRITA_INSTALL_DIR%\share\appdata %pkg_root%\share\appdata 0700 rem xcopy /Y /S /I %KRITA_INSTALL_DIR%\share\applications %pkg_root%\share\applications 0701 rem xcopy /Y /S /I %DEPS_INSTALL_DIR%\share\doc %pkg_root%\share\doc 0702 rem xcopy /Y /S /I %DEPS_INSTALL_DIR%\share\kservices5 %pkg_root%\share\kservices5 0703 rem xcopy /Y /S /I %DEPS_INSTALL_DIR%\share\man %pkg_root%\share\man 0704 rem xcopy /Y /S /I %DEPS_INSTALL_DIR%\share\ocio %pkg_root%\share\ocio 0705 0706 :: Copy locale to bin 0707 xcopy /Y /S /I %KRITA_INSTALL_DIR%\share\locale %pkg_root%\bin\locale 0708 xcopy /Y /S /I %DEPS_INSTALL_DIR%\share\locale %pkg_root%\bin\locale 0709 0710 :: Copy shortcut link from source (can't create it dynamically) 0711 copy %KRITA_SRC_DIR%\packaging\windows\krita.lnk %pkg_root% 0712 copy %KRITA_SRC_DIR%\packaging\windows\krita-minimal.lnk %pkg_root% 0713 copy %KRITA_SRC_DIR%\packaging\windows\krita-animation.lnk %pkg_root% 0714 0715 set "QMLDIR_ARGS=--qmldir %DEPS_INSTALL_DIR%\qml" 0716 if exist "%KRITA_INSTALL_DIR%\lib\qml" ( 0717 xcopy /Y /S /I %KRITA_INSTALL_DIR%\lib\qml %pkg_root%\bin 0718 :: This doesn't really seem to do anything 0719 set "QMLDIR_ARGS=%QMLDIR_ARGS% --qmldir %KRITA_INSTALL_DIR%\lib\qml" 0720 ) 0721 0722 :: windeployqt 0723 windeployqt.exe %QMLDIR_ARGS% --release -gui -core -concurrent -network -printsupport -svg -xml -sql -multimedia -qml -quick -quickwidgets %pkg_root%\bin\krita.exe %pkg_root%\bin\krita.dll 0724 if errorlevel 1 ( 0725 echo ERROR: WinDeployQt failed! 1>&2 0726 exit /B 1 0727 ) 0728 0729 :: ffmpeg 0730 copy %DEPS_INSTALL_DIR%\bin\ffmpeg.exe %pkg_root%\bin 0731 copy %DEPS_INSTALL_DIR%\bin\ffmpeg_LICENSE.txt %pkg_root%\bin 0732 copy %DEPS_INSTALL_DIR%\bin\ffmpeg_README.txt %pkg_root%\bin 0733 0734 0735 :: Copy embedded Python 0736 xcopy /Y /S /I %DEPS_INSTALL_DIR%\python %pkg_root%\python 0737 del /q %pkg_root%\python\python.exe %pkg_root%\python\pythonw.exe 0738 0739 :: For chopping relative path 0740 :: 512 should be enough 0741 :: n+2 to also account for a trailing backslash 0742 setlocal enableextensions enabledelayedexpansion 0743 for /L %%n in (1 1 512) do if "!pkg_root:~%%n,1!" neq "" set /a "pkg_root_len_plus_one=%%n+2" 0744 endlocal & set pkg_root_len_plus_one=%pkg_root_len_plus_one% 0745 0746 echo. 0747 setlocal enableextensions enabledelayedexpansion 0748 :: Remove Python cache files 0749 for /d /r "%pkg_root%" %%F in (__pycache__\) do ( 0750 if EXIST "%%F" ( 0751 set relpath=%%F 0752 set relpath=!relpath:~%pkg_root_len_plus_one%! 0753 echo Deleting Python cache !relpath! 0754 rmdir /S /Q "%%F" 0755 ) 0756 ) 0757 endlocal 0758 0759 echo. 0760 echo Splitting debug info from binaries... 0761 call :split-debug "%pkg_root%\bin\krita.exe" bin\krita.exe 0762 call :split-debug "%pkg_root%\bin\krita.com" bin\krita.com 0763 call :split-debug "%pkg_root%\bin\kritarunner.exe" bin\kritarunner.exe 0764 call :split-debug "%pkg_root%\bin\kritarunner.com" bin\kritarunner.com 0765 setlocal enableextensions enabledelayedexpansion 0766 :: Find all DLLs 0767 for /r "%pkg_root%" %%F in (*.dll) do ( 0768 set relpath=%%F 0769 set relpath=!relpath:~%pkg_root_len_plus_one%! 0770 call :split-debug "%%F" !relpath! 0771 ) 0772 endlocal 0773 setlocal enableextensions enabledelayedexpansion 0774 :: Find all Python native modules 0775 for /r "%pkg_root%\share\krita\pykrita\" %%F in (*.pyd) do ( 0776 set relpath=%%F 0777 set relpath=!relpath:~%pkg_root_len_plus_one%! 0778 call :split-debug "%%F" !relpath! 0779 ) 0780 for /r "%pkg_root%\lib\krita-python-libs\" %%F in (*.pyd) do ( 0781 set relpath=%%F 0782 set relpath=!relpath:~%pkg_root_len_plus_one%! 0783 call :split-debug "%%F" !relpath! 0784 ) 0785 for /r "%pkg_root%\lib\site-packages\" %%F in (*.pyd) do ( 0786 set relpath=%%F 0787 set relpath=!relpath:~%pkg_root_len_plus_one%! 0788 call :split-debug "%%F" !relpath! 0789 ) 0790 endlocal 0791 0792 if not "%ARG_PRE_ZIP_HOOK%" == "" ( 0793 echo Running pre-zip-hook... 0794 setlocal 0795 cmd /c ""%ARG_PRE_ZIP_HOOK%" "%pkg_root%\"" 0796 if errorlevel 1 ( 0797 echo ERROR: Got exit code !errorlevel! from pre-zip-hook! 1>&2 0798 exit /b 1 0799 ) 0800 endlocal 0801 ) 0802 0803 echo. 0804 echo Packaging stripped binaries... 0805 "%SEVENZIP_EXE%" a -tzip %pkg_name%.zip %pkg_root%\ "-xr^!.debug" 0806 echo -------- 0807 0808 echo. 0809 echo Packaging debug info... 0810 :: (note that the top-level package dir is not included) 0811 "%SEVENZIP_EXE%" a -tzip %pkg_name%-dbg.zip -r %pkg_root%\*.debug 0812 echo -------- 0813 0814 echo. 0815 echo. 0816 echo Krita packaged as %pkg_name%.zip 0817 if exist %pkg_name%-dbg.zip echo Debug info packaged as %pkg_name%-dbg.zip 0818 echo Packaging dir is %pkg_root% 0819 echo NOTE: Do not create installer with packaging dir. Extract from 0820 echo %pkg_name%.zip instead, 0821 echo and do _not_ run krita inside the extracted directory because it will 0822 echo create extra unnecessary files. 0823 echo. 0824 echo Please remember to actually test the package before releasing it. 0825 echo. 0826 %PAUSE% 0827 0828 exit /b 0829 0830 :split-debug 0831 echo Splitting debug info of %2 0832 objcopy --only-keep-debug %~1 %~1.debug 0833 if ERRORLEVEL 1 exit /b %ERRORLEVEL% 0834 :: If the debug file is small enough then consider there being no debug info. 0835 :: Discard these files since they somehow make gdb crash. 0836 call :getfilesize %~1.debug 0837 if /i %getfilesize_retval% LEQ 2048 ( 0838 echo Discarding %2.debug 0839 del %~1.debug 0840 exit /b 0 0841 ) 0842 if not exist %~dp1.debug mkdir %~dp1.debug 0843 move %~1.debug %~dp1.debug\ > NUL 0844 strip --strip-debug %~1 0845 :: Add debuglink 0846 :: FIXME: There is a problem with gdb that cause it to output this warning 0847 :: FIXME: "warning: section .gnu_debuglink not found in xxx.debug" 0848 :: FIXME: I tried adding a link to itself but this kills drmingw :( 0849 objcopy --add-gnu-debuglink="%~dp1.debug\%~nx1.debug" %~1 0850 exit /b %ERRORLEVEL% 0851 0852 :getfilesize 0853 set getfilesize_retval=%~z1 0854 goto :eof 0855 0856 :relpath_dirpath 0857 call :relpath_dirpath_internal "" "%~1" 0858 goto :eof 0859 0860 :relpath_dirpath_internal 0861 for /f "tokens=1* delims=\" %%a in ("%~2") do ( 0862 :: If part 2 is empty, it means part 1 is probably the file name 0863 if x%%b==x ( 0864 set relpath_dirpath_retval=%~1 0865 ) else ( 0866 call :relpath_dirpath_internal "%~1%%a\" %%b 0867 ) 0868 ) 0869 goto :eof