diff --git a/Makefile b/Makefile index 22931f96..7f3b8ead 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,24 @@ BUILD_SETTINGS += ARCHS="$(ARCHS)" BUILD_SETTINGS += ONLY_ACTIVE_ARCH=NO endif +spmDebug: + swift build -c debug --package-path ./Packages/vChewing_MainAssembly/ + +spmRelease: + swift build -c release --package-path ./Packages/vChewing_MainAssembly/ + +spmLintFormat: + make lint --file=./Packages/Makefile || true + make format --file=./Packages/Makefile || true + +spmClean: + @for currentDir in $$(ls ./Packages/); do \ + if [ -d $$a ]; then \ + echo "processing folder $$currentDir"; \ + swift package clean --package-path ./Packages/$$currentDir || true; \ + fi; \ + done; + release: xcodebuild -project vChewing.xcodeproj -scheme vChewingInstaller -configuration Release $(BUILD_SETTINGS) build @@ -42,6 +60,7 @@ install-release: permission-check .PHONY: clean clean: + make clean --file=./Packages/Makefile || true xcodebuild -scheme vChewingInstaller -configuration Debug $(BUILD_SETTINGS) clean xcodebuild -scheme vChewingInstaller -configuration Release $(BUILD_SETTINGS) clean make clean --file=./Source/Data/Makefile || true diff --git a/Packages/.clang-format b/Packages/.clang-format new file mode 100644 index 00000000..d4f347b2 --- /dev/null +++ b/Packages/.clang-format @@ -0,0 +1 @@ +BasedOnStyle: Microsoft diff --git a/Packages/.swiftformat.json b/Packages/.swiftformat.json new file mode 100644 index 00000000..1160d8b5 --- /dev/null +++ b/Packages/.swiftformat.json @@ -0,0 +1,104 @@ +# SwiftFormat config compliant with Google Swift Guideline +# https://google.github.io/swift/#control-flow-statements + +# Specify version used in a project + +--swiftversion 5.5 + +# Rules explicitly required by the guideline + +--rules \ +blankLinesAroundMark, \ +blankLinesAtEndOfScope, \ +blankLinesAtStartOfScope, \ +blankLinesBetweenScopes, \ +braces, \ +consecutiveBlankLines, \ +consecutiveSpaces, \ +duplicateImports, \ +elseOnSameLine, \ +emptyBraces, \ +enumNamespaces, \ +extensionAccessControl, \ +hoistPatternLet, \ +indent, \ +leadingDelimiters, \ +linebreakAtEndOfFile, \ +markTypes, \ +organizeDeclarations, \ +redundantInit, \ +redundantParens, \ +redundantPattern, \ +redundantRawValues, \ +redundantType, \ +redundantVoidReturnType, \ +semicolons, \ +sortedImports, \ +sortedSwitchCases, \ +spaceAroundBraces, \ +spaceAroundBrackets, \ +spaceAroundComments, \ +spaceAroundGenerics, \ +spaceAroundOperators, \ +spaceAroundParens, \ +spaceInsideBraces, \ +spaceInsideBrackets, \ +spaceInsideComments, \ +spaceInsideGenerics, \ +spaceInsideParens, \ +todos, \ +trailingClosures, \ +trailingCommas, \ +trailingSpace, \ +typeSugar, \ +void, \ +wrap, \ +wrapArguments, \ +wrapAttributes, \ +# +# +# Additional rules not mentioned in the guideline, but helping to keep the codebase clean +# Quoting the guideline: +# Common themes among the rules in this section are: +# avoid redundancy, avoid ambiguity, and prefer implicitness over explicitness +# unless being explicit improves readability and/or reduces ambiguity. +# +# +andOperator, \ +isEmpty, \ +redundantBackticks, \ +redundantBreak, \ +redundantExtensionACL, \ +redundantGet, \ +redundantLetError, \ +redundantNilInit, \ +redundantObjc, \ +redundantReturn, \ +redundantSelf, \ +strongifiedSelf + + +# Options for basic rules + +--extensionacl on-declarations +--funcattributes prev-line +--indent 2 +--maxwidth 100 +--typeattributes prev-line +--varattributes prev-line +--voidtype tuple +--wraparguments before-first +--wrapparameters before-first +--wrapcollections before-first +--wrapreturntype if-multiline +--wrapconditions after-first + +# Option for additional rules + +--self init-only + +# Excluded folders + +--exclude Pods,**/UNTESTED_TODO,vendor,fastlane + +# https://github.com/NoemiRozpara/Google-SwiftFormat-Config \ No newline at end of file diff --git a/Packages/Makefile b/Packages/Makefile new file mode 100644 index 00000000..a6175e3c --- /dev/null +++ b/Packages/Makefile @@ -0,0 +1,29 @@ ++.PHONY: all + +all: debug + +debug: + swift build -c debug --package-path ./vChewing_MainAssembly/ + +release: + swift build -c release --package-path ./vChewing_MainAssembly/ + +clean: + @for currentDir in $$(ls ./); do \ + if [ -d $$a ]; then \ + echo "processing folder $$currentDir"; \ + swift package clean --package-path ./$$currentDir || true; \ + fi; \ + done; + +.PHONY: lint format + +lintFormat: lint format + +format: + @swiftformat --swiftversion 5.5 --indent 2 ./ + +lint: + @git ls-files --exclude-standard | grep -E '\.swift$$' | swiftlint --fix --autocorrect + +.PHONY: permission-check install-debug install-release