From 656627eefc58a66fabe293ed08a97364a6e111b6 Mon Sep 17 00:00:00 2001 From: Jesse Rosenstock Date: Fri, 13 Mar 2026 11:24:33 +0100 Subject: [PATCH] Use getconf instead of nproc --- .github/workflows/cmake_arm64_macos.yml | 23 +++++------------------ .github/workflows/cmake_x64_linux.yml | 23 +++++------------------ openfst/extensions/far/sttable.cc | 4 +++- 3 files changed, 13 insertions(+), 37 deletions(-) diff --git a/.github/workflows/cmake_arm64_macos.yml b/.github/workflows/cmake_arm64_macos.yml index a9fb4865..28dc5607 100644 --- a/.github/workflows/cmake_arm64_macos.yml +++ b/.github/workflows/cmake_arm64_macos.yml @@ -33,11 +33,11 @@ jobs: build-and-test-arm64-macos-cmake: name: Build and Test runs-on: macos-latest - env: - cache-name: ${{github.job}} - cache-path: "./build" steps: - uses: actions/checkout@v6 + - name: Set Build Parallelism + run: | + echo "NPROC=$(getconf _NPROCESSORS_ONLN)" >> $GITHUB_ENV - name: Setup Python uses: actions/setup-python@v6 - name: Check Python @@ -45,13 +45,6 @@ jobs: - name: Install dependendcies run: | python3 -m pip install --break-system-packages absl-py cython - - name: Restore CMake cache - uses: actions/cache/restore@v5 - id: cmake-cache-restore - with: - path: ${{env.cache-path}} - key: cmake-cache-${{env.cache-name}} - restore-keys: cmake-cache-${{env.cache-name}}- - name: Configure run: >- cmake -S . -B build @@ -60,13 +53,7 @@ jobs: -DOPENFST_ENABLE_CATEGORIAL=ON - name: Build run: | - cmake --build build -j$(nproc) + cmake --build build -j "$NPROC" - name: Test run: | - ctest --test-dir build --output-on-failure -j$(nproc) - - name: Save new cache for main - if: github.ref == 'refs/heads/main' - uses: actions/cache/save@v5 - with: - path: ${{env.cache-path}} - key: cmake-cache-${{env.cache-name}}-${{github.run_id}} + ctest --test-dir build --output-on-failure -j "$NPROC" diff --git a/.github/workflows/cmake_x64_linux.yml b/.github/workflows/cmake_x64_linux.yml index d529102f..b66ca3ec 100644 --- a/.github/workflows/cmake_x64_linux.yml +++ b/.github/workflows/cmake_x64_linux.yml @@ -33,11 +33,11 @@ jobs: build-and-test-x64-linux-cmake: name: Build and Test runs-on: ubuntu-latest - env: - cache-name: ${{github.job}} - cache-path: "./build" steps: - uses: actions/checkout@v6 + - name: Set Build Parallelism + run: | + echo "NPROC=$(getconf _NPROCESSORS_ONLN)" >> $GITHUB_ENV - name: Setup Python uses: actions/setup-python@v6 - name: Check Python @@ -45,13 +45,6 @@ jobs: - name: Install dependendcies run: | python3 -m pip install --break-system-packages absl-py cython - - name: Restore CMake cache - uses: actions/cache/restore@v5 - id: cmake-cache-restore - with: - path: ${{env.cache-path}} - key: cmake-cache-${{env.cache-name}} - restore-keys: cmake-cache-${{env.cache-name}}- - name: Configure run: >- cmake -S . -B build @@ -60,13 +53,7 @@ jobs: -DOPENFST_ENABLE_CATEGORIAL=ON - name: Build run: | - cmake --build build -j$(nproc) + cmake --build build -j "$NPROC" - name: Test run: | - ctest --test-dir build --output-on-failure -j$(nproc) - - name: Save new cache for main - if: github.ref == 'refs/heads/main' - uses: actions/cache/save@v5 - with: - path: ${{env.cache-path}} - key: cmake-cache-${{env.cache-name}}-${{github.run_id}} + ctest --test-dir build --output-on-failure -j "$NPROC" diff --git a/openfst/extensions/far/sttable.cc b/openfst/extensions/far/sttable.cc index fd4a558d..4fec719b 100644 --- a/openfst/extensions/far/sttable.cc +++ b/openfst/extensions/far/sttable.cc @@ -18,6 +18,7 @@ #include "openfst/extensions/far/sttable.h" #include +#include #include #include "absl/strings/string_view.h" @@ -27,7 +28,8 @@ namespace fst { bool IsSTTable(absl::string_view source) { - file::FileInStream strm((std::string(source))); + file::FileInStream strm(std::string(source), + std::ios_base::in | std::ios_base::binary); if (!strm.good()) return false; int32_t magic_number = 0;