Makefile 8.66 KB
Newer Older
dylan grafmyre's avatar
dylan grafmyre committed
1
.SECONDARY:
dylan grafmyre's avatar
dylan grafmyre committed
2
#
dylan grafmyre's avatar
dylan grafmyre committed
3
PROJECT_DIR?=C:\\hammer\ttt_terrorcon
dylan grafmyre's avatar
dylan grafmyre committed
4
5

PYTHON_BIN?=./env/scripts/python
6
7
8
SHLEX_BIN?=./contrib/shlex
SHLEX_FLAGS?=

dylan grafmyre's avatar
dylan grafmyre committed
9
10
#SHELL=C:\\Program\ Files\\Git\\bin\\bash.exe
#.SHELLFLAGS=-c
11
12

GAME?=hl2.exe
dylan grafmyre's avatar
dylan grafmyre committed
13
14
15
16
17
CONSOLE_LOG?=garrysmod/console.log

GAME_TTT_FLAGS?=+ttt_preptime_seconds 3 +ttt_firstpreptime_seconds 3 +gamemode terrortown +ttt_debug_preventwin 1
GAME_PLAY_FLAGS?=+mat_specular 1 +mat_hdr_level 2 $(GAME_TTT_FLAGS)
GAME_FLAGS?=-condebug
18
GAME_DIR?=C:\\Program Files (x86)\\Steam\\steamapps\\common\\GarrysMod\\
dylan grafmyre's avatar
snap    
dylan grafmyre committed
19
20
VBIN_DIR?=$(GAME_DIR)bin\\
MOD_DIR?=$(GAME_DIR)garrysmod\\
dylan grafmyre's avatar
dylan grafmyre committed
21
MOUNT_DIR?=.\\
22
VBIN_FLAGS?=-game "'$(MOD_DIR)'"
dylan grafmyre's avatar
dylan grafmyre committed
23
24
25
26
	# windows is insufferable
	# ALL bins have a space in the name and NO WINDOWS SHELL
	# can handle bins with spaces in the name, WTF
SHLEX_HL2LOG_FLAGS?=--tail-bin CPROGRAMFILES/Git/usr/bin/tail.exe  --tail CPROGRAMFILESOLD\\steam\\steamapps\\common\\garrysmod\\$(CONSOLE_LOG)
dylan grafmyre's avatar
dylan grafmyre committed
27

dylan grafmyre's avatar
dylan grafmyre committed
28
SUPERVISE_V_BIN?=./contrib/supervise-v
29
30
SUPERVISE_V_FLAGS?=--shlex
BSP_BIN?=$(SUPERVISE_V_BIN) $(SUPERVISE_V_FLAGS) "'$(VBIN_DIR)vbsp.exe'"
dylan grafmyre's avatar
dylan grafmyre committed
31
BSP_FLAGS?=$(VBIN_FLAGS)
32
VIS_BIN?=$(SUPERVISE_V_BIN) $(SUPERVISE_V_FLAGS) "'$(VBIN_DIR)vvis.exe'"
dylan grafmyre's avatar
dylan grafmyre committed
33
VIS_FLAGS?=$(VBIN_FLAGS) -fast
34
RAD_BIN?=$(SUPERVISE_V_BIN) $(SUPERVISE_V_FLAGS) "'$(VBIN_DIR)vrad.exe'"
dylan grafmyre's avatar
dylan grafmyre committed
35
RAD_FLAGS?=$(VBIN_FLAGS) -StaticPropLighting -bounce 2 -noextra
36
# -StaticPropSampleScale 0.25
37
BSPZIP_BIN?=$(SUPERVISE_V_BIN) $(SUPERVISE_V_FLAGS) "'$(VBIN_DIR)bspzip.exe'"
38
BSPZIP_FLAGS?=$(VBIN_FLAGS)
39
GMAD_BIN?="$(VBIN_DIR)gmad.exe"
Dylan Grafmyre's avatar
Dylan Grafmyre committed
40
GMAD_FLAGS?=
dylan grafmyre's avatar
dylan grafmyre committed
41
42
GMPUBLISH_BIN?="'$(VBIN_DIR)gmpublish.exe'"
GMPUBLISH_FLAGS?="update -id 2600874638"  # or "create"
dylan grafmyre's avatar
dylan grafmyre committed
43

dylan grafmyre's avatar
snap    
dylan grafmyre committed
44
GEN_BSPZIP_ADDLIST_BIN?=$(PYTHON_BIN) ./contrib/gen-bspzip-addlist
45
GEN_BSPZIP_ADDLIST_FLAGS?=--pack-used-local
dylan grafmyre's avatar
dylan grafmyre committed
46
47
GMA_INSTALL_BSPZIP_ADDLIST_BIN?=$(PYTHON_BIN) ./contrib/gma-install-bspzip-addlist
GMA_INSTALL_BSPZIP_ADDLIST_FLAGS?=
48

