Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mengning committed Apr 15, 2024
1 parent 0ed870a commit 0c2a40b
Show file tree
Hide file tree
Showing 163 changed files with 33,683 additions and 2 deletions.
26 changes: 26 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2014 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This isn't meant to be authoritative, but it's good enough to be useful.
# Still use your best judgement for formatting decisions: clang-format
# sometimes makes strange choices.

BasedOnStyle: Google
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
Cpp11BracedListStyle: false
IndentCaseLabels: false
DerivePointerBinding: false
17 changes: 17 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
Checks: '
,readability-avoid-const-params-in-decls,
,readability-inconsistent-declaration-parameter-name,
,readability-non-const-parameter,
,readability-redundant-string-cstr,
,readability-redundant-string-init,
,readability-simplify-boolean-expr,
'
WarningsAsErrors: '
,readability-avoid-const-params-in-decls,
,readability-inconsistent-declaration-parameter-name,
,readability-non-const-parameter,
,readability-redundant-string-cstr,
,readability-redundant-string-init,
,readability-simplify-boolean-expr,
'
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
end_of_line = lf

[CMakeLists.txt]
indent_style = tab
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
208 changes: 208 additions & 0 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
name: Linux

on:
pull_request:
push:
release:
types: published

jobs:
build:
runs-on: [ubuntu-latest]
container:
image: centos:7
steps:
- uses: actions/checkout@v2
- uses: codespell-project/actions-codespell@master
with:
ignore_words_list: fo,wee
- name: Install dependencies
run: |
curl -L -O https://github.com/Kitware/CMake/releases/download/v3.16.4/cmake-3.16.4-Linux-x86_64.sh
chmod +x cmake-3.16.4-Linux-x86_64.sh
./cmake-3.16.4-Linux-x86_64.sh --skip-license --prefix=/usr/local
curl -L -O https://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/7/x86_64/Packages/p/p7zip-16.02-20.el7.x86_64.rpm
curl -L -O https://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/7/x86_64/Packages/p/p7zip-plugins-16.02-20.el7.x86_64.rpm
rpm -U --quiet p7zip-16.02-20.el7.x86_64.rpm
rpm -U --quiet p7zip-plugins-16.02-20.el7.x86_64.rpm
yum install -y make gcc-c++ libasan clang-analyzer
- 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: ./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@v3
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@v2
- name: Install dependencies
run: |
apt update
apt install -y python3-pytest ninja-build clang-tidy 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' -DCMAKE_EXPORT_COMPILE_COMMANDS=1

- 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

- name: clang-tidy
run: /usr/lib/llvm-10/share/clang/run-clang-tidy.py -header-filter=src
working-directory: build-clang

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@v2
- 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@v3

- 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@v3
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-aarch64.zip
asset_name: ninja-linux-aarch64.zip
asset_content_type: application/zip
53 changes: 53 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: macOS

on:
pull_request:
push:
release:
types: published

jobs:
build:
runs-on: macos-12

steps:
- uses: actions/checkout@v2

- name: Install dependencies
run: brew install re2c p7zip cmake

- name: Build ninja
shell: bash
env:
MACOSX_DEPLOYMENT_TARGET: 10.15
run: |
cmake -Bbuild -GXcode '-DCMAKE_OSX_ARCHITECTURES=arm64;x86_64'
cmake --build build --config Release
- name: Test ninja
run: ctest -C Release -vv
working-directory: build

- name: Create ninja archive
shell: bash
run: |
mkdir artifact
7z a artifact/ninja-mac.zip ./build/Release/ninja
# Upload ninja binary archive as an artifact
- name: Upload artifact
uses: actions/upload-artifact@v3
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-mac.zip
asset_name: ninja-mac.zip
asset_content_type: application/zip
67 changes: 67 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Windows

on:
pull_request:
push:
release:
types: published

jobs:
build:
runs-on: windows-latest

strategy:
fail-fast: false
matrix:
include:
- arch: 'x64'
suffix: ''
- arch: 'arm64'
suffix: 'arm64'

steps:
- uses: actions/checkout@v2

- name: Install dependencies
run: choco install re2c

- name: Build ninja
shell: bash
run: |
cmake -Bbuild -A ${{ matrix.arch }}
cmake --build build --parallel --config Debug
cmake --build build --parallel --config Release
- name: Test ninja (Debug)
if: matrix.arch != 'arm64'
run: .\ninja_test.exe
working-directory: build/Debug

- name: Test ninja (Release)
if: matrix.arch != 'arm64'
run: .\ninja_test.exe
working-directory: build/Release

- name: Create ninja archive
shell: bash
run: |
mkdir artifact
7z a artifact/ninja-win${{ matrix.suffix }}.zip ./build/Release/ninja.exe
# Upload ninja binary archive as an artifact
- name: Upload artifact
uses: actions/upload-artifact@v3
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-win${{ matrix.suffix }}.zip
asset_name: ninja-win${{ matrix.suffix }}.zip
asset_content_type: application/zip
Loading

0 comments on commit 0c2a40b

Please sign in to comment.