-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
executable file
·118 lines (89 loc) · 4.08 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
TEMPORARY_FOLDER?=/tmp/StringsLint.dst
PREFIX?=/usr/local
BUILD_TOOL?=xcodebuild
XCODEFLAGS=-workspace 'StringsLint.xcworkspace' \
-scheme 'stringslint' \
DSTROOT=$(TEMPORARY_FOLDER) \
OTHER_LDFLAGS=-Wl,-headerpad_max_install_names
SWIFT_BUILD_FLAGS=--configuration release --arch arm64 --arch x86_64 -Xlinker -dead_strip
STRINGSLINT_EXECUTABLE=$(shell swift build $(SWIFT_BUILD_FLAGS) --show-bin-path)/stringslint
TSAN_LIB=$(subst bin/swift,lib/swift/clang/lib/darwin/libclang_rt.tsan_osx_dynamic.dylib,$(shell xcrun --find swift))
TSAN_SWIFT_BUILD_FLAGS=-Xswiftc -sanitize=thread
TSAN_TEST_BUNDLE=$(shell swift build $(TSAN_SWIFT_BUILD_FLAGS) --show-bin-path)/StringsLintPackageTests.xctest
TSAN_XCTEST=$(shell xcrun --find xctest)
FRAMEWORKS_FOLDER=/Library/Frameworks
BINARIES_FOLDER=/usr/local/bin
LICENSE_PATH="$(shell pwd)/LICENSE"
OUTPUT_PACKAGE=StringsLint.pkg
STRINGSLINT_PLIST=Sources/StringsLint/Supporting Files/Info.plist
STRINGSLINTFRAMEWORK_PLIST=Sources/StringsLintFramework/Supporting Files/Info.plist
#VERSION_STRING=$(shell /usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$(STRINGSLINT_PLIST)")
VERSION_STRING=$(shell ./script/get-version)
.PHONY: all clean build install package test uninstall
all: build
sourcery: Tests/LinuxMain.swift
Tests/LinuxMain.swift: Tests/*/*.swift .sourcery/LinuxMain.stencil
sourcery --sources Tests --exclude-sources Tests/StringsLintFrameworkTests/Resources --templates .sourcery/LinuxMain.stencil --output .sourcery --force-parse generated
mv .sourcery/LinuxMain.generated.swift Tests/LinuxMain.swift
clean:
rm -f "$(OUTPUT_PACKAGE)"
rm -rf "$(TEMPORARY_FOLDER)"
rm -f "./portable_swiftlint.zip"
swift package clean
clean_xcode: clean
$(BUILD_TOOL) $(XCODEFLAGS) -configuration Test clean
test: clean_xcode
$(BUILD_TOOL) $(XCODEFLAGS) test
test_tsan:
swift build --build-tests $(TSAN_SWIFT_BUILD_FLAGS)
DYLD_INSERT_LIBRARIES=$(TSAN_LIB) $(TSAN_XCTEST) $(TSAN_TEST_BUNDLE)
build:
swift build $(SWIFT_BUILD_FLAGS)
build_with_disable_sandbox:
swift build --disable-sandbox $(SWIFT_BUILD_FLAGS)
install: clean build
install -d "$(BINARIES_FOLDER)"
install "$(STRINGSLINT_EXECUTABLE)" "$(BINARIES_FOLDER)"
uninstall:
rm -rf "$(FRAMEWORKS_FOLDER)/StringsLintFramework.framework"
rm -f "$(BINARIES_FOLDER)/stringslint"
installables: build
install -d "$(TEMPORARY_FOLDER)$(BINARIES_FOLDER)"
install "$(STRINGSLINT_EXECUTABLE)" "$(TEMPORARY_FOLDER)$(BINARIES_FOLDER)"
prefix_install: clean build_with_disable_sandbox
install -d "$(PREFIX)/bin/"
install "$(STRINGSLINT_EXECUTABLE)" "$(PREFIX)/bin/"
portable_zip: installables
cp -f "$(TEMPORARY_FOLDER)$(BINARIES_FOLDER)/stringslint" "$(TEMPORARY_FOLDER)"
cp -f "$(LICENSE_PATH)" "$(TEMPORARY_FOLDER)"
(cd "$(TEMPORARY_FOLDER)"; zip -yr - "stringslint" "LICENSE") > "./portable_stringslint.zip"
package: installables
pkgbuild \
--identifier "com.alessandrocalzavara.stringslint" \
--install-location "/" \
--root "$(TEMPORARY_FOLDER)" \
--version "$(VERSION_STRING)" \
"$(OUTPUT_PACKAGE)"
release: package portable_zip
publish:
#brew update && brew bump-formula-pr --tag=$(shell git describe --tags) --revision=$(shell git rev-parse HEAD) stringslint
pod trunk push StringsLint.podspec
get_version:
@echo $(VERSION_STRING)
# make push_version <VERSION>: <NAME>
push_version:
ifneq ($(strip $(shell git status --untracked-files=no --porcelain 2>/dev/null)),)
$(error git state is not clean)
endif
$(eval NEW_VERSION_AND_NAME := $(filter-out $@,$(MAKECMDGOALS)))
$(eval NEW_VERSION := $(shell echo $(NEW_VERSION_AND_NAME) | sed 's/:.*//' ))
@sed -i '' 's/## Master/## $(NEW_VERSION_AND_NAME)/g' CHANGELOG.md
@sed 's/__VERSION__/$(NEW_VERSION)/g' script/Version.swift.template > Sources/StringsLintFramework/Models/Version.swift
@/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $(NEW_VERSION)" "$(STRINGSLINTFRAMEWORK_PLIST)"
@/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $(NEW_VERSION)" "$(STRINGSLINT_PLIST)"
git commit -a -m "release $(NEW_VERSION)"
git tag -a $(NEW_VERSION) -m "$(NEW_VERSION_AND_NAME)"
git push origin master
git push origin $(NEW_VERSION)
%:
@: