test_package.bat 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. @echo OFF
  2. setlocal enabledelayedexpansion
  3. set "FullScriptPath=%~dp0"
  4. set "FullExecPath=%cd%"
  5. if not exist "%FullScriptPath%..\..\..\DesktopPrivate" (
  6. echo.
  7. echo This script is for building the production version of Telegram Desktop.
  8. echo.
  9. echo For building custom versions please visit the build instructions page at:
  10. echo https://github.com/telegramdesktop/tdesktop/#build-instructions
  11. exit /b
  12. )
  13. set "HomePath=%FullScriptPath%.."
  14. set "SignAppxPath=%HomePath%\..\..\DesktopPrivate\AppxSign.bat"
  15. set "ResourcesPath=%HomePath%\Resources"
  16. set "SolutionPath=%HomePath%\.."
  17. set "ReleasePath=%HomePath%\..\out\Debug"
  18. set "BinaryName=Telegram"
  19. if exist %ReleasePath%\AppX\ (
  20. echo Result folder out\Debug\AppX already exists!
  21. exit /b 1
  22. )
  23. cd "%HomePath%"
  24. call gyp\refresh.bat
  25. if %errorlevel% neq 0 goto error
  26. cd "%SolutionPath%"
  27. call ninja -C out/Debug Telegram
  28. if %errorlevel% neq 0 goto error
  29. cd "%HomePath%"
  30. mkdir "%ReleasePath%\AppX"
  31. xcopy "Resources\uwp\AppX\*" "%ReleasePath%\AppX\" /E
  32. set "ResourcePath=%ReleasePath%\AppX\AppxManifest.xml"
  33. call :repl "Argument= (Publisher=)"CN=536BC709-8EE1-4478-AF22-F0F0F26FF64A"/ $1"CN=Telegram FZ-LLC, O=Telegram FZ-LLC, L=Dubai, C=AE"" "Filename=%ResourcePath%" || goto :error
  34. call :repl "Argument= (ProcessorArchitecture=)"ARCHITECTURE"/ $1"x64"" "Filename=%ResourcePath%" || goto :error
  35. makepri new /pr Resources\uwp\AppX\ /cf Resources\uwp\priconfig.xml /mn %ReleasePath%\AppX\AppxManifest.xml /of %ReleasePath%\AppX\resources.pri
  36. if %errorlevel% neq 0 goto error
  37. xcopy "%ReleasePath%\%BinaryName%.exe" "%ReleasePath%\AppX\"
  38. MakeAppx.exe pack /d "%ReleasePath%\AppX" /l /p ..\out\Debug\%BinaryName%.appx
  39. if %errorlevel% neq 0 goto error
  40. call "%SignAppxPath%" "..\out\Debug\%BinaryName%.appx"
  41. move "%ReleasePath%\%BinaryName%.appx" "%ReleasePath%\AppX\"
  42. echo Done.
  43. exit /b
  44. :repl
  45. (
  46. set %1
  47. set %2
  48. set "TempFilename=!Filename!__tmp__"
  49. cscript //Nologo "%FullScriptPath%replace.vbs" "Replace" "!Argument!" < "!Filename!" > "!TempFilename!" || goto :repl_finish
  50. xcopy /Y !TempFilename! !Filename! >NUL || goto :repl_finish
  51. goto :repl_finish
  52. )
  53. :repl_finish
  54. (
  55. set ErrorCode=%errorlevel%
  56. if !ErrorCode! neq 0 (
  57. echo Replace error !ErrorCode!
  58. echo While replacing "%Replace%"
  59. echo In file "%Filename%"
  60. )
  61. del %TempFilename%
  62. exit /b !ErrorCode!
  63. )