Skip to content

Commit dcbe93e

Browse files
committed
Try to produce SARIF from linux clang
This is just horrible.
1 parent 2a2cae5 commit dcbe93e

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-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: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ jobs:
264264
env:
265265
CC: ${{ inputs.compiler-CC }}
266266
CXX: ${{ inputs.compiler-CXX }}
267+
FAMILY: ${{ inputs.compiler-family }}
267268
CLANG_TIDY: ${{ inputs.compiler-CLANG_TIDY }}
268269
GCOV: ${{ inputs.compiler-GCOV }}
269270
SRC_DIR: ${{ github.workspace }}/rawspeed
@@ -279,8 +280,9 @@ jobs:
279280
cmake -E make_directory "${INSTALL_PREFIX}"
280281
export ECO="${ECO} -DRAWSPEED_REFERENCE_SAMPLE_ARCHIVE=${RPUU_DST}"
281282
export ECO="${ECO} -DCMAKE_CXX_CLANG_TIDY_EXPORT_FIXES_DIR=${BUILD_DIR}/clang-tidy/"
282-
if [ "$FLAVOR" = "ClangTidy" ] || [ "$FLAVOR" = "ClangStaticAnalysis" ] || [ "$FLAVOR" = "ClangCTUStaticAnalysis" ] || [ "$FLAVOR" = "CodeQLAnalysis" ]; then
283+
if [ "$FAMILY" = "LLVM" ]; then
283284
export ECO="${ECO} -DRAWSPEED_ENABLE_WERROR=OFF"
285+
export ECO="${ECO} -DCMAKE_CXX_COMPILER_LAUNCHER='${SRC_DIR}/.ci/clang-sarif-wrapper.sh;${GITHUB_WORKSPACE}/clang_report/'"
284286
fi
285287
"${SRC_DIR}/.ci/ci-script.sh"
286288
- name: Build
@@ -295,6 +297,18 @@ jobs:
295297
run: |
296298
set -xe
297299
"${SRC_DIR}/.ci/ci-script.sh"
300+
if [ "$FAMILY" = "LLVM" ] || [ "$FLAVOR" = "ClangTidy" ] || [ "$FLAVOR" = "ClangStaticAnalysis" ] || [ "$FLAVOR" = "ClangCTUStaticAnalysis" ] || [ "$FLAVOR" = "CodeQLAnalysis" ]; then
301+
else
302+
exit [ ! -f ${GITHUB_WORKSPACE}/clang_report/.warnings ]
303+
fi
304+
- name: Upload results of clang compile [SARIF]
305+
timeout-minutes: 1
306+
if: inputs.compiler-family == 'LLVM' && !cancelled() && steps.build.conclusion != 'skipped'
307+
uses: github/codeql-action/upload-sarif@v3
308+
with:
309+
sarif_file: "${{ github.workspace }}/clang_report/"
310+
checkout_path: "${{ github.workspace }}/rawspeed"
311+
category: ${{ job.name }}
298312
- name: Test (unit tests)
299313
timeout-minutes: 1
300314
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)