From 1defa6c404f3d2684bc94bb2620d7cf0c0536edc Mon Sep 17 00:00:00 2001 From: zfsopv Date: Sun, 30 Aug 2026 08:58:27 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat(dfss):=20=E6=94=AF=E6=8C=81=20macOS=20?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=EF=BC=88x86=5F64=20+=20arm64=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - linux_release.sh/build_libs.sh 新增 darwin 构建目标,Mac 本机按当前芯片 生成 dfss-cpp-darwin-{x86_64,arm64},依赖 zlib/mbedtls/libssh2 静态编译 - Makefile 兼容 Darwin strip(-x)、main.cpp 修复 clang 下 filesystem 包含 并为 macOS 提供 _NSGetExecutablePath 获取可执行路径 - dfss pip 包架构识别支持 darwin-x86_64/darwin-arm64 二进制选择 - readme/release.sh 同步 darwin 支持说明 适用于 Intel Mac (x86_64) 与 Apple Silicon (arm64),需 Mac 本机构建 (darwin 交叉编译需要 macOS SDK,非 macOS 主机拦截并报错) Co-Authored-By: Claude --- source/pdfss_cpp/dfss_pip/dfss/__main__.py | 5 ++ source/pdfss_cpp/libs/build_libs.sh | 63 ++++++++++++++++++++-- source/pdfss_cpp/linux_release.sh | 19 ++++++- source/pdfss_cpp/readme.md | 10 ++++ source/pdfss_cpp/release.sh | 14 +++-- source/pdfss_cpp/src/Makefile | 6 ++- source/pdfss_cpp/src/main.cpp | 15 ++++-- 7 files changed, 118 insertions(+), 14 deletions(-) diff --git a/source/pdfss_cpp/dfss_pip/dfss/__main__.py b/source/pdfss_cpp/dfss_pip/dfss/__main__.py index 2c8261e2..88e8608a 100644 --- a/source/pdfss_cpp/dfss_pip/dfss/__main__.py +++ b/source/pdfss_cpp/dfss_pip/dfss/__main__.py @@ -15,6 +15,8 @@ def get_architecture(): return 'linux-amd64' elif system == 'windows': return 'win-amd64.exe' + elif system == 'darwin': + return 'darwin-x86_64' if arch == 'amd64': if system == 'linux': return 'linux-amd64' @@ -23,6 +25,9 @@ def get_architecture(): elif arch == 'i686' or arch == 'x86': if system == 'windows': return 'win-i686.exe' + elif arch == 'arm64': + if system == 'darwin': + return 'darwin-arm64' elif arch == 'aarch64': if system == 'linux': return 'linux-arm64' diff --git a/source/pdfss_cpp/libs/build_libs.sh b/source/pdfss_cpp/libs/build_libs.sh index 6d3b89db..f3767cf9 100755 --- a/source/pdfss_cpp/libs/build_libs.sh +++ b/source/pdfss_cpp/libs/build_libs.sh @@ -3,7 +3,12 @@ set -e unset build_shell -build_shell="$(dirname "$(readlink -f "$0")")" +if [[ "$(uname -s)" == "Darwin" ]]; then + # macOS 没有 readlink -f + build_shell="$(cd "$(dirname "$0")" && pwd -P)" +else + build_shell="$(dirname "$(readlink -f "$0")")" +fi unset CROSS_COMPILE unset CC @@ -11,9 +16,16 @@ unset CXX unset ARCH unset CROSS_COMPILE -sudo rm -rf libssh* -sudo rm -rf zlib* -sudo rm -rf mbedtls* +if [[ "$(uname -s)" == "Darwin" ]]; then + # macOS 上不需要 sudo(解压目录属于当前用户),避免交互式密码卡住 + rm -rf libssh* + rm -rf zlib* + rm -rf mbedtls* +else + sudo rm -rf libssh* + sudo rm -rf zlib* + sudo rm -rf mbedtls* +fi tar -xaf "$(find ${build_shell}/zips/ -name "libssh2*")" -C ./ mv libssh2* libssh2 @@ -403,4 +415,47 @@ elif [[ "$1" == "sw_64" ]]; then make -j$(nproc) VERBOSE=1 || exit 1 make install -j$(nproc) popd #libssh2 +elif [[ "$1" == "darwin" ]]; then + # macOS 本机编译(x86_64 / arm64 取决于当前 Mac),交叉编译 darwin 需要 macOS SDK,仅本机构建 + if [[ "$(uname -s)" != "Darwin" ]]; then + echo "ERROR: darwin 目标必须在 macOS 主机上构建(需要 macOS SDK/工具链)。非 macOS 主机请构建 linux/win 目标。" >&2 + exit 1 + fi + rm -rf darwin_build + mkdir -p darwin_build + unset CROSS_COMPILE + unset CC + unset CXX + + make_procs="$(sysctl -n hw.ncpu 2>/dev/null || echo 1)" + + ## zlib static + pushd "${build_shell}/zlib" + CC=gcc ./configure --prefix="${build_target}" --static + make clean + make -j"${make_procs}" + make install -j"${make_procs}" + popd #zlib + + ## mbedtls static + pushd "${build_shell}/mbedtls" + mkdir -p build + cd build + cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTING=OFF -DUSE_STATIC_MBEDTLS_LIBRARY=ON -DUSE_SHARED_MBEDTLS_LIBRARY=OFF -DINSTALL_MBEDTLS_HEADERS=ON -DCMAKE_INSTALL_PREFIX="${build_target}" .. + make -j"${make_procs}" + make install -j"${make_procs}" + cd .. + popd #mbedtls + + pushd "${build_target}" + ln -s lib lib64 2>/dev/null || true + popd + + ## libssh2 static + pushd "${build_shell}/libssh2" + ./configure --disable-examples-build --disable-sshd-tests --disable-docker-tests --with-sysroot="${build_target}" --enable-static=yes --enable-shared=no --with-libmbedcrypto-prefix="${build_target}" --prefix="${build_target}" --with-crypto=mbedtls --with-libz --with-libz-prefix="${build_target}" + make clean + make -j"${make_procs}" VERBOSE=1 || exit 1 + make install -j"${make_procs}" + popd #libssh2 fi diff --git a/source/pdfss_cpp/linux_release.sh b/source/pdfss_cpp/linux_release.sh index ad31b01e..4dc265bf 100755 --- a/source/pdfss_cpp/linux_release.sh +++ b/source/pdfss_cpp/linux_release.sh @@ -1,6 +1,11 @@ #!/bin/bash -build_shell="$(dirname "$(readlink -f "$0")")" +if [[ "$(uname -s)" == "Darwin" ]]; then + # macOS 没有 readlink -f + build_shell="$(cd "$(dirname "$0")" && pwd -P)" +else + build_shell="$(dirname "$(readlink -f "$0")")" +fi if [[ "$2" == "lib" ]]; then pushd libs @@ -53,5 +58,17 @@ elif [[ "$1" == "sw_64" ]]; then make clean EXT_LIB_FLAG_STATIC=" -static -Wl,-Bstatic -lssh2 -lmbedcrypto -lpthread -lz " EXT_LIB_FLAG_DYNAMIC=" " EXT_FLAG=" " ARCH="sw_64" BUILD_PATH="${build_shell}" CROSS_COMPILE="sw_64-sunway-linux-gnu-" LIBS_TYPE="${build_target}" NEED_DEBUG="${NEED_DEBUG}" make VERBOSE=1 mv dfss-cpp ${build_shell}/output/dfss-cpp-linux-sw_64 +elif [[ "$1" == "darwin" ]]; then + # macOS 本机编译(x86_64 / arm64 取决于当前 Mac),交叉编译 darwin 需要 macOS SDK,仅本机构建 + if [[ "$(uname -s)" != "Darwin" ]]; then + echo "ERROR: darwin 目标必须在 macOS 主机上构建(需要 macOS SDK/工具链)。非 macOS 主机请构建 linux/win 目标。" >&2 + exit 1 + fi + make clean + MAC_ARCH="$(uname -m)" + EXT_LIB_FLAG_STATIC=" -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libssh2.a -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libmbedtls.a -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libmbedx509.a -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libmbedcrypto.a -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libz.a " + EXT_LIB_FLAG_DYNAMIC=" -lpthread " + EXT_FLAG=" " ARCH="${MAC_ARCH}" BUILD_PATH="${build_shell}" CROSS_COMPILE="" LIBS_TYPE="darwin_build" NEED_DEBUG="${NEED_DEBUG}" make VERBOSE=1 + mv dfss-cpp ${build_shell}/output/dfss-cpp-darwin-${MAC_ARCH} fi popd diff --git a/source/pdfss_cpp/readme.md b/source/pdfss_cpp/readme.md index 6a5a6684..53fe6fee 100644 --- a/source/pdfss_cpp/readme.md +++ b/source/pdfss_cpp/readme.md @@ -48,6 +48,8 @@ dfss的install功能可以方便地下载和安装软件包。 * riscv64 linux * armbi linux * sw_64 linux +* x86_64 darwin (macOS Intel) +* arm64 darwin (macOS Apple Silicon) ### 示例 @@ -60,8 +62,15 @@ dfss的install功能可以方便地下载和安装软件包。 ./linux_release.sh riscv64 lib; ./linux_release.sh mingw lib; ./linux_release.sh mingw64 lib; +./linux_release.sh darwin lib; ``` +### macOS 说明 + +* macOS 目标需在 Mac 本机上编译(交叉编译 darwin 需要 macOS SDK,Linux 环境下无法构建),`./linux_release.sh darwin lib` 会按当前 Mac 芯片生成对应架构产物 +* Intel Mac (x86_64) 生成 `dfss-cpp-darwin-x86_64`,Apple Silicon (arm64) 生成 `dfss-cpp-darwin-arm64` +* 编译依赖 Xcode Command Line Tools(提供 clang/链接器等),依赖库 zlib/mbedtls/libssh2 会由 `libs/build_libs.sh` 自动构建静态版本 + ### 默认编译器版本 * amd64 linux gcc9.4(ubuntu20) static @@ -72,6 +81,7 @@ dfss的install功能可以方便地下载和安装软件包。 * riscv64 linux gcc9.4(ubuntu20) static * armbi linux gcc9.4(ubuntu20) * sw_64 linux gcc8.3(ubuntu20) static +* darwin clang(macOS Xcode CLT) 静态库 zlib/mbedtls/libssh2 + 动态系统库 ### 发布方式 diff --git a/source/pdfss_cpp/release.sh b/source/pdfss_cpp/release.sh index 30cbc641..c5cc9044 100644 --- a/source/pdfss_cpp/release.sh +++ b/source/pdfss_cpp/release.sh @@ -1,13 +1,18 @@ #!/bin/bash # pdfss_cpp 统一构建接口 (M1 规范 v0.1) # 用法: bash release.sh [ARCH] [VERSION] -# ARCH: host(amd64) | arm64 | all(默认 host;all=8 架构,含 win/loongarch64/riscv64/sw_64/armbi) +# ARCH: host(amd64) | arm64 | darwin(macOS 本机) | all(默认 host;all=8 架构,含 win/loongarch64/riscv64/sw_64/armbi) # VERSION: 显式版本号(默认读 git_version 文件) # env OUTPUT_DIR: 产物目录(默认 /output/pdfss_cpp/) # 注意: 多架构交叉需要对应工具链,全部在 sophon-tools-build 镜像内预置。 set -euo pipefail -SCRIPT_DIR="$(cd "$(dirname "$(readlink -f "$0")")" && pwd)" +if [[ "$(uname -s)" == "Darwin" ]]; then + # macOS 没有 readlink -f + SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd -P)" +else + SCRIPT_DIR="$(cd "$(dirname "$(readlink -f "$0")")" && pwd)" +fi REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" ARCH="${1:-host}" OUTPUT_DIR="${OUTPUT_DIR:-$REPO_ROOT/output/pdfss_cpp}" @@ -19,10 +24,11 @@ echo "==> pdfss_cpp version=$VERSION" case "$ARCH" in host|amd64) TARGETS="host" ;; arm64) TARGETS="aarch64" ;; - all) TARGETS="host aarch64 armbi loongarch64 riscv64 sw_64 mingw64 mingw" ;; + all) TARGETS="host aarch64 armbi loongarch64 riscv64 sw_64 mingw64 mingw" ;; # darwin 需在 macOS 主机单独构建 + darwin) TARGETS="darwin" ;; sw_64) TARGETS="sw_64" ;; loongarch64) TARGETS="loongarch64" ;; - *) echo "ERROR: ARCH 必须是 host|amd64|arm64|all,得到: $ARCH" >&2; exit 1 ;; + *) echo "ERROR: ARCH 必须是 host|amd64|arm64|darwin|all,得到: $ARCH" >&2; exit 1 ;; esac mkdir -p "$OUTPUT_DIR" diff --git a/source/pdfss_cpp/src/Makefile b/source/pdfss_cpp/src/Makefile index 53b4637f..38df8775 100644 --- a/source/pdfss_cpp/src/Makefile +++ b/source/pdfss_cpp/src/Makefile @@ -24,7 +24,11 @@ ifeq ($(NEED_DEBUG),1) STRIP_CMD := @echo "Skip stripping in debug mode" else BUILD_TYPE_FLAG := -O3 - STRIP_CMD := $(STRIP) -v --strip-debug --strip-unneeded + ifeq ($(shell uname -s),Darwin) + STRIP_CMD := $(STRIP) -x + else + STRIP_CMD := $(STRIP) -v --strip-debug --strip-unneeded + endif endif CFLAGS = $(EXT_FLAG) -I. $(INCLUDE) $(LIBS) -std=gnu99 -Wall ${BUILD_TYPE_FLAG} diff --git a/source/pdfss_cpp/src/main.cpp b/source/pdfss_cpp/src/main.cpp index 12e7ec40..44e9f12f 100644 --- a/source/pdfss_cpp/src/main.cpp +++ b/source/pdfss_cpp/src/main.cpp @@ -14,13 +14,11 @@ #include #include #include -#if defined(__GNUC__) && !defined(__clang__) -#if (__GNUC__ > 4) && (__GNUC__ < 8) +#if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ > 4) && (__GNUC__ < 8) #include #else #include #endif -#endif #include "cxxopts.hpp" #include "httplib.h" @@ -40,6 +38,10 @@ #include #endif +#ifdef __APPLE__ +#include +#endif + extern "C" { #include "log.h" } @@ -54,7 +56,7 @@ extern "C" { using namespace std; using json = nlohmann::json; -#if (__GNUC__ > 4) && (__GNUC__ < 8) +#if defined(__GNUC__) && !defined(__clang__) && (__GNUC__ > 4) && (__GNUC__ < 8) namespace fs = std::experimental::filesystem; #else namespace fs = std::filesystem; @@ -1240,6 +1242,11 @@ std::string getExecutablePath() { memset(buffer_in, 0, 1024); #ifdef _WIN32 GetModuleFileNameA(NULL, buffer_in, sizeof(buffer_in)); +#elif defined(__APPLE__) + uint32_t path_size = sizeof(buffer_in); + if (_NSGetExecutablePath(buffer_in, &path_size) != 0) { + return std::string(); + } #else ssize_t len = readlink("/proc/self/exe", buffer_in, sizeof(buffer_in) - 1); if (len != -1) { From 85129f54dd85b633e10abfdca16f37a1bd6bd328 Mon Sep 17 00:00:00 2001 From: zfsopv Date: Sun, 30 Aug 2026 09:08:53 +0800 Subject: [PATCH 2/5] =?UTF-8?q?fix(dfss):=20macOS=20review=20=E4=BF=AE?= =?UTF-8?q?=E8=AE=A2=E2=80=94=E2=80=94=E5=85=8D=E4=BA=A4=E4=BA=92=20sudo?= =?UTF-8?q?=E3=80=81realpath=20=E8=A7=A3=E6=9E=90=E5=8F=AF=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E8=B7=AF=E5=BE=84=E3=80=81=E6=98=BE=E5=BC=8F=E6=9C=80?= =?UTF-8?q?=E4=BD=8E=E7=B3=BB=E7=BB=9F=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - build_libs.sh 的 build_target 清理区分 Darwin(免 sudo,避免交互式密码挂死) - getExecutablePath macOS 分支补 realpath(),符号链接行为与 Linux 一致 - darwin 构建显式 -mmacosx-version-min=10.15(std::filesystem/clock_gettime 依赖) Co-Authored-By: Claude --- source/pdfss_cpp/libs/build_libs.sh | 6 +++++- source/pdfss_cpp/linux_release.sh | 2 +- source/pdfss_cpp/readme.md | 1 + source/pdfss_cpp/src/main.cpp | 6 ++++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/source/pdfss_cpp/libs/build_libs.sh b/source/pdfss_cpp/libs/build_libs.sh index f3767cf9..67ad4d34 100755 --- a/source/pdfss_cpp/libs/build_libs.sh +++ b/source/pdfss_cpp/libs/build_libs.sh @@ -43,7 +43,11 @@ unset AR unset CROSS_COMPILE build_target="${build_shell}/${1}_build" -sudo rm -rf "${build_target}" +if [[ "$(uname -s)" == "Darwin" ]]; then + rm -rf "${build_target}" +else + sudo rm -rf "${build_target}" +fi if [[ "$1" == "host" ]]; then # host gcc diff --git a/source/pdfss_cpp/linux_release.sh b/source/pdfss_cpp/linux_release.sh index 4dc265bf..aa7c96e3 100755 --- a/source/pdfss_cpp/linux_release.sh +++ b/source/pdfss_cpp/linux_release.sh @@ -68,7 +68,7 @@ elif [[ "$1" == "darwin" ]]; then MAC_ARCH="$(uname -m)" EXT_LIB_FLAG_STATIC=" -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libssh2.a -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libmbedtls.a -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libmbedx509.a -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libmbedcrypto.a -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libz.a " EXT_LIB_FLAG_DYNAMIC=" -lpthread " - EXT_FLAG=" " ARCH="${MAC_ARCH}" BUILD_PATH="${build_shell}" CROSS_COMPILE="" LIBS_TYPE="darwin_build" NEED_DEBUG="${NEED_DEBUG}" make VERBOSE=1 + EXT_FLAG=" -mmacosx-version-min=10.15 " ARCH="${MAC_ARCH}" BUILD_PATH="${build_shell}" CROSS_COMPILE="" LIBS_TYPE="darwin_build" NEED_DEBUG="${NEED_DEBUG}" make VERBOSE=1 mv dfss-cpp ${build_shell}/output/dfss-cpp-darwin-${MAC_ARCH} fi popd diff --git a/source/pdfss_cpp/readme.md b/source/pdfss_cpp/readme.md index 53fe6fee..3879b388 100644 --- a/source/pdfss_cpp/readme.md +++ b/source/pdfss_cpp/readme.md @@ -70,6 +70,7 @@ dfss的install功能可以方便地下载和安装软件包。 * macOS 目标需在 Mac 本机上编译(交叉编译 darwin 需要 macOS SDK,Linux 环境下无法构建),`./linux_release.sh darwin lib` 会按当前 Mac 芯片生成对应架构产物 * Intel Mac (x86_64) 生成 `dfss-cpp-darwin-x86_64`,Apple Silicon (arm64) 生成 `dfss-cpp-darwin-arm64` * 编译依赖 Xcode Command Line Tools(提供 clang/链接器等),依赖库 zlib/mbedtls/libssh2 会由 `libs/build_libs.sh` 自动构建静态版本 +* 最低支持 macOS 10.15(`std::filesystem` 与 `clock_gettime` 依赖,构建时已显式指定 `-mmacosx-version-min=10.15`) ### 默认编译器版本 diff --git a/source/pdfss_cpp/src/main.cpp b/source/pdfss_cpp/src/main.cpp index 44e9f12f..9e0c24a2 100644 --- a/source/pdfss_cpp/src/main.cpp +++ b/source/pdfss_cpp/src/main.cpp @@ -1247,6 +1247,12 @@ std::string getExecutablePath() { if (_NSGetExecutablePath(buffer_in, &path_size) != 0) { return std::string(); } + // 解析符号链接,与 Linux /proc/self/exe 行为一致 + char resolved_path[PATH_MAX]; + if (realpath(buffer_in, resolved_path) != nullptr) { + return std::string(resolved_path); + } + return std::string(buffer_in); #else ssize_t len = readlink("/proc/self/exe", buffer_in, sizeof(buffer_in) - 1); if (len != -1) { From 381c7cdde751631cf1f68eb0a9c3187cfc09536a Mon Sep 17 00:00:00 2001 From: zfsopv Date: Sun, 30 Aug 2026 09:21:17 +0800 Subject: [PATCH 3/5] =?UTF-8?q?ci(dfss):=20=E6=B7=BB=E5=8A=A0=20macOS=20?= =?UTF-8?q?=E5=8F=8C=E6=9E=B6=E6=9E=84=E8=99=9A=E6=8B=9F=E5=8C=96=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GitHub Actions 官方 macOS 托管 runner(macos-15-intel x86_64 + macos-15 arm64) 上构建 darwin 目标并冒烟运行 --no_json --list,产物上传 artifact --- .github/workflows/dfss-macos.yml | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/dfss-macos.yml diff --git a/.github/workflows/dfss-macos.yml b/.github/workflows/dfss-macos.yml new file mode 100644 index 00000000..1d2ebd28 --- /dev/null +++ b/.github/workflows/dfss-macos.yml @@ -0,0 +1,60 @@ +name: dfss-macos + +on: + pull_request: + paths: + - 'source/pdfss_cpp/**' + push: + branches: [main] + paths: + - 'source/pdfss_cpp/**' + workflow_dispatch: + +jobs: + build-x86-64: + name: build darwin x86_64 + runs-on: macos-15-intel + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + - name: build dfss-cpp darwin (x86_64) + run: | + bash source/pdfss_cpp/linux_release.sh darwin lib + - name: smoke test + run: | + cd source/pdfss_cpp/output + test "$(uname -m)" = "x86_64" + file dfss-cpp-darwin-x86_64 + ./dfss-cpp-darwin-x86_64 --no_json --list + - name: upload artifact + uses: actions/upload-artifact@v4 + with: + name: dfss-cpp-darwin-x86_64 + path: source/pdfss_cpp/output/dfss-cpp-darwin-x86_64 + retention-days: 14 + + build-arm64: + name: build darwin arm64 + runs-on: macos-15 + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v4 + - name: build dfss-cpp darwin (arm64) + run: | + bash source/pdfss_cpp/linux_release.sh darwin lib + - name: smoke test + run: | + cd source/pdfss_cpp/output + test "$(uname -m)" = "arm64" + file dfss-cpp-darwin-arm64 + ./dfss-cpp-darwin-arm64 --no_json --list + - name: upload artifact + uses: actions/upload-artifact@v4 + with: + name: dfss-cpp-darwin-arm64 + path: source/pdfss_cpp/output/dfss-cpp-darwin-arm64 + retention-days: 14 \ No newline at end of file From ec8386241528973df4f6d2ed603447440c141144 Mon Sep 17 00:00:00 2001 From: zfsopv Date: Sun, 30 Aug 2026 10:34:38 +0800 Subject: [PATCH 4/5] =?UTF-8?q?fix(dfss):=20linux=5Frelease.sh=20=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E8=B7=AF=E5=BE=84=E8=87=AA=E5=8C=85=E5=90=AB=EF=BC=8C?= =?UTF-8?q?=E6=B6=88=E9=99=A4=E5=AF=B9=E8=B0=83=E7=94=A8=E8=80=85=20cwd=20?= =?UTF-8?q?=E7=9A=84=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI 从仓库根调用 bash source/pdfss_cpp/linux_release.sh darwin lib 时, pushd libs/pushd src 等相对路径基于调用者目录解析失败;现基于脚本所在 目录 cd,对既有"在脚本目录运行"流程行为不变 --- source/pdfss_cpp/linux_release.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/pdfss_cpp/linux_release.sh b/source/pdfss_cpp/linux_release.sh index aa7c96e3..234bfb02 100755 --- a/source/pdfss_cpp/linux_release.sh +++ b/source/pdfss_cpp/linux_release.sh @@ -6,6 +6,8 @@ if [[ "$(uname -s)" == "Darwin" ]]; then else build_shell="$(dirname "$(readlink -f "$0")")" fi +# 脚本路径自包含:以下相对路径(libs/src/output)均以脚本所在目录为基准 +cd "$build_shell" if [[ "$2" == "lib" ]]; then pushd libs From 70d91718cb7bc2cfdc968514d3b7a7afd3126f56 Mon Sep 17 00:00:00 2001 From: zfsopv Date: Sun, 30 Aug 2026 10:40:50 +0800 Subject: [PATCH 5/5] =?UTF-8?q?fix(dfss):=20darwin=20=E5=88=86=E6=94=AF=20?= =?UTF-8?q?EXT=5FLIB=5FFLAG=5FSTATIC/DYNAMIC=20=E9=9C=80=20export=20?= =?UTF-8?q?=E4=BC=A0=E7=BB=99=20make?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 独立行赋值只作用于 shell 变量,make 收不到链接参数,导致 macOS 链接 缺 force_load 静态库与 -lpthread 而报 symbol(s) not found --- source/pdfss_cpp/linux_release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/pdfss_cpp/linux_release.sh b/source/pdfss_cpp/linux_release.sh index 234bfb02..94e6e9ac 100755 --- a/source/pdfss_cpp/linux_release.sh +++ b/source/pdfss_cpp/linux_release.sh @@ -68,8 +68,8 @@ elif [[ "$1" == "darwin" ]]; then fi make clean MAC_ARCH="$(uname -m)" - EXT_LIB_FLAG_STATIC=" -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libssh2.a -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libmbedtls.a -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libmbedx509.a -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libmbedcrypto.a -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libz.a " - EXT_LIB_FLAG_DYNAMIC=" -lpthread " + export EXT_LIB_FLAG_STATIC=" -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libssh2.a -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libmbedtls.a -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libmbedx509.a -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libmbedcrypto.a -Wl,-force_load,${build_shell}/libs/darwin_build/lib/libz.a " + export EXT_LIB_FLAG_DYNAMIC=" -lpthread " EXT_FLAG=" -mmacosx-version-min=10.15 " ARCH="${MAC_ARCH}" BUILD_PATH="${build_shell}" CROSS_COMPILE="" LIBS_TYPE="darwin_build" NEED_DEBUG="${NEED_DEBUG}" make VERBOSE=1 mv dfss-cpp ${build_shell}/output/dfss-cpp-darwin-${MAC_ARCH} fi