dylan grafmyre's avatar
snap    
dylan grafmyre committed
49
50
51
J2_BIN?=$(PYTHON_BIN) ./contrib/j2
J2_FLAGS?=

dylan grafmyre's avatar
dylan grafmyre committed
52
53
GMAD_TAR_BIN?=$(PYTHON_BIN) ./contrib/gmad-tar
GMAD_TAR_FLAGS?=
54
55
MOUNT_BIN?=$(PYTHON_BIN) ./contrib/mount
MOUNT_FLAGS?=--mod-dir "'$(MOD_DIR)'"
dylan grafmyre's avatar
dylan grafmyre committed
56
57

%_p.bsp: %.bsp
58
	$(BSPZIP_BIN) -addlist $^ $(^:.bsp=.bspzip-addlist) $@ $(BSPZIP_FLAGS)
59
	cp $@ $(MOUNT_DIR)maps\\$(notdir $@)
dylan grafmyre's avatar
dylan grafmyre committed
60

61
62
63
%.bspzip-addlist: %.vmf
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $@

dylan grafmyre's avatar
dylan grafmyre committed
64
%.game: %.bsp
dylan grafmyre's avatar
snap    
dylan grafmyre committed
65
ifeq ($(GAME),0)
dylan grafmyre's avatar
dylan grafmyre committed
66
	echo "user disabled run game via GAME=0"
dylan grafmyre's avatar
snap    
dylan grafmyre committed
67
else
dylan grafmyre's avatar
dylan grafmyre committed
68
69
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_PLAY_FLAGS) +map $(notdir $(basename $^))
dylan grafmyre's avatar
snap    
dylan grafmyre committed
70
endif
dylan grafmyre's avatar
dylan grafmyre committed
71

dylan grafmyre's avatar
dylan grafmyre committed
72
73
74
75
%.game-mount: addons/%/.mount
ifeq ($(GAME),0)
	echo "user disabled run game via GAME=0"
else
dylan grafmyre's avatar
dylan grafmyre committed
76
77
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_PLAY_FLAGS) +map $(notdir $(^:/.mount=))
dylan grafmyre's avatar
dylan grafmyre committed
78
79
endif

80
%.game-only:
dylan grafmyre's avatar
dylan grafmyre committed
81
82
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_PLAY_FLAGS) +map $(notdir $(basename $@))
83

dylan grafmyre's avatar
dylan grafmyre committed
84

dylan grafmyre's avatar
snap    
dylan grafmyre committed
85
maps/%.bsp: %.bsp
dylan grafmyre's avatar
dylan grafmyre committed
86
	ln $^ $@
dylan grafmyre's avatar
dylan grafmyre committed
87
88

# hammer default flags
dylan grafmyre's avatar
snap    
dylan grafmyre committed
89
%.bsp: %.vmf
dylan grafmyre's avatar
dylan grafmyre committed
90
91
92
93
	# default
	$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
	$(VIS_BIN) $(VBIN_FLAGS) $(basename $^)
	$(RAD_BIN) $(VBIN_FLAGS) $(basename $^)
94
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
95
96
97
98
99

%_fast.bsp: %.vmf
	# fast
	$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
	$(VIS_BIN) -fast $(VBIN_FLAGS) $(basename $^)
100
	$(RAD_BIN) -bounce 2 -noextra $(VBIN_FLAGS) $(basename $^)
dylan grafmyre's avatar
dylan grafmyre committed
101
	ln $(@:_fast.bsp=.vmf) $(@:_fast.bsp=_fast.vmf)
dylan grafmyre's avatar
dylan grafmyre committed
102
	mv  $(@:_fast.bsp=.bsp) $@
103
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
104
105
106
107
108
109

%_hdr.bsp: %.vmf
	# hdr
	$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
	$(VIS_BIN) $(VBIN_FLAGS) $(basename $^)
	$(RAD_BIN) -both $(VBIN_FLAGS) $(basename $^)
dylan grafmyre's avatar
dylan grafmyre committed
110
	ln $(@:_hdr.bsp=.vmf) $(@:_hdr.bsp=_hdr.vmf)
dylan grafmyre's avatar
dylan grafmyre committed
111
	mv $(@:_hdr.bsp=.bsp) $@
112
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
113
114
115
116
117
118

%_hdr_final.bsp: %.vmf
	# hdr-final
	$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
	$(VIS_BIN) $(VBIN_FLAGS) $(basename $^)
	$(RAD_BIN) -both -final $(VBIN_FLAGS) $(basename $^)
