Upcoming Gitlab Maintenance - May 25 - 03:30 UTC (2 hours)

Commit e3fa0c8e authored by dylan grafmyre's avatar dylan grafmyre
Browse files

tools to pack/test gma files

parent 4cef3985
......@@ -33,6 +33,8 @@ GMPUBLISH_FLAGS?=
GEN_BSPZIP_ADDLIST_BIN?=$(PYTHON_BIN) ./contrib/gen-bspzip-addlist
GEN_BSPZIP_ADDLIST_FLAGS?=--pack-used-local
GMA_INSTALL_BSPZIP_ADDLIST_BIN?=$(PYTHON_BIN) ./contrib/gma-install-bspzip-addlist
GMA_INSTALL_BSPZIP_ADDLIST_FLAGS?=
J2_BIN?=$(PYTHON_BIN) ./contrib/j2
J2_FLAGS?=
......@@ -56,6 +58,13 @@ else
$(SHLEX_BIN) $(SHLEX_FLAGS) "'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) +map $(notdir $(basename $^)) +gamemode terrortown +ttt_debug_preventwin 1 +ttt_preptime_seconds 10 +ttt_minimum_players 1
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) +map $(notdir $(^:/.mount=)) +gamemode terrortown +ttt_debug_preventwin 1 +ttt_preptime_seconds 10 +ttt_minimum_players 1
endif
%.game-only:
$(SHLEX_BIN) $(SHLEX_FLAGS) "'$(GAME_DIR)$(GAME)'" -allowdebug $(VBIN_FLAGS) +map $(notdir $(basename $@)) +gamemode terrortown +ttt_debug_preventwin 1 +ttt_preptime_seconds 10 +ttt_minimum_players 1
......@@ -124,6 +133,7 @@ addons/%.gma: %.bsp addons-src/addon.json
|| true
cp $(word 1, $^) addons-src/maps/
cp thumbnail_map_128.png addons-src/maps/thumb/$(basename $(word 1, $^)).png
$(GMA_INSTALL_BSPZIP_ADDLIST_BIN) $(GMA_INSTALL_BSPZIP_ADDLIST_FLAGS) --bspzip-addlist $(basename $(word 1, $^)).bspzip-addlist --dst-prefix addons-src
$(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)
addons/%/.d: addons/%.gma
......@@ -137,10 +147,10 @@ mount:
$(SHLEX_BIN) $(SHLEX_FLAGS) $(MOUNT_BIN) $(MOUNT_FLAGS)
mount-dev:
$(SHLEX_BIN) $(SHLEX_FLAGS) $(MOUNT_BIN) $(MOUNT_FLAGS) --mod-dir "'$(MOD_DIR)'" --set-mount ttt_terrorcon "'$(PROJECT_DIR)'" --normpath
$(SHLEX_BIN) $(SHLEX_FLAGS) $(MOUNT_BIN) $(MOUNT_FLAGS) --set-mount ttt_terrorcon "'$(PROJECT_DIR)'" --normpath
addons/%/.mount: addons/%/.d
$(SHLEX_BIN) $(SHLEX_FLAGS) $(MOUNT_BIN) $(MOUNT_FLAGS) --mod-dir "'$(MOD_DIR)'" --set-mount ttt_terrorcon "'$(PROJECT_DIR)\\$(basename $@)'" --normpath
$(SHLEX_BIN) $(SHLEX_FLAGS) $(MOUNT_BIN) $(MOUNT_FLAGS) --set-mount ttt_terrorcon "'$(PROJECT_DIR)\\$(basename $@)'" --normpath
# garrysmod refuses to load gma files untill after thier published and live
# so no use trying to test them
......
#!/usr/bin/env python3
import argparse
import os
import logging
import sys
import collections
import shutil
LOGGER = logging.getLogger(os.path.basename(__file__))
def file_type(*args, **kwargs):
def _(name):
if name == '-':
if 'w' in args[0]:
return sys.stdout.buffer
if 'r' in args[0]:
return sys.stdin.buffer
try:
fh = open(name, *args, **kwargs)
return fh
except Exception as err:
LOGGER.exception('%r', err)
raise
return _
ARGP = argparse.ArgumentParser()
ARGP.add_argument('--bspzip-addlist', type=argparse.FileType())
ARGP.add_argument('--src-prefix', default='.')
ARGP.add_argument('--dst-prefix', required=True)
class BspzipAddlistItem(collections.namedtuple('BaseScrDest', ['src', 'dst'])):
@classmethod
def new_from_bspzip_addlist_iter(cls, file_):
src = None
dst = None
while True:
src = file_.readline()
if not src:
break
dst = file_.readline()
yield cls(src.rstrip('\n'), dst.rstrip('\n'))
def copyfile(src, dst):
os.makedirs(os.path.dirname(dst), exist_ok=True)
return shutil.copy(src, dst)
def main(argp=None, argv=None):
if argp is None:
argp = ARGP.parse_args()
logging.basicConfig(level=logging.INFO)
for item in BspzipAddlistItem.new_from_bspzip_addlist_iter(argp.bspzip_addlist):
src = os.path.normpath(os.path.join(argp.src_prefix, item.src))
dst = os.path.normpath(os.path.join(argp.dst_prefix, item.dst))
LOGGER.info('copy: %r -> %r', src, dst)
copyfile(src, dst)
if __name__ == "__main__":
exit(main())
......@@ -113,7 +113,7 @@ def main_set_mount(argp):
nbytes = fh.write(mbuf)
fh.truncate()
fh.flush()
LOGGER.info('wrote %r', nbytes)
LOGGER.info('wrote %r to %r', nbytes, fh.name)
def del_mount(buf, name):
......
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