Skip to content

Commit a121be4

Browse files
committed
update to current upstream
2 parents 015bc9e + 7c9c841 commit a121be4

27 files changed

+2737
-1539
lines changed

.clang-format

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
Language: Cpp
3+
BasedOnStyle: Google
4+
DerivePointerAlignment: false
5+
SortIncludes: true
6+
...

.github/workflows/bazel-build.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Bazel build
2+
3+
on:
4+
pull_request:
5+
6+
permissions: read-all
7+
8+
jobs:
9+
bazel-build:
10+
name: Build and run tests using Bazel
11+
strategy:
12+
matrix:
13+
os: [ubuntu-latest, macos-latest, windows-latest]
14+
runs-on: ${{matrix.os}}
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v3
18+
with:
19+
fetch-depth: '0'
20+
- name: Clone submodules
21+
run: git submodule update --init --recursive
22+
- name: Mount Bazel cache
23+
uses: actions/cache@v3
24+
with:
25+
path: ~/.bazel/cache
26+
key: bazel-cache-${{ runner.os }}
27+
- name: Build
28+
run: bazel --output_user_root=~/.bazel/cache build :all
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Code formatting check
2+
3+
on:
4+
pull_request:
5+
6+
# Cancel previous runs if a more recent commit is pushed.
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref }}
9+
cancel-in-progress: true
10+
11+
permissions: read-all
12+
13+
jobs:
14+
clang-format-check:
15+
name: clang-format
16+
runs-on: "ubuntu-20.04"
17+
steps:
18+
- name: Setup clang-format
19+
run: |
20+
sudo apt-get install -yqq clang-format-12
21+
- name: Checkout repository
22+
uses: actions/checkout@v3
23+
with:
24+
fetch-depth: '0'
25+
- name: Switch to pull request branch
26+
run: |
27+
git checkout ${GITHUB_SHA}
28+
- name: Run clang-format
29+
run: |
30+
git diff origin/${{ github.base_ref }} -U0 --no-color -- '**/*.cpp' '**/*.cc' '**/*.h' '**/*.hh' '**/*.hpp' \
31+
| clang-format-diff-12 -p1 >not-formatted.diff 2>&1
32+
- name: Check formatting
33+
run: |
34+
if ! grep -q '[^[:space:]]' not-formatted.diff ; then
35+
echo "Code is formatted."
36+
else
37+
echo "Code is not formatted."
38+
echo "Run clang-format-diff on your changes:"
39+
echo " git diff origin/${{ github.base_ref }} -U0 --no-color | clang-format-diff -p1 -i"
40+
echo ""
41+
echo "You can disable clang-format for specific code blocks. Follow https://clang.llvm.org/docs/ClangFormatStyleOptions.html#disabling-formatting-on-a-piece-of-code."
42+
echo ""
43+
echo "Diff:"
44+
cat not-formatted.diff
45+
echo ""
46+
exit 3
47+
fi
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Linux build
2+
3+
on:
4+
pull_request:
5+
6+
# Cancel previous runs if a more recent commit is pushed.
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref }}
9+
cancel-in-progress: true
10+
11+
permissions: read-all
12+
13+
jobs:
14+
linux-build:
15+
name: Build and run tests on Linux using CMake
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v3
20+
with:
21+
fetch-depth: '0'
22+
- name: Clone submodules
23+
run: git submodule update --init --recursive
24+
- name: Build
25+
run: |
26+
mkdir build
27+
cd build
28+
cmake .. -DSPIRV_REFLECT_BUILD_TESTS=ON
29+
make -j $(nproc)
30+
- name: Run unit tests
31+
run: |
32+
cd build
33+
./test-spirv-reflect
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Windows build
2+
3+
on:
4+
pull_request:
5+
6+
# Cancel previous runs if a more recent commit is pushed.
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.head_ref }}
9+
cancel-in-progress: true
10+
11+
permissions: read-all
12+
13+
jobs:
14+
windows-build:
15+
name: Build and run tests on Windows using CMake
16+
runs-on: windows-latest
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v3
20+
with:
21+
fetch-depth: '0'
22+
- name: Clone submodules
23+
run: git submodule update --init --recursive
24+
- name: Build
25+
run: |
26+
mkdir build
27+
cd build
28+
cmake -DSPIRV_REFLECT_BUILD_TESTS=ON ..
29+
30+
cmake --build . --config Release -- /nologo /verbosity:minimal /maxcpucount

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
/build*
2-
/bin/*
2+
/bin/*
3+
bazel-bin
4+
bazel-genfiles
5+
bazel-out
6+
bazel-spirv-reflect
7+
bazel-SPIRV-Reflect
8+
bazel-testlogs

BUILD.bazel

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ package(
44

55
# Description:
66
#
7-
# The Amber project provides an API and commands for testing shader
8-
# compiler stack.
7+
# SPIRV-Reflect is a lightweight library that provides a C/C++ reflection API for SPIR-V shader bytecode in Vulkan applications.
98

109
licenses(["notice"]) # Apache 2.0
1110

@@ -14,16 +13,43 @@ exports_files([
1413
"LICENSE",
1514
])
1615

17-
COMMON_COPTS = [
16+
COPTS_WINDOWS = [
17+
"/Gy",
18+
"/Gw",
19+
20+
"/W3",
21+
"/WX",
22+
]
23+
24+
COPTS_DEFAULT = [
1825
"-ffunction-sections",
1926
"-fdata-sections",
20-
]
2127

22-
COMMON_CPPOPTS = COMMON_COPTS + [
23-
"-std=c++14",
28+
"-Werror",
29+
"-Wswitch",
30+
"-Wimplicit-fallthrough",
31+
"-Wunused-variable",
2432
]
2533

26-
COMMON_LINKOPTS = ["-Wl,--gc-sections"]
34+
COMMON_COPTS = select({
35+
"@bazel_tools//src/conditions:windows": COPTS_WINDOWS,
36+
"//conditions:default": COPTS_DEFAULT,
37+
})
38+
39+
COMMON_CPPOPTS = select({
40+
"@bazel_tools//src/conditions:windows": COPTS_WINDOWS + [
41+
"/std:c++14"
42+
],
43+
"//conditions:default": COPTS_DEFAULT + [
44+
"-std=c++14",
45+
]
46+
})
47+
48+
COMMON_LINKOPTS = select({
49+
"@bazel_tools//src/conditions:darwin": ["-Wl,-dead_strip"],
50+
"@bazel_tools//src/conditions:windows": ["/OPT:REF"],
51+
"//conditions:default": ["-Wl,--gc-sections"],
52+
})
2753

2854
cc_library(
2955
name = "libspirv_reflect",

0 commit comments

Comments
 (0)