dylan grafmyre's avatar
dylan grafmyre committed
119
	ln $(@:_hdr_final.bsp=.vmf) $(@:_hdr_final.bsp=_hdr.vmf)
dylan grafmyre's avatar
dylan grafmyre committed
120
	mv $(@:_hdr_final.bsp=.bsp) $@
121
	$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
dylan grafmyre's avatar
dylan grafmyre committed
122

dylan grafmyre's avatar
dylan grafmyre committed
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
#	note, most of the console is blocked
#	https://wiki.facepunch.com/gmod/Blocked_ConCommands
#	see workarounds/
#	note, lua scripts do not use cfg/mount.cfg like other hl2 engine mod content
# example run lua on bsp
#	ln -f lua/cubeldr.lua "$(MOD_DIR)/lua/autorun/runme.lua"
#	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
#		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_TTT_FLAGS) +sv_cheats 1 \
#		+map $(notdir $(basename $^))
#	rm "$(MOD_DIR)/lua/autorun/runme.lua"

%.cubeldr: %.bsp 
	./workarounds/buildcubemaps.exe &
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_TTT_FLAGS) +sv_cheats 1 \
		+mat_specular 0 +map $(notdir $(basename $^))

%.cubehdr: %.bsp %.cubeldr
	./workarounds/buildcubemaps.exe &
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_TTT_FLAGS) +sv_cheats 1 \
		+mat_specular 0 +mat_hdr_level 0 +map $(notdir $(basename $^))

%.mapedit: %.bsp
	# compile map from vmf
	# open vmf in hammer
	# open bsp in game via map_edit
	# wait
	# flush via hammer_update_entity
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
		"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_TTT_FLAGS) \
		+sv_cheats 1 +map_edit $(notdir $(basename $^))
		+lua_run "print('manual tasks: [hammer_update_entity, quit]');"
dylan grafmyre's avatar
dylan grafmyre committed
156

dylan grafmyre's avatar
dylan grafmyre committed
157
158
159
160
161
162
# only ents works on an existing bsp,
# which are not typically left "in place" for this operation
#%_ents.bsp: %.vmf
#	# only-ents
#	$(BSP_BIN) -onlyents $(VBIN_FLAGS) $(basename $^)
#	mv $(@:_ents.bsp=.bsp) $@
Dylan Grafmyre's avatar
Dylan Grafmyre committed
163

dylan grafmyre's avatar
snap    
dylan grafmyre committed
164
165

# create gma files for publishing
166
# testing requirest then extracting the gma and mounting it via
dylan grafmyre's avatar
snap    
dylan grafmyre committed
167
# Garrysmod/garrysmod/cfg/mount.cfg
dylan grafmyre's avatar
dylan grafmyre committed
168
169
#
# todo: pack bsp-zip list with gma instead (non _p variants? only)
dylan grafmyre's avatar
snap    
dylan grafmyre committed
170
171
#
	#$(J2_BIN) $(J2_FLAGS) <addons-src/512x512.vmt.j2 $(basename $^).vmt >addons-src/materials/vgui/maps/menu_thumb_$(basename $^).vmt
dylan grafmyre's avatar
snap    
dylan grafmyre committed
172
	#$(J2_BIN) $(J2_FLAGS) <addons-src/maps/template.res.j2 $(basename $(word 1, $^)) >addons-src/maps/$(basename $(word 1, $^)).res
dylan grafmyre's avatar
snap    
dylan grafmyre committed
173
174
175
176
	#cp addons-src/512x512.vtf addons-src/materials/vgui/maps/menu_thumb_$(basename $^).vtf
	#cp addons-src/128x128.png addons-src/maps/thumb/$(basename $^).png
	#	addons-src/materials/vgui/maps/*.vmt
	#	addons-src/materials/vgui/maps/*.vtf
dylan grafmyre's avatar
snap    
dylan grafmyre committed
177
	# 	addons-src/maps/*.res
dylan grafmyre's avatar
dylan grafmyre committed
178
	# $(GMAD_BIN) $(GMAD_FLAGS) create -folder "addons-src" -out "$@"
