Skip to content

Commit d409ff2

Browse files
committed
Fix format-xx.sh files wrt logging, add proper Swift formatting configuration.
1 parent 0dd86df commit d409ff2

Some content is hidden

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

49 files changed

+892
-690
lines changed

Package.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ let package = Package(
2727
.byName(
2828
name: "Spine",
2929
condition: .when(platforms: [
30-
.iOS,
30+
.iOS
3131
])
3232
),
3333
"SpineCppLite",
@@ -38,21 +38,21 @@ let package = Package(
3838
.target(
3939
name: "Spine",
4040
dependencies: [
41-
"SpineCppLite", "SpineShadersStructs"
41+
"SpineCppLite", "SpineShadersStructs",
4242
],
4343
path: "spine-ios/Sources/Spine"
4444
),
4545
.target(
4646
name: "SpineCppLite",
4747
path: "spine-ios/Sources/SpineCppLite",
4848
linkerSettings: [
49-
.linkedLibrary("c++"),
49+
.linkedLibrary("c++")
5050
]
5151
),
5252
.systemLibrary(
5353
name: "SpineShadersStructs",
5454
path: "spine-ios/Sources/SpineShadersStructs"
55-
)
55+
),
5656
],
5757
cxxLanguageStandard: .cxx11
5858
)

formatters/.swift-format

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"version": 1,
3+
"lineLength": 150,
4+
"indentation": {
5+
"spaces": 4
6+
},
7+
"tabWidth": 4,
8+
"maximumBlankLines": 2,
9+
"respectsExistingLineBreaks": true,
10+
"lineBreakBeforeControlFlowKeywords": false,
11+
"lineBreakBeforeEachArgument": false,
12+
"lineBreakBeforeEachGenericRequirement": false,
13+
"prioritizeKeepingFunctionOutputTogether": true,
14+
"indentConditionalCompilationBlocks": true,
15+
"lineBreakAroundMultilineExpressionChainComponents": false,
16+
"rules": {
17+
"AllPublicDeclarationsHaveDocumentation": false,
18+
"AlwaysUseLowerCamelCase": true,
19+
"AmbiguousTrailingClosureOverload": true,
20+
"BeginDocumentationCommentWithOneLineSummary": false,
21+
"DoNotUseSemicolons": true,
22+
"DontRepeatTypeInStaticProperties": true,
23+
"FileScopedDeclarationPrivacy": true,
24+
"FullyIndirectEnum": true,
25+
"GroupNumericLiterals": true,
26+
"IdentifiersMustBeASCII": true,
27+
"NeverForceUnwrap": false,
28+
"NeverUseForceTry": false,
29+
"NeverUseImplicitlyUnwrappedOptionals": false,
30+
"NoAccessLevelOnExtensionDeclaration": true,
31+
"NoBlockComments": true,
32+
"NoCasesWithOnlyFallthrough": true,
33+
"NoEmptyTrailingClosureParentheses": true,
34+
"NoLabelsInCasePatterns": true,
35+
"NoLeadingUnderscores": false,
36+
"NoParensAroundConditions": true,
37+
"NoVoidReturnOnFunctionSignature": true,
38+
"OneCasePerLine": true,
39+
"OneVariableDeclarationPerLine": true,
40+
"OnlyOneTrailingClosureArgument": false,
41+
"OrderedImports": true,
42+
"ReturnVoidInsteadOfEmptyTuple": true,
43+
"UseEarlyExits": false,
44+
"UseLetInEveryBoundCaseVariable": true,
45+
"UseShorthandTypeNames": true,
46+
"UseSingleLinePropertyGetter": true,
47+
"UseSynthesizedInitializer": true,
48+
"UseTripleSlashForDocumentationComments": true,
49+
"UseWhereClausesInForLoops": false,
50+
"ValidateDocumentationComments": false
51+
}
52+
}

formatters/format-cpp.sh

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
#!/bin/bash
22
set -e
33

4-
# Format C/C++ files with clang-format
5-
echo "Formatting C/C++ files..."
6-
74
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
85

6+
# Source logging utilities
7+
source "$dir/logging/logging.sh"
8+
9+
log_title "C/C++ Formatting"
10+
911
# Store original directory
1012
pushd "$dir" > /dev/null
1113

