diff --git a/Telegram.sln b/Telegram.sln deleted file mode 100644 index 1652e9f53..000000000 --- a/Telegram.sln +++ /dev/null @@ -1,106 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25123.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Telegram", "Telegram\Telegram.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" - ProjectSection(ProjectDependencies) = postProject - {E4DF8176-4DEF-4859-962F-B497E3E7A323} = {E4DF8176-4DEF-4859-962F-B497E3E7A323} - {E417CAA4-259B-4C99-88E3-805F1300E8EB} = {E417CAA4-259B-4C99-88E3-805F1300E8EB} - {7C25BFBD-7930-4DE2-AF33-27CE1CC521E6} = {7C25BFBD-7930-4DE2-AF33-27CE1CC521E6} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MetaEmoji", "Telegram\MetaEmoji.vcxproj", "{EB7D16AC-EACF-4577-B05A-F28E5F356794}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Updater", "Telegram\Updater.vcxproj", "{6B4BA3BE-7B15-4B4C-B200-81ABFDEF2C76}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MetaLang", "Telegram\MetaLang.vcxproj", "{E417CAA4-259B-4C99-88E3-805F1300E8EB}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "codegen", "codegen", "{2F863EAD-33C9-4014-A573-93F085BA9CB1}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Packer", "Telegram\Packer.vcxproj", "{56A9A4B2-21E5-4360-AFA8-85B43AC43B08}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "codegen_style", "Telegram\build\vc\codegen_style\codegen_style.vcxproj", "{E4DF8176-4DEF-4859-962F-B497E3E7A323}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "codegen_numbers", "Telegram\build\vc\codegen_numbers\codegen_numbers.vcxproj", "{7C25BFBD-7930-4DE2-AF33-27CE1CC521E6}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Deploy|Win32 = Deploy|Win32 - Deploy|x64 = Deploy|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|Win32.ActiveCfg = Debug|Win32 - {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|Win32.Build.0 = Debug|Win32 - {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|Win32.Deploy.0 = Debug|Win32 - {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|x64.ActiveCfg = Debug|Win32 - {B12702AD-ABFB-343A-A199-8E24837244A3}.Deploy|Win32.ActiveCfg = Deploy|Win32 - {B12702AD-ABFB-343A-A199-8E24837244A3}.Deploy|Win32.Build.0 = Deploy|Win32 - {B12702AD-ABFB-343A-A199-8E24837244A3}.Deploy|x64.ActiveCfg = Release|Win32 - {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|Win32.ActiveCfg = Release|Win32 - {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|Win32.Build.0 = Release|Win32 - {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|x64.ActiveCfg = Release|Win32 - {EB7D16AC-EACF-4577-B05A-F28E5F356794}.Debug|Win32.ActiveCfg = Debug|Win32 - {EB7D16AC-EACF-4577-B05A-F28E5F356794}.Debug|x64.ActiveCfg = Debug|Win32 - {EB7D16AC-EACF-4577-B05A-F28E5F356794}.Deploy|Win32.ActiveCfg = Deploy|Win32 - {EB7D16AC-EACF-4577-B05A-F28E5F356794}.Deploy|x64.ActiveCfg = Release|Win32 - {EB7D16AC-EACF-4577-B05A-F28E5F356794}.Release|Win32.ActiveCfg = Release|Win32 - {EB7D16AC-EACF-4577-B05A-F28E5F356794}.Release|x64.ActiveCfg = Release|Win32 - {6B4BA3BE-7B15-4B4C-B200-81ABFDEF2C76}.Debug|Win32.ActiveCfg = Debug|Win32 - {6B4BA3BE-7B15-4B4C-B200-81ABFDEF2C76}.Debug|Win32.Build.0 = Debug|Win32 - {6B4BA3BE-7B15-4B4C-B200-81ABFDEF2C76}.Debug|x64.ActiveCfg = Debug|Win32 - {6B4BA3BE-7B15-4B4C-B200-81ABFDEF2C76}.Deploy|Win32.ActiveCfg = Deploy|Win32 - {6B4BA3BE-7B15-4B4C-B200-81ABFDEF2C76}.Deploy|Win32.Build.0 = Deploy|Win32 - {6B4BA3BE-7B15-4B4C-B200-81ABFDEF2C76}.Deploy|x64.ActiveCfg = Release|Win32 - {6B4BA3BE-7B15-4B4C-B200-81ABFDEF2C76}.Release|Win32.ActiveCfg = Release|Win32 - {6B4BA3BE-7B15-4B4C-B200-81ABFDEF2C76}.Release|Win32.Build.0 = Release|Win32 - {6B4BA3BE-7B15-4B4C-B200-81ABFDEF2C76}.Release|x64.ActiveCfg = Release|Win32 - {E417CAA4-259B-4C99-88E3-805F1300E8EB}.Debug|Win32.ActiveCfg = Debug|Win32 - {E417CAA4-259B-4C99-88E3-805F1300E8EB}.Debug|Win32.Build.0 = Debug|Win32 - {E417CAA4-259B-4C99-88E3-805F1300E8EB}.Debug|x64.ActiveCfg = Debug|Win32 - {E417CAA4-259B-4C99-88E3-805F1300E8EB}.Deploy|Win32.ActiveCfg = Deploy|Win32 - {E417CAA4-259B-4C99-88E3-805F1300E8EB}.Deploy|Win32.Build.0 = Deploy|Win32 - {E417CAA4-259B-4C99-88E3-805F1300E8EB}.Deploy|x64.ActiveCfg = Release|Win32 - {E417CAA4-259B-4C99-88E3-805F1300E8EB}.Release|Win32.ActiveCfg = Release|Win32 - {E417CAA4-259B-4C99-88E3-805F1300E8EB}.Release|Win32.Build.0 = Release|Win32 - {E417CAA4-259B-4C99-88E3-805F1300E8EB}.Release|x64.ActiveCfg = Release|Win32 - {56A9A4B2-21E5-4360-AFA8-85B43AC43B08}.Debug|Win32.ActiveCfg = Debug|Win32 - {56A9A4B2-21E5-4360-AFA8-85B43AC43B08}.Debug|x64.ActiveCfg = Debug|Win32 - {56A9A4B2-21E5-4360-AFA8-85B43AC43B08}.Deploy|Win32.ActiveCfg = Deploy|Win32 - {56A9A4B2-21E5-4360-AFA8-85B43AC43B08}.Deploy|Win32.Build.0 = Deploy|Win32 - {56A9A4B2-21E5-4360-AFA8-85B43AC43B08}.Deploy|x64.ActiveCfg = Release|Win32 - {56A9A4B2-21E5-4360-AFA8-85B43AC43B08}.Release|Win32.ActiveCfg = Release|Win32 - {56A9A4B2-21E5-4360-AFA8-85B43AC43B08}.Release|x64.ActiveCfg = Release|Win32 - {E4DF8176-4DEF-4859-962F-B497E3E7A323}.Debug|Win32.ActiveCfg = Debug|Win32 - {E4DF8176-4DEF-4859-962F-B497E3E7A323}.Debug|Win32.Build.0 = Debug|Win32 - {E4DF8176-4DEF-4859-962F-B497E3E7A323}.Debug|x64.ActiveCfg = Debug|Win32 - {E4DF8176-4DEF-4859-962F-B497E3E7A323}.Deploy|Win32.ActiveCfg = Deploy|Win32 - {E4DF8176-4DEF-4859-962F-B497E3E7A323}.Deploy|Win32.Build.0 = Deploy|Win32 - {E4DF8176-4DEF-4859-962F-B497E3E7A323}.Deploy|x64.ActiveCfg = Release|Win32 - {E4DF8176-4DEF-4859-962F-B497E3E7A323}.Deploy|x64.Build.0 = Release|Win32 - {E4DF8176-4DEF-4859-962F-B497E3E7A323}.Release|Win32.ActiveCfg = Release|Win32 - {E4DF8176-4DEF-4859-962F-B497E3E7A323}.Release|Win32.Build.0 = Release|Win32 - {E4DF8176-4DEF-4859-962F-B497E3E7A323}.Release|x64.ActiveCfg = Release|Win32 - {7C25BFBD-7930-4DE2-AF33-27CE1CC521E6}.Debug|Win32.ActiveCfg = Debug|Win32 - {7C25BFBD-7930-4DE2-AF33-27CE1CC521E6}.Debug|Win32.Build.0 = Debug|Win32 - {7C25BFBD-7930-4DE2-AF33-27CE1CC521E6}.Debug|x64.ActiveCfg = Debug|Win32 - {7C25BFBD-7930-4DE2-AF33-27CE1CC521E6}.Deploy|Win32.ActiveCfg = Deploy|Win32 - {7C25BFBD-7930-4DE2-AF33-27CE1CC521E6}.Deploy|Win32.Build.0 = Deploy|Win32 - {7C25BFBD-7930-4DE2-AF33-27CE1CC521E6}.Deploy|x64.ActiveCfg = Release|Win32 - {7C25BFBD-7930-4DE2-AF33-27CE1CC521E6}.Deploy|x64.Build.0 = Release|Win32 - {7C25BFBD-7930-4DE2-AF33-27CE1CC521E6}.Release|Win32.ActiveCfg = Release|Win32 - {7C25BFBD-7930-4DE2-AF33-27CE1CC521E6}.Release|Win32.Build.0 = Release|Win32 - {7C25BFBD-7930-4DE2-AF33-27CE1CC521E6}.Release|x64.ActiveCfg = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {E4DF8176-4DEF-4859-962F-B497E3E7A323} = {2F863EAD-33C9-4014-A573-93F085BA9CB1} - {7C25BFBD-7930-4DE2-AF33-27CE1CC521E6} = {2F863EAD-33C9-4014-A573-93F085BA9CB1} - EndGlobalSection -EndGlobal diff --git a/Telegram/SourceFiles/_other/genlang.cpp b/Telegram/SourceFiles/_other/genlang.cpp index ec073ac35..f8924fadb 100644 --- a/Telegram/SourceFiles/_other/genlang.cpp +++ b/Telegram/SourceFiles/_other/genlang.cpp @@ -777,7 +777,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org\n\ cpp.close(); } if (write_cpp) { - cout << "lang.cpp updated, writing " << keysOrder.size() << " rows.\n"; if (!cpp.open(QIODevice::WriteOnly)) throw Exception("Could not open lang.cpp for writing!"); if (cpp.write(cppText) != cppText.size()) throw Exception("Could not open lang.cpp for writing!"); } @@ -791,7 +790,6 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org\n\ h.close(); } if (write_h) { - cout << "lang.h updated, writing " << keysOrder.size() << " rows.\n"; if (!h.open(QIODevice::WriteOnly)) throw Exception("Could not open lang.h for writing!"); if (h.write(hText) != hText.size()) throw Exception("Could not open lang.h for writing!"); } diff --git a/Telegram/SourceFiles/_other/packer.cpp b/Telegram/SourceFiles/_other/packer.cpp index 9805a7131..08f17ccb5 100644 --- a/Telegram/SourceFiles/_other/packer.cpp +++ b/Telegram/SourceFiles/_other/packer.cpp @@ -20,7 +20,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org */ #include "packer.h" -#include +#include #ifdef Q_OS_MAC Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin) diff --git a/Telegram/SourceFiles/codegen/style/options.cpp b/Telegram/SourceFiles/codegen/style/options.cpp index 4052b401d..433c10913 100644 --- a/Telegram/SourceFiles/codegen/style/options.cpp +++ b/Telegram/SourceFiles/codegen/style/options.cpp @@ -47,6 +47,14 @@ Options parseOptions() { if (arg == "--rebuild") { result.rebuildDependencies = true; + // Skip generating style modules + } else if (arg == "--skip-styles") { + result.skipStyles = true; + + // Skip generating sprite_125x.png and sprite_150x.png + } else if (arg == "--skip-sprites") { + result.skipSprites = true; + // Include paths } else if (arg == "-I") { if (++i == count) { diff --git a/Telegram/SourceFiles/codegen/style/options.h b/Telegram/SourceFiles/codegen/style/options.h index 34746ee2d..f1f591b7c 100644 --- a/Telegram/SourceFiles/codegen/style/options.h +++ b/Telegram/SourceFiles/codegen/style/options.h @@ -31,6 +31,8 @@ struct Options { QString outputPath = "."; QString inputPath; bool rebuildDependencies = false; + bool skipStyles = false; + bool skipSprites = false; }; // Parsing failed if inputPath is empty in the result. diff --git a/Telegram/SourceFiles/codegen/style/processor.cpp b/Telegram/SourceFiles/codegen/style/processor.cpp index 39f02c41e..4b534e7c2 100644 --- a/Telegram/SourceFiles/codegen/style/processor.cpp +++ b/Telegram/SourceFiles/codegen/style/processor.cpp @@ -65,36 +65,40 @@ int Processor::launch() { } bool Processor::write(const structure::Module &module) const { - QDir dir(options_.outputPath); - if (!dir.mkpath(".")) { - common::logError(kErrorCantWritePath, "Command Line") << "can not open path for writing: " << dir.absolutePath().toStdString(); - return false; + bool forceReGenerate = false; + bool onlyStyles = options_.skipSprites; + bool onlySprites = options_.skipStyles; + if (!onlyStyles) { + SpriteGenerator spriteGenerator(module, forceReGenerate); + if (!spriteGenerator.writeSprites()) { + return false; + } } + if (!onlySprites) { + QDir dir(options_.outputPath); + if (!dir.mkpath(".")) { + common::logError(kErrorCantWritePath, "Command Line") << "can not open path for writing: " << dir.absolutePath().toStdString(); + return false; + } - QFileInfo srcFile(module.filepath()); - QString dstFilePath = dir.absolutePath() + '/' + destFileBaseName(module); + QFileInfo srcFile(module.filepath()); + QString dstFilePath = dir.absolutePath() + '/' + destFileBaseName(module); - bool forceReGenerate = false;// !options_.rebuildDependencies; - common::ProjectInfo project = { - "codegen_style", - srcFile.fileName(), - "stdafx.h", - forceReGenerate - }; + common::ProjectInfo project = { + "codegen_style", + srcFile.fileName(), + "stdafx.h", + forceReGenerate + }; - SpriteGenerator spriteGenerator(module, forceReGenerate); - if (!spriteGenerator.writeSprites()) { - return false; + Generator generator(module, dstFilePath, project); + if (!generator.writeHeader()) { + return false; + } + if (!generator.writeSource()) { + return false; + } } - - Generator generator(module, dstFilePath, project); - if (!generator.writeHeader()) { - return false; - } - if (!generator.writeSource()) { - return false; - } - return true; } diff --git a/Telegram/build/build.bat b/Telegram/build/build.bat index 775427765..28289def6 100644 --- a/Telegram/build/build.bat +++ b/Telegram/build/build.bat @@ -40,7 +40,7 @@ set "SolutionPath=%HomePath%\.." set "UpdateFile=tupdate%AppVersion%" set "SetupFile=tsetup.%AppVersionStrFull%.exe" set "PortableFile=tportable.%AppVersionStrFull%.zip" -set "ReleasePath=%HomePath%\..\Win32\Deploy" +set "ReleasePath=%HomePath%\..\out\Release" set "DeployPath=%ReleasePath%\deploy\%AppVersionStrMajor%\%AppVersionStrFull%" set "SignPath=%HomePath%\..\..\TelegramPrivate\Sign.bat" set "BinaryName=Telegram" @@ -80,18 +80,11 @@ if %BetaVersion% neq 0 ( ) cd "%HomePath%" -"..\Win32\codegen\Deploy\codegen_style.exe" "-I.\Resources" "-I.\SourceFiles" "-o.\GeneratedFiles\styles" all_files.style --rebuild - -cd "%ResourcesPath%" -if "%1" == "fast" ( - echo Skipping touching of telegram.qrc... -) else ( - copy telegram.qrc /B+,,/Y -) +call gyp\refresh.bat if %errorlevel% neq 0 goto error cd "%SolutionPath%" -MSBuild Telegram.sln /property:Configuration=Deploy +call ninja -C out/Release Telegram if %errorlevel% neq 0 goto error echo . @@ -112,8 +105,9 @@ call "%SignPath%" "Updater.exe" if %errorlevel% neq 0 goto error if %BetaVersion% equ 0 ( - iscc /dMyAppVersion=%AppVersionStrSmall% /dMyAppVersionZero=%AppVersionStr% /dMyAppVersionFull=%AppVersionStrFull% "%FullScriptPath%setup.iss" + iscc /dMyAppVersion=%AppVersionStrSmall% /dMyAppVersionZero=%AppVersionStr% /dMyAppVersionFull=%AppVersionStrFull% "/dReleasePath=%ReleasePath%" "%FullScriptPath%setup.iss" if %errorlevel% neq 0 goto error + if not exist "tsetup.%AppVersionStrFull%.exe" goto error call "%SignPath%" "tsetup.%AppVersionStrFull%.exe" if %errorlevel% neq 0 goto error diff --git a/Telegram/build/setup.iss b/Telegram/build/setup.iss index 6f8bd3c33..78faee5a4 100644 --- a/Telegram/build/setup.iss +++ b/Telegram/build/setup.iss @@ -19,7 +19,7 @@ AppUpdatesURL={#MyAppURL} DefaultDirName={userappdata}\{#MyAppName} DefaultGroupName={#MyAppName} AllowNoIcons=yes -OutputDir={#SourcePath}..\..\Win32\Deploy +OutputDir={#ReleasePath} OutputBaseFilename=tsetup.{#MyAppVersionFull} SetupIconFile={#SourcePath}..\Resources\art\icon256.ico UninstallDisplayIcon={app}\Telegram.exe @@ -45,8 +45,8 @@ Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{ Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; OnlyBelowVersion: 0,6.1 [Files] -Source: "{#SourcePath}..\..\Win32\Deploy\Telegram.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "{#SourcePath}..\..\Win32\Deploy\Updater.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#ReleasePath}\Telegram.exe"; DestDir: "{app}"; Flags: ignoreversion +Source: "{#ReleasePath}\Updater.exe"; DestDir: "{app}"; Flags: ignoreversion ; NOTE: Don't use "Flags: ignoreversion" on any shared system files [Icons] diff --git a/Telegram/gyp/Telegram.gyp b/Telegram/gyp/Telegram.gyp index 75d661587..fe41c5951 100644 --- a/Telegram/gyp/Telegram.gyp +++ b/Telegram/gyp/Telegram.gyp @@ -24,18 +24,33 @@ 'libs_loc': '../../../Libraries', 'src_loc': '../SourceFiles', 'res_loc': '../Resources', + 'style_files': [ + '<(res_loc)/basic.style', + '<(res_loc)/basic_types.style', + '<(src_loc)/boxes/boxes.style', + '<(src_loc)/dialogs/dialogs.style', + '<(src_loc)/history/history.style', + '<(src_loc)/media/view/mediaview.style', + '<(src_loc)/overview/overview.style', + '<(src_loc)/profile/profile.style', + '<(src_loc)/ui/widgets/widgets.style', + ], + 'qrc_files': [ + '<(res_loc)/telegram.qrc', + '<(res_loc)/telegram_emojis.qrc', + ], }, 'includes': [ 'common_executable.gypi', 'qt.gypi', + 'codegen_rules.gypi', ], 'dependencies': [ 'codegen.gyp:codegen_style', 'codegen.gyp:codegen_numbers', 'codegen.gyp:MetaLang', -# 'utils.gyp:Packer', -# 'utils.gyp:Updater', + 'utils.gyp:Updater', ], 'defines': [ @@ -52,26 +67,13 @@ '<(libs_loc)/ffmpeg', '<(libs_loc)/openal-soft/include', '../ThirdParty/minizip', - '<(libs_loc)/openssl/Release/include', - '<(libs_loc)/openssl_debug/Debug/include', ], 'library_dirs': [ '<(libs_loc)/ffmpeg', ], 'sources': [ - '<(res_loc)/telegram.qrc', - '<(res_loc)/telegram_emojis.qrc', - '<(res_loc)/telegram_wnd.qrc', - '<(res_loc)/telegram_mac.qrc', - '<(res_loc)/basic.style', - '<(res_loc)/basic_types.style', - '<(src_loc)/boxes/boxes.style', - '<(src_loc)/dialogs/dialogs.style', - '<(src_loc)/history/history.style', - '<(src_loc)/media/view/mediaview.style', - '<(src_loc)/overview/overview.style', - '<(src_loc)/profile/profile.style', - '<(src_loc)/ui/widgets/widgets.style', + '<@(qrc_files)', + '<@(style_files)', '<(src_loc)/main.cpp', '<(src_loc)/stdafx.cpp', '<(src_loc)/stdafx.h', @@ -283,6 +285,8 @@ '<(src_loc)/platform/linux/file_dialog_linux.h', '<(src_loc)/platform/linux/main_window_linux.cpp', '<(src_loc)/platform/linux/main_window_linux.h', + '<(src_loc)/platform/mac/main_window_mac.mm', + '<(src_loc)/platform/mac/main_window_mac.h', '<(src_loc)/platform/win/main_window_win.cpp', '<(src_loc)/platform/win/main_window_win.h', '<(src_loc)/platform/win/windows_app_user_model_id.cpp', @@ -404,6 +408,9 @@ ], 'configurations': { 'Debug': { + 'include_dirs': [ + '<(libs_loc)/openssl_debug/Debug/include', + ], 'library_dirs': [ '<(libs_loc)/lzma/C/Util/LzmaLib/Debug', '<(libs_loc)/libexif-0.6.20/win32/Debug', @@ -415,6 +422,16 @@ ], }, 'Release': { + 'conditions': [ + ['"<(official_build_target)" != ""', { + 'defines': [ + 'CUSTOM_API_ID', + ], + }], + ], + 'include_dirs': [ + '<(libs_loc)/openssl/Release/include', + ], 'library_dirs': [ '<(libs_loc)/lzma/C/Util/LzmaLib/Release', '<(libs_loc)/libexif-0.6.20/win32/Release', @@ -450,59 +467,39 @@ 'lib\exception_handler', 'lib\crash_generation_client', ], - 'actions': [{ - 'action_name': 'codegen_lang', - 'inputs': [ - '<(PRODUCT_DIR)/MetaLang.exe', - '<(res_loc)/langs/lang.strings', - ], - 'outputs': [ - '<(SHARED_INTERMEDIATE_DIR)/lang_auto.cpp', - '<(SHARED_INTERMEDIATE_DIR)/lang_auto.h', - ], - 'action': [ - '<(PRODUCT_DIR)/MetaLang.exe', - '-lang_in', '<(res_loc)/langs/lang.strings', - '-lang_out', '<(SHARED_INTERMEDIATE_DIR)/lang_auto', - ], - 'message': 'codegen_lang-ing lang.strings..', - 'process_outputs_as_sources': 1, - }, { - 'action_name': 'codegen_numbers', - 'inputs': [ - '<(PRODUCT_DIR)/codegen_numbers.exe', - '<(res_loc)/numbers.txt', - ], - 'outputs': [ - '<(SHARED_INTERMEDIATE_DIR)/numbers.cpp', - '<(SHARED_INTERMEDIATE_DIR)/numbers.h', - ], - 'action': [ - '<(PRODUCT_DIR)/codegen_numbers.exe', - '-o<(SHARED_INTERMEDIATE_DIR)', '<(res_loc)/numbers.txt', - ], - 'message': 'codegen_numbers-ing numbers.txt..', - 'process_outputs_as_sources': 1, - }], - 'rules': [{ - 'rule_name': 'gen_style', - 'extension': 'style', - 'inputs': [ - '<(PRODUCT_DIR)/codegen_style.exe', - ], - 'outputs': [ - '<(SHARED_INTERMEDIATE_DIR)/styles/style_<(RULE_INPUT_ROOT).h', - '<(SHARED_INTERMEDIATE_DIR)/styles/style_<(RULE_INPUT_ROOT).cpp', - ], - 'action': [ - '<(PRODUCT_DIR)/codegen_style.exe', - '-I<(res_loc)', '-I<(src_loc)', - '-o<(SHARED_INTERMEDIATE_DIR)/styles', '<(RULE_INPUT_PATH)', - ], - 'message': 'codegen_style-ing <(RULE_INPUT_ROOT).style..', - 'process_outputs_as_sources': 1, - }], 'conditions': [ + [ '"<(official_build_target)" != ""', { + 'dependencies': [ + 'utils.gyp:Packer', + ], + }], + [ 'build_linux', { + 'variables': { + 'qrc_files': [ + '<(res_loc)/telegram_linux.qrc', + ], + } + }], + [ 'build_mac', { + 'variables': { + 'qrc_files': [ + '<(res_loc)/telegram_mac.qrc', + ], + } + }], + [ 'build_win', { + 'msvs_precompiled_source': '<(src_loc)/stdafx.cpp', + 'msvs_precompiled_header': '<(src_loc)/stdafx.h', + 'msbuild_toolset': 'v140_xp', #Windows7.1SDK + 'sources': [ + '<(res_loc)/winrc/Telegram.rc', + ], + 'variables': { + 'qrc_files': [ + '<(res_loc)/telegram_wnd.qrc', + ], + } + }], [ '"<(build_linux)" != "1"', { 'sources!': [ '<(src_loc)/platform/linux/linux_gdk_helper.cpp', @@ -517,7 +514,8 @@ }], [ '"<(build_mac)" != "1"', { 'sources!': [ - '<(res_loc)/telegram_mac.qrc', + '<(src_loc)/platform/mac/main_window_mac.mm', + '<(src_loc)/platform/mac/main_window_mac.h', ], }], [ '"<(build_win)" != "1"', { @@ -532,15 +530,6 @@ '<(src_loc)/platform/win/windows_event_filter.h', '<(src_loc)/platform/win/windows_toasts.cpp', '<(src_loc)/platform/win/windows_toasts.h', - '<(res_loc)/telegram_wnd.qrc', - ], - }], - [ 'build_win', { - 'msvs_precompiled_source': '<(src_loc)/stdafx.cpp', - 'msvs_precompiled_header': '<(src_loc)/stdafx.h', - 'msbuild_toolset': 'v140_xp', #Windows7.1SDK - 'sources': [ - '<(res_loc)/winrc/Telegram.rc', ], }], ], diff --git a/Telegram/gyp/codegen_rules.gypi b/Telegram/gyp/codegen_rules.gypi new file mode 100644 index 000000000..a437037e9 --- /dev/null +++ b/Telegram/gyp/codegen_rules.gypi @@ -0,0 +1,124 @@ +# This file is part of Telegram Desktop, +# the official desktop version of Telegram messaging app, see https://telegram.org +# +# Telegram Desktop is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# It is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# In addition, as a special exception, the copyright holders give permission +# to link the code of portions of this program with the OpenSSL library. +# +# Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE +# Copyright (c) 2014 John Preston, https://desktop.telegram.org + +{ + 'actions': [{ + 'action_name': 'update_sprites', + 'inputs': [ + '<(PRODUCT_DIR)/codegen_style.exe', + '<(res_loc)/basic.style', + '<(res_loc)/art/sprite.png', + '<(res_loc)/art/sprite_200x.png', + ], + 'outputs': [ + '<(res_loc)/art/sprite_125x.png', + '<(res_loc)/art/sprite_150x.png', + ], + 'action': [ + '<(PRODUCT_DIR)/codegen_style.exe', + '-I<(res_loc)', '-I<(src_loc)', + '--skip-styles', '<(res_loc)/basic.style', + ], + 'message': 'Updating sprites..', + }, { + 'action_name': 'update_dependent_styles', + 'inputs': [ + '<(DEPTH)/update_dependent.py', + '<@(style_files)', + ], + 'outputs': [ + '<(SHARED_INTERMEDIATE_DIR)/update_dependent_styles.timestamp', + ], + 'action': [ + 'python', '<(DEPTH)/update_dependent.py', '-tstyle', + '-I<(res_loc)', '-I<(src_loc)', + '-o<(SHARED_INTERMEDIATE_DIR)/update_dependent_styles.timestamp', + '<@(style_files)', + ], + 'message': 'Updating dependent style files..', + }, { + 'action_name': 'update_dependent_qrc', + 'inputs': [ + '<(DEPTH)/update_dependent.py', + '<@(qrc_files)', + ' 1 and sys.argv[1] == '--read-target': + target_path = my_path + '/../build/target' + if os.path.isfile(target_path): + with open(target_path) as f: + for line in f: + cleanline = re.sub(r'^\s*|\s*$', '', line); + if cleanline != '': + print(cleanline); +else: + print('This is a helper script, it should not be called directly.') diff --git a/Telegram/gyp/qt.gypi b/Telegram/gyp/qt.gypi index 4ad8b7555..4e394e034 100644 --- a/Telegram/gyp/qt.gypi +++ b/Telegram/gyp/qt.gypi @@ -137,6 +137,9 @@ }, { 'rule_name': 'qt_rcc', 'extension': 'qrc', + 'inputs': [ + '<(SHARED_INTERMEDIATE_DIR)/update_dependent_qrc.timestamp', + ], 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/<(_target_name)/qrc/qrc_<(RULE_INPUT_ROOT).cpp', ], diff --git a/Telegram/gyp/refresh.bat b/Telegram/gyp/refresh.bat index cb78665f6..4b6ca6a9f 100644 --- a/Telegram/gyp/refresh.bat +++ b/Telegram/gyp/refresh.bat @@ -6,6 +6,13 @@ set "FullExecPath=%cd%" set "Silence=>nul" if "%1" == "-v" set "Silence=" +rem strangely linking of Release Telegram build complains about the absence of lib.pdb +if exist "%FullScriptPath%..\..\..\Libraries\openssl\tmp32\lib.pdb" ( + if not exist "%FullScriptPath%..\..\..\Libraries\openssl\Release\lib\lib.pdb" ( + xcopy "%FullScriptPath%..\..\..\Libraries\openssl\tmp32\lib.pdb" "%FullScriptPath%..\..\..\Libraries\openssl\Release\lib\" %Silence% + ) +) + cd "%FullScriptPath%" call gyp --depth=. --generator-output=../.. -Goutput_dir=out Telegram.gyp --format=ninja if %errorlevel% neq 0 goto error diff --git a/Telegram/gyp/update_dependent.py b/Telegram/gyp/update_dependent.py new file mode 100644 index 000000000..62e3f9a89 --- /dev/null +++ b/Telegram/gyp/update_dependent.py @@ -0,0 +1,192 @@ +''' +This file is part of Telegram Desktop, +the official desktop version of Telegram messaging app, see https://telegram.org + +Telegram Desktop is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +It is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +In addition, as a special exception, the copyright holders give permission +to link the code of portions of this program with the OpenSSL library. + +Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE +Copyright (c) 2014 John Preston, https://desktop.telegram.org +''' +from __future__ import print_function +import sys +import os +import re +import time + +def eprint(*args, **kwargs): + print(*args, file=sys.stderr, **kwargs) + sys.exit(1) + +my_path = os.path.dirname(os.path.realpath(__file__)).replace('\\', '/') + +def get_qrc_dependencies(file_path): + global one_modified + dependencies = {} + if not os.path.isfile(file_path): + eprint('File not found: ' + file_path) + dir_name = os.path.dirname(file_path).replace('\\', '/') + with open(file_path) as f: + for line in f: + file_match = re.match('^\s*]*)?>([^<]+)', line) + if file_match: + full_path = dir_name + '/' + file_match.group(2) + dependencies[full_path] = 1 + return dependencies + +def list_qrc_dependencies(file_path): + global one_modified + dependencies = get_qrc_dependencies(file_path) + for path in dependencies: + print(path) + sys.exit(0) + +one_modified = 0 +def handle_qrc_dependencies(file_path): + global one_modified + dependencies = get_qrc_dependencies(file_path) + file_modified = os.path.getmtime(file_path) + latest_modified = file_modified + for path in dependencies: + if os.path.isfile(path): + dependency_modified = os.path.getmtime(path) + if latest_modified < dependency_modified: + latest_modified = dependency_modified + else: + eprint('File not found: ' + full_path) + if file_modified < latest_modified: + os.utime(file_path, None); + one_modified = 1 + +def get_direct_style_dependencies(file_path): + dependencies = {} + dependencies[file_path] = 1 + if not os.path.isfile(file_path): + eprint('File not found: ' + file_path) + with open(file_path) as f: + for line in f: + using_match = re.match('^\s*using "([^"]+)"', line) + if using_match: + path = using_match.group(1) + found = 0 + for include_dir in include_dirs: + full_path = include_dir + '/' + path + if os.path.isfile(full_path): + try: + if dependencies[full_path]: + eprint('Cyclic dependencies: ' + full_path) + except KeyError: + dependencies[full_path] = 1 + found = 1 + break + if found != 1: + eprint('File not found: ' + path) + return dependencies + +include_dirs = [] +def handle_style_dependencies(file_path): + global one_modified + all_dependencies = {} + all_dependencies[file_path] = 1 + added_from = {} + while len(added_from) != len(all_dependencies): + for dependency in all_dependencies: + try: + if added_from[dependency]: + continue + except KeyError: + added_from[dependency] = 1 + add = get_direct_style_dependencies(dependency) + for new_dependency in add: + all_dependencies[new_dependency] = 1 + break + + file_modified = os.path.getmtime(file_path) + latest_modified = file_modified + for path in all_dependencies: + if path != file_path: + dependency_modified = os.path.getmtime(path) + if latest_modified < dependency_modified: + latest_modified = dependency_modified + if file_modified < latest_modified: + os.utime(file_path, None); + one_modified = 1 + +file_paths = [] +file_type = '' +output_file = '' +next_file_type = 0 +next_include_dir = 0 +next_output_file = 0 +next_self = 1 +for arg in sys.argv: + if next_self != 0: + next_self = 0 + continue + if next_file_type != 0: + next_file_type = 0 + file_type = arg + continue + if next_include_dir != 0: + next_include_dir = 0 + include_dirs.append(arg) + continue + if next_output_file != 0: + next_output_file = 0 + output_file = arg + continue + + type_match = re.match(r'^\-t(.*)$', arg) + if type_match: + file_type = type_match.group(1) + if file_type == '': + next_file_type = 1 + continue + + include_dir_match = re.match(r'^\-I(.*)$', arg) + if include_dir_match: + include_dir = include_dir_match.group(1) + if include_dir == '': + next_include_dir = 1 + else: + include_dirs.append(include_dir) + continue + + output_match = re.match(r'^-o(.*)$', arg) + if output_match: + output_file = output_match.group(1) + if output_file == '': + next_output_file = 1 + continue + + file_paths.append(arg) + +if file_type == 'style': + for file_path in file_paths: + handle_style_dependencies(file_path) +elif file_type == 'qrc': + for file_path in file_paths: + handle_qrc_dependencies(file_path) +elif file_type == 'qrc_list': + for file_path in file_paths: + list_qrc_dependencies(file_path) +elif file_type != '': + eprint('Unknown file type: ' + file_type) +else: + eprint('File type was not provided.') + +if not os.path.isfile(output_file): + with open(output_file, "w") as f: + f.write('1') +elif one_modified != 0: + os.utime(output_file, None); diff --git a/Telegram/gyp/utils.gyp b/Telegram/gyp/utils.gyp new file mode 100644 index 000000000..a4eb2c588 --- /dev/null +++ b/Telegram/gyp/utils.gyp @@ -0,0 +1,112 @@ +# This file is part of Telegram Desktop, +# the official desktop version of Telegram messaging app, see https://telegram.org +# +# Telegram Desktop is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# It is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# In addition, as a special exception, the copyright holders give permission +# to link the code of portions of this program with the OpenSSL library. +# +# Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE +# Copyright (c) 2014 John Preston, https://desktop.telegram.org + +{ + 'targets': [{ + 'target_name': 'Updater', + 'variables': { + 'libs_loc': '../../../Libraries', + 'src_loc': '../SourceFiles', + }, + 'includes': [ + 'common_executable.gypi', + ], + + 'include_dirs': [ + '<(src_loc)', + ], + 'sources': [ + '<(src_loc)/_other/updater.cpp', + '<(src_loc)/_other/updater.h', + '<(src_loc)/_other/updater_linux.cpp', + '<(src_loc)/_other/updater_osx.m', + ], + 'conditions': [ + [ '<(build_win)', { + 'sources': [ + '<(res_loc)/winrc/Updater.rc', + ], + }], + [ '"<(build_linux)" != "1"', { + 'sources!': [ + '<(src_loc)/_other/updater_linux.cpp', + ], + }], + [ '"<(build_mac)" != "1"', { + 'sources!': [ + '<(src_loc)/_other/updater_osx.m', + ], + }], + [ '"<(build_win)" != "1"', { + 'sources!': [ + '<(src_loc)/_other/updater.cpp', + ], + }], + ], + }, { + 'target_name': 'Packer', + 'variables': { + 'libs_loc': '../../../Libraries', + 'src_loc': '../SourceFiles', + }, + 'includes': [ + 'common_executable.gypi', + 'qt.gypi', + ], + 'libraries': [ + 'libeay32', + 'ssleay32', + 'Crypt32', + 'zlibstat', + 'LzmaLib', + ], + + 'include_dirs': [ + '<(src_loc)', + '<(libs_loc)/lzma/C', + '<(libs_loc)/zlib-1.2.8', + ], + 'sources': [ + '<(src_loc)/_other/packer.cpp', + '<(src_loc)/_other/packer.h', + ], + 'configurations': { + 'Debug': { + 'include_dirs': [ + '<(libs_loc)/openssl_debug/Debug/include', + ], + 'library_dirs': [ + '<(libs_loc)/lzma/C/Util/LzmaLib/Debug', + '<(libs_loc)/zlib-1.2.8/contrib/vstudio/vc11/x86/ZlibStatDebug', + '<(libs_loc)/openssl_debug/Debug/lib', + ], + }, + 'Release': { + 'include_dirs': [ + '<(libs_loc)/openssl/Release/include', + ], + 'library_dirs': [ + '<(libs_loc)/lzma/C/Util/LzmaLib/Release', + '<(libs_loc)/zlib-1.2.8/contrib/vstudio/vc11/x86/ZlibStatRelease', + '<(libs_loc)/openssl/Release/lib', + ], + }, + }, + }], +}