dylan grafmyre's avatar
snap    
dylan grafmyre committed
179
addons/%.gma: %.bsp addons-src/addon.json
dylan grafmyre's avatar
snap    
dylan grafmyre committed
180
181
	rm -rv \
		addons-src/maps/*.bsp \
dylan grafmyre's avatar
snap    
dylan grafmyre committed
182
		addons-src/maps/thumb/*.png \
dylan grafmyre's avatar
snap    
dylan grafmyre committed
183
		|| true
dylan grafmyre's avatar
snap    
dylan grafmyre committed
184
	cp $(word 1, $^) addons-src/maps/
dylan grafmyre's avatar
dylan grafmyre committed
185
	cp thumbnail_map_128.png addons-src/maps/thumb/$(basename $(word 1, $^)).png
dylan grafmyre's avatar
dylan grafmyre committed
186
	$(GMA_INSTALL_BSPZIP_ADDLIST_BIN) $(GMA_INSTALL_BSPZIP_ADDLIST_FLAGS) --bspzip-addlist $(basename $(word 1, $^)).bspzip-addlist --dst-prefix addons-src
dylan grafmyre's avatar
dylan grafmyre committed
187
	$(GMAD_TAR_BIN) addons-src/ --output-tar $(@:.gma=.tar) --tar-prefix $(basename $(word 1, $^)) --gmad-bin $(GMAD_BIN) --output-gma $@ --output-index $(@:.gma=.tar-index) --output-digest $(@:.gma=.tar-sha1sums)
dylan grafmyre's avatar
snap    
dylan grafmyre committed
188

dylan grafmyre's avatar
snap    
dylan grafmyre committed
189
190
191
192
193
194
195
addons/%/.d: addons/%.gma
	tar -C addons -xvf $(^:.gma=.tar)
	touch $@

addons/%: addons/%/.d
	true

dylan grafmyre's avatar
dylan grafmyre committed
196
197
198
199
mount:
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(MOUNT_BIN) $(MOUNT_FLAGS)

mount-dev:
dylan grafmyre's avatar
dylan grafmyre committed
200
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(MOUNT_BIN) $(MOUNT_FLAGS) --set-mount ttt_terrorcon "'$(PROJECT_DIR)'" --normpath
dylan grafmyre's avatar
dylan grafmyre committed
201
202

addons/%/.mount: addons/%/.d
dylan grafmyre's avatar
dylan grafmyre committed
203
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(MOUNT_BIN) $(MOUNT_FLAGS) --set-mount ttt_terrorcon "'$(PROJECT_DIR)\\$(basename $@)'" --normpath
dylan grafmyre's avatar
dylan grafmyre committed
204

dylan grafmyre's avatar
snap    
dylan grafmyre committed
205
206
207
208
209
210
# garrysmod refuses to load gma files untill after thier published and live
# so no use trying to test them
#.PHONY: install-addons
#
#install-addons:
#	cp -var addons/*.gma $(MOD_DIR)/addons/
dylan grafmyre's avatar
snap    
dylan grafmyre committed
211

dylan grafmyre's avatar
dylan grafmyre committed
212
publish: addons/ttt_terrorcon_v2_hdr_final.gma
213
	$(SHLEX_BIN) $(SHLEX_FLAGS) $(GMPUBLISH_BIN) $(GMPUBLISH_FLAGS) -icon "'C:\\hammer\\ttt_terrorcon\\addons\\512x512.jpg'" -addon "$^"
dylan grafmyre's avatar
dylan grafmyre committed
214

dylan grafmyre's avatar
dylan grafmyre committed
215
216
217
218

# custom rules

.DEFAULT: all
219
all: lint maps/ttt_terrorcon_v2_hdr_final.bsp addons/ttt_terrorcon_v2_hdr_final.gma ttt_terrorcon_v2_hdr_final.game
dylan grafmyre's avatar
dylan grafmyre committed
220
221
fast: lint maps/ttt_terrorcon_v2_fast.bsp ttt_terrorcon_v2_fast.game

222
install-bsp: maps/ttt_terrorcon_v2_hdr_final.bsp maps/thumb/ttt_terrorcon_v2_hdr_final.png
dylan grafmyre's avatar
dylan grafmyre committed
223
224
225
	cp -v $(word 1, $^) $(MOD_DIR)maps\\
	cp -v $(word 2, $^) $(MOD_DIR)maps\\thumb\\

dylan grafmyre's avatar
snap    
dylan grafmyre committed
226
# gmod dosn't allow mounting gma files
dylan grafmyre's avatar
dylan grafmyre committed
227
# so instead, i've got a parallel artifact being built that can be installed to garrysmod
dylan grafmyre's avatar
snap    
dylan grafmyre committed
228
# tar files are produced, these can be extracted and added as a garrysmod mount to test
dylan grafmyre's avatar
dylan grafmyre committed
229
230
#install-gma: addons/ttt_terrocon_v2_hdr_final_p.gma
#	cp -v $^ $(MOD_DIR)addons\\
Dylan Grafmyre's avatar
Dylan Grafmyre committed
231

dylan grafmyre's avatar
dylan grafmyre committed
232
lint: ttt_terrorcon_v2.bspzip-addlist
dylan grafmyre's avatar
dylan grafmyre committed
233
	$(PYTHON_BIN) ./contrib/bspzip-lint $^ 2>&1 | tee $^.lint