Skip to content

Commit

Permalink
First attempt to build Telegram on Windows using GYP+Ninja.
Browse files Browse the repository at this point in the history
It already builds in Debug, using rules for Qt MOC and RCC.
Need to start use rules for styles/langs/numbers, test on WinXP.
Need to support Release and Deploy configurations.
  • Loading branch information
john-preston committed Aug 10, 2016
1 parent 67a3f33 commit 62cab07
Show file tree
Hide file tree
Showing 7 changed files with 894 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/out/
/Telegram/build/target
/Telegram/build/msvs/
/Telegram/GeneratedFiles/
/Telegram/SourceFiles/art/grid.png
/Telegram/SourceFiles/art/grid_125x.png
Expand Down
502 changes: 502 additions & 0 deletions Telegram/gyp/Telegram.gyp

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions Telegram/gyp/common.gypi
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# 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

{
'variables': {
'variables': {
'variables': {
'build_os%': '<(OS)',
},
'build_os%': '<(build_os)',
'conditions': [
[ 'build_os == "win"', {
'build_win': 1,
}, {
'build_win': 0,
}],
[ 'build_os == "mac"', {
'build_mac': 1,
}, {
'build_mac': 0,
}],
[ 'build_os == "linux"', {
'build_linux': 1,
}, {
'build_linux': 0,
}],
],
},
'build_os%': '<(build_os)',
'build_win%': '<(build_win)',
'build_mac%': '<(build_mac)',
'build_linux%': '<(build_linux)',

# GYP does not support per-configuration libraries :(
# So they will be emulated through additional link flags,
# which will contain <(ld_lib_prefix)LibraryName<(ld_lib_postfix)
'conditions': [
[ 'build_win', {
'ld_lib_prefix': '',
'ld_lib_postfix': '.lib',
}, {
'ld_lib_prefix': '-l',
'ld_lib_postfix': '',
}],
],
'ld_lib_prefix': '<(ld_lib_prefix)',
'ld_lib_postfix': '<(ld_lib_postfix)',

'library%': 'static_library',
},

'configurations': {
'Debug': {
'defines': [
'_DEBUG',
],
},
'Release': {
'defines': [
'NDEBUG',
],
},
},
}
29 changes: 29 additions & 0 deletions Telegram/gyp/common_executable.gypi
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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

{
'type': 'executable',
'variables': {
'win_subsystem': '2', # Windows application
},
'includes': [
'common.gypi',
'settings_win.gypi',
],
}
153 changes: 153 additions & 0 deletions Telegram/gyp/qt.gypi
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# 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

{
'variables': {
'variables': {
'variables': {
'qt_version%': '5.6.0',
},
'qt_version%': '<(qt_version)',
'qt_version_loc': '<!(python -c "print(\'<(qt_version)\'.replace(\'.\', \'_\')))',
'qtlibs_debug': [
'<(ld_lib_prefix)Qt5Cored<(ld_lib_postfix)',
'<(ld_lib_prefix)qtmaind<(ld_lib_postfix)',
'<(ld_lib_prefix)qtpcred<(ld_lib_postfix)',
'<(ld_lib_prefix)Qt5Guid<(ld_lib_postfix)',
'<(ld_lib_prefix)qtfreetyped<(ld_lib_postfix)',
'<(ld_lib_prefix)Qt5Widgetsd<(ld_lib_postfix)',
'<(ld_lib_prefix)qtharfbuzzngd<(ld_lib_postfix)',
'<(ld_lib_prefix)Qt5Networkd<(ld_lib_postfix)',
'<(ld_lib_prefix)Qt5PlatformSupportd<(ld_lib_postfix)',
'<(ld_lib_prefix)imageformats\qwebpd<(ld_lib_postfix)',
],
'qtlibs_release': [
'<(ld_lib_prefix)Qt5Core<(ld_lib_postfix)',
'<(ld_lib_prefix)qtmain<(ld_lib_postfix)',
'<(ld_lib_prefix)qtpcre<(ld_lib_postfix)',
'<(ld_lib_prefix)Qt5Gui<(ld_lib_postfix)',
'<(ld_lib_prefix)qtfreetype<(ld_lib_postfix)',
'<(ld_lib_prefix)Qt5Widgets<(ld_lib_postfix)',
'<(ld_lib_prefix)qtharfbuzzng<(ld_lib_postfix)',
'<(ld_lib_prefix)Qt5Network<(ld_lib_postfix)',
'<(ld_lib_prefix)Qt5PlatformSupport<(ld_lib_postfix)',
'<(ld_lib_prefix)imageformats\qwebp<(ld_lib_postfix)',
],
},
'qt_version%': '<(qt_version)',
'conditions': [
[ 'build_win', {
'qtlibs_debug': [
'<(ld_lib_prefix)platforms/qwindowsd<(ld_lib_postfix)',
'<@(qtlibs_debug)',
],
'qtlibs_release': [
'<(ld_lib_prefix)platforms/qwindows<(ld_lib_postfix)',
'<@(qtlibs_release)',
],
'qt_loc': '../../../Libraries/qt<(qt_version_loc)/qtbase',
}, {
'qtlibs_debug': [ '<@(qtlibs_debug)' ],
'qtlibs_release': [ '<@(qtlibs_release)' ],
'qt_loc': '/usr/local/qt<(qt_version_loc)/qtbase',
}],
],
},

'configurations': {
'Debug': {
'conditions' : [
[ 'build_win', {
'msvs_settings': {
'VCLinkerTool': {
'AdditionalDependencies': [
'<@(qtlibs_debug)'
],
},
},
}],
],
},
'Release': {
'conditions' : [
[ 'build_win', {
'msvs_settings': {
'VCLinkerTool': {
'AdditionalDependencies': [
'<@(qtlibs_release)',
],
},
},
}],
],
},
},

'include_dirs': [
'<(qt_loc)/include',
'<(qt_loc)/include/QtCore/<(qt_version)/QtCore',
'<(qt_loc)/include/QtGui/<(qt_version)/QtGui',
],
'library_dirs': [
'<(qt_loc)/lib',
'<(qt_loc)/plugins',
],
'defines': [
'QT_WIDGETS_LIB',
'QT_NETWORK_LIB',
'QT_GUI_LIB',
'QT_CORE_LIB',
],

'rules': [{
'rule_name': 'qt_moc',
'extension': 'h',
'inputs': [
],
'outputs': [
'<(gen_loc)/moc/moc_<(RULE_INPUT_ROOT).cpp',
],
'action': [
'<(qt_loc)/bin/moc.exe',
'<!@(python -c "for s in \'<@(_defines)\'.split(\' \'): print(\'-D\' + s))',
'<!@(python -c "for s in \'<@(_include_dirs)\'.split(\' \'): print(\'-I\' + s))',
'<(RULE_INPUT_PATH)',
'-o', '<(gen_loc)/moc/moc_<(RULE_INPUT_ROOT).cpp',
],
'message': 'Moc-ing <(RULE_INPUT_ROOT).h..',
'process_outputs_as_sources': 1,
}, {
'rule_name': 'qt_rcc',
'extension': 'qrc',
'inputs': [
],
'outputs': [
'<(gen_loc)/qrc/qrc_<(RULE_INPUT_ROOT).cpp',
],
'action': [
'<(qt_loc)/bin/rcc.exe',
'-name', '<(RULE_INPUT_ROOT)',
'-no-compress',
'<(RULE_INPUT_PATH)',
'-o', '<(gen_loc)/qrc/qrc_<(RULE_INPUT_ROOT).cpp',
],
'message': 'Rcc-ing <(RULE_INPUT_ROOT).qrc..',
'process_outputs_as_sources': 1,
}],
}
11 changes: 11 additions & 0 deletions Telegram/gyp/refresh.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@echo OFF
setlocal enabledelayedexpansion
set "FullScriptPath=%~dp0"
set "FullExecPath=%cd%"

cd "%FullScriptPath%"
call gyp --depth=. --generator-output=../build/msvs -Goutput_dir=../../../out Telegram.gyp --format=ninja
call gyp --depth=. --generator-output=../build/msvs -Goutput_dir=../../../out Telegram.gyp --format=msvs-ninja
cd "%FullExecPath%"

exit /b
Loading

0 comments on commit 62cab07

Please sign in to comment.