diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 9bbf8e7..1603e84 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -5,7 +5,7 @@ on: jobs: build: - runs-on: ubuntu-24.04 + runs-on: windows-2025 steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/.github/workflows/macos-build.yml b/.github/workflows/macos-build.yml index 7ddbb27..2cb440e 100644 --- a/.github/workflows/macos-build.yml +++ b/.github/workflows/macos-build.yml @@ -34,6 +34,12 @@ jobs: # Details see: https://github.com/actions/checkout with: submodules: true + - name: Install Essentials + shell: bash + # Install essential tools/libs + # - autoconf used to build jemalloc + run: | + brew install autoconf - name: Build Dependencies shell: bash run: | diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index 27e1285..2f2e3d7 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -22,7 +22,8 @@ jobs: fail-fast: false matrix: # The support os can see: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#choosing-github-hosted-runners - os: [ windows-2025, windows-11-arm ] + ## jemalloc not available windows-11-arm + os: [ windows-2025 ] build_type: [ Release ] c_compiler: [ cl] cpp_compiler: [ cl ] @@ -32,14 +33,46 @@ jobs: # Details see: https://github.com/actions/checkout with: submodules: true + - name: Install required packages + uses: msys2/setup-msys2@v2 + # Install essential tools/libs + # - autoconf used to build jemalloc + with: + update: true + install: >- + base-devel + autoconf + automake + libtool + make + gcc + perl + perl-Pod-Usage + - name: Set up MSYS2 environment + shell: bash + # 确保MSYS2工具在PATH中 + run: | + echo "C:/msys64/usr/bin" >> $GITHUB_PATH + echo "C:/msys64/mingw64/bin" >> $GITHUB_PATH + + - name: Verify tools + shell: bash + # 验证工具是否可用 + run: | + which autoconf + autoconf --version + which perl + perl --version + which make + make --version - name: Create arm64 lib soft link # cmake not find libs in */lib/*/arm64/* folders, create soft link to fix it if: matrix.os == 'windows-11-arm' run: | cmd /c mklink /D "C:/Program Files/OpenSSL/lib/VC/x64" "C:/Program Files/OpenSSL/lib/VC/arm64" - name: Build Dependencies - shell: bash run: | + export PATH="/c/msys64/usr/bin:/c/msys64/mingw64/bin:$PATH" bash '${{ github.workspace }}/bin/build_deps.sh' - name: Set Reusable Strings # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. diff --git a/.gitmodules b/.gitmodules index 950ee59..d351e8f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "thirdparty/regex"] path = thirdparty/regex url = https://github.com/boostorg/regex.git +[submodule "thirdparty/jemalloc"] + path = thirdparty/jemalloc + url = https://github.com/jemalloc/jemalloc.git diff --git a/README.md b/README.md index 54c9473..045e083 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ This section describes how to add `jaclks` as a dependency to your C++ project. | Ubuntu-22.04 | x64, ARM64 | [gcc, g++] | ✔ | | Ubuntu-24.04 | x64, ARM64 | [gcc, g++] | ✔ | | Windows 2025 | x64 | [cl, cl] | ✔ | -| Windows 11 | ARM64 | [cl, cl] | ✔ | +| Windows 11 | ARM64 | [cl, cl] | ✘ | | MacOS 13 | x64 | [gcc, g++] | ✔ | | MacOS 15 | ARM64 | [gcc, g++] | ✔ | | Linux - Others | Not supported | | ✘ | diff --git a/bin/build_deps.sh b/bin/build_deps.sh index a6e5c40..47f39bc 100644 --- a/bin/build_deps.sh +++ b/bin/build_deps.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +# exit shell if cmd fail +set -e + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" @@ -7,7 +10,7 @@ THIRD_ROOT_DIR="$PROJECT_ROOT_DIR/thirdparty" THIRD_DIST_DIR="$PROJECT_ROOT_DIR/dist" THIRD_DIST_PKG_CONFIG_DIR="$THIRD_DIST_DIR/lib/pkgconfig" -export PKG_CONFIG_PATH="${THIRD_DIST_PKG_CONFIG_DIR}:${PKG_CONFIG_PATH}" +export PKG_CONFIG_PATH="${THIRD_DIST_PKG_CONFIG_DIR}:${PKG_CONFIG_PATH:-}" if pkg-config --exists gtest; then echo "googletest installed" @@ -16,11 +19,10 @@ if pkg-config --exists gtest; then echo "libs: $(pkg-config --libs gtest)" else echo "googletest not installed, build and install now ..." - pushd "${PROJECT_ROOT_DIR}" >/dev/null || exit - - ## Build googletest GOOGLETEST_ROOT_DIR="$THIRD_ROOT_DIR/googletest" + pushd "${GOOGLETEST_ROOT_DIR}" >/dev/null || exit + ## Build googletest cmake -B "${GOOGLETEST_ROOT_DIR}/build" \ -S "${GOOGLETEST_ROOT_DIR}" \ -DCMAKE_BUILD_TYPE=Release \ @@ -32,3 +34,21 @@ else popd >/dev/null || exit fi + +if pkg-config --exists jemalloc; then + echo "jemalloc installed" + echo "version: $(pkg-config --modversion jemalloc)" + echo "cflags: $(pkg-config --cflags jemalloc)" + echo "libs: $(pkg-config --libs jemalloc)" +else + echo "jemalloc not installed, build and install now ..." + JEMALLOC_ROOT_DIR="$THIRD_ROOT_DIR/jemalloc" + pushd "${JEMALLOC_ROOT_DIR}" >/dev/null || exit + + ## Build jemalloc + sh autogen.sh --prefix=${THIRD_DIST_DIR} + make + make install + + popd >/dev/null || exit +fi diff --git a/thirdparty/jemalloc b/thirdparty/jemalloc new file mode 160000 index 0000000..54eaed1 --- /dev/null +++ b/thirdparty/jemalloc @@ -0,0 +1 @@ +Subproject commit 54eaed1d8b56b1aa528be3bdd1877e59c56fa90c