1+ # Use bash, and immediately exit on failure
2+ SHELL := bash
3+ .SHELLFLAGS := -ceu
4+
5+ # This doesn't work on directories.
6+ # See https://stackoverflow.com/questions/25752543/make-delete-on-error-for-directory-targets
7+ .DELETE_ON_ERROR :
8+
19ifdef CI
210LINTFLAGS := --reporter github-actions-logging
311FMTFLAGS := --lint --reporter github-actions-log
@@ -11,18 +19,26 @@ XCPROJECT := Coder\ Desktop/Coder\ Desktop.xcodeproj
1119SCHEME := Coder\ Desktop
1220SWIFT_VERSION := 6.0
1321
22+ MUTAGEN_RESOURCES := mutagen-agents.tar.gz mutagen-darwin-arm64 mutagen-darwin-amd64
23+ ifndef MUTAGEN_VERSION
24+ MUTAGEN_VERSION: =$(shell grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$$' $(PROJECT ) /Resources/.mutagenversion)
25+ endif
26+ ifeq ($(strip $(MUTAGEN_VERSION ) ) ,)
27+ $(error MUTAGEN_VERSION must be a valid version)
28+ endif
29+
1430ifndef CURRENT_PROJECT_VERSION
15- CURRENT_PROJECT_VERSION:=$(shell git describe --match 'v[0-9]*' --dirty='.devel' --always --tags)
31+ CURRENT_PROJECT_VERSION: =$(shell git describe --match 'v[0-9]* ' --dirty='.devel' --always --tags)
1632endif
1733ifeq ($(strip $(CURRENT_PROJECT_VERSION ) ) ,)
18- $(error CURRENT_PROJECT_VERSION cannot be empty)
34+ $(error CURRENT_PROJECT_VERSION cannot be empty)
1935endif
2036
2137ifndef MARKETING_VERSION
22- MARKETING_VERSION:=$(shell git describe --match 'v[0-9]*' --tags --abbrev=0 | sed 's/^v//' | sed 's/-.*$$//')
38+ MARKETING_VERSION: =$(shell git describe --match 'v[0-9]* ' --tags --abbrev=0 | sed 's/^v//' | sed 's/-.* $$//')
2339endif
2440ifeq ($(strip $(MARKETING_VERSION ) ) ,)
25- $(error MARKETING_VERSION cannot be empty)
41+ $(error MARKETING_VERSION cannot be empty)
2642endif
2743
2844# Define the keychain file name first
@@ -32,10 +48,16 @@ APP_SIGNING_KEYCHAIN := $(if $(wildcard $(KEYCHAIN_FILE)),$(shell realpath $(KEY
3248
3349.PHONY : setup
3450setup : \
51+ $(addprefix $(PROJECT ) /Resources/,$(MUTAGEN_RESOURCES ) ) \
3552 $(XCPROJECT ) \
3653 $(PROJECT ) /VPNLib/vpn.pb.swift \
3754 $(PROJECT ) /VPNLib/FileSync/daemon.pb.swift
3855
56+ # Mutagen resources
57+ $(addprefix $(PROJECT ) /Resources/,$(MUTAGEN_RESOURCES ) ) : $(PROJECT ) /Resources/.mutagenversion
58+ curl -sL " https://storage.googleapis.com/coder-desktop/mutagen/$( MUTAGEN_VERSION) /$$ (basename " $@ " )" -o " $@ "
59+ chmod +x " $@ "
60+
3961$(XCPROJECT ) : $(PROJECT ) /project.yml
4062 cd $(PROJECT ) ; \
4163 SWIFT_VERSION=$(SWIFT_VERSION ) \
@@ -113,7 +135,7 @@ lint/actions: ## Lint GitHub Actions
113135 zizmor .
114136
115137.PHONY : clean
116- clean : clean/project clean/keychain clean/build # # Clean project and artifacts
138+ clean : clean/project clean/keychain clean/build clean/mutagen # # Clean project and artifacts
117139
118140.PHONY : clean/project
119141clean/project :
@@ -136,6 +158,10 @@ clean/keychain:
136158clean/build :
137159 rm -rf build/ release/ $$ out
138160
161+ .PHONY : clean/mutagen
162+ clean/mutagen :
163+ find $(PROJECT ) /Resources -name ' mutagen-*' -delete
164+
139165.PHONY : proto
140166proto : $(PROJECT ) /VPNLib/vpn.pb.swift $(PROJECT ) /VPNLib/FileSync/daemon.pb.swift # # Generate Swift files from protobufs
141167
0 commit comments