From 036e4f52b70386c3810d6138ac6465cae4c52945 Mon Sep 17 00:00:00 2001 From: Jerry Ma Date: Tue, 4 Jun 2024 12:24:52 +0800 Subject: [PATCH] Prevent use building uv on 7.4 (#471) * Prevent use building uv on 7.4 * Add swoole test * Use github source for libcares * Add libcares missing file patch * Add libcares missing file patch --- .github/workflows/tests.yml | 2 +- config/source.json | 11 +- src/SPC/builder/extension/uv.php | 19 ++++ src/SPC/builder/unix/library/libcares.php | 11 ++ src/globals/extra/libcares_dnsinfo.h | 128 ++++++++++++++++++++++ src/globals/test-extensions.php | 2 +- 6 files changed, 168 insertions(+), 5 deletions(-) create mode 100644 src/SPC/builder/extension/uv.php create mode 100644 src/globals/extra/libcares_dnsinfo.h diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index ab5aa4a2..71d4dfb7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -178,7 +178,7 @@ jobs: max_attempts: 3 retry_on: error command: | - bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src --debug --retry=3 + bin/spc download --for-extensions="$(php src/globals/test-extensions.php extensions)" --for-libs="$(php src/globals/test-extensions.php libs)" --with-php=${{ matrix.php }} --ignore-cache-sources=php-src,libcares --debug --retry=3 - name: "Run Build Tests (build, *nix)" if: matrix.os != 'windows-latest' diff --git a/config/source.json b/config/source.json index 789f4e31..8fdfc85c 100644 --- a/config/source.json +++ b/config/source.json @@ -259,9 +259,14 @@ } }, "libcares": { - "type": "filelist", - "url": "https://c-ares.org/download/", - "regex": "/href=\"\\/download\\/(?c-ares-(?[^\"]+)\\.tar\\.gz)\"/", + "type": "ghrel", + "repo": "c-ares/c-ares", + "match": "c-ares-.+\\.tar\\.gz", + "alt": { + "type": "filelist", + "url": "https://c-ares.org/download/", + "regex": "/href=\"\\/download\\/(?c-ares-(?[^\"]+)\\.tar\\.gz)\"/" + }, "license": { "type": "file", "path": "LICENSE.md" diff --git a/src/SPC/builder/extension/uv.php b/src/SPC/builder/extension/uv.php new file mode 100644 index 00000000..af879882 --- /dev/null +++ b/src/SPC/builder/extension/uv.php @@ -0,0 +1,19 @@ +builder->getPHPVersionID() < 80000 && getenv('SPC_SKIP_PHP_VERSION_CHECK') !== 'yes') { + throw new \RuntimeException('The latest uv extension requires PHP 8.0 or later'); + } + } +} diff --git a/src/SPC/builder/unix/library/libcares.php b/src/SPC/builder/unix/library/libcares.php index c57ef375..ea56d8cd 100644 --- a/src/SPC/builder/unix/library/libcares.php +++ b/src/SPC/builder/unix/library/libcares.php @@ -5,9 +5,20 @@ namespace SPC\builder\unix\library; use SPC\exception\RuntimeException; +use SPC\store\FileSystem; trait libcares { + public function patchBeforeBuild(): bool + { + if (!file_exists($this->source_dir . '/src/lib/thirdparty/apple/dnsinfo.h')) { + FileSystem::createDir($this->source_dir . '/src/lib/thirdparty/apple'); + copy(ROOT_DIR . '/src/globals/extra/libcares_dnsinfo.h', $this->source_dir . '/src/lib/thirdparty/apple/dnsinfo.h'); + return true; + } + return false; + } + /** * @throws RuntimeException */ diff --git a/src/globals/extra/libcares_dnsinfo.h b/src/globals/extra/libcares_dnsinfo.h new file mode 100644 index 00000000..e6a9ed11 --- /dev/null +++ b/src/globals/extra/libcares_dnsinfo.h @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2004-2006, 2008, 2009, 2011-2013, 2015-2018 Apple Inc. All rights reserved. + * + * @APPLE_LICENSE_HEADER_START@ + * + * This file contains Original Code and/or Modifications of Original Code + * as defined in and that are subject to the Apple Public Source License + * Version 2.0 (the 'License'). You may not use this file except in + * compliance with the License. Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this + * file. + * + * The Original Code and all software distributed under the License are + * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, + * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. + * Please see the License for the specific language governing rights and + * limitations under the License. + * + * @APPLE_LICENSE_HEADER_END@ + */ + +#ifndef __DNSINFO_H__ +#define __DNSINFO_H__ + +/* + * These routines provide access to the systems DNS configuration + */ + +#include +#include +#include +#include +#include +#include + +#define DNSINFO_VERSION 20170629 + +#define DEFAULT_SEARCH_ORDER 200000 /* search order for the "default" resolver domain name */ + +#define DNS_PTR(type, name) \ + union { \ + type name; \ + uint64_t _ ## name ## _p; \ + } + +#define DNS_VAR(type, name) \ + type name + + +#pragma pack(4) +typedef struct { + struct in_addr address; + struct in_addr mask; +} dns_sortaddr_t; +#pragma pack() + + +#pragma pack(4) +typedef struct { + DNS_PTR(char *, domain); /* domain */ + DNS_VAR(int32_t, n_nameserver); /* # nameserver */ + DNS_PTR(struct sockaddr **, nameserver); + DNS_VAR(uint16_t, port); /* port (in host byte order) */ + DNS_VAR(int32_t, n_search); /* # search */ + DNS_PTR(char **, search); + DNS_VAR(int32_t, n_sortaddr); /* # sortaddr */ + DNS_PTR(dns_sortaddr_t **, sortaddr); + DNS_PTR(char *, options); /* options */ + DNS_VAR(uint32_t, timeout); /* timeout */ + DNS_VAR(uint32_t, search_order); /* search_order */ + DNS_VAR(uint32_t, if_index); + DNS_VAR(uint32_t, flags); + DNS_VAR(uint32_t, reach_flags); /* SCNetworkReachabilityFlags */ + DNS_VAR(uint32_t, service_identifier); + DNS_PTR(char *, cid); /* configuration identifer */ + DNS_PTR(char *, if_name); /* if_index interface name */ +} dns_resolver_t; +#pragma pack() + + +#define DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS 0x0002 /* always requesting for A dns records in queries */ +#define DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS 0x0004 /* always requesting for AAAA dns records in queries */ + +#define DNS_RESOLVER_FLAGS_REQUEST_ALL_RECORDS \ + (DNS_RESOLVER_FLAGS_REQUEST_A_RECORDS | DNS_RESOLVER_FLAGS_REQUEST_AAAA_RECORDS) + +#define DNS_RESOLVER_FLAGS_SCOPED 0x1000 /* configuration is for scoped questions */ +#define DNS_RESOLVER_FLAGS_SERVICE_SPECIFIC 0x2000 /* configuration is service-specific */ +#define DNS_RESOLVER_FLAGS_SUPPLEMENTAL 0x4000 /* supplemental match configuration */ + + +#pragma pack(4) +typedef struct { + DNS_VAR(int32_t, n_resolver); /* resolver configurations */ + DNS_PTR(dns_resolver_t **, resolver); + DNS_VAR(int32_t, n_scoped_resolver); /* "scoped" resolver configurations */ + DNS_PTR(dns_resolver_t **, scoped_resolver); + DNS_VAR(uint64_t, generation); + DNS_VAR(int32_t, n_service_specific_resolver); + DNS_PTR(dns_resolver_t **, service_specific_resolver); + DNS_VAR(uint32_t, version); +} dns_config_t; +#pragma pack() + + +__BEGIN_DECLS + +/* + * DNS configuration access APIs + */ +const char * +dns_configuration_notify_key (void) API_AVAILABLE(macos(10.4), ios(2.0)); + +dns_config_t * +dns_configuration_copy (void) API_AVAILABLE(macos(10.4), ios(2.0)); + +void +dns_configuration_free (dns_config_t *config) API_AVAILABLE(macos(10.4), ios(2.0)); + +void +_dns_configuration_ack (dns_config_t *config, + const char *bundle_id) API_AVAILABLE(macos(10.8), ios(6.0)); + +__END_DECLS + +#endif /* __DNSINFO_H__ */ \ No newline at end of file diff --git a/src/globals/test-extensions.php b/src/globals/test-extensions.php index 22a42e07..f8f2e763 100644 --- a/src/globals/test-extensions.php +++ b/src/globals/test-extensions.php @@ -19,7 +19,7 @@ // If you want to test your added extensions and libs, add below (comma separated, example `bcmath,openssl`). $extensions = match (PHP_OS_FAMILY) { - 'Linux', 'Darwin' => 'libxml', + 'Linux', 'Darwin' => 'libxml,swoole', 'Windows' => 'mbstring,pdo_sqlite,mbregex,libxml', };