Skip to content

Commit f700a71

Browse files
authored
pre-commit: enable shfmt and shellcheck (#9021)
1 parent 9baf7fc commit f700a71

44 files changed

Lines changed: 905 additions & 873 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/testing-ecosystem.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
3535
echo "deb http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-${LLVM_VERSION} main" | \
3636
sudo tee "/etc/apt/sources.list.d/llvm-${LLVM_VERSION}.list"
37-
37+
3838
# Get everything else from upstream Ubuntu
3939
sudo apt-get update && sudo apt-get install -y \
4040
"clang-${LLVM_VERSION}" \
@@ -48,7 +48,7 @@ jobs:
4848
"liblld-${LLVM_VERSION}-dev" \
4949
"lld-${LLVM_VERSION}" \
5050
"llvm-${LLVM_VERSION}-dev" \
51-
pybind11-dev
51+
pybind11-dev
5252
5353
- name: Check CMake configures
5454
run: cmake --preset ubuntu-release -DHalide_LLVM_ROOT="/usr/lib/llvm-${LLVM_VERSION}"

.pre-commit-config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,19 @@ repos:
5858
- id: ruff-check
5959
- id: ruff-format
6060

61+
- repo: https://github.com/shellcheck-py/shellcheck-py
62+
rev: v0.11.0.1
63+
hooks:
64+
- id: shellcheck
65+
exclude: ^apps/HelloAndroid.*/gradlew$
66+
67+
- repo: https://github.com/maxwinterstein/shfmt-py
68+
rev: v3.12.0.1
69+
hooks:
70+
- id: shfmt
71+
args: [ -i, "4", -ci, -s, -w ]
72+
exclude: ^apps/HelloAndroid.*/gradlew$
73+
6174
- repo: https://github.com/ComPWA/taplo-pre-commit
6275
rev: v0.9.3
6376
hooks:

CMakePresets.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,19 @@
124124
},
125125
{
126126
"name": "ubuntu-debug",
127-
"inherits": ["ubuntu", "debug"],
127+
"inherits": [
128+
"ubuntu",
129+
"debug"
130+
],
128131
"displayName": "Debug (Ubuntu)",
129132
"description": "Debug build for a single-config generator, Ubuntu dependencies"
130133
},
131134
{
132135
"name": "ubuntu-release",
133-
"inherits": ["ubuntu", "release"],
136+
"inherits": [
137+
"ubuntu",
138+
"release"
139+
],
134140
"displayName": "Release (Ubuntu)",
135141
"description": "Release build for a single-config generator, Ubuntu dependencies"
136142
},

apps/HelloAndroid/build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ c++ jni/hello_generator.cpp ../../tools/GenGen.cpp \
88
-L ../../bin -lHalide -ldl -lpthread -lz \
99
-o bin/hello_generator
1010

11-
for archs in arm-32-android,armeabi arm-32-android-armv7s,armeabi-v7a arm-64-android,arm64-v8a x86-64-android-sse41,x86_64 x86-32-android,x86 ; do
11+
for archs in arm-32-android,armeabi arm-32-android-armv7s,armeabi-v7a arm-64-android,arm64-v8a x86-64-android-sse41,x86_64 x86-32-android,x86; do
1212
IFS=,
1313
set $archs
1414
HL_TARGET=$1
1515
ANDROID_ABI=$2
16-
mkdir -p bin/$ANDROID_ABI
17-
./bin/hello_generator -g hello -o bin/$ANDROID_ABI target=$HL_TARGET
16+
mkdir -p bin/"$ANDROID_ABI"
17+
./bin/hello_generator -g hello -o bin/"$ANDROID_ABI" target="$HL_TARGET"
1818
unset IFS
1919
done
2020

apps/HelloAndroidCamera2/build.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ c++ jni/deinterleave_generator.cpp ../../tools/GenGen.cpp \
2020
-L ../../bin -lHalide -ldl -lpthread -lz \
2121
-o bin/deinterleave_generator
2222

