diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 07431bf..1310b8e 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -7,222 +7,242 @@ on: types: published jobs: - fedora: + ubuntu: runs-on: [ubuntu-latest] container: - image: fedora:40 + image: ubuntu:20.04 steps: - uses: actions/checkout@v4 - name: Install dependencies - run: dnf install -y ninja-build cmake gtest-devel re2c clang util-linux clang-tools-extra + run: sudo apt-get update && sudo apt-get install -y git cmake g++ gcc googletest libgmock-dev libssl-dev pkg-config uuid-dev grpc++ libprotobuf-dev protobuf-compiler-grpc ninja-build libyaml-cpp-dev + - name: Linting run: misc/ci.py - - name: Configure with CMake - run: cmake -Bbuild -G"Ninja Multi-Config" -DNINJA_CLANG_TIDY=1 - - name: Build debug ninja - run: CLICOLOR_FORCE=1 ninja - working-directory: build - - name: Test debug ninja - working-directory: build/Debug - run: | - ./ninja_test --gtest_color=yes - ../../misc/output_test.py - - name: Build release ninja - run: CLICOLOR_FORCE=1 ninja -f build-Release.ninja - working-directory: build - - name: Test release ninja - working-directory: build/Release - run: | - ./ninja_test --gtest_color=yes - ../../misc/output_test.py - - build: - runs-on: [ubuntu-latest] - container: - image: rockylinux:8 - steps: - - uses: actions/checkout@v4 - - uses: codespell-project/actions-codespell@master - with: - ignore_words_list: fo,wee,addin,notin - - name: Install dependencies - run: | - dnf install -y make gcc-c++ libasan clang-analyzer cmake dnf-plugins-core epel-release - dnf config-manager --set-enabled powertools - dnf install -y gtest-devel p7zip p7zip-plugins - - - name: Build debug ninja - shell: bash - env: - CFLAGS: -fstack-protector-all -fsanitize=address - CXXFLAGS: -fstack-protector-all -fsanitize=address - run: | - scan-build -o scanlogs cmake -DCMAKE_BUILD_TYPE=Debug -B debug-build - scan-build -o scanlogs cmake --build debug-build --parallel --config Debug - - - name: Test debug ninja - run: ASAN_OPTIONS=detect_leaks=0 ./ninja_test - working-directory: debug-build + continue-on-error: true - name: Build release ninja - shell: bash - run: | - cmake -DCMAKE_BUILD_TYPE=Release -B release-build - cmake --build release-build --parallel --config Release - strip release-build/ninja - - - name: Test release ninja - run: ./ninja_test - working-directory: release-build - - - name: Create ninja archive - run: | - mkdir artifact - 7z a artifact/ninja-linux.zip ./release-build/ninja - - # Upload ninja binary archive as an artifact - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: ninja-binary-archives - path: artifact - - - name: Upload release asset - if: github.event.action == 'published' - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ github.event.release.upload_url }} - asset_path: ./artifact/ninja-linux.zip - asset_name: ninja-linux.zip - asset_content_type: application/zip - - test: - runs-on: [ubuntu-latest] - container: - image: ubuntu:20.04 - steps: - - uses: actions/checkout@v4 - - name: Install dependencies - run: | - apt update - apt install -y python3-pytest ninja-build python3-pip clang libgtest-dev - pip3 install cmake==3.17.* - - name: Configure (GCC) - run: cmake -Bbuild-gcc -DCMAKE_BUILD_TYPE=Debug -G'Ninja Multi-Config' - - - name: Build (GCC, Debug) - run: cmake --build build-gcc --config Debug - - name: Unit tests (GCC, Debug) - run: ./build-gcc/Debug/ninja_test - - name: Python tests (GCC, Debug) - run: pytest-3 --color=yes ../.. - working-directory: build-gcc/Debug - - - name: Build (GCC, Release) - run: cmake --build build-gcc --config Release - - name: Unit tests (GCC, Release) - run: ./build-gcc/Release/ninja_test - - name: Python tests (GCC, Release) - run: pytest-3 --color=yes ../.. - working-directory: build-gcc/Release - - - name: Configure (Clang) - run: CC=clang CXX=clang++ cmake -Bbuild-clang -DCMAKE_BUILD_TYPE=Debug -G'Ninja Multi-Config' - - - name: Build (Clang, Debug) - run: cmake --build build-clang --config Debug - - name: Unit tests (Clang, Debug) - run: ./build-clang/Debug/ninja_test - - name: Python tests (Clang, Debug) - run: pytest-3 --color=yes ../.. - working-directory: build-clang/Debug - - - name: Build (Clang, Release) - run: cmake --build build-clang --config Release - - name: Unit tests (Clang, Release) - run: ./build-clang/Release/ninja_test - - name: Python tests (Clang, Release) - run: pytest-3 --color=yes ../.. - working-directory: build-clang/Release - - build-with-python: - runs-on: [ubuntu-latest] - container: - image: ${{ matrix.image }} - strategy: - matrix: - image: ['ubuntu:20.04', 'ubuntu:22.04', 'ubuntu:24.04'] - steps: - - uses: actions/checkout@v4 - - name: Install dependencies - run: | - apt update - apt install -y g++ python3 - - name: ${{ matrix.image }} - run: | - python3 configure.py --bootstrap - ./ninja all - python3 misc/ninja_syntax_test.py - ./misc/output_test.py - - build-aarch64: - name: Build Linux ARM64 - runs-on: [ubuntu-latest] - steps: - - uses: actions/checkout@v4 - - - name: Build - uses: uraimo/run-on-arch-action@v2 - with: - arch: aarch64 - distro: ubuntu18.04 - githubToken: ${{ github.token }} - dockerRunArgs: | - --volume "${PWD}:/ninja" - install: | - apt-get update -q -y - apt-get install -q -y make gcc g++ libasan5 clang-tools curl p7zip-full file + shell: bash run: | - set -x - cd /ninja - - # INSTALL CMAKE - CMAKE_VERSION=3.23.4 - curl -L -O https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-aarch64.sh - chmod +x cmake-${CMAKE_VERSION}-Linux-aarch64.sh - ./cmake-${CMAKE_VERSION}-Linux-aarch64.sh --skip-license --prefix=/usr/local - - # BUILD cmake -DCMAKE_BUILD_TYPE=Release -B release-build cmake --build release-build --parallel --config Release - strip release-build/ninja - file release-build/ninja - - # TEST - pushd release-build - ./ninja_test - popd - - # CREATE ARCHIVE - mkdir artifact - 7z a artifact/ninja-linux-aarch64.zip ./release-build/ninja - - # Upload ninja binary archive as an artifact - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: ninja-aarch64-binary-archives - path: artifact - - - name: Upload release asset - if: github.event.action == 'published' - uses: actions/upload-release-asset@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - upload_url: ${{ github.event.release.upload_url }} - asset_path: ./artifact/ninja-linux-aarch64.zip - asset_name: ninja-linux-aarch64.zip - asset_content_type: application/zip + strip release-build/bin/ninja + + - name: Test release ninja + run: ./bin/ninja_test + working-directory: release-build + + - name: Create ninja archive + run: | + ./build.sh build + ./build.sh package + mkdir -p artifact + cp build/bin/ninja2.tar.gz artifact/ninja2.tar.gz + + # Upload ninja binary archive as an artifact + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ninja-binary-archives + path: artifact + + - name: Upload release asset + if: github.event.action == 'published' + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: ./artifact/ninja2.tar.gz + asset_name: ninja2.tar.gz + asset_content_type: application/gzip + + # build: + # runs-on: [ubuntu-latest] + # container: + # image: rockylinux:8 + # steps: + # - uses: actions/checkout@v4 + # - uses: codespell-project/actions-codespell@master + # with: + # ignore_words_list: fo,wee,addin,notin + # - name: Install dependencies + # run: | + # dnf install -y make gcc-c++ libasan clang-analyzer cmake dnf-plugins-core epel-release + # dnf config-manager --set-enabled powertools + # dnf install -y gtest-devel p7zip p7zip-plugins + + # - name: Build debug ninja + # shell: bash + # env: + # CFLAGS: -fstack-protector-all -fsanitize=address + # CXXFLAGS: -fstack-protector-all -fsanitize=address + # run: | + # scan-build -o scanlogs cmake -DCMAKE_BUILD_TYPE=Debug -B debug-build + # scan-build -o scanlogs cmake --build debug-build --parallel --config Debug + + # - name: Test debug ninja + # run: ASAN_OPTIONS=detect_leaks=0 ./ninja_test + # working-directory: debug-build + + # - name: Build release ninja + # shell: bash + # run: | + # cmake -DCMAKE_BUILD_TYPE=Release -B release-build + # cmake --build release-build --parallel --config Release + # strip release-build/ninja + + # - name: Test release ninja + # run: ./ninja_test + # working-directory: release-build + + # - name: Create ninja archive + # run: | + # mkdir artifact + # 7z a artifact/ninja-linux.zip ./release-build/ninja + + # # Upload ninja binary archive as an artifact + # - name: Upload artifact + # uses: actions/upload-artifact@v4 + # with: + # name: ninja-binary-archives + # path: artifact + + # - name: Upload release asset + # if: github.event.action == 'published' + # uses: actions/upload-release-asset@v1 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # with: + # upload_url: ${{ github.event.release.upload_url }} + # asset_path: ./artifact/ninja-linux.zip + # asset_name: ninja-linux.zip + # asset_content_type: application/zip + + # test: + # runs-on: [ubuntu-latest] + # container: + # image: ubuntu:20.04 + # steps: + # - uses: actions/checkout@v4 + # - name: Install dependencies + # run: | + # apt update + # apt install -y python3-pytest ninja-build python3-pip clang libgtest-dev + # pip3 install cmake==3.17.* + # - name: Configure (GCC) + # run: cmake -Bbuild-gcc -DCMAKE_BUILD_TYPE=Debug -G'Ninja Multi-Config' + + # - name: Build (GCC, Debug) + # run: cmake --build build-gcc --config Debug + # - name: Unit tests (GCC, Debug) + # run: ./build-gcc/Debug/ninja_test + # - name: Python tests (GCC, Debug) + # run: pytest-3 --color=yes ../.. + # working-directory: build-gcc/Debug + + # - name: Build (GCC, Release) + # run: cmake --build build-gcc --config Release + # - name: Unit tests (GCC, Release) + # run: ./build-gcc/Release/ninja_test + # - name: Python tests (GCC, Release) + # run: pytest-3 --color=yes ../.. + # working-directory: build-gcc/Release + + # - name: Configure (Clang) + # run: CC=clang CXX=clang++ cmake -Bbuild-clang -DCMAKE_BUILD_TYPE=Debug -G'Ninja Multi-Config' + + # - name: Build (Clang, Debug) + # run: cmake --build build-clang --config Debug + # - name: Unit tests (Clang, Debug) + # run: ./build-clang/Debug/ninja_test + # - name: Python tests (Clang, Debug) + # run: pytest-3 --color=yes ../.. + # working-directory: build-clang/Debug + + # - name: Build (Clang, Release) + # run: cmake --build build-clang --config Release + # - name: Unit tests (Clang, Release) + # run: ./build-clang/Release/ninja_test + # - name: Python tests (Clang, Release) + # run: pytest-3 --color=yes ../.. + # working-directory: build-clang/Release + + # build-with-python: + # runs-on: [ubuntu-latest] + # container: + # image: ${{ matrix.image }} + # strategy: + # matrix: + # image: ['ubuntu:20.04', 'ubuntu:22.04', 'ubuntu:24.04'] + # steps: + # - uses: actions/checkout@v4 + # - name: Install dependencies + # run: | + # apt update + # apt install -y g++ python3 + # - name: ${{ matrix.image }} + # run: | + # python3 configure.py --bootstrap + # ./ninja all + # python3 misc/ninja_syntax_test.py + # ./misc/output_test.py + + # build-aarch64: + # name: Build Linux ARM64 + # runs-on: [ubuntu-latest] + # steps: + # - uses: actions/checkout@v4 + + # - name: Build + # uses: uraimo/run-on-arch-action@v2 + # with: + # arch: aarch64 + # distro: ubuntu18.04 + # githubToken: ${{ github.token }} + # dockerRunArgs: | + # --volume "${PWD}:/ninja" + # install: | + # apt-get update -q -y + # apt-get install -q -y make gcc g++ libasan5 clang-tools curl p7zip-full file + # run: | + # set -x + # cd /ninja + + # # INSTALL CMAKE + # CMAKE_VERSION=3.23.4 + # curl -L -O https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-aarch64.sh + # chmod +x cmake-${CMAKE_VERSION}-Linux-aarch64.sh + # ./cmake-${CMAKE_VERSION}-Linux-aarch64.sh --skip-license --prefix=/usr/local + + # # BUILD + # cmake -DCMAKE_BUILD_TYPE=Release -B release-build + # cmake --build release-build --parallel --config Release + # strip release-build/ninja + # file release-build/ninja + + # # TEST + # pushd release-build + # ./ninja_test + # popd + + # # CREATE ARCHIVE + # mkdir artifact + # 7z a artifact/ninja-linux-aarch64.zip ./release-build/ninja + + # # Upload ninja binary archive as an artifact + # - name: Upload artifact + # uses: actions/upload-artifact@v4 + # with: + # name: ninja-aarch64-binary-archives + # path: artifact + + # - name: Upload release asset + # if: github.event.action == 'published' + # uses: actions/upload-release-asset@v1 + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # with: + # upload_url: ${{ github.event.release.upload_url }} + # asset_path: ./artifact/ninja-linux-aarch64.zip + # asset_name: ninja-linux-aarch64.zip + # asset_content_type: application/zip diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/localbuild-test.yml similarity index 99% rename from .github/workflows/linux-ci.yml rename to .github/workflows/localbuild-test.yml index 81cc454..ad1a41a 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/localbuild-test.yml @@ -1,4 +1,4 @@ -name: ninja2-CI +name: LocalBuild Tests on: push: diff --git a/.github/workflows/test_install_sh.yml b/.github/workflows/test_install_sh.yml index f834174..1109910 100644 --- a/.github/workflows/test_install_sh.yml +++ b/.github/workflows/test_install_sh.yml @@ -15,7 +15,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-20.04, ubuntu-22.04] + os: ['ubuntu:20.04', 'ubuntu:22.04', 'ubuntu:24.04'] steps: - name: Checkout repository diff --git a/.gitignore b/.gitignore index ca36ec8..3453222 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *.ilk /build*/ /build.ninja +/release-build*/ /ninja /ninja.bootstrap /build_log_perftest diff --git a/build.sh b/build.sh index 4b4bea1..e596dbc 100755 --- a/build.sh +++ b/build.sh @@ -78,6 +78,7 @@ function package { # package new ninja binary mkdir -p build/bin/ninja2 cp "build/bin/ninja" "build/bin/ninja2/" + cp $(ldd ./build/bin/ninja | awk '{print $3}' | grep '/lib') ./build/bin/ninja2/ cat < "build/bin/ninja2/ninja2.conf" # Copyright 2024 Mengning Software All rights reserved. diff --git a/install.sh b/install.sh index 2bd0268..bce4050 100755 --- a/install.sh +++ b/install.sh @@ -27,19 +27,19 @@ function install_dependencies { case $OS_ID in ubuntu|debian) - sudo apt-get update - sudo apt-get install -y git cmake g++ gcc googletest libgmock-dev libssl-dev pkg-config uuid-dev grpc++ libprotobuf-dev protobuf-compiler-grpc ninja-build libyaml-cpp-dev + # sudo apt-get update + # sudo apt-get install -y git cmake g++ gcc googletest libgmock-dev libssl-dev pkg-config uuid-dev grpc++ libprotobuf-dev protobuf-compiler-grpc ninja-build libyaml-cpp-dev ;; centos) - sudo yum update -y - sudo yum install -y epel-release - sudo yum groupinstall -y "Development Tools" - sudo yum install -y git cmake3 gtest gtest-devel openssl openssl-devel pkgconfig uuid-devel grpc-devel protobuf protobuf-devel protobuf-compiler ninja-build yaml-cpp yaml-cpp-devel + # sudo yum update -y + # sudo yum install -y epel-release + # sudo yum groupinstall -y "Development Tools" + # sudo yum install -y git cmake3 gtest gtest-devel openssl openssl-devel pkgconfig uuid-devel grpc-devel protobuf protobuf-devel protobuf-compiler ninja-build yaml-cpp yaml-cpp-devel ;; fedora) - sudo dnf update -y - sudo dnf group install -y "Development Tools" - sudo dnf install -y git cmake g++ gtest gtest-devel openssl openssl-devel pkgconfig uuid-devel grpc-devel protobuf protobuf-devel protobuf-compiler ninja-build yaml-cpp yaml-cpp-devel + # sudo dnf update -y + # sudo dnf group install -y "Development Tools" + # sudo dnf install -y git cmake g++ gtest gtest-devel openssl openssl-devel pkgconfig uuid-devel grpc-devel protobuf protobuf-devel protobuf-compiler ninja-build yaml-cpp yaml-cpp-devel ;; *) failure "Unsupported OS: $OS_ID" @@ -75,6 +75,8 @@ function install { # Install new ninja binary sudo cp "ninja2/ninja" "$install_path" sudo cp "ninja2/ninja2.conf" "$config_file" + sudo cp -n ninja2/*.so.* /usr/local/lib/ + sudo ldconfig success "---------------------------------" success "New Ninja2 installed successfully at $install_path" success "---------------------------------"