From b75d12fe63505370c7c4cc808f43e2bfae7c632e Mon Sep 17 00:00:00 2001 From: Sergei Reznikov Date: Tue, 12 Sep 2017 13:49:12 +0300 Subject: [PATCH] gyp: enable Haiku support * also add patch to make Telegram build go further --- dev-util/gyp/gyp-git.recipe | 3 +- dev-util/gyp/patches/gyp-git.patchset | 227 ++++++++++++++++++++++++++ dev-util/gyp/patches/gyp-r1948.patch | 144 ---------------- 3 files changed, 229 insertions(+), 145 deletions(-) create mode 100644 dev-util/gyp/patches/gyp-git.patchset delete mode 100644 dev-util/gyp/patches/gyp-r1948.patch diff --git a/dev-util/gyp/gyp-git.recipe b/dev-util/gyp/gyp-git.recipe index 379724fd0..542dafa26 100644 --- a/dev-util/gyp/gyp-git.recipe +++ b/dev-util/gyp/gyp-git.recipe @@ -4,7 +4,7 @@ DESCRIPTION="GYP is created by Google to generate native IDE project files \ HOMEPAGE="https://gyp.gsrc.io/" COPYRIGHT="2012 Google Inc." LICENSE="BSD (2-clause)" -REVISION="3" +REVISION="4" # Note that the hash which FreeBSD keeps for this version is not the same as # the commit ID in the official gyp repository. This revision in the FreeBSD # mirror is equivalent to commit 02b145a1 in the official repository, which @@ -14,6 +14,7 @@ freebsdRevision="e679e688ba6db12336b79650c27fcf8a5ed21e60" SOURCE_URI="http://distcache.freebsd.org/local-distfiles/hrs/gyp-$freebsdRevision.tar.gz" CHECKSUM_SHA256="51fadf46a7a108b0c8f273fb726b113609d7be5394d286716cbf472d1327d18c" SOURCE_DIR="gyp-$freebsdRevision" +PATCH="gyp-$portVersion.patchset" ARCHITECTURES="x86 x86_gcc2 x86_64" diff --git a/dev-util/gyp/patches/gyp-git.patchset b/dev-util/gyp/patches/gyp-git.patchset new file mode 100644 index 000000000..2b0dab69c --- /dev/null +++ b/dev-util/gyp/patches/gyp-git.patchset @@ -0,0 +1,227 @@ +From ca8b5365a32578eec212e282dd882ca7b3488c31 Mon Sep 17 00:00:00 2001 +From: Augustin Cavalier +Date: Mon, 30 Jun 2014 14:41:57 -0400 +Subject: [PATCH] Make GYP work on Haiku. + + +diff --git a/gyptest.py b/gyptest.py +index 8e4fc47..396ed91 100755 +--- a/gyptest.py ++++ b/gyptest.py +@@ -225,6 +225,7 @@ def main(argv=None): + 'linux2': ['make', 'ninja'], + 'linux3': ['make', 'ninja'], + 'darwin': ['make', 'ninja', 'xcode', 'xcode-ninja'], ++ 'haiku1': ['make'], + }[sys.platform] + + for format in format_list: +diff --git a/pylib/gyp/common.py b/pylib/gyp/common.py +index a1e1db5..fb128c2 100644 +--- a/pylib/gyp/common.py ++++ b/pylib/gyp/common.py +@@ -429,12 +429,14 @@ def GetFlavor(params): + return 'netbsd' + if sys.platform.startswith('aix'): + return 'aix' ++ if sys.platform.startswith('haiku'): ++ return 'haiku' + + return 'linux' + + + def CopyTool(flavor, out_path, generator_flags={}): +- """Finds (flock|mac|win)_tool.gyp in the gyp directory and copies it ++ """Finds (flock|mac|win|haiku)_tool.gyp in the gyp directory and copies it + to |out_path|.""" + # aix and solaris just need flock emulation. mac and win use more complicated + # support scripts. +@@ -442,7 +444,8 @@ def CopyTool(flavor, out_path, generator_flags={}): + 'aix': 'flock', + 'solaris': 'flock', + 'mac': 'mac', +- 'win': 'win' ++ 'win': 'win', ++ 'haiku': 'haiku', + }.get(flavor, None) + if not prefix: + return +diff --git a/pylib/gyp/generator/make.py b/pylib/gyp/generator/make.py +index b7da768..3337235 100644 +--- a/pylib/gyp/generator/make.py ++++ b/pylib/gyp/generator/make.py +@@ -497,6 +497,13 @@ quiet_cmd_infoplist = INFOPLIST $@ + cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@" + """ + ++SHARED_HEADER_HAIKU_COMMANDS = """ ++# gyp-haiku-tool is written next to the root Makefile by gyp. ++# Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd ++# already. ++quiet_cmd_haiku_tool = HAIKUTOOL $(4) $< ++cmd_haiku_tool = ./gyp-haiku-tool $(4) $< "$@" ++""" + + def WriteRootHeaderSuffixRules(writer): + extensions = sorted(COMPILABLE_EXTENSIONS.keys(), key=str.lower) +@@ -2057,6 +2064,12 @@ def GenerateOutput(target_list, target_dicts, data, params): + 'flock': './gyp-flock-tool flock', + 'flock_index': 2, + }) ++ elif flavor == 'haiku': ++ header_params.update({ ++ 'flock': './gyp-haiku-tool flock', ++ 'flock_index': 2, ++ 'extra_commands': SHARED_HEADER_HAIKU_COMMANDS, ++ }) + + header_params.update({ + 'CC.target': GetEnvironFallback(('CC_target', 'CC'), '$(CC)'), +diff --git a/pylib/gyp/haiku_tool.py b/pylib/gyp/haiku_tool.py +new file mode 100644 +index 0000000..cf23ca5 +--- /dev/null ++++ b/pylib/gyp/haiku_tool.py +@@ -0,0 +1,49 @@ ++#!python ++# Copyright (c) 2011 Google Inc. All rights reserved. ++# Use of this source code is governed by a BSD-style license that can be ++# found in the LICENSE file. ++ ++"""These functions are executed via gyp-haiku-tool when using the Makefile ++generator.""" ++ ++import fcntl ++import os ++import struct ++import subprocess ++import sys ++ ++ ++def main(args): ++ executor = HaikuTool() ++ executor.Dispatch(args) ++ ++ ++class HaikuTool(object): ++ """This class performs all the Haiku tooling steps. The methods can either be ++ executed directly, or dispatched from an argument list.""" ++ ++ def Dispatch(self, args): ++ """Dispatches a string command to a method.""" ++ if len(args) < 1: ++ raise Exception("Not enough arguments") ++ ++ method = "Exec%s" % self._CommandifyName(args[0]) ++ getattr(self, method)(*args[1:]) ++ ++ def _CommandifyName(self, name_string): ++ """Transforms a tool name like copy-info-plist to CopyInfoPlist""" ++ return name_string.title().replace('-', '') ++ ++ def ExecFlock(self, lockfile, *cmd_list): ++ """Emulates the most basic behavior of Linux's flock(1).""" ++ # Rely on exception handling to report errors. ++ fd = os.open(lockfile, os.O_RDONLY|os.O_NOCTTY|os.O_CREAT, 0o666) ++ fcntl.flock(fd, fcntl.LOCK_EX) ++ ret = subprocess.call(cmd_list) ++ # Haiki bug -- lock is not released on file close? ++ fcntl.flock(fd, fcntl.LOCK_UN) ++ return ret ++ ++ ++if __name__ == '__main__': ++ sys.exit(main(sys.argv[1:])) +-- +2.13.1 + + +From 36773846915ef458b904b00ea290ec8c4e76f7f7 Mon Sep 17 00:00:00 2001 +From: Sergei Reznikov +Date: Tue, 12 Sep 2017 12:46:50 +0300 +Subject: patch from Telegram team + + +diff --git a/pylib/gyp/generator/cmake.py b/pylib/gyp/generator/cmake.py +index a2b9629..68d7020 100644 +--- a/pylib/gyp/generator/cmake.py ++++ b/pylib/gyp/generator/cmake.py +@@ -1070,6 +1070,23 @@ def WriteTarget(namer, qualified_target, target_dicts, build_dir, config_to_use, + + output.write(')\n') + ++ # Precompile header ++ precompiled_header = config.get('cmake_precompiled_header', '') ++ if precompiled_header: ++ precompiled_header_script = config.get('cmake_precompiled_header_script', '') ++ if not precompiled_header_script: ++ print ('ERROR: cmake_precompiled_header requires cmake_precompiled_header_script') ++ cmake_precompiled_header = NormjoinPath(path_from_cmakelists_to_gyp, precompiled_header) ++ cmake_precompiled_header_script = NormjoinPathForceCMakeSource(path_from_cmakelists_to_gyp, precompiled_header_script) ++ output.write('include(') ++ output.write(cmake_precompiled_header_script) ++ output.write(')\n') ++ output.write('add_precompiled_header(') ++ output.write(cmake_target_name) ++ output.write(' ') ++ output.write(cmake_precompiled_header) ++ output.write(')\n') ++ + UnsetVariable(output, 'TOOLSET') + UnsetVariable(output, 'TARGET') + +diff --git a/pylib/gyp/generator/xcode.py b/pylib/gyp/generator/xcode.py +index db99d6a..8d56baf 100644 +--- a/pylib/gyp/generator/xcode.py ++++ b/pylib/gyp/generator/xcode.py +@@ -72,6 +72,10 @@ generator_additional_non_configuration_keys = [ + 'ios_app_extension', + 'ios_watch_app', + 'ios_watchkit_extension', ++ ++ 'mac_sandbox', # sandbox support ++ 'mac_sandbox_development_team', ++ + 'mac_bundle', + 'mac_bundle_resources', + 'mac_framework_headers', +@@ -772,6 +776,26 @@ def GenerateOutput(target_list, target_dicts, data, params): + xcode_targets[qualified_target] = xct + xcode_target_to_target_dict[xct] = spec + ++ # sandbox support ++ is_sandbox = int(spec.get('mac_sandbox', 0)) ++ if is_sandbox: ++ dev_team = spec.get('mac_sandbox_development_team', '%%ERROR%%') ++ assert dev_team != '%%ERROR%%', ( ++ 'mac_sandbox must be accompanied by mac_sandbox_development_team (target "%s")' % ++ target_name) ++ try: ++ tmp = pbxp._properties['attributes']['TargetAttributes'] ++ except KeyError: ++ pbxp._properties['attributes']['TargetAttributes'] = {} ++ pbxp._properties['attributes']['TargetAttributes'][xct] = { ++ 'DevelopmentTeam': dev_team, ++ 'SystemCapabilities': { ++ 'com.apple.Sandbox': { ++ 'enabled': 1, ++ }, ++ }, ++ } ++ + spec_actions = spec.get('actions', []) + spec_rules = spec.get('rules', []) + +@@ -1141,7 +1165,8 @@ exit 1 + groups = [x for x in groups if not x.endswith('_excluded')] + for group in groups: + for item in rule.get(group, []): +- pbxp.AddOrGetFileInRootGroup(item) ++ concrete_item = ExpandXcodeVariables(item, rule_input_dict) ++ pbxp.AddOrGetFileInRootGroup(concrete_item) + + # Add "sources". + for source in spec.get('sources', []): +-- +2.13.1 + diff --git a/dev-util/gyp/patches/gyp-r1948.patch b/dev-util/gyp/patches/gyp-r1948.patch deleted file mode 100644 index c4021f888..000000000 --- a/dev-util/gyp/patches/gyp-r1948.patch +++ /dev/null @@ -1,144 +0,0 @@ -From 7acf243286c74a67a0a3a80faff38572d430f160 Mon Sep 17 00:00:00 2001 -From: Augustin Cavalier -Date: Mon, 30 Jun 2014 14:41:57 -0400 -Subject: [PATCH] Make GYP work on Haiku. - ---- - gyptest.py | 1 + - pylib/gyp/common.py | 7 +++++-- - pylib/gyp/generator/make.py | 13 ++++++++++++ - pylib/gyp/haiku_tool.py | 49 +++++++++++++++++++++++++++++++++++++++++++++ - 4 files changed, 68 insertions(+), 2 deletions(-) - create mode 100644 pylib/gyp/haiku_tool.py - -diff --git a/gyptest.py b/gyptest.py -index 8f3ee0f..88125b0 100755 ---- a/gyptest.py -+++ b/gyptest.py -@@ -225,6 +225,7 @@ def main(argv=None): - 'linux2': ['make', 'ninja'], - 'linux3': ['make', 'ninja'], - 'darwin': ['make', 'ninja', 'xcode'], -+ 'haiku1': ['make'], - }[sys.platform] - - for format in format_list: -diff --git a/pylib/gyp/common.py b/pylib/gyp/common.py -index df71d97..8f2d888 100644 ---- a/pylib/gyp/common.py -+++ b/pylib/gyp/common.py -@@ -420,12 +420,14 @@ def GetFlavor(params): - return 'openbsd' - if sys.platform.startswith('aix'): - return 'aix' -+ if sys.platform.startswith('haiku'): -+ return 'haiku' - - return 'linux' - - - def CopyTool(flavor, out_path): -- """Finds (flock|mac|win)_tool.gyp in the gyp directory and copies it -+ """Finds (flock|mac|win|haiku)_tool.gyp in the gyp directory and copies it - to |out_path|.""" - # aix and solaris just need flock emulation. mac and win use more complicated - # support scripts. -@@ -433,7 +435,8 @@ def CopyTool(flavor, out_path): - 'aix': 'flock', - 'solaris': 'flock', - 'mac': 'mac', -- 'win': 'win' -+ 'win': 'win', -+ 'haiku': 'haiku', - }.get(flavor, None) - if not prefix: - return -diff --git a/pylib/gyp/generator/make.py b/pylib/gyp/generator/make.py -index 8c31d10..a7db337 100644 ---- a/pylib/gyp/generator/make.py -+++ b/pylib/gyp/generator/make.py -@@ -505,6 +505,13 @@ quiet_cmd_infoplist = INFOPLIST $@ - cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@" - """ - -+SHARED_HEADER_HAIKU_COMMANDS = """ -+# gyp-haiku-tool is written next to the root Makefile by gyp. -+# Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd -+# already. -+quiet_cmd_haiku_tool = HAIKUTOOL $(4) $< -+cmd_haiku_tool = ./gyp-haiku-tool $(4) $< "$@" -+""" - - def WriteRootHeaderSuffixRules(writer): - extensions = sorted(COMPILABLE_EXTENSIONS.keys(), key=str.lower) -@@ -2056,6 +2063,12 @@ def GenerateOutput(target_list, target_dicts, data, params): - 'flock': './gyp-flock-tool flock', - 'flock_index': 2, - }) -+ elif flavor == 'haiku': -+ header_params.update({ -+ 'flock': './gyp-haiku-tool flock', -+ 'flock_index': 2, -+ 'extra_commands': SHARED_HEADER_HAIKU_COMMANDS, -+ }) - - header_params.update({ - 'CC.target': GetEnvironFallback(('CC_target', 'CC'), '$(CC)'), -diff --git a/pylib/gyp/haiku_tool.py b/pylib/gyp/haiku_tool.py -new file mode 100644 -index 0000000..cf23ca5 ---- /dev/null -+++ b/pylib/gyp/haiku_tool.py -@@ -0,0 +1,49 @@ -+#!python -+# Copyright (c) 2011 Google Inc. All rights reserved. -+# Use of this source code is governed by a BSD-style license that can be -+# found in the LICENSE file. -+ -+"""These functions are executed via gyp-haiku-tool when using the Makefile -+generator.""" -+ -+import fcntl -+import os -+import struct -+import subprocess -+import sys -+ -+ -+def main(args): -+ executor = HaikuTool() -+ executor.Dispatch(args) -+ -+ -+class HaikuTool(object): -+ """This class performs all the Haiku tooling steps. The methods can either be -+ executed directly, or dispatched from an argument list.""" -+ -+ def Dispatch(self, args): -+ """Dispatches a string command to a method.""" -+ if len(args) < 1: -+ raise Exception("Not enough arguments") -+ -+ method = "Exec%s" % self._CommandifyName(args[0]) -+ getattr(self, method)(*args[1:]) -+ -+ def _CommandifyName(self, name_string): -+ """Transforms a tool name like copy-info-plist to CopyInfoPlist""" -+ return name_string.title().replace('-', '') -+ -+ def ExecFlock(self, lockfile, *cmd_list): -+ """Emulates the most basic behavior of Linux's flock(1).""" -+ # Rely on exception handling to report errors. -+ fd = os.open(lockfile, os.O_RDONLY|os.O_NOCTTY|os.O_CREAT, 0o666) -+ fcntl.flock(fd, fcntl.LOCK_EX) -+ ret = subprocess.call(cmd_list) -+ # Haiki bug -- lock is not released on file close? -+ fcntl.flock(fd, fcntl.LOCK_UN) -+ return ret -+ -+ -+if __name__ == '__main__': -+ sys.exit(main(sys.argv[1:])) --- -1.8.3.4 -