From 3c204908f5cf21bcbad2f81a9ed1c2c1d2ea2435 Mon Sep 17 00:00:00 2001 From: OscarL Date: Fri, 2 Jun 2023 17:22:00 -0300 Subject: [PATCH] gyp: update to latest version, switch to Python 3.9. (#8779) Note: The upstream repo was archived in Feb 2023. Works well enough as to be able to build the only in-tree package that requires cmd:gyp (aquaskk, albeit that recipe still requires some minor mods). --- dev-util/gyp/gyp-20160504~git.recipe | 54 ----- dev-util/gyp/gyp-20230301~git.recipe | 58 +++++ ...git.patchset => gyp-20230301~git.patchset} | 221 +++++++++--------- 3 files changed, 170 insertions(+), 163 deletions(-) delete mode 100644 dev-util/gyp/gyp-20160504~git.recipe create mode 100644 dev-util/gyp/gyp-20230301~git.recipe rename dev-util/gyp/patches/{gyp-20160504~git.patchset => gyp-20230301~git.patchset} (84%) diff --git a/dev-util/gyp/gyp-20160504~git.recipe b/dev-util/gyp/gyp-20160504~git.recipe deleted file mode 100644 index bfa7cba19..000000000 --- a/dev-util/gyp/gyp-20160504~git.recipe +++ /dev/null @@ -1,54 +0,0 @@ -SUMMARY="Generate Your Projects (GYP) is a build automation tool" -DESCRIPTION="GYP is created by Google to generate native IDE project files \ -(such as Visual Studio and Xcode) for building the Chromium web browser." -HOMEPAGE="https://gyp.gsrc.io/" -COPYRIGHT="2012 Google Inc." -LICENSE="BSD (2-clause)" -REVISION="5" -# 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 -# cannot be used because the source tarballs it creates are different for each -# request. -freebsdRevision="e679e688ba6db12336b79650c27fcf8a5ed21e60" -SOURCE_URI="http://distcache.freebsd.org/local-distfiles/hrs/gyp-$freebsdRevision.tar.gz" -CHECKSUM_SHA256="51fadf46a7a108b0c8f273fb726b113609d7be5394d286716cbf472d1327d18c" -SOURCE_DIR="gyp-$freebsdRevision" -PATCHES="gyp-$portVersion.patchset" - -ARCHITECTURES="all" - -PROVIDES=" - gyp = $portVersion - cmd:gyp = $portVersion - " -REQUIRES=" - haiku - cmd:python - setuptools_python - " - -BUILD_REQUIRES=" - haiku_devel - setuptools_python - " -BUILD_PREREQUIRES=" - cmd:python - " - -BUILD() -{ - $portPackageLinksDir/cmd~python/bin/python setup.py build -} - -INSTALL() -{ - # GENERIC: all python_setuptools-based installs need this - pythonVersion=$(python --version 2>&1 | sed 's/Python //' | head -c3) - installLocation=$prefix/lib/python$pythonVersion/vendor-packages/ - export PYTHONPATH=$installLocation:$PYTHONPATH - mkdir -p $installLocation - - $portPackageLinksDir/cmd~python/bin/python setup.py install \ - --prefix=$prefix -} diff --git a/dev-util/gyp/gyp-20230301~git.recipe b/dev-util/gyp/gyp-20230301~git.recipe new file mode 100644 index 000000000..2feab39e7 --- /dev/null +++ b/dev-util/gyp/gyp-20230301~git.recipe @@ -0,0 +1,58 @@ +SUMMARY="Generate Your Projects (GYP) is a build automation tool" +DESCRIPTION="GYP is created by Google to generate native IDE project files \ +(such as Visual Studio and Xcode) for building the Chromium web browser." +HOMEPAGE="https://gyp.gsrc.io/" +COPYRIGHT="2009 Google Inc." +LICENSE="BSD (3-clause)" +REVISION="1" +srcGitRev="c6d8b9f7ee355cff1531b0f369cd338a50baeb07" +SOURCE_URI="https://github.com/chromium/gyp/archive/$srcGitRev.tar.gz" +CHECKSUM_SHA256="b4be9a3baccc2d0457aa24e56d96eb703263b7ff7323ecce9177b75385fdfd88" +SOURCE_DIR="gyp-$srcGitRev" +PATCHES="gyp-$portVersion.patchset" + +ARCHITECTURES="any" + +pythonVersion=3.9 +pyVer=${pythonVersion//.} + +PROVIDES=" + gyp = $portVersion + cmd:gyp = $portVersion + " +REQUIRES=" + haiku + six_python$pyVer + cmd:python3 + " + +BUILD_REQUIRES=" + haiku_devel + setuptools_python$pyVer + " +BUILD_PREREQUIRES=" + cmd:python3 + " + +PATCH() +{ + # Some day, python will mean python3. Not yet thou, so we patch all the things! + find ./ -name '*.py' -type f -print0 | xargs -0 sed -i 's|#!/usr/bin/env python|#!/bin/python3|' + find ./ -name '*.py' -type f -print0 | xargs -0 sed -i 's|#!/usr/bin/python|#!/bin/python3|' + find ./ -name '*.py' -type f -print0 | xargs -0 sed -i 's|python -c|python3 -c|' +} + +BUILD() +{ + python3 setup.py build +} + +INSTALL() +{ + installLocation=$prefix/lib/python$pythonVersion/vendor-packages/ + export PYTHONPATH=$installLocation:$PYTHONPATH + mkdir -p $installLocation + + python3 setup.py install \ + --prefix=$prefix +} diff --git a/dev-util/gyp/patches/gyp-20160504~git.patchset b/dev-util/gyp/patches/gyp-20230301~git.patchset similarity index 84% rename from dev-util/gyp/patches/gyp-20160504~git.patchset rename to dev-util/gyp/patches/gyp-20230301~git.patchset index 31539844b..7bff9344f 100644 --- a/dev-util/gyp/patches/gyp-20160504~git.patchset +++ b/dev-util/gyp/patches/gyp-20230301~git.patchset @@ -1,33 +1,126 @@ -From ca8b5365a32578eec212e282dd882ca7b3488c31 Mon Sep 17 00:00:00 2001 +From 5c24c71c87f14636774bc3acdba2bdcef8ad2269 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 4a2041c..0ffb2bf 100644 +--- a/pylib/gyp/generator/cmake.py ++++ b/pylib/gyp/generator/cmake.py +@@ -1078,6 +1078,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 8bc22be..be1aed4 100644 +--- a/pylib/gyp/generator/xcode.py ++++ b/pylib/gyp/generator/xcode.py +@@ -74,6 +74,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', +@@ -774,6 +778,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', []) + +@@ -1132,7 +1156,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.37.3 + + +From d338394a6f6f73cd634d3b83de3862e367a58a62 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. +Subject: Make GYP work on Haiku. +Minor adjustments so it applies to latest gyp code. (OscarL, 2023/06/02) diff --git a/gyptest.py b/gyptest.py -index 8e4fc47..396ed91 100755 +index 1a9ffca..7b643dd 100755 --- a/gyptest.py +++ b/gyptest.py -@@ -225,6 +225,7 @@ def main(argv=None): +@@ -104,6 +104,7 @@ def main(argv=None): + 'linux': ['make', 'ninja'], 'linux2': ['make', 'ninja'], 'linux3': ['make', 'ninja'], - 'darwin': ['make', 'ninja', 'xcode', 'xcode-ninja'], + 'haiku1': ['make'], - }[sys.platform] - for format in format_list: + # TODO: Re-enable xcode-ninja. + # https://bugs.chromium.org/p/gyp/issues/detail?id=530 diff --git a/pylib/gyp/common.py b/pylib/gyp/common.py -index a1e1db5..fb128c2 100644 +index f3ba8a0..e516793 100644 --- a/pylib/gyp/common.py +++ b/pylib/gyp/common.py -@@ -429,12 +429,14 @@ def GetFlavor(params): +@@ -430,6 +430,8 @@ def GetFlavor(params): return 'netbsd' if sys.platform.startswith('aix'): return 'aix' + if sys.platform.startswith('haiku'): + return 'haiku' - - return 'linux' + if sys.platform.startswith('zos'): + return 'zos' + if sys.platform.startswith('os390'): +@@ -439,7 +441,7 @@ def GetFlavor(params): def CopyTool(flavor, out_path, generator_flags={}): @@ -36,21 +129,21 @@ index a1e1db5..fb128c2 100644 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={}): +@@ -447,7 +449,8 @@ def CopyTool(flavor, out_path, generator_flags={}): 'aix': 'flock', 'solaris': 'flock', 'mac': 'mac', - 'win': 'win' + 'win': 'win', -+ 'haiku': 'haiku', ++ '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 +index 997eec0..f19778b 100644 --- a/pylib/gyp/generator/make.py +++ b/pylib/gyp/generator/make.py -@@ -497,6 +497,13 @@ quiet_cmd_infoplist = INFOPLIST $@ +@@ -522,6 +522,13 @@ quiet_cmd_infoplist = INFOPLIST $@ cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@" """ @@ -64,7 +157,7 @@ index b7da768..3337235 100644 def WriteRootHeaderSuffixRules(writer): extensions = sorted(COMPILABLE_EXTENSIONS.keys(), key=str.lower) -@@ -2057,6 +2064,12 @@ def GenerateOutput(target_list, target_dicts, data, params): +@@ -2099,6 +2106,12 @@ def GenerateOutput(target_list, target_dicts, data, params): 'flock': './gyp-flock-tool flock', 'flock_index': 2, }) @@ -79,11 +172,11 @@ index b7da768..3337235 100644 '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 +index 0000000..44c91b4 --- /dev/null +++ b/pylib/gyp/haiku_tool.py @@ -0,0 +1,49 @@ -+#!python ++#!python3 +# 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. @@ -133,95 +226,5 @@ index 0000000..cf23ca5 +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 +2.37.3