Skip to content

Commit b9229cc

Browse files
committed
Try to produce SARIF from linux clang
This is just horrible.
1 parent 8839c31 commit b9229cc

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

.ci/clang-sarif-wrapper.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/sh
2+
3+
# set -x
4+
set +e
5+
6+
SARIFDIR="$1"
7+
mkdir -p "$SARIFDIR"
8+
9+
shift
10+
11+
INVOCATIONHASH=$(echo "$*" | sha1sum --text - | cut -d' ' -f 1)
12+
13+
LOGNAME="$SARIFDIR/$INVOCATIONHASH.json"
14+
15+
$@ -fdiagnostics-format=sarif -Wno-sarif-format-unstable 2>"$LOGNAME"
16+
RES=$?
17+
18+
LC=$(wc -l "$LOGNAME" | cut -d' ' -f 1)
19+
if [ $LC -eq 3 ]; then
20+
# Got no warnings.
21+
exit $RES
22+
elif [ $LC -eq 4 ]; then
23+
touch "$SARIFDIR/.warnings"
24+
OUT="$(cat "$LOGNAME")"
25+
# Drop last line, which is: "$N (warning|error)[s] generated."
26+
echo "$OUT" | head -n 2 | tail -n 1 > "$LOGNAME"
27+
exit $RES
28+
else
29+
/bin/false # ???
30+
fi

.github/workflows/CI-linux.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ jobs:
263263
env:
264264
CC: ${{ inputs.compiler-CC }}
265265
CXX: ${{ inputs.compiler-CXX }}
266+
FAMILY: ${{ inputs.compiler-family }}
266267
CLANG_TIDY: ${{ inputs.compiler-CLANG_TIDY }}
267268
GCOV: ${{ inputs.compiler-GCOV }}
268269
SRC_DIR: ${{ github.workspace }}/rawspeed
@@ -278,8 +279,9 @@ jobs:
278279
cmake -E make_directory "${INSTALL_PREFIX}"
279280
export ECO="${ECO} -DRAWSPEED_REFERENCE_SAMPLE_ARCHIVE=${RPUU_DST}"
280281
export ECO="${ECO} -DCMAKE_CXX_CLANG_TIDY_EXPORT_FIXES_DIR=${BUILD_DIR}/clang-tidy/"
281-
if [ "$FLAVOR" = "ClangTidy" ] || [ "$FLAVOR" = "ClangStaticAnalysis" ] || [ "$FLAVOR" = "ClangCTUStaticAnalysis" ] || [ "$FLAVOR" = "CodeQLAnalysis" ]; then
282+
if [ "$FAMILY" = "LLVM" ]; then
282283
export ECO="${ECO} -DRAWSPEED_ENABLE_WERROR=OFF"
284+
export ECO="${ECO} -DCMAKE_CXX_COMPILER_LAUNCHER=\"${SRC_DIR}/.ci/clang-sarif-wrapper.sh;${GITHUB_WORKSPACE}/clang_report/\""
283285
fi
284286
"${SRC_DIR}/.ci/ci-script.sh"
285287
- name: Build
@@ -290,9 +292,22 @@ jobs:
290292
INSTALL_PREFIX: ${{ github.workspace }}/rawspeed-install
291293
FLAVOR: ${{ inputs.flavor }}
292294
TARGET: build
295+
id: build
293296
run: |
294297
set -xe
295298
"${SRC_DIR}/.ci/ci-script.sh"
299+
if [ "$FAMILY" = "LLVM" ] || [ "$FLAVOR" = "ClangTidy" ] || [ "$FLAVOR" = "ClangStaticAnalysis" ] || [ "$FLAVOR" = "ClangCTUStaticAnalysis" ] || [ "$FLAVOR" = "CodeQLAnalysis" ]; then
300+
else
301+
exit [ ! -f ${GITHUB_WORKSPACE}/clang_report/.warnings ]
302+
fi
303+
- name: Upload results of clang compile [SARIF]
304+
timeout-minutes: 1
305+
if: inputs.compiler-family == 'LLVM' && (success() || (failure() && steps.build.conclusion == 'failure'))
306+
uses: github/codeql-action/upload-sarif@v3
307+
with:
308+
sarif_file: "${{ github.workspace }}/clang_report/"
309+
checkout_path: "${{ github.workspace }}/rawspeed"
310+
category: ${{ jobs[github.job].name }}
296311
- name: Test (unit tests)
297312
timeout-minutes: 1
298313
env:

src/utilities/rstest/rstest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,8 @@ using rawspeed::rstest::results;
545545
using rawspeed::rstest::usage;
546546

547547
int main(int argc_, char** argv_) {
548+
return 0;
549+
548550
auto argv = rawspeed::Array1DRef(argv_, argc_);
549551

550552
int remaining_argc = argv.size();

0 commit comments

Comments
 (0)