-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathmakefile
More file actions
261 lines (233 loc) · 9.09 KB
/
Copy pathmakefile
File metadata and controls
261 lines (233 loc) · 9.09 KB
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
#SHELL := /bin/bash
# Version checking
MSBUILD := msbuild
NUGET := nuget
MIN_MONO_VERSION:= "5.18.0"
MONO_VERSION:= $(shell mono --version | awk '/version/ { print $$5 }')
MIN_NUGET_VERSION:= "2.16.0"
NUGET_VERSION:= $(shell $NUGET help 2> /dev/null | awk '/Version:/ { print $$3; exit 0}')
GreaterVersion = $(shell printf '%s\n' $(1) $(2) | sort -t. -k 1,1nr -k 2,2nr -k 3,3nr -k 4,4nr | head -n 1)
PROGRAM_VERSION = $(shell git describe --tags --exact-match 2> /dev/null)
ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
# Directories
DEBUG_DIR := bin_debug
RELEASE_DIR := bin_release
OUTPUT_DIR := $(DEBUG_DIR)
# Final output names
MAC_BUILD_RESULT = macbuild.dmg
LINUX_BUILD_RESULT = linuxbuild.zip
DEBIAN_BUILD_RESULT = debianbuild.deb
# Used output name
ifeq ($(shell uname -s),Darwin)
BUILD_RESULT = $(MAC_BUILD_RESULT)
else
BUILD_RESULT = $(LINUX_BUILD_RESULT)
endif
# Colors
COLOR_BLACK := "\033[1;30m"
COLOR_RED := "\033[1;31m"
COLOR_GREEN := "\033[1;32m"
COLOR_YELLOW := "\033[1;33m"
COLOR_BLUE := "\033[1;34m"
COLOR_MAGENTA := "\033[1;35m"
COLOR_CYAN := "\033[1;36m"
COLOR_WHITE := "\033[1;37m"
COLOR_END := "\033[0m"
# Literal sequences don't work in the info command....
red:=$(shell tput setaf 1)
green:=$(shell tput setaf 2)
blue:=$(shell tput setaf 4)
reset:=$(shell tput sgr0)
.PHONY: all
.PHONY: all-debug
.PHONY: all-release
.PHONY: debug
.PHONY: release
.PHONY: clean
.PHONY: clean-all
.PHONY: openbve
.PHONY: openbve-debug
.PHONY: openbve-release
.PHONY: publish
.PHONY: debian
.PHONY: restore
.PHONY: prequisite-check
restore:
$(NUGET) restore OpenBVE.sln
debug: openbve-debug
release: openbve-release
openbve: openbve-debug
openbve-debug: restore
$(info Building OpenBVE in debug mode....)
$(MSBUILD) /t:OpenBve /p:Configuration=Debug OpenBVE.sln
@cp source/LibRender2/OpenTK.dll.config bin_debug/OpenTK.dll.config
openbve-release: restore
$(info Building OpenBVE in release mode....)
$(MSBUILD) /t:OpenBve /p:Configuration=Release OpenBVE.sln
@cp source/LibRender2/OpenTK.dll.config bin_release/OpenTK.dll.config
all: all-debug
all-debug: restore
$(info Building OpenBVE and developer tools in debug mode....)
$(MSBUILD) /t:build /p:Configuration=Debug OpenBVE.sln
@cp source/LibRender2/OpenTK.dll.config bin_debug/OpenTK.dll.config
all-release: restore
$(info Building OpenBVE and developer tools in release mode....)
$(MSBUILD) /t:build /p:Configuration=Release OpenBVE.sln
@cp source/LibRender2/OpenTK.dll.config bin_release/OpenTK.dll.config
clean-all: clean
clean:
$(info Runing solution clean....)
$(MSBUILD) /t:clean /p:Configuration=Debug OpenBVE.sln
$(MSBUILD) /t:clean /p:Configuration=Release OpenBVE.sln
# Release Files
rm -f $(MAC_BUILD_RESULT) $(LINUX_BUILD_RESULT)
CP_UPDATE_FLAG = -u
CP_RECURSE = -r
ifeq ($(shell uname -s),Darwin)
CP_UPDATE_FLAG =
CP_RECURSE = -R
endif
ifeq ($(shell uname -s),Darwin)
publish: $(MAC_BUILD_RESULT)
else
publish: $(LINUX_BUILD_RESULT)
endif
debian: $(DEBIAN_BUILD_RESULT)
prequisite-check:
#Very basic prequisite check function
ifeq (forky/sid, $(shell cat /etc/debian_version))
# Forky mono seems to need this....
# remove if they actually fix the thing
$$TERM=linux
endif
$(info Checking for prequisite system libraries.)
$(info Checking for Mono....)
ifeq (, $(shell which mono))
$(info Mono does not appear to be installed on this system.)
$(info Please install the $(green)mono-complete$(reset) package provided by your distribution, or the latest version of Mono from $(blue)https://www.mono-project.com/$(reset))
$(error )
endif
$(info Mono Version $(MONO_VERSION) found.)
ifeq "$(call GreaterVersion, $(MONO_VERSION), $(MIN_MONO_VERSION))" "$(MONO_VERSION)"
#Nothing
else
$(info OpenBVE requires a minimum Mono version of 5.20)
$(info Please install the latest version of Mono from $(blue)https://www.mono-project.com/$(reset))
$(error )
endif
$(info Checking for MSBuild....)
ifeq (, $(shell which msbuild))
ifeq (forky/sid, $(shell cat /etc/debian_version))
$(info Debian Forky system- downloading msbuild if required)
ifneq ($(shell test -d packages/MSBuild/15.0/bin && echo 1 || echo 0), 1)
ifneq ($(shell test -f msbuild.zip && echo 1 || echo 0), 1)
$(shell wget https\://download-cdn.jetbrains.com/resharper/JetMSBuild.v15.9.20.62856.zip -O msbuild.zip)
$(info MSBuild downloaded)
endif
endif
# this is horrid, but makefile gets in a twist if output is enabled
$(shell exec > /dev/null 2>&1 unzip -n $(CURDIR)/msbuild.zip -d $(CURDIR)/packages)
$(info wft)
MSBUILD = ./packages/MSBuild/15.0/bin/MSBuild.exe
else
$(info msbuild does not appear to be installed on this system.)
$(info Please either install the $(green)mono-xbuild$(reset) package provided by your distribution, or the latest version of Mono from $(blue)https://www.mono-project.com/$(reset))
$(error )
endif
endif
$(info Checking for nuget....)
ifeq (, $(shell which nuget))
ifeq (forky/sid, $(shell cat /etc/debian_version))
$(info Debian Forky system, downloading nuget if required...)
ifneq ($(shell test -f packages/nuget.exe && echo 1 || echo 0), 1)
$(shell wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -O packages/nuget.exe)
endif
NUGET = ./packages/nuget.exe
else
$(info nuget does not appear to be installed on this system.)
$(info Please either install the $(green)nuget$(reset) package provided by your distribution, or the latest version of Mono from $(blue)https://www.mono-project.com/$(reset))
$(error )
endif
endif
$(info nuget Version $(NUGET_VERSION) found.)
ifeq "$(call GreaterVersion, $(NUGET_VERSION), $(MIN_NUGET_VERSION))" "$(NUGET_VERSION)"
#Nothing
else ifeq ($(strip $(NUGET_VERSION)),)
ifeq (, $(shell which nuget))
$(bash $(NUGET) update)
else
$(info Unable to determine the nuget version installed.)
$(info OpenBVE requires a minimum nuget version of 2.16- The build will fail with versions below this.)
endif
else
ifeq ("$(NUGET) $(nuget.exe))","")
$(shell $(NUGET) update)
else
$(info OpenBVE requires a minimum nuget version of 2.16)
$(info Please run $(red)nuget update -self$(reset) with administrative priveledges.)
$(error )
endif
endif
$(info Attempting to restore nuget packages (This may take a while)....)
$(MAC_BUILD_RESULT): all-release
@rm -rf bin_release/DevTools/
@echo $(COLOR_RED)Decompressing $(COLOR_CYAN)installers/mac/MacBundle.tgz$(COLOR_END)
# Clear previous Mac build temporary files if they exist
@rm -rf mac
@rm -rf macbuild.dmg
@mkdir mac
@tar -C mac -xzf installers/mac/MacBundle.tgz
@./VersionCreator.sh
@echo $(COLOR_RED)Copying build data into $(COLOR_CYAN)OpenBVE.app$(COLOR_END)
@cp -r $(RELEASE_DIR)/* mac/OpenBVE.app/Contents/Resources/
@test -f mac/OpenBVE.app/Contents/Resources/OpenTK.dll.config || (echo "OpenTK.dll.config is missing from the macOS app bundle"; exit 1)
# Because Azure is iffy on MacOS13, let's try a custom script
@echo $(COLOR_RED)Creating $(COLOR_CYAN)$(MAC_BUILD_RESULT)$(COLOR_END)
@./DMGScript.sh
@echo Renaming final output file
ifeq (, $(PROGRAM_VERSION))
@echo This is a $(COLOR_BLUE)Daily build$(COLOR_END)
@echo Final filename: $(COLOR_RED)OpenBVE-$$(date '+%F').dmg$(COLOR_END)
@mv macbuild.dmg OpenBVE-$$(date '+%F').dmg
else
@echo This is a $(COLOR_YELLOW)Tagged Release build$(COLOR_END)
@echo Final filename: $(COLOR_RED)OpenBVE-$(PROGRAM_VERSION).dmg$(COLOR_END)
@mv macbuild.dmg OpenBVE-$(PROGRAM_VERSION).dmg
endif
$(LINUX_BUILD_RESULT): all-release
@rm -rf bin_release/DevTools/
@echo $(COLOR_RED)Compressing $(COLOR_CYAN)$(LINUX_BUILD_RESULT)$(COLOR_END)
@cd $(RELEASE_DIR); zip -qr9Z deflate ../$(LINUX_BUILD_RESULT) *
@echo Renaming final output file
ifeq (, $(PROGRAM_VERSION))
@echo This is a $(COLOR_BLUE)Daily build$(COLOR_END)
@echo Final filename: $(COLOR_RED)OpenBVE-$$(date '+%F').zip$(COLOR_END)
@mv linuxbuild.zip OpenBVE-$$(date '+%F').zip
else
@echo This is a $(COLOR_YELLOW)Tagged Release build$(COLOR_END)
@echo Final filename: $(COLOR_RED)OpenBVE-$(PROGRAM_VERSION).zip$(COLOR_END)
@mv linuxbuild.zip OpenBVE-$(PROGRAM_VERSION).zip
endif
$(DEBIAN_BUILD_RESULT): all-release
@rm -rf bin_release/DevTools/
@echo $(COLOR_RED)Copying build into place....$(COLOR_END)
@mkdir -p installers/debian/usr/lib/openbve
#Generate current dpkg control file
@./VersionCreator.sh
#Mark launch script as executable before packaging
#Also deliberately chmod assets directory to 755- https://github.com/leezer3/OpenBVE/issues/656#issuecomment-865164917
@chmod -R 755 bin_release/Data
@chmod +x installers/debian/usr/games/openbve
@cp -r -f $(CP_UPDATE_FLAG) $(RELEASE_DIR)/* installers/debian/usr/lib/openbve
@echo $(COLOR_RED)Compressing $(COLOR_CYAN)$(DEBIAN_BUILD_RESULT)$(COLOR_END)
@fakeroot dpkg-deb --build installers/debian
@echo Renaming final output file
ifeq (, $(PROGRAM_VERSION))
@echo This is a $(COLOR_BLUE)Daily build$(COLOR_END)
@echo Final filename: $(COLOR_RED)OpenBVE-$$(date '+%F').deb$(COLOR_END)
@mv installers/debian.deb OpenBVE-$$(date '+%F').deb
else
@echo This is a $(COLOR_YELLOW)Tagged Release build$(COLOR_END)
@echo Final filename: $(COLOR_RED)OpenBVE-$(PROGRAM_VERSION).deb$(COLOR_END)
@mv "$(ROOT_DIR)/installers/debian.deb" OpenBVE-$(PROGRAM_VERSION).deb
endif