forked from bazel-xcode/xchammer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
193 lines (158 loc) · 6.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
.PHONY : test workspace archive install compile_commands debug run run_force test build build build-release
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
PRODUCT := xchammer.app
XCHAMMER_BIN := $(ROOT_DIR)/$(PRODUCT)/Contents/MacOS/XCHammer
PREFIX := /usr/local
# Make an XCHammer XCHammer Xcode project.
# Note: we manually build the XCHammer config here, consider better support to
# build the project DSL within XCHammer directly.
workspace: build
@tools/bazelwrapper build :xchammer_config
$(XCHAMMER_BIN) generate \
bazel-genfiles/xchammer_config/XCHammer.json \
--bazel $(ROOT_DIR)/tools/bazelwrapper \
--force
# Experimental Xcode project generator based on Bazel
workspace_v2:
tools/bazelwrapper build -s :workspace_v2
clean:
$(ROOT_DIR)/tools/bazelwrapper clean
archive: build-release
# Brew support
install: archive
mkdir -p $(PREFIX)/bin
ditto $(PRODUCT) $(PREFIX)/bin/$(PRODUCT)
ln -s $(PREFIX)/bin/$(PRODUCT)/Contents/MacOS/xchammer $(PREFIX)/bin/xchammer
uninstall:
unlink $(PREFIX)/bin/xchammer
rm -rf $(PREFIX)/bin/$(PRODUCT)
build-debug: BAZELFLAGS = --announce_rc \
--disk_cache=$(HOME)/Library/Caches/Bazel
build-debug: build-impl
build-release: BAZELFLAGS = --announce_rc \
--compilation_mode opt \
--disk_cache=$(HOME)/Library/Caches/Bazel
build-release: build-impl
build-impl:
$(ROOT_DIR)/tools/bazelwrapper build \
$(BAZELFLAGS) xchammer
@rm -rf $(ROOT_DIR)/xchammer.app
@unzip -q $(ROOT_DIR)/bazel-bin/xchammer.zip
build: build-debug
test: build
XCHAMMER_BIN=$(XCHAMMER_BIN) SAMPLE=UrlGet $(ROOT_DIR)/IntegrationTests/run_tests.sh
debug: build
# Launches LLDB with XCHammer
# Example usage ( set a breakpoint at a line )
# The run
# br set -f Spec.swift -l 334
# r
lldb $(XCHAMMER_BIN)
# XCHammer Samples
# A sample exemplifies important behavior in XCHammer
#
# Conventions:
# - in the directory sample i.e. sample/UrlGet
# - has an XCHammer.yaml
# - contains a project named after the dir i.e. UrlGet.xcodeproj
# - has bazel and non bazel targets that build.
# - has a bazelwrapper ( a shellscript that runs some bazel )
SAMPLE ?= UrlGet
# Run a debug build of XCHammer against a sample
# Development hack: don't actually install, just symlink the debug build
# See README for usage in a normal project
run: build
$(XCHAMMER_BIN) generate \
$(ROOT_DIR)/sample/$(SAMPLE)/XCHammer.yaml \
--workspace_root $(ROOT_DIR)/sample/$(SAMPLE) \
--bazel $(ROOT_DIR)/sample/$(SAMPLE)/tools/bazelwrapper
# FIXME: add code to handle `xcworkspace` to `run`
run_workspace: build
$(XCHAMMER_BIN) generate \
$(ROOT_DIR)/sample/SnapshotMe/XCHammer.yaml \
--workspace_root $(ROOT_DIR)/sample/SnapshotMe \
--xcworkspace $(ROOT_DIR)/sample/SnapshotMe/SnapshotMe.xcworkspace \
--bazel $(ROOT_DIR)/sample/SnapshotMe/tools/bazelwrapper
run_force: build
$(XCHAMMER_BIN) generate \
$(ROOT_DIR)/sample/$(SAMPLE)/XCHammer.yaml \
--workspace_root $(ROOT_DIR)/sample/$(SAMPLE) \
--bazel $(ROOT_DIR)/sample/$(SAMPLE)/tools/bazelwrapper \
--force
run_perf: build-release
@[[ -d sample/Frankenstein/Vendor/rules_pods ]] \
|| (echo "Run 'make' in sample/Frankenstein" && exit 1)
$(XCHAMMER_BIN) generate \
$(ROOT_DIR)/sample/Frankenstein/XCHammer.yaml \
--workspace_root $(ROOT_DIR)/sample/Frankenstein \
--bazel $(ROOT_DIR)/sample/Frankenstein/tools/bazelwrapper \
--force
# Create golden files from samples.
# Expectations:
# - output is stable. i.e. things don't move around
# - output is reproducible across machines
# TODO: Port Frankenstein to external PodToBUILD before adding it as a
# goldmaster
clean_goldmaster:
@rm -rf IntegrationTests/Goldmaster
@mkdir -p IntegrationTests/Goldmaster
goldmaster_cli:
@for S in $$(ls sample); do \
[[ $$S != "Frankenstein" ]] || continue; \
[[ $$S != "SnapshotMe" ]] || continue; \
SAMPLE=$$S make run_force || exit 1; \
echo "Making goldmaster for $$S"; \
MASTER=IntegrationTests/Goldmaster/$$S/$$S.xcodeproj; \
mkdir -p $$MASTER; \
ditto sample/$$S/$$S.xcodeproj/project.pbxproj $$MASTER/project.pbxproj; \
sed -i '' 's,$(PWD),__PWD__,g' $$MASTER/project.pbxproj; \
sed -i '' 's,XCHAMMER.*,,g' $$MASTER/project.pbxproj; \
ditto sample/$$S/$$S.xcodeproj/xcshareddata/xcschemes $$MASTER/xcshareddata/xcschemes; \
find IntegrationTests/Goldmaster/$$S/ -name *.xcscheme -exec sed -i '' 's,TEMP.*,",g' {} \; ; \
done
goldmaster_bazel:
@for S in $$(ls sample); do \
[[ $$S != "Frankenstein" ]] || continue; \
SAMPLE=$$S make run_force_bazel || exit 1; \
echo "Making goldmaster for $$S"; \
MASTER=IntegrationTests/Goldmaster/$$S/XcodeBazel.xcodeproj; \
mkdir -p $$MASTER; \
ditto sample/$$S/XcodeBazel.xcodeproj/project.pbxproj $$MASTER/project.pbxproj; \
sed -i '' 's,$(PWD),__PWD__,g' $$MASTER/project.pbxproj; \
sed -i '' 's,XCHAMMER.*,,g' $$MASTER/project.pbxproj; \
ditto sample/$$S/XcodeBazel.xcodeproj/xcshareddata/xcschemes $$MASTER/xcshareddata/xcschemes; \
done
goldmaster: clean_goldmaster goldmaster_bazel goldmaster_cli
run_swift: build
$(XCHAMMER_BIN) generate \
$(ROOT_DIR)/sample/Tailor/XCHammer.yaml \
--workspace_root $(ROOT_DIR)/sample/Tailor \
--bazel $(ROOT_DIR)/sample/Tailor/tools/bazelwrapper \
--force
# TODO:
# - currently the Bazel Xcode projects require defining xchammer_resources
# in the workspace. This needs to be resolved ( ideally moved to defining this
# as @xchammer as a bianry release in the WORKSPACE )
# - there seems to be an issue without running without standalone
run_force_bazel: build
cd sample/$(SAMPLE)/ && \
tools/bazelwrapper clean && \
tools/bazelwrapper build -s :XcodeBazel --spawn_strategy=standalone
# On the CI we always load the deps
run_perf_ci:
rm -rf sample/Frankenstein/Vendor/rules_pods
$(MAKE) -C sample/Frankenstein
$(MAKE) run_perf
# On the CI - we stick a .bazelrc into the home directory to control
# how every single bazel build works. ( Any sample get's this )
bazelrc_home:
echo "build --disk_cache=$(HOME)/Library/Caches/Bazel \\" > ~/.bazelrc
echo " --spawn_strategy=standalone" >> ~/.bazelrc
ci: bazelrc_home test run_perf_ci run_swift run_force_bazel goldmaster
format:
$(ROOT_DIR)/tools/bazelwrapper run buildifier
.PHONY:
xchammer_config:
tools/bazelwrapper build xchammer_config
update_bazelwrappers:
find sample -name bazelwrapper -exec cp tools/bazelwrapper {} \;