23-
for archs in arm-32-android,armeabi arm-32-android-armv7s,armeabi-v7a arm-64-android,arm64-v8a x86-64-android-sse41,x86_64 x86-32-android,x86 ; do
23+
for archs in arm-32-android,armeabi arm-32-android-armv7s,armeabi-v7a arm-64-android,arm64-v8a x86-64-android-sse41,x86_64 x86-32-android,x86; do
2424
IFS=,
2525
set $archs
2626
HL_TARGET=$1
2727
ANDROID_ABI=$2
28-
mkdir -p bin/$ANDROID_ABI
29-
./bin/edge_detect_generator -g edge_detect -o bin/$ANDROID_ABI target=$HL_TARGET
30-
./bin/deinterleave_generator -g deinterleave -o bin/$ANDROID_ABI target=$HL_TARGET
28+
mkdir -p bin/"$ANDROID_ABI"
29+
./bin/edge_detect_generator -g edge_detect -o bin/"$ANDROID_ABI" target="$HL_TARGET"
30+
./bin/deinterleave_generator -g deinterleave -o bin/"$ANDROID_ABI" target="$HL_TARGET"
3131
unset IFS
3232
done
3333

34-
${ANDROID_NDK_HOME}/ndk-build NDK_GEN_OUT=./bin/gen NDK_LIBS_OUT=./bin/lib NDK_OUT=./bin/obj
34+
"${ANDROID_NDK_HOME}"/ndk-build NDK_GEN_OUT=./bin/gen NDK_LIBS_OUT=./bin/lib NDK_OUT=./bin/obj
3535
ant debug
3636
adb install -r bin/HelloAndroidCamera2-debug.apk
3737
adb logcat

apps/HelloBaremetal/cmake-external_project/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -eo pipefail
44
# Prerequisite :
55
# Halide is installed system-wide in your host machine or discoverable via CMAKE_PREFIX_PATH
66

7-
cd "$(dirname ${BASH_SOURCE[0]})"
7+
cd "$(dirname "${BASH_SOURCE[0]}")"
88
readonly TOOLCHAIN_FILE="${PWD}/../cmake/toolchain.noos-arm32-sample.cmake"
99

1010
rm -rf build
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22

3-
cd "$(dirname ${BASH_SOURCE[0]})"
3+
cd "$(dirname "${BASH_SOURCE[0]}")" || exit
44
../run_baremetal.sh build/bin/add_filter ../../images/gray_small.pgm 16 build/out.pgm

apps/HelloBaremetal/cmake-super_build/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -eo pipefail
44
# Prerequisite :
55
# Halide is installed system-wide in your host machine or discoverable via CMAKE_PREFIX_PATH
66

7-
cd "$(dirname ${BASH_SOURCE[0]})"
7+
cd "$(dirname "${BASH_SOURCE[0]}")"
88
readonly TOOLCHAIN_FILE="${PWD}/../cmake/toolchain.noos-arm32-sample.cmake"
99

1010
rm -rf build
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/bash
22

3-
cd "$(dirname ${BASH_SOURCE[0]})"
3+
cd "$(dirname "${BASH_SOURCE[0]}")" || exit
44
../run_baremetal.sh build/bin/add_filter ../../images/gray_small.pgm 16 build/out.pgm

apps/HelloBaremetal/cmake-twice/build.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -eo pipefail
44
# Prerequisite :
55
# Halide is installed system-wide in your host machine or discoverable via CMAKE_PREFIX_PATH
66

7-
cd "$(dirname ${BASH_SOURCE[0]})"
7+
cd "$(dirname "${BASH_SOURCE[0]}")"
88
readonly TOOLCHAIN_FILE="${PWD}/../cmake/toolchain.noos-arm32-sample.cmake"
99
readonly GEN_PACKAGE="HelloBaremetal-add_generator"
1010

@@ -22,8 +22,8 @@ cmake --build build-host/ --target "${GEN_PACKAGE}"
2222
# Build application with cross compiler,
2323
# where the generator executable built in Step 1 is just imported and called
2424
cmake -S . -B build-target \
25-
-DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" \
26-
-DGEN_PACKAGE="${GEN_PACKAGE}" \
27-
-D${GEN_PACKAGE}_ROOT:FILEPATH=build-host
25+
-DCMAKE_TOOLCHAIN_FILE="${TOOLCHAIN_FILE}" \
26+
-DGEN_PACKAGE="${GEN_PACKAGE}" \
27+
-D${GEN_PACKAGE}_ROOT:FILEPATH=build-host
2828

2929
cmake --build build-target/

0 commit comments

Comments
 (0)