Skip to content

Commit

Permalink
cpprestsdk: fix build on powerpc
Browse files Browse the repository at this point in the history
  • Loading branch information
barracuda156 committed Sep 22, 2024
1 parent ca67d66 commit 348a933
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 2 deletions.
29 changes: 27 additions & 2 deletions www/cpprestsdk/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,36 @@ depends_lib-append port:libiconv \

compiler.cxx_standard 2011

configure.args-append -DBUILD_SAMPLES=OFF -DBUILD_TESTS=OFF \
-DOPENSSL_ROOT_DIR=${prefix} -DWERROR=OFF
# asyncrt_utils.h:317:13: error: 'locale_t' does not name a type
# asyncrt_utils.h:320:24: error: 'xplat_locale' does not name a type
# https://github.com/microsoft/cpprestsdk/pull/1804
patchfiles-append 0001-asyncrt_utils.h-include-xlocale-on-macOS.patch
# Fallback to Boost regex when using GCC.
patchfiles-append 0002-parsing_tests.cpp-use-Boost-regex-on-macOS-with-gcc.patch

configure.args-append \
-DBUILD_SAMPLES=OFF \
-DBUILD_TESTS=OFF \
-DOPENSSL_ROOT_DIR=${prefix} \
-DWERROR=OFF

variant tests description {build tests.} {
configure.args-replace -DBUILD_TESTS=OFF -DBUILD_TESTS=ON
configure.post_args-append -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF
test.run yes
}

# The following block is only used on macOS powerpc.
platform darwin powerpc {
patchfiles-append \
0003-x509_cert_utilities.h-no-support-for-ASIO_CERT_VERIF.patch

# pplxapple.cpp uses dispatch since:
# https://github.com/microsoft/cpprestsdk/commit/a5346271951e5b301b962516aeb26179a9fc2fc7
depends_lib-append \
port:libdispatch-legacy
configure.cppflags-append \
-I${prefix}/libexec/dispatch/usr/include
configure.ldflags-append \
${prefix}/libexec/dispatch/usr/lib/libdispatch.a
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
From 532fb1edcee321633550c5ad52dd28a99d51e06a Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <barracuda@macos-powerpc.org>
Date: Sun, 22 Sep 2024 06:14:49 +0800
Subject: [PATCH] asyncrt_utils.h: include xlocale on macOS

---
Release/include/cpprest/asyncrt_utils.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git Release/include/cpprest/asyncrt_utils.h Release/include/cpprest/asyncrt_utils.h
index 3e4bfdd5..616ceae5 100644
--- Release/include/cpprest/asyncrt_utils.h
+++ Release/include/cpprest/asyncrt_utils.h
@@ -26,7 +26,7 @@

#ifndef _WIN32
#include <sys/time.h>
-#if !defined(ANDROID) && !defined(__ANDROID__) && defined(HAVE_XLOCALE_H) // CodePlex 269
+#if !defined(ANDROID) && !defined(__ANDROID__) && (defined(HAVE_XLOCALE_H) || defined(__APPLE__)) // CodePlex 269
/* Systems using glibc: xlocale.h has been removed from glibc 2.26
The above include of locale.h is sufficient
Further details: https://sourceware.org/git/?p=glibc.git;a=commit;h=f0be25b6336db7492e47d2e8e72eb8af53b5506d */
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
From dd24ef1934de452d2c69ee7628d057c0626258bb Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <barracuda@macos-powerpc.org>
Date: Sun, 22 Sep 2024 12:18:17 +0800
Subject: [PATCH] parsing_tests.cpp: use Boost regex on macOS with gcc

---
Release/tests/functional/json/parsing_tests.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git Release/tests/functional/json/parsing_tests.cpp Release/tests/functional/json/parsing_tests.cpp
index bd43ee25..bd23a302 100644
--- Release/tests/functional/json/parsing_tests.cpp
+++ Release/tests/functional/json/parsing_tests.cpp
@@ -14,7 +14,7 @@
#include <array>
#include <iomanip>

-#if defined(_WIN32) || defined(__APPLE__)
+#if defined(_WIN32) || (defined(__APPLE__) && defined(__clang__))
#include <regex>
#elif (defined(ANDROID) || defined(__ANDROID__))
#else
@@ -172,7 +172,7 @@ namespace json_tests
{
inline bool verify_parsing_error_msg(const std::string& str)
{
-#if defined(_WIN32) || defined(__APPLE__)
+#if defined(_WIN32) || (defined(__APPLE__) && defined(__clang__))
auto spattern = "^\\* Line \\d+, Column \\d+ Syntax error: .+";
static std::regex pattern(spattern);
return std::regex_match(str, pattern, std::regex_constants::match_flag_type::match_not_null);
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
From a97b324431895777ff6ca9852e5f3ec6ab124a16 Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <barracuda@macos-powerpc.org>
Date: Sun, 22 Sep 2024 11:14:52 +0800
Subject: [PATCH] x509_cert_utilities.h: no support for ASIO_CERT_VERIFICATION
on ppc

---
Release/src/http/common/x509_cert_utilities.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git Release/src/http/common/x509_cert_utilities.h Release/src/http/common/x509_cert_utilities.h
index 854e3053..9096546e 100644
--- Release/src/http/common/x509_cert_utilities.h
+++ Release/src/http/common/x509_cert_utilities.h
@@ -61,7 +61,7 @@ struct winhttp_cert_chain_context
} // namespace web
#endif // _WIN32

-#if defined(__APPLE__) || (defined(ANDROID) || defined(__ANDROID__)) || \
+#if (defined(__APPLE__) && !defined(__ppc__)) || (defined(ANDROID) || defined(__ANDROID__)) || \
(defined(_WIN32) && defined(CPPREST_FORCE_HTTP_CLIENT_ASIO)) || \
(defined(_WIN32) && !defined(__cplusplus_winrt) && !defined(_M_ARM) && !defined(CPPREST_EXCLUDE_WEBSOCKETS))
#define CPPREST_PLATFORM_ASIO_CERT_VERIFICATION_AVAILABLE

0 comments on commit 348a933

Please sign in to comment.