Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create make file to run SwiftFormat #638

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ jobs:
run: sudo xcode-select -s "/Applications/Xcode_15.1.app"

- name: SwiftFormat
run: swift run -c release --package-path ./BuildTools swiftformat --lint .
run: make format-lint
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ xcuserdata/
DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
.netrc
/BuildTools/
2 changes: 1 addition & 1 deletion .swiftformat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Don't format
--exclude .build,UI/UIx/SwiftUI/Epoxy
--exclude .build,UI/UIx/SwiftUI/Epoxy,BuildTools

# Options

Expand Down
Empty file removed BuildTools/Empty.swift
Empty file.
14 changes: 0 additions & 14 deletions BuildTools/Package.resolved

This file was deleted.

11 changes: 0 additions & 11 deletions BuildTools/Package.swift

This file was deleted.

38 changes: 38 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
BUILD_TOOLS_DIR=./BuildTools

SWIFTFORMAT_REPO=https://github.com/nicklockwood/SwiftFormat
SWIFTFORMAT_VERSION=0.53.10
SWIFTFORMAT_DIR=$(BUILD_TOOLS_DIR)/SwiftFormat
SWIFTFORMAT_BIN=$(SWIFTFORMAT_DIR)/.build/release/swiftformat

clone-swiftformat:
@mkdir -p $(BUILD_TOOLS_DIR)
@if [ ! -d $(SWIFTFORMAT_DIR) ]; then \
echo "Cloning SwiftFormat repository..."; \
git clone --branch $(SWIFTFORMAT_VERSION) --depth 1 $(SWIFTFORMAT_REPO) $(SWIFTFORMAT_DIR); \
else \
echo "SwiftFormat repository already exists."; \
fi

build-swiftformat: clone-swiftformat
@if [ ! -f $(SWIFTFORMAT_BIN) ]; then \
echo "Building swiftformat in $(SWIFTFORMAT_DIR)"; \
cd $(SWIFTFORMAT_DIR) && swift build -c release; \
else \
echo "SwiftFormat binary already exists."; \
fi

force-build-swiftformat: clone-swiftformat
@echo "Force building swiftformat in $(SWIFTFORMAT_DIR)"
cd $(SWIFTFORMAT_DIR) && swift build -c release

clean-swiftformat:
@rm -rf $(SWIFTFORMAT_DIR)/.build

format-lint: $(SWIFTFORMAT_BIN)
$(SWIFTFORMAT_BIN) --lint .

format-autocorrect: $(SWIFTFORMAT_BIN)
$(SWIFTFORMAT_BIN) .

$(SWIFTFORMAT_BIN): build-swiftformat
Loading