12-
if [ ! -f ".clang-format" ]; then
13-
echo "Error: .clang-format not found in formatters directory"
14+
log_action "Checking for formatters/.clang-format"
15+
if [ -f ".clang-format" ]; then
16+
log_ok
17+
else
18+
log_fail
1419
popd > /dev/null
1520
exit 1
1621
fi
@@ -22,47 +27,47 @@ cpp_dirs=(
2227
"../spine-cpp/src/spine"
2328
"../spine-cpp/spine-cpp-lite"
2429
"../spine-cpp/tests"
25-
30+
2631
# spine-c
2732
"../spine-c/include"
2833
"../spine-c/src"
2934
"../spine-c/src/generated"
3035
"../spine-c/tests"
31-
36+
3237
# spine-godot
3338
"../spine-godot/spine_godot"
34-
39+
3540
# spine-ue
3641
"../spine-ue/Source/SpineUE"
3742
"../spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Public"
3843
"../spine-ue/Plugins/SpinePlugin/Source/SpinePlugin/Private"
3944
"../spine-ue/Plugins/SpinePlugin/Source/SpineEditorPlugin/Public"
4045
"../spine-ue/Plugins/SpinePlugin/Source/SpineEditorPlugin/Private"
41-
46+
4247
# spine-glfw
4348
"../spine-glfw/src"
4449
"../spine-glfw/example"
45-
50+
4651
# spine-sdl
4752
"../spine-sdl/src"
4853
"../spine-sdl/example"
49-
54+
5055
# spine-sfml
5156
"../spine-sfml/c/src/spine"
5257
"../spine-sfml/c/example"
5358
"../spine-sfml/cpp/src/spine"
5459
"../spine-sfml/cpp/example"
55-
60+
5661
# spine-cocos2dx
5762
"../spine-cocos2dx/spine-cocos2dx/src/spine"
5863
"../spine-cocos2dx/example/Classes"
59-
64+
6065
# spine-ios
6166
"../spine-ios/Sources/SpineCppLite"
6267
"../spine-ios/Sources/SpineCppLite/include"
6368
"../spine-ios/Sources/SpineShadersStructs"
6469
"../spine-ios/Example/Spine iOS Example"
65-
70+
6671
# spine-flutter
6772
"../spine-flutter/ios/Classes"
6873
"../spine-flutter/macos/Classes"
@@ -86,22 +91,16 @@ for cpp_dir in "${cpp_dirs[@]}"; do
8691
fi
8792
done
8893

89-
echo "Found ${#files[@]} C/C++ files to format"
9094

91-
# Format all files in one call - works for both Docker and native
92-
echo "Formatting ${#files[@]} files..."
93-
if ! clang-format -i -style=file:".clang-format" "${files[@]}" 2>&1; then
94-
echo "Error: clang-format failed"
95-
errors=1
95+
log_action "Formatting ${#files[@]} C/C++ files"
96+
if FORMAT_OUTPUT=$(clang-format -i -style=file:".clang-format" "${files[@]}" 2>&1); then
97+
log_ok
9698
else
97-
errors=0
98-
fi
99-
100-
if [ $errors -gt 0 ]; then
101-
echo "Completed with $errors errors"
99+
log_fail
100+
log_error_output "$FORMAT_OUTPUT"
101+
popd > /dev/null
102+
exit 1
102103
fi
103104

104-
echo "C/C++ formatting complete"
105-
106105
# Return to original directory
107106
popd > /dev/null

formatters/format-csharp.sh

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,66 @@
11
#!/bin/bash
22
set -e
33

4-
# Format C# files with dotnet-format
5-
echo "Formatting C# files..."
6-
74
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
85

6+
# Source logging utilities
7+
source "$dir/logging/logging.sh"
8+
9+
log_title "C# Formatting"
10+
911
if command -v dotnet &> /dev/null; then
1012
# Store original directory
1113
pushd "$dir" > /dev/null
12-
13-
# Copy .editorconfig to C# directories
14+
1415
cp .editorconfig ../spine-csharp/ 2>/dev/null || true
1516
cp .editorconfig ../spine-monogame/ 2>/dev/null || true
1617
cp .editorconfig ../spine-unity/ 2>/dev/null || true
1718

1819
# Format spine-csharp
20+
log_action "Formatting spine-csharp"
1921
pushd ../spine-csharp > /dev/null
20-
dotnet format spine-csharp.csproj --no-restore --verbosity quiet 2>/dev/null || echo "Warning: Some issues with spine-csharp formatting"
22+
if DOTNET_OUTPUT=$(dotnet format spine-csharp.csproj --no-restore --verbosity quiet 2>&1); then
23+
log_ok
24+
else
25+
log_warn
26+
log_detail "$DOTNET_OUTPUT"
27+
fi
2128
popd > /dev/null
22-
29+
2330
# Format spine-monogame
31+
log_action "Formatting spine-monogame"
2432
pushd ../spine-monogame > /dev/null
25-
dotnet format --no-restore --verbosity quiet 2>/dev/null || echo "Warning: Some issues with spine-monogame formatting"
33+
if DOTNET_OUTPUT=$(dotnet format --no-restore --verbosity quiet 2>&1); then
34+
log_ok
35+
else
36+
log_warn
37+
log_detail "$DOTNET_OUTPUT"
38+
fi
2639
popd > /dev/null
27-
40+
2841
# Format spine-unity - look for .cs files directly
29-
if [ -d ../spine-unity ]; then
30-
echo "Formatting spine-unity C# files directly..."
31-
pushd ../spine-unity > /dev/null
32-
# Find all .cs files and format them using dotnet format whitespace
42+
log_action "Formatting spine-unity C# files"
43+
pushd ../spine-unity > /dev/null
44+
# Find all .cs files and format them using dotnet format whitespace
45+
cs_files=$(find . -name "*.cs" -type f -not -path "./Library/*" -not -path "./Temp/*" -not -path "./obj/*" -not -path "./bin/*" | wc -l | tr -d ' ')
46+
if [ "$cs_files" -gt 0 ]; then
3347
find . -name "*.cs" -type f -not -path "./Library/*" -not -path "./Temp/*" -not -path "./obj/*" -not -path "./bin/*" | while read -r file; do
3448
dotnet format whitespace --include "$file" --no-restore 2>/dev/null || true
3549
done
36-
popd > /dev/null
50+
log_ok
51+
else
52+
log_skip
3753
fi
54+
popd > /dev/null
3855

39-
# Clean up .editorconfig files
4056
rm -f ../spine-csharp/.editorconfig
4157
rm -f ../spine-monogame/.editorconfig
4258
rm -f ../spine-unity/.editorconfig
43-
59+
4460
# Return to original directory
4561
popd > /dev/null
4662
else
47-
echo "Warning: dotnet not found. Skipping C# formatting."
63+
log_fail
64+
log_error_output "dotnet not found. Please install .NET SDK to format C# files."
65+
exit 1
4866
fi

formatters/format-dart.sh

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,44 @@
11
#!/bin/bash
22
set -e
33

4-
# Format Dart files
5-
echo "Formatting Dart files..."
6-
74
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
85

6+
# Source logging utilities
7+
source "$dir/logging/logging.sh"
8+
9+
log_title "Dart Formatting"
10+
911
# Store original directory
1012
pushd "$dir" > /dev/null
1113

1214
if command -v dart &> /dev/null; then
13-
find .. -name "*.dart" \
15+
dart_files=$(find .. -name "*.dart" \
1416
-not -path "*/.*" \
1517
-not -path "*/node_modules/*" \
16-
-not -path "*/build/*" \
17-
-exec dart format --page-width 120 {} +
18+
-not -path "*/build/*" | wc -l | tr -d ' ')
19+
20+
if [ "$dart_files" -gt 0 ]; then
21+
log_action "Formatting $dart_files Dart files"
22+
if DART_OUTPUT=$(find .. -name "*.dart" \
23+
-not -path "*/.*" \
24+
-not -path "*/node_modules/*" \
25+
-not -path "*/build/*" \
26+
-exec dart format --page-width 120 {} + 2>&1); then
27+
log_ok
28+
else
29+
log_fail
30+
log_error_output "$DART_OUTPUT"
31+
popd > /dev/null
32+
exit 1
33+
fi
34+
else
35+
log_action "Formatting Dart files"
36+
log_skip
37+
fi
1838
else
19-
echo "Warning: dart not found. Skipping Dart formatting."
39+
log_fail
40+
log_error_output "dart not found. Please install Dart SDK to format Dart files."
41+
exit 1
2042
fi
2143

2244
# Return to original directory

formatters/format-haxe.sh

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,45 @@
11
#!/bin/bash
22
set -e
33

4-
# Format Haxe files
5-
echo "Formatting Haxe files..."
6-
74
dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
85

6+
# Source logging utilities
7+
source "$dir/logging/logging.sh"
8+
9+
log_title "Haxe Formatting"
10+
911
# Store original directory
1012
pushd "$dir" > /dev/null
1113

12-
if command -v haxelib &> /dev/null && haxelib list formatter &> /dev/null; then
13-
# Format spine-haxe directory
14-
if [ -d ../spine-haxe ]; then
15-
haxelib run formatter -s ../spine-haxe
14+
if command -v haxelib &> /dev/null; then
15+
log_action "Checking Haxe formatter availability"
16+
if HAXELIB_OUTPUT=$(haxelib list formatter 2>&1); then
17+
log_ok
18+
19+
# Format spine-haxe directory
20+
if [ -d ../spine-haxe ]; then
21+
log_action "Formatting spine-haxe directory"
22+
if FORMATTER_OUTPUT=$(haxelib run formatter -s ../spine-haxe 2>&1); then
23+
log_ok
24+
else
25+
log_fail
26+
log_error_output "$FORMATTER_OUTPUT"
27+
popd > /dev/null
28+
exit 1
29+
fi
30+
else
31+
log_action "Formatting spine-haxe directory"
32+
log_skip
33+
fi
34+
else
35+
log_fail
36+
log_error_output "Haxe formatter not found. Install with: haxelib install formatter"
37+
exit 1
1638
fi
1739
else
18-
echo "Warning: haxe formatter not found. Install with: haxelib install formatter"
40+
log_fail
41+
log_error_output "haxelib not found. Please install Haxe to format Haxe files."
42+
exit 1
1943
fi
2044

2145
# Return to original directory

0 commit comments

Comments
 (0)