Commit 74b9f5bf authored by dylan grafmyre's avatar dylan grafmyre
Browse files

"automate" building cubemaps

also got hl2 console to get into the make log however hacky
parent efc4ab67
......@@ -24,3 +24,4 @@ addons/*.gma
*.tar-index
addons/*/
*.bak
*.exe
......@@ -10,11 +10,20 @@ SHLEX_FLAGS?=
#.SHELLFLAGS=-c
GAME?=hl2.exe
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
GAME_DIR?=C:\\Program Files (x86)\\Steam\\steamapps\\common\\GarrysMod\\
VBIN_DIR?=$(GAME_DIR)bin\\
MOD_DIR?=$(GAME_DIR)garrysmod\\
MOUNT_DIR?=.\\
VBIN_FLAGS?=-game "'$(MOD_DIR)'"
# 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)
SUPERVISE_V_BIN?=./contrib/supervise-v
SUPERVISE_V_FLAGS?=--shlex
......@@ -56,22 +65,25 @@ MOUNT_FLAGS?=--mod-dir "'$(MOD_DIR)'"
ifeq ($(GAME),0)
echo "user disabled run game via GAME=0"
else
$(SHLEX_BIN) $(SHLEX_FLAGS) "'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) +mat_specular 1 +ttt_preptime_seconds 3 +ttt_firstpreptime_seconds 3 +gamemode terrortown +ttt_debug_preventwin 1 +ttt_minimum_players 1 +map $(notdir $(basename $^))
$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_PLAY_FLAGS) +map $(notdir $(basename $^))
endif
%.game-mount: addons/%/.mount
ifeq ($(GAME),0)
echo "user disabled run game via GAME=0"
else
$(SHLEX_BIN) $(SHLEX_FLAGS) "'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) +mat_specular 1 +ttt_preptime_seconds 3 +ttt_firstpreptime_seconds 3 +gamemode terrortown +ttt_debug_preventwin 1 +ttt_minimum_players 1 +map $(notdir $(^:/.mount=))
$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_PLAY_FLAGS) +map $(notdir $(^:/.mount=))
endif
%.game-only:
$(SHLEX_BIN) $(SHLEX_FLAGS) "'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) +mat_specular 1 +ttt_preptime_seconds 3 +ttt_firstpreptime_seconds 3 +gamemode terrortown +ttt_debug_preventwin 1 +ttt_minimum_players 1 +map $(notdir $(basename $@))
$(SHLEX_BIN) $(SHLEX_FLAGS) $(SHLEX_HL2LOG_FLAGS) \
"'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) $(GAME_FLAGS) $(GAME_PLAY_FLAGS) +map $(notdir $(basename $@))
maps/%.bsp: %.bsp
cp $^ $@
ln $^ $@
# hammer default flags
%.bsp: %.vmf
......@@ -86,6 +98,7 @@ maps/%.bsp: %.bsp
$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
$(VIS_BIN) -fast $(VBIN_FLAGS) $(basename $^)
$(RAD_BIN) -bounce 2 -noextra $(VBIN_FLAGS) $(basename $^)
ln $(@:_fast.bsp=.vmf) $(@:_fast.bsp=_fast.vmf)
mv $(@:_fast.bsp=.bsp) $@
$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
......@@ -94,6 +107,7 @@ maps/%.bsp: %.bsp
$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
$(VIS_BIN) $(VBIN_FLAGS) $(basename $^)
$(RAD_BIN) -both $(VBIN_FLAGS) $(basename $^)
ln $(@:_hdr.bsp=.vmf) $(@:_hdr.bsp=_hdr.vmf)
mv $(@:_hdr.bsp=.bsp) $@
$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
......@@ -102,19 +116,43 @@ maps/%.bsp: %.bsp
$(BSP_BIN) $(VBIN_FLAGS) $(basename $^)
$(VIS_BIN) $(VBIN_FLAGS) $(basename $^)
$(RAD_BIN) -both -final $(VBIN_FLAGS) $(basename $^)
ln $(@:_hdr_final.bsp=.vmf) $(@:_hdr_final.bsp=_hdr.vmf)
mv $(@:_hdr_final.bsp=.bsp) $@
$(GEN_BSPZIP_ADDLIST_BIN) $(GEN_BSPZIP_ADDLIST_FLAGS) $^ > $(@:.bsp=.bspzip-addlist)
%.cubeldr: %.bsp
$(SHLEX_BIN) $(SHLEX_FLAGS) "'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) \
+mat_specular 0 +map $(notdir $(basename $^)) \
+sv_cheats 1 +buildcubemaps +disconnect +mat_specular 1 +quit
%.cubehdr: %.bsp
$(SHLEX_BIN) $(SHLEX_FLAGS) "'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) \
+mat_specular 0 +map $(notdir $(basename $^)) +lua_openscript helloworld.lua \
+sv_cheats 1 +buildcubemaps +lua_openscript helloworld.lua +disconnect +sv_cheats 0 \
+mat_hdr_level 0 +map $(notdir $(basename $^)) +lua_openscript helloworld.lua \
+sv_cheats 1 +buildcubemaps +lua_openscript helloworld.lua +disconnect +mat_specular 1 +quit
# 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]');"
# only ents works on an existing bsp,
# which are not typically left "in place" for this operation
......
......@@ -15,6 +15,8 @@ LOGGER = logging.getLogger(os.path.basename(__file__))
ARGP = argparse.ArgumentParser()
ARGP.add_argument('--subprocess-shell', '-S', action='store_true')
ARGP.add_argument('--verbose', '-v', action='store_true')
ARGP.add_argument('--tail-bin')
ARGP.add_argument('--tail', help="follow a file while supervising a subprocess")
ARGP.add_argument('remainder', nargs=argparse.REMAINDER)
def main(argp=None, argv=None):
......@@ -43,7 +45,18 @@ def main(argp=None, argv=None):
LOGGER.info('execve: %r', execve)
LOGGER.info('execve_shell: %r', argp.subprocess_shell)
tail_popen = None
if argp.tail:
if not argp.tail_bin:
raise RuntimeError('--tail-bin is required')
if 'CPROGRAMFILESOLD' in argp.tail:
argp.tail = argp.tail.replace('CPROGRAMFILESOLD', 'C:\\program files (x86)')
if 'CPROGRAMFILES' in argp.tail_bin:
argp.tail_bin = argp.tail_bin.replace('CPROGRAMFILES', 'C:\\program files')
tail_popen = subprocess.Popen([argp.tail_bin, '-fn0', argp.tail], stdout=sys.stderr.buffer)
cproc = subprocess.run(execve, shell=argp.subprocess_shell)
if tail_popen:
tail_popen.kill()
LOGGER.info('execve_rc: %r', cproc.returncode)
return cproc.returncode
......
# note, buildcubemaps is hardcodeded-disabled so fuck me a iguess
local function main()
print( "cubeldr:runme:main: buildcubemaps start ..." )
RunConsoleCommand( "buildcubemaps" )
print( "cubeldr:runme:main: buildcubemaps finish ..." )
RunConsoleCommand( "quit" )
end
timer.Simple( 3, main )
function wait(time)
local duration = os.time() + time
while os.time() < duration do end
end
print( "Hello world before" )
print( os.time() )
wait(1000)
print( "Hello world after" )
print( os.time() )
local clock = os.clock
function sleep(n) -- seconds
local t0 = clock()
while clock() - t0 <= n do end
end
-- That way you are overriding the default hook.
-- You can use hook.Add to make more functions get called on initialization.
hook.Add( "Initialize", "some_unique_name", function()
print( "[gmight] Initialization hook called" )
end )
function wait(time)
local duration = os.time() + time
while os.time() < duration do end
end
print( "[gmight] Hello world before" )
print( os.time() )
sleep(1)
print( "[gmight] Hello world after" )
print( os.time() )
local function cubeldr( ply, command, arguments )
print( "[gmight] cubeldr" )
end
local function main()
print( "cubeldr:runme:main: buildcubemaps start ..." )
RunConsoleCommand( "buildcubemaps" )
print( "cubeldr:runme:main: buildcubemaps finish ..." )
RunConsoleCommand( "quit" )
end
timer.Simple( 3, main )
concommand.Add( "lua_cubeldr", cubeldr, nil, "build ldr cubemaps", 0 )
SetKeyDelay, 3130
Sleep, 30000 ; 30 sec
Send, {``}
Sleep, 2000 ; 2 sec
Send, buildcubemaps{Enter}
Sleep, 30000 ; 30 sec
Send, quit{Enter}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment