forked from jpsim/SourceKitten
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
132 lines (99 loc) · 4.32 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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
TEMPORARY_FOLDER?=/tmp/SourceKitten.dst
PREFIX?=/usr/local
BUILD_TOOL?=xcodebuild
XCODEFLAGS=-workspace 'SourceKitten.xcworkspace' \
-scheme 'sourcekitten' \
DSTROOT=$(TEMPORARY_FOLDER) \
OTHER_LDFLAGS=-Wl,-headerpad_max_install_names
SWIFT_BUILD_FLAGS=--configuration release
UNAME=$(shell uname)
ifeq ($(UNAME), Darwin)
USE_SWIFT_STATIC_STDLIB:=$(shell test -d $$(dirname $$(xcrun --find swift))/../lib/swift_static/macosx && echo yes)
ifeq ($(USE_SWIFT_STATIC_STDLIB), yes)
SWIFT_BUILD_FLAGS+= -Xswiftc -static-stdlib
endif
endif
SOURCEKITTEN_EXECUTABLE=$(shell swift build $(SWIFT_BUILD_FLAGS) --show-bin-path)/sourcekitten
FRAMEWORKS_FOLDER=$(PREFIX)/Frameworks
BINARIES_FOLDER=$(PREFIX)/bin
OUTPUT_PACKAGE=SourceKitten.pkg
SOURCEKITTEN_PLIST=Source/sourcekitten/Info.plist
SOURCEKITTENFRAMEWORK_PLIST=Source/SourceKittenFramework/Info.plist
VERSION_STRING=$(shell /usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$(SOURCEKITTEN_PLIST)")
.PHONY: all bootstrap clean install package test uninstall
all: build
bootstrap:
script/bootstrap
test: clean_xcode bootstrap
$(BUILD_TOOL) $(XCODEFLAGS) test
clean:
rm -f "$(OUTPUT_PACKAGE)"
rm -rf "$(TEMPORARY_FOLDER)"
swift package clean
clean_xcode: clean
$(BUILD_TOOL) $(XCODEFLAGS) -configuration Test clean
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 "$(SOURCEKITTEN_EXECUTABLE)" "$(BINARIES_FOLDER)"
uninstall:
rm -rf "$(FRAMEWORKS_FOLDER)/SourceKittenFramework.framework"
rm -f "$(BINARIES_FOLDER)/sourcekitten"
installables: clean build
install -d "$(TEMPORARY_FOLDER)$(BINARIES_FOLDER)"
install "$(SOURCEKITTEN_EXECUTABLE)" "$(TEMPORARY_FOLDER)$(BINARIES_FOLDER)"
prefix_install: clean build_with_disable_sandbox
install -d "$(PREFIX)/bin/"
install "$(SOURCEKITTEN_EXECUTABLE)" "$(PREFIX)/bin/"
package: installables
pkgbuild \
--identifier "com.sourcekitten.SourceKitten" \
--install-location "/" \
--root "$(TEMPORARY_FOLDER)" \
--version "$(VERSION_STRING)" \
"$(OUTPUT_PACKAGE)"
archive:
carthage build --no-skip-current --platform mac
carthage archive SourceKittenFramework Yams SWXMLHash
release: package archive
docker_test:
docker run -v `pwd`:`pwd` -w `pwd` --name sourcekitten --rm swift:5.1 swift test --parallel
docker_htop:
docker run -it --rm --pid=container:sourcekitten terencewestphal/htop || reset
# http://irace.me/swift-profiling/
display_compilation_time:
$(BUILD_TOOL) $(XCODEFLAGS) OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies" clean build-for-testing | grep -E ^[1-9]{1}[0-9]*.[0-9]+ms | sort -n
publish:
brew update && brew bump-formula-pr --tag=$(shell git describe --tags) --revision=$(shell git rev-parse HEAD) sourcekitten
pod trunk push --verbose
update_clang_headers:
rm -rf Source/Clang_C/include
svn export http://llvm.org/svn/llvm-project/cfe/trunk/include/clang-c
mv clang-c Source/Clang_C/include
rm Source/Clang_C/include/module.modulemap
echo '#include "BuildSystem.h"\n#include "CXCompilationDatabase.h"\n#include "CXErrorCode.h"\n#include "CXString.h"\n#include "Documentation.h"\n#include "Index.h"\n#include "Platform.h"' > Source/Clang_C/include/Clang_C.h
sed -i '' "s/^#include \"clang-c\/\(.*\)\"/#include \"\1\"/g" Source/Clang_C/include/*
update_commandant_fixtures: update_commandant_fixtures_macos update_commandant_fixtures_docker
update_commandant_fixtures_macos:
for identifier in org.swift.50120190418a org.swift.5120190905a ; do \
swift package reset ; \
OVERWRITE_FIXTURES=1 xcrun --toolchain $$identifier swift test --filter Commandant ; \
done
update_commandant_fixtures_docker:
for image in swift:5.0 swift:5.1; do \
swift package reset ; \
docker run -t -v `pwd`:`pwd` -w `pwd` --rm $$image env OVERWRITE_FIXTURES=1 swift test --filter Commandant ; \
done
get_version:
@echo $(VERSION_STRING)
set_version:
$(eval NEW_VERSION := $(filter-out $@,$(MAKECMDGOALS)))
@sed -i '' 's/## Master/## $(NEW_VERSION)/g' CHANGELOG.md
@sed 's/__VERSION__/$(NEW_VERSION)/g' script/Version.swift.template > Source/SourceKittenFramework/Version.swift
@/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $(NEW_VERSION)" "$(SOURCEKITTENFRAMEWORK_PLIST)"
@/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $(NEW_VERSION)" "$(SOURCEKITTEN_PLIST)"
%:
@: