From b821978a36740e5597e302fa35a892d275e91ee0 Mon Sep 17 00:00:00 2001
From: John Preston <johnprestonmail@gmail.com>
Date: Mon, 29 Aug 2016 20:46:57 -0600
Subject: [PATCH] Added Xcode projects to .gitignore, added some Xcode settings
 to GYP.

---
 .gitignore                     |  1 +
 Telegram/gyp/common.gypi       | 11 ++++++++++-
 Telegram/gyp/settings_mac.gypi | 26 ++++++++++++++++++++++----
 Telegram/gyp/telegram_mac.gypi | 18 +++++++++++++-----
 4 files changed, 46 insertions(+), 10 deletions(-)

diff --git a/.gitignore b/.gitignore
index bfc3d5081..c667fdda1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,6 +25,7 @@
 *.opendb
 *.VC.db
 *.aps
+*.xcodeproj
 /Win32/
 ipch/
 
diff --git a/Telegram/gyp/common.gypi b/Telegram/gyp/common.gypi
index 6e0c965d8..b7d1c3d92 100644
--- a/Telegram/gyp/common.gypi
+++ b/Telegram/gyp/common.gypi
@@ -57,11 +57,14 @@
       'build_win%': '<(build_win)',
       'build_mac%': '<(build_mac)',
       'build_linux%': '<(build_linux)',
+
+	    'official_build_target%': '<!(python <(DEPTH)/official.py --read-target)',
     },
     'build_os%': '<(build_os)',
     'build_win%': '<(build_win)',
     'build_mac%': '<(build_mac)',
     'build_linux%': '<(build_linux)',
+    'official_build_target%': '<(official_build_target)',
     'mac_target%': '10.8',
 
     # GYP does not support per-configuration libraries :(
@@ -77,6 +80,13 @@
         'ld_lib_postfix': '',
         'exe_ext': '',
       }],
+      [ '"<(official_build_target)" == "mac32"', {
+        'mac_target%': '10.6',
+        'build_mac32': 1,
+      }, {
+        'mac_target%': '10.8',
+        'build_mac32': 0,
+      }]
     ],
     'ld_lib_prefix': '<(ld_lib_prefix)',
     'ld_lib_postfix': '<(ld_lib_postfix)',
@@ -84,7 +94,6 @@
 
     'library%': 'static_library',
 
-    'official_build_target%': '<!(python <(DEPTH)/official.py --read-target)',
   },
 
   'configurations': {
diff --git a/Telegram/gyp/settings_mac.gypi b/Telegram/gyp/settings_mac.gypi
index 42bbe7e45..5ecad2818 100644
--- a/Telegram/gyp/settings_mac.gypi
+++ b/Telegram/gyp/settings_mac.gypi
@@ -46,19 +46,37 @@
           'CoreWLAN',
           'IOKit',
         ],
+        'mac_common_flags': [
+          '-pipe',
+          '-g',
+          '-Wall',
+          '-W',
+          '-fPIE',
+          '-Wno-unused-variable',
+          '-Wno-unused-parameter',
+          '-Wno-unused-function',
+          '-Wno-switch',
+          '-Wno-comment',
+          '-Wno-missing-field-initializers',
+        ],
       },
       'xcode_settings': {
-		    'SYMROOT': '../../out',
+        'SYMROOT': '../../out',
+        'OTHER_CFLAGS': [
+          '<@(mac_common_flags)',
+        ],
         'OTHER_CPLUSPLUSFLAGS': [
-          '-std=c++14',
-          '-Wno-switch',
-          '-stdlib=libc++',
+          '<@(mac_common_flags)',
         ],
         'OTHER_LDFLAGS': [
           '-stdlib=libc++',
           '<!@(python -c "for s in \'<@(mac_frameworks)\'.split(\' \'): print(\'-framework \' + s)")',
         ],
         'MACOSX_DEPLOYMENT_TARGET': '<(mac_target)',
+        'COMBINE_HIDPI_IMAGES': 'YES',
+        'COPY_PHASE_STRIP': 'NO',
+        'CLANG_CXX_LANGUAGE_STANDARD': 'c++14',
+        'CLANG_CXX_LIBRARY': 'libc++',
       },
     }],
   ],
diff --git a/Telegram/gyp/telegram_mac.gypi b/Telegram/gyp/telegram_mac.gypi
index 7f2fac247..71d46d80b 100644
--- a/Telegram/gyp/telegram_mac.gypi
+++ b/Telegram/gyp/telegram_mac.gypi
@@ -31,16 +31,16 @@
         '-lm',
         '-lssl',
         '-lcrypto',
-        '-llzma',
-        '-lopenal',
-        '-lopus',
-        '-lexif',
+        '/usr/local/lib/liblzma.a',
+        '/usr/local/lib/libopenal.a',
+        '/usr/local/lib/libopus.a',
+        '/usr/local/lib/libexif.a',
         '-lavcodec',
         '-lavformat',
         '-lswscale',
         '-lswresample',
         '-lavutil',
-        '-liconv',
+        '/usr/local/lib/libiconv.a',
         '-lbase',
         '-lcrashpad_client',
         '-lcrashpad_util',
@@ -60,11 +60,19 @@
         'library_dirs': [
           '<(libs_loc)/crashpad/crashpad/out/Debug',
         ],
+        'xcode_settings': {
+          'GCC_OPTIMIZATION_LEVEL': '0',
+        },
       },
       'Release': {
         'library_dirs': [
           '<(libs_loc)/crashpad/crashpad/out/Release',
         ],
+        'xcode_settings': {
+          'DEBUG_INFORMATION_FORMAT': 'dwarf-with-dsym',
+          'LLVM_LTO': 'YES',
+          'GCC_OPTIMIZATION_LEVEL': 'fast',
+        },
       },
     },
     'mac_bundle': '1',