From 676106ba92d8bf4e6caf3fd3e5bc33c0f46f24bc Mon Sep 17 00:00:00 2001 From: Jack Edge Date: Wed, 22 Jun 2016 19:28:55 +0100 Subject: [PATCH] Travis now checks templates --- .travis.yml | 3 ++- _maps/.gitignore | 3 ++- tools/travis/before_build_tools.sh | 8 +++++-- tools/travis/template_dm_generator.py | 30 +++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100755 tools/travis/template_dm_generator.py diff --git a/.travis.yml b/.travis.yml index 0182ca5b97a..3b9aa939f05 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ env: - DM_MAPFILE="dreamstation" - DM_MAPFILE="birdstation" - DM_MAPFILE="efficiencystation" + - DM_MAPFILE="templates" cache: @@ -43,4 +44,4 @@ before_script: script: - tools/travis/check_filedirs.sh tgstation.dme - tools/travis/build_tools.sh - - tools/travis/build_byond.sh \ No newline at end of file + - tools/travis/build_byond.sh diff --git a/_maps/.gitignore b/_maps/.gitignore index dcc0a313b3c..430f3a0b4fa 100644 --- a/_maps/.gitignore +++ b/_maps/.gitignore @@ -1 +1,2 @@ -backup/ \ No newline at end of file +backup/ +templates.dm diff --git a/tools/travis/before_build_tools.sh b/tools/travis/before_build_tools.sh index c475d8e3898..89fc61bfb9d 100755 --- a/tools/travis/before_build_tools.sh +++ b/tools/travis/before_build_tools.sh @@ -1,6 +1,10 @@ #!/bin/bash set -e -if [ "$BUILD_TOOLS" = true ]; then - cd tgui && source ~/.nvm/nvm.sh && npm install && cd .. +if [ "$BUILD_TOOLS" = true ]; then + cd tgui && source ~/.nvm/nvm.sh && npm install && cd .. +fi; + +if [ "$DM_MAPFILE" = "templates" ]; then + python tools/travis/template_dm_generator.py fi; diff --git a/tools/travis/template_dm_generator.py b/tools/travis/template_dm_generator.py new file mode 100755 index 00000000000..89e1d2647d9 --- /dev/null +++ b/tools/travis/template_dm_generator.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +import os +import os.path +import sys + +folders = ["_maps/RandomRuins", "_maps/RandomZLevels", "_maps/shuttles", + "_maps/templates"] + +generated = "_maps/templates.dm" + +template_filenames = [] + +def find_dm(path): + L = [] + for dirpath, dirnames, filenames in os.walk(path): + for name in filenames: + if name.endswith(".dmm"): + s = os.path.join(dirpath, name) + s = s.replace("_maps/","") + L.append(s) + return L + +for folder in folders: + template_filenames.extend(find_dm(folder)) + +with open(generated, 'w') as f: + for template in template_filenames: + f.write('''#include "{}"\n'''.format(template)) +