forked from bazel-xcode/xchammer
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
149 lines (119 loc) · 4.72 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
.PHONY : test workspace release install compile_commands debug run run_force test build build build-release
ROOT_DIR:=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
PRODUCT := xchammer.app
XCHAMMER_APP := $(ROOT_DIR)/bazel-bin/xchammer_archive-root/xchammer.app
XCHAMMER_BIN := $(XCHAMMER_APP)/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-bin/xchammer_config/XCHammer.json \
--bazel $(ROOT_DIR)/tools/bazelwrapper \
--force
workspace_v2:
tools/bazelwrapper build $(BAZEL_OPTS) :workspace_v2 :xchammer_dev
clean:
$(ROOT_DIR)/tools/bazelwrapper clean
release: build-release
# Brew support
install: release
mkdir -p $(PREFIX)/bin
ditto $(XCHAMMER_APP) $(PREFIX)/bin/$(PRODUCT)
ln -s $(PREFIX)/bin/$(PRODUCT)/Contents/MacOS/xchammer $(PREFIX)/bin/xchammer
uninstall:
unlink $(PREFIX)/bin/xchammer
rm -rf $(PREFIX)/bin/$(PRODUCT)
# Note: this is used here to have a dynamic `home` variable, as its idomatic
# to put the cache here with macOS.
BAZEL_CACHE_OPTS=--repository_cache=$(HOME)/Library/Caches/Bazel \
--disk_cache=$(HOME)/Library/Caches/Bazel
build-debug: BAZEL_OPTS=$(BAZEL_CACHE_OPTS)
build-debug: build-impl
build-release: BAZEL_OPTS=$(BAZEL_CACHE_OPTS) \
--compilation_mode opt
build-release: build-impl
build-impl:
$(ROOT_DIR)/tools/bazelwrapper build $(BAZEL_OPTS) :xchammer :xchammer_dist :xchammer_dev
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
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 $(BAZEL_CACHE_OPTS)
# On the CI we always load the deps
run_perf_ci: build
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 $(BAZEL_CACHE_OPTS) \\" > ~/.bazelrc
echo " --spawn_strategy=standalone" >> ~/.bazelrc
format:
$(ROOT_DIR)/tools/bazelwrapper run buildifier
xchammer_config:
tools/bazelwrapper build xchammer_config
update_bazelwrappers:
find sample -name bazelwrapper -exec cp tools/bazelwrapper {} \;