From 6480b0fa854762734aa08d90f3d08d38a71c93f4 Mon Sep 17 00:00:00 2001 From: Timofei Zhakov Date: Mon, 11 Nov 2024 09:11:29 +0100 Subject: [PATCH] [serf] new port (build using scons) (#41043) --- ports/serf/portfile.cmake | 139 ++++++++++++++++++ ports/serf/serf-fix-expat.patch | 17 +++ ports/serf/serf-use-debug-libs.patch | 68 +++++++++ ports/serf/vcpkg.json | 14 ++ .../vcpkg_find_acquire_program(SCONS).cmake | 15 +- .../vcpkg-find-acquire-program/portfile.cmake | 6 +- versions/baseline.json | 4 + versions/s-/serf.json | 9 ++ 8 files changed, 261 insertions(+), 11 deletions(-) create mode 100644 ports/serf/portfile.cmake create mode 100644 ports/serf/serf-fix-expat.patch create mode 100644 ports/serf/serf-use-debug-libs.patch create mode 100644 ports/serf/vcpkg.json create mode 100644 versions/s-/serf.json diff --git a/ports/serf/portfile.cmake b/ports/serf/portfile.cmake new file mode 100644 index 0000000000..b8bb2443ce --- /dev/null +++ b/ports/serf/portfile.cmake @@ -0,0 +1,139 @@ +vcpkg_download_distfile(ARCHIVE + URLS "https://dlcdn.apache.org/serf/serf-${VERSION}.tar.bz2" + FILENAME "serf-${VERSION}.tar.bz2" + SHA512 19165274d35c694935cda33f99ef92a7663a5d9c540fb7fd6792aa0efe39941b2fa87ff8b61afd060c6676baec634fd33dc2e9d34ecbee45ed99dfaed077802c +) + +vcpkg_extract_source_archive( + SOURCE_PATH + ARCHIVE "${ARCHIVE}" + PATCHES + serf-fix-expat.patch + serf-use-debug-libs.patch +) + +# Note: custom architecture is not supported on Unix. +if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") + set(SCONS_ARCH "TARGET_ARCH=x86_64") +elseif(VCPKG_TARGET_IS_WINDOWS AND VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") + set(SCONS_ARCH "TARGET_ARCH=x86") +else() + set(SCONS_ARCH "") +endif() + +if(EXISTS "${CURRENT_INSTALLED_DIR}/bin/libapr-1.dll") + set(APR_STATIC "no") +else() + set(APR_STATIC "yes") +endif() + +vcpkg_find_acquire_program(SCONS) + +message(STATUS "Building ${TARGET_TRIPLET}-rel") + +if(VCPKG_TARGET_IS_WINDOWS) + SET(apr_opts + "APR=${CURRENT_INSTALLED_DIR}" + "APU=${CURRENT_INSTALLED_DIR}" + "APR_STATIC=${APR_STATIC}" + ) +else() + SET(apr_opts + "APR=${CURRENT_INSTALLED_DIR}/tools/apr/bin/apr-1-config" + "APU=${CURRENT_INSTALLED_DIR}/tools/apr-util/bin/apu-1-config" + ) +endif() + +vcpkg_execute_build_process( + COMMAND ${SCONS} + "SOURCE_LAYOUT=no" + "PREFIX=${CURRENT_PACKAGES_DIR}" + "LIBDIR=${CURRENT_PACKAGES_DIR}/lib" + "OPENSSL=${CURRENT_INSTALLED_DIR}" + "ZLIB=${CURRENT_INSTALLED_DIR}" + ${apr_opts} + "${SCONS_ARCH}" + "DEBUG=no" + "install-lib" "install-inc" "install-pc" + WORKING_DIRECTORY "${SOURCE_PATH}" + LOGNAME "scons-rel" +) + +# Fixup installed files. +if(VCPKG_TARGET_IS_WINDOWS) + if("${VCPKG_LIBRARY_LINKAGE}" STREQUAL "dynamic" AND VCPKG_TARGET_IS_WINDOWS) + file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/bin") + file(RENAME + "${CURRENT_PACKAGES_DIR}/lib/libserf-1.dll" + "${CURRENT_PACKAGES_DIR}/bin/libserf-1.dll" + ) + file(RENAME + "${CURRENT_PACKAGES_DIR}/lib/libserf-1.pdb" + "${CURRENT_PACKAGES_DIR}/bin/libserf-1.pdb" + ) + else() + file(REMOVE + "${CURRENT_PACKAGES_DIR}/lib/libserf-1.dll" + "${CURRENT_PACKAGES_DIR}/lib/libserf-1.pdb" + "${CURRENT_PACKAGES_DIR}/lib/libserf-1.lib" + ) + endif() + file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/libserf-1.exp") +endif() + +if(NOT VCPKG_BUILD_TYPE) + message(STATUS "Building ${TARGET_TRIPLET}-dbg") + + if(VCPKG_TARGET_IS_WINDOWS) + SET(apr_opts + "APR=${CURRENT_INSTALLED_DIR}/debug" + "APU=${CURRENT_INSTALLED_DIR}/debug" + "APR_STATIC=${APR_STATIC}" + ) + else() + SET(apr_opts + "APR=${CURRENT_INSTALLED_DIR}/tools/apr/debug/bin/apr-1-config" + "APU=${CURRENT_INSTALLED_DIR}/tools/apr-util/debug/bin/apu-1-config" + ) + endif() + + vcpkg_execute_build_process( + COMMAND ${SCONS} + "SOURCE_LAYOUT=no" + "PREFIX=${CURRENT_PACKAGES_DIR}/debug" + "LIBDIR=${CURRENT_PACKAGES_DIR}/debug/lib" + "OPENSSL=${CURRENT_INSTALLED_DIR}" + "ZLIB=${CURRENT_INSTALLED_DIR}" + ${apr_opts} + "${SCONS_ARCH}" + "DEBUG=yes" + "install-lib" "install-pc" + WORKING_DIRECTORY "${SOURCE_PATH}" + LOGNAME "scons-dbg" + ) + + # Fixup installed files. + if(VCPKG_TARGET_IS_WINDOWS) + if("${VCPKG_LIBRARY_LINKAGE}" STREQUAL "dynamic") + file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/debug/bin") + file(RENAME + "${CURRENT_PACKAGES_DIR}/debug/lib/libserf-1.dll" + "${CURRENT_PACKAGES_DIR}/debug/bin/libserf-1.dll" + ) + file(RENAME + "${CURRENT_PACKAGES_DIR}/debug/lib/libserf-1.pdb" + "${CURRENT_PACKAGES_DIR}/debug/bin/libserf-1.pdb" + ) + else() + file(REMOVE + "${CURRENT_PACKAGES_DIR}/debug/lib/libserf-1.dll" + "${CURRENT_PACKAGES_DIR}/debug/lib/libserf-1.pdb" + "${CURRENT_PACKAGES_DIR}/debug/lib/libserf-1.lib" + ) + endif() + file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/lib/libserf-1.exp") + endif() +endif() + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") +vcpkg_fixup_pkgconfig() diff --git a/ports/serf/serf-fix-expat.patch b/ports/serf/serf-fix-expat.patch new file mode 100644 index 0000000000..eb6a2a02e8 --- /dev/null +++ b/ports/serf/serf-fix-expat.patch @@ -0,0 +1,17 @@ +Index: SConstruct +=================================================================== +--- SConstruct (revision 1920717) ++++ SConstruct (working copy) +@@ -324,7 +324,11 @@ + if aprstatic: + apr_libs='apr-1.lib' + apu_libs='aprutil-1.lib' +- env.Append(LIBS=['shell32.lib', 'xml.lib']) ++ env.Append(LIBS=['shell32.lib']) ++ if debug: ++ env.Append(LIBS=['libexpatdMD.lib']) ++ else: ++ env.Append(LIBS=['libexpatMD.lib']) + else: + apr_libs='libapr-1.lib' + apu_libs='libaprutil-1.lib' diff --git a/ports/serf/serf-use-debug-libs.patch b/ports/serf/serf-use-debug-libs.patch new file mode 100644 index 0000000000..41d3d3c9ba --- /dev/null +++ b/ports/serf/serf-use-debug-libs.patch @@ -0,0 +1,68 @@ +Index: SConstruct +=================================================================== +--- SConstruct (revision 1920717) ++++ SConstruct (working copy) +@@ -331,8 +331,12 @@ + + env.Append(LIBS=[apr_libs, apu_libs]) + if not env.get('SOURCE_LAYOUT', None): +- env.Append(LIBPATH=['$APR/lib', '$APU/lib'], +- CPPPATH=['$APR/include/apr-1', '$APU/include/apr-1']) ++ if debug: ++ env.Append(LIBPATH=['$APR/debug/lib', '$APU/lib'], ++ CPPPATH=['$APR/include/apr-1', '$APU/include/apr-1']) ++ else: ++ env.Append(LIBPATH=['$APR/lib', '$APU/debug/lib'], ++ CPPPATH=['$APR/include/apr-1', '$APU/include/apr-1']) + elif aprstatic: + env.Append(LIBPATH=['$APR/LibR','$APU/LibR'], + CPPPATH=['$APR/include', '$APU/include']) +@@ -341,10 +345,15 @@ + CPPPATH=['$APR/include', '$APU/include']) + + # zlib +- env.Append(LIBS=['zlib.lib']) + if not env.get('SOURCE_LAYOUT', None): +- env.Append(CPPPATH=['$ZLIB/include'], +- LIBPATH=['$ZLIB/lib']) ++ if debug: ++ env.Append(CPPPATH=['$ZLIB/include'], ++ LIBPATH=['$ZLIB/debug/lib']) ++ env.Append(LIBS=['zlibd.lib']) ++ else: ++ env.Append(CPPPATH=['$ZLIB/include'], ++ LIBPATH=['$ZLIB/lib']) ++ env.Append(LIBS=['zlib.lib']) + else: + env.Append(CPPPATH=['$ZLIB'], + LIBPATH=['$ZLIB']) +@@ -351,8 +360,12 @@ + + # openssl + if not env.get('SOURCE_LAYOUT', None): +- env.Append(CPPPATH=['$OPENSSL/include/openssl'], +- LIBPATH=['$OPENSSL/lib']) ++ if debug: ++ env.Append(CPPPATH=['$OPENSSL/include/openssl'], ++ LIBPATH=['$OPENSSL/debug/lib']) ++ else: ++ env.Append(CPPPATH=['$OPENSSL/include/openssl'], ++ LIBPATH=['$OPENSSL/lib']) + elif 0: # opensslstatic: + env.Append(CPPPATH=['$OPENSSL/inc32'], + LIBPATH=['$OPENSSL/out32']) +@@ -392,8 +405,12 @@ + apr_libs = '' + apu_libs = '' + +- env.Append(CPPPATH=['$OPENSSL/include']) +- env.Append(LIBPATH=['$OPENSSL/lib']) ++ if debug: ++ env.Append(CPPPATH=['$OPENSSL/include/openssl'], ++ LIBPATH=['$OPENSSL/debug/lib']) ++ else: ++ env.Append(CPPPATH=['$OPENSSL/include/openssl'], ++ LIBPATH=['$OPENSSL/debug']) + + + # If build with gssapi, get its information and define SERF_HAVE_GSSAPI diff --git a/ports/serf/vcpkg.json b/ports/serf/vcpkg.json new file mode 100644 index 0000000000..7a50fecb89 --- /dev/null +++ b/ports/serf/vcpkg.json @@ -0,0 +1,14 @@ +{ + "name": "serf", + "version": "1.3.10", + "description": "The serf library is a high performance C-based HTTP client library built upon the Apache Portable Runtime (APR) library. It is permissively licensed under the Apache License, v2.", + "homepage": "https://serf.apache.org/", + "license": "Apache-2.0", + "supports": "!uwp & !staticcrt & !arm", + "dependencies": [ + "apr", + "apr-util", + "openssl", + "zlib" + ] +} diff --git a/scripts/cmake/vcpkg_find_acquire_program(SCONS).cmake b/scripts/cmake/vcpkg_find_acquire_program(SCONS).cmake index e5056a9e76..ddcfcd547d 100644 --- a/scripts/cmake/vcpkg_find_acquire_program(SCONS).cmake +++ b/scripts/cmake/vcpkg_find_acquire_program(SCONS).cmake @@ -1,10 +1,9 @@ set(program_name scons) -set(program_version 4.1.0) -set(interpreter PYTHON2) +set(program_version 4.8.1) +set(interpreter PYTHON3) set(search_names "scons.py") -if(CMAKE_HOST_WIN32) - set(download_urls "https://sourceforge.net/projects/scons/files/scons-local-${program_version}.zip/download") - set(download_filename "scons-local-${program_version}.zip") - set(download_sha512 b173176ce8aca25039c64fcc68ec1b9ad31e03a926fd545e7631b3f9b374d914adffc593f505e3e7e2867b0ffe85e8deb0b39afe314edf05d02974ce5db1badb) - set(tool_subdirectory "${program_version}") -endif() + +set(download_urls "https://sourceforge.net/projects/scons/files/scons-local-${program_version}.zip/download") +set(download_filename "scons-local-${program_version}.zip") +set(download_sha512 7ce428ccb3279359f916417f0eaca93d36a101b0760156ce53e3aa2c9c3f0a14869aadf49f21a9eb27ba366a27e3f5deab61669e5bf0b43f1547668da940c3b7) +set(tool_subdirectory "${program_version}") diff --git a/scripts/test_ports/vcpkg-find-acquire-program/portfile.cmake b/scripts/test_ports/vcpkg-find-acquire-program/portfile.cmake index 1ecf14c154..084229301a 100644 --- a/scripts/test_ports/vcpkg-find-acquire-program/portfile.cmake +++ b/scripts/test_ports/vcpkg-find-acquire-program/portfile.cmake @@ -3,7 +3,7 @@ set(VCPKG_POLICY_EMPTY_PACKAGE enabled) # For each vcpkg_find_acquire_program(NAME).cmake script, # there must be a literal call to vcpkg_find_acquire_program(NAME).cmake -set(variables BAZEL BISON FLEX GIT GN NINJA PERL PKGCONFIG PYTHON3 YASM) +set(variables BAZEL BISON FLEX GIT GN NINJA PERL PKGCONFIG PYTHON3 SCONS YASM) vcpkg_find_acquire_program(BAZEL) vcpkg_find_acquire_program(BISON) vcpkg_find_acquire_program(FLEX) @@ -13,6 +13,7 @@ vcpkg_find_acquire_program(NINJA) vcpkg_find_acquire_program(PERL) vcpkg_find_acquire_program(PKGCONFIG) vcpkg_find_acquire_program(PYTHON3) +vcpkg_find_acquire_program(SCONS) vcpkg_find_acquire_program(YASM) if(NOT VCPKG_TARGET_IS_OSX) @@ -32,7 +33,7 @@ if(VCPKG_HOST_IS_WINDOWS) file(REMOVE_RECURSE "${DOWNLOADS}/tools/nasm") file(MAKE_DIRECTORY "${DOWNLOADS}/tools/nasm") - list(APPEND variables 7Z ARIA2 CLANG DARK DOXYGEN GASPREPROCESSOR GO GPERF JOM NASM NUGET PYTHON2 RUBY SCONS SWIG) + list(APPEND variables 7Z ARIA2 CLANG DARK DOXYGEN GASPREPROCESSOR GO GPERF JOM NASM NUGET PYTHON2 RUBY SWIG) vcpkg_find_acquire_program(7Z) vcpkg_find_acquire_program(ARIA2) vcpkg_find_acquire_program(CLANG) @@ -46,7 +47,6 @@ if(VCPKG_HOST_IS_WINDOWS) vcpkg_find_acquire_program(NUGET) vcpkg_find_acquire_program(PYTHON2) vcpkg_find_acquire_program(RUBY) - vcpkg_find_acquire_program(SCONS) vcpkg_find_acquire_program(SWIG) endif() diff --git a/versions/baseline.json b/versions/baseline.json index 4121d1883e..995e500d09 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -8268,6 +8268,10 @@ "baseline": "0.1.4.1", "port-version": 0 }, + "serf": { + "baseline": "1.3.10", + "port-version": 0 + }, "sese": { "baseline": "2.3.0", "port-version": 2 diff --git a/versions/s-/serf.json b/versions/s-/serf.json new file mode 100644 index 0000000000..25953a0b26 --- /dev/null +++ b/versions/s-/serf.json @@ -0,0 +1,9 @@ +{ + "versions": [ + { + "git-tree": "703faeed41a5142b4ee46dbd247823a14a05b31f", + "version": "1.3.10", + "port-version": 0 + } + ] +}