summaryrefslogtreecommitdiffstats
path: root/extras
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2024-10-30 13:45:53 +0800
committerGitHub <noreply@github.com>2024-10-30 13:45:53 +0800
commit22d1e345037eea853e54b84af718340cb9776513 (patch)
treee63754ab1e7c7f6c95d75ff5bc785b9afdbd54b4 /extras
parent44dc5ea202ac43cd4f18c268e95143c2a23f5d26 (diff)
format yaml and json (#5428)
* format yaml and json * format shell scripts
Diffstat (limited to 'extras')
-rwxr-xr-xextras/formatting.sh39
-rw-r--r--extras/macos-notarize.json12
-rw-r--r--extras/macos-sign.json20
3 files changed, 54 insertions, 17 deletions
diff --git a/extras/formatting.sh b/extras/formatting.sh
index 664eb68b9..88bf219ff 100755
--- a/extras/formatting.sh
+++ b/extras/formatting.sh
@@ -74,6 +74,8 @@ require_bin "gersemi" "0.17"
require_bin "xargs" "3"
require_bin "diff" "2"
require_bin "clang-format" "17" "18"
+require_bin "prettier" "3"
+require_bin "shfmt" "3"
if [ "$missing_bin" ]; then
exit 1
@@ -82,6 +84,8 @@ fi
exit_code=0
cmake_formatting() {
+ echo "Formatting CMake files..."
+
readarray -t files < <(git ls-files '*.cmake' 'CMakeLists.txt' '**/CMakeLists.txt')
common_args=(
@@ -99,7 +103,9 @@ cmake_formatting() {
}
cpp_formatting() {
- readarray -t files < <(git ls-files '*.cpp' '*.hpp' '*.c' '*.h')
+ echo "Formatting cpp files..."
+
+ readarray -t files < <(git ls-files '*.cpp' '*.hpp' '*.c' '*.h' ':!external/**')
if [ "$check_only" -eq 1 ]; then
local tmpdir
@@ -123,7 +129,38 @@ cpp_formatting() {
fi
}
+yaml_json_formatting() {
+ echo "Formatting yaml and json files..."
+
+ readarray -t files < <(git ls-files "*.yaml" "*.yml" "*.json" ':!external/**')
+
+ if [ "$check_only" -eq 1 ]; then
+ prettier --check "${files[@]}" || exit_code=1
+ else
+ prettier --write "${files[@]}" | grep -v '(unchanged)' || :
+ fi
+}
+
+sh_formatting() {
+ echo "Formatting sh files..."
+
+ readarray -t files < <(git ls-files "*.sh")
+
+ common_args=(
+ # default 8 is way too wide
+ --indent 2
+ )
+
+ if [ "$check_only" -eq 1 ]; then
+ shfmt "${common_args[@]}" --diff "${files[@]}" || exit_code=1
+ else
+ shfmt "${common_args[@]}" --write "${files[@]}"
+ fi
+}
+
cmake_formatting
cpp_formatting
+yaml_json_formatting
+sh_formatting
exit $exit_code
diff --git a/extras/macos-notarize.json b/extras/macos-notarize.json
index ee369a0ac..517ea30f4 100644
--- a/extras/macos-notarize.json
+++ b/extras/macos-notarize.json
@@ -1,7 +1,7 @@
{
- "notarize" :{
- "path": "slang-macos-dist.zip",
- "bundle_id": "shader-slang.slang",
- "staple": false
- }
-} \ No newline at end of file
+ "notarize": {
+ "path": "slang-macos-dist.zip",
+ "bundle_id": "shader-slang.slang",
+ "staple": false
+ }
+}
diff --git a/extras/macos-sign.json b/extras/macos-sign.json
index fbe511bf3..b37429498 100644
--- a/extras/macos-sign.json
+++ b/extras/macos-sign.json
@@ -1,11 +1,11 @@
{
- "source" : [
- "./bin/macosx-*/release/libslang.dylib",
- "./bin/macosx-*/release/slangc",
- "./bin/macosx-*/release/slangd"
- ],
- "bundle_id" : "shader-slang.slang",
- "sign" :{
- "application_identity" : "d6ada82a113e4204aaad914e1013e9548ffd30d0"
- }
-} \ No newline at end of file
+ "source": [
+ "./bin/macosx-*/release/libslang.dylib",
+ "./bin/macosx-*/release/slangc",
+ "./bin/macosx-*/release/slangd"
+ ],
+ "bundle_id": "shader-slang.slang",
+ "sign": {
+ "application_identity": "d6ada82a113e4204aaad914e1013e9548ffd30d0"
+ }
+}