Ensure required variables are defined before running scripts.
This commit is contained in:
parent
76585aab79
commit
9078ff73c7
19
Makefile
19
Makefile
@ -34,7 +34,20 @@ HAS_LUAC = $(shell command -v luac 2> /dev/null)
|
||||
LUA_FILES = $(shell find mods/*/maps/* -iname '*.lua')
|
||||
PROJECT_DIRS = $(shell dirname $$(find . -iname "*.csproj" -not -path "$(ENGINE_DIRECTORY)/*"))
|
||||
|
||||
engine:
|
||||
variables:
|
||||
@if [ -z "$(MOD_ID)" ] || [ -z "$(ENGINE_DIRECTORY)" ];then \
|
||||
echo "Required mod.config variables are missing:"; \
|
||||
if [ -z "$(MOD_ID)" ]; then \
|
||||
echo " MOD_ID"; \
|
||||
fi; \
|
||||
if [ -z "$(ENGINE_DIRECTORY)" ]; then \
|
||||
echo " ENGINE_DIRECTORY"; \
|
||||
fi; \
|
||||
echo "Repair your mod.config (or user.config) and try again."; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
engine: variables
|
||||
@./fetch-engine.sh || (printf "Unable to continue without engine files\n"; exit 1)
|
||||
@cd $(ENGINE_DIRECTORY) && make core
|
||||
|
||||
@ -60,13 +73,13 @@ endif
|
||||
@cd $(ENGINE_DIRECTORY) && make clean
|
||||
@printf "The engine has been cleaned.\n"
|
||||
|
||||
version:
|
||||
version: variables
|
||||
@awk '{sub("Version:.*$$","Version: $(VERSION)"); print $0}' $(MANIFEST_PATH) > $(MANIFEST_PATH).tmp && \
|
||||
awk '{sub("/[^/]*: User$$", "/$(VERSION): User"); print $0}' $(MANIFEST_PATH).tmp > $(MANIFEST_PATH) && \
|
||||
rm $(MANIFEST_PATH).tmp
|
||||
@printf "Version changed to $(VERSION).\n"
|
||||
|
||||
check-scripts:
|
||||
check-scripts: variables
|
||||
ifeq ("$(HAS_LUAC)","")
|
||||
@printf "'luac' not found.\n" && exit 1
|
||||
endif
|
||||
|
||||
@ -5,6 +5,18 @@
|
||||
command -v curl >/dev/null 2>&1 || { echo >&2 "The OpenRA mod template requires curl."; exit 1; }
|
||||
command -v python >/dev/null 2>&1 || { echo >&2 "The OpenRA mod template requires python."; exit 1; }
|
||||
|
||||
require_variables() {
|
||||
missing=""
|
||||
for i in "$@"; do
|
||||
eval check="\$$i"
|
||||
[ -z "${check}" ] && missing="${missing} ${i}\n"
|
||||
done
|
||||
if [ ! -z "${missing}" ]; then
|
||||
echo "Required mod.config variables are missing:\n${missing}Repair your mod.config (or user.config) and try again."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
TEMPLATE_LAUNCHER=$(python -c "import os; print(os.path.realpath('$0'))")
|
||||
TEMPLATE_ROOT=$(dirname "${TEMPLATE_LAUNCHER}")
|
||||
|
||||
@ -16,6 +28,8 @@ if [ -f "${TEMPLATE_ROOT}/user.config" ]; then
|
||||
. "${TEMPLATE_ROOT}/user.config"
|
||||
fi
|
||||
|
||||
require_variables "MOD_ID" "ENGINE_VERSION" "ENGINE_DIRECTORY"
|
||||
|
||||
CURRENT_ENGINE_VERSION=$(cat "${ENGINE_DIRECTORY}/VERSION" 2> /dev/null)
|
||||
|
||||
if [ -f "${ENGINE_DIRECTORY}/VERSION" ] && [ "${CURRENT_ENGINE_VERSION}" = "${ENGINE_VERSION}" ]; then
|
||||
@ -23,6 +37,8 @@ if [ -f "${ENGINE_DIRECTORY}/VERSION" ] && [ "${CURRENT_ENGINE_VERSION}" = "${EN
|
||||
fi
|
||||
|
||||
if [ "${AUTOMATIC_ENGINE_MANAGEMENT}" = "True" ]; then
|
||||
require_variables "AUTOMATIC_ENGINE_SOURCE" "AUTOMATIC_ENGINE_EXTRACT_DIRECTORY" "AUTOMATIC_ENGINE_TEMP_ARCHIVE_NAME"
|
||||
|
||||
echo "OpenRA engine version ${ENGINE_VERSION} is required."
|
||||
|
||||
if [ -d "${ENGINE_DIRECTORY}" ]; then
|
||||
|
||||
@ -10,12 +10,17 @@ set EnableSingleplayer=False
|
||||
set Password=""
|
||||
|
||||
@echo off
|
||||
setlocal EnableDelayedExpansion
|
||||
|
||||
title %Name%
|
||||
FOR /F "tokens=1,2 delims==" %%A IN (mod.config) DO (set %%A=%%B)
|
||||
if exist user.config (FOR /F "tokens=1,2 delims==" %%A IN (user.config) DO (set %%A=%%B))
|
||||
set MOD_SEARCH_PATHS=%~dp0mods,./mods
|
||||
|
||||
if "!MOD_ID!" == "" goto badconfig
|
||||
if "!ENGINE_VERSION!" == "" goto badconfig
|
||||
if "!ENGINE_DIRECTORY!" == "" goto badconfig
|
||||
|
||||
if not exist %ENGINE_DIRECTORY%\OpenRA.Game.exe goto noengine
|
||||
>nul find %ENGINE_VERSION% %ENGINE_DIRECTORY%\VERSION || goto noengine
|
||||
cd %ENGINE_DIRECTORY%
|
||||
@ -28,4 +33,11 @@ goto loop
|
||||
echo Required engine files not found.
|
||||
echo Run `make all` in the mod directory to fetch and build the required files, then try again.
|
||||
pause
|
||||
exit /b
|
||||
|
||||
:badconfig
|
||||
echo Required mod.config variables are missing.
|
||||
echo Ensure that MOD_ID ENGINE_VERSION and ENGINE_DIRECTORY are
|
||||
echo defined in your mod.config (or user.config) and try again.
|
||||
pause
|
||||
exit /b
|
||||
@ -8,6 +8,18 @@ set -e
|
||||
command -v python >/dev/null 2>&1 || { echo >&2 "The OpenRA mod template requires python."; exit 1; }
|
||||
command -v mono >/dev/null 2>&1 || { echo >&2 "The OpenRA mod template requires mono."; exit 1; }
|
||||
|
||||
require_variables() {
|
||||
missing=""
|
||||
for i in "$@"; do
|
||||
eval check="\$$i"
|
||||
[ -z "${check}" ] && missing="${missing} ${i}\n"
|
||||
done
|
||||
if [ ! -z "${missing}" ]; then
|
||||
echo "Required mod.config variables are missing:\n${missing}Repair your mod.config (or user.config) and try again."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
TEMPLATE_LAUNCHER=$(python -c "import os; print(os.path.realpath('$0'))")
|
||||
TEMPLATE_ROOT=$(dirname "${TEMPLATE_LAUNCHER}")
|
||||
MOD_SEARCH_PATHS="${TEMPLATE_ROOT}/mods,./mods"
|
||||
@ -20,6 +32,8 @@ if [ -f "${TEMPLATE_ROOT}/user.config" ]; then
|
||||
. "${TEMPLATE_ROOT}/user.config"
|
||||
fi
|
||||
|
||||
require_variables "MOD_ID" "ENGINE_VERSION" "ENGINE_DIRECTORY"
|
||||
|
||||
NAME="${Name:-"Dedicated Server"}"
|
||||
LAUNCH_MOD="${Mod:-"${MOD_ID}"}"
|
||||
LISTEN_PORT="${ListenPort:-"1234"}"
|
||||
|
||||
@ -1,10 +1,16 @@
|
||||
@echo off
|
||||
setlocal EnableDelayedExpansion
|
||||
title OpenRA
|
||||
|
||||
FOR /F "tokens=1,2 delims==" %%A IN (mod.config) DO (set %%A=%%B)
|
||||
if exist user.config (FOR /F "tokens=1,2 delims==" %%A IN (user.config) DO (set %%A=%%B))
|
||||
set TEMPLATE_LAUNCHER=%0
|
||||
set MOD_SEARCH_PATHS=%~dp0mods,./mods
|
||||
|
||||
if "!MOD_ID!" == "" goto badconfig
|
||||
if "!ENGINE_VERSION!" == "" goto badconfig
|
||||
if "!ENGINE_DIRECTORY!" == "" goto badconfig
|
||||
|
||||
set TEMPLATE_DIR=%CD%
|
||||
if not exist %ENGINE_DIRECTORY%\OpenRA.Game.exe goto noengine
|
||||
>nul find %ENGINE_VERSION% %ENGINE_DIRECTORY%\VERSION || goto noengine
|
||||
@ -23,6 +29,13 @@ echo Run `make all` in the mod directory to fetch and build the required files,
|
||||
pause
|
||||
exit /b
|
||||
|
||||
:badconfig
|
||||
echo Required mod.config variables are missing.
|
||||
echo Ensure that MOD_ID ENGINE_VERSION and ENGINE_DIRECTORY are
|
||||
echo defined in your mod.config (or user.config) and try again.
|
||||
pause
|
||||
exit /b
|
||||
|
||||
:crashdialog
|
||||
echo ----------------------------------------
|
||||
echo OpenRA has encountered a fatal error.
|
||||
|
||||
@ -4,6 +4,18 @@ set -e
|
||||
command -v python >/dev/null 2>&1 || { echo >&2 "The OpenRA mod template requires python."; exit 1; }
|
||||
command -v mono >/dev/null 2>&1 || { echo >&2 "The OpenRA mod template requires mono."; exit 1; }
|
||||
|
||||
require_variables() {
|
||||
missing=""
|
||||
for i in "$@"; do
|
||||
eval check="\$$i"
|
||||
[ -z "${check}" ] && missing="${missing} ${i}\n"
|
||||
done
|
||||
if [ ! -z "${missing}" ]; then
|
||||
echo "Required mod.config variables are missing:\n${missing}Repair your mod.config (or user.config) and try again."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
TEMPLATE_LAUNCHER=$(python -c "import os; print(os.path.realpath('$0'))")
|
||||
TEMPLATE_ROOT=$(dirname "${TEMPLATE_LAUNCHER}")
|
||||
MOD_SEARCH_PATHS="${TEMPLATE_ROOT}/mods,./mods"
|
||||
@ -16,6 +28,8 @@ if [ -f "${TEMPLATE_ROOT}/user.config" ]; then
|
||||
. "${TEMPLATE_ROOT}/user.config"
|
||||
fi
|
||||
|
||||
require_variables "MOD_ID" "ENGINE_VERSION" "ENGINE_DIRECTORY"
|
||||
|
||||
cd "${TEMPLATE_ROOT}"
|
||||
if [ ! -f "${ENGINE_DIRECTORY}/OpenRA.Game.exe" ] || [ "$(cat "${ENGINE_DIRECTORY}/VERSION")" != "${ENGINE_VERSION}" ]; then
|
||||
echo "Required engine files not found."
|
||||
|
||||
21
make.ps1
21
make.ps1
@ -228,6 +228,27 @@ function ParseConfigFile($fileName)
|
||||
ReadConfigLine $line $name
|
||||
}
|
||||
}
|
||||
|
||||
$missing = @()
|
||||
foreach ($name in $names)
|
||||
{
|
||||
if (!([System.Environment]::GetEnvironmentVariable($name)))
|
||||
{
|
||||
$missing += $name
|
||||
}
|
||||
}
|
||||
|
||||
if ($missing)
|
||||
{
|
||||
echo "Required mod.config variables are missing:"
|
||||
foreach ($m in $missing)
|
||||
{
|
||||
echo " $m"
|
||||
}
|
||||
echo "Repair your mod.config (or user.config) and try again."
|
||||
WaitForInput
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
###############################################################
|
||||
|
||||
@ -7,6 +7,18 @@ command -v python >/dev/null 2>&1 || { echo >&2 "The OpenRA mod template require
|
||||
command -v tar >/dev/null 2>&1 || { echo >&2 "The OpenRA mod template requires tar."; exit 1; }
|
||||
command -v curl >/dev/null 2>&1 || { echo >&2 "The OpenRA mod template requires curl."; exit 1; }
|
||||
|
||||
require_variables() {
|
||||
missing=""
|
||||
for i in "$@"; do
|
||||
eval check="\$$i"
|
||||
[ -z "${check}" ] && missing="${missing} ${i}\n"
|
||||
done
|
||||
if [ ! -z "${missing}" ]; then
|
||||
echo "Required mod.config variables are missing:\n${missing}Repair your mod.config (or user.config) and try again."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
if [ $# -eq "0" ]; then
|
||||
echo "Usage: `basename $0` version [outputdir]"
|
||||
exit 1
|
||||
@ -23,6 +35,10 @@ if [ -f "${TEMPLATE_ROOT}/user.config" ]; then
|
||||
. "${TEMPLATE_ROOT}/user.config"
|
||||
fi
|
||||
|
||||
require_variables "MOD_ID" "ENGINE_DIRECTORY" "PACKAGING_DISPLAY_NAME" "PACKAGING_INSTALLER_NAME" \
|
||||
"PACKAGING_APPIMAGE_DEPENDENCIES_TAG" "PACKAGING_APPIMAGE_DEPENDENCIES_SOURCE" "PACKAGING_APPIMAGE_DEPENDENCIES_TEMP_ARCHIVE_NAME" \
|
||||
"PACKAGING_FAQ_URL"
|
||||
|
||||
TAG="$1"
|
||||
if [ $# -eq "1" ]; then
|
||||
OUTPUTDIR=$(python -c "import os; print(os.path.realpath('.'))")
|
||||
|
||||
@ -6,6 +6,18 @@ command -v make >/dev/null 2>&1 || { echo >&2 "The OpenRA mod template requires
|
||||
command -v python >/dev/null 2>&1 || { echo >&2 "The OpenRA mod template requires python."; exit 1; }
|
||||
command -v curl >/dev/null 2>&1 || { echo >&2 "The OpenRA mod template requires curl."; exit 1; }
|
||||
|
||||
require_variables() {
|
||||
missing=""
|
||||
for i in "$@"; do
|
||||
eval check="\$$i"
|
||||
[ -z "${check}" ] && missing="${missing} ${i}\n"
|
||||
done
|
||||
if [ ! -z "${missing}" ]; then
|
||||
echo "Required mod.config variables are missing:\n${missing}Repair your mod.config (or user.config) and try again."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
if [ $# -eq "0" ]; then
|
||||
echo "Usage: `basename $0` version [outputdir]"
|
||||
exit 1
|
||||
@ -22,6 +34,10 @@ if [ -f "${TEMPLATE_ROOT}/user.config" ]; then
|
||||
. "${TEMPLATE_ROOT}/user.config"
|
||||
fi
|
||||
|
||||
require_variables "MOD_ID" "ENGINE_DIRECTORY" "PACKAGING_DISPLAY_NAME" "PACKAGING_INSTALLER_NAME" \
|
||||
"PACKAGING_OSX_LAUNCHER_TAG" "PACKAGING_OSX_LAUNCHER_SOURCE" "PACKAGING_OSX_LAUNCHER_TEMP_ARCHIVE_NAME" \
|
||||
"PACKAGING_FAQ_URL"
|
||||
|
||||
TAG="$1"
|
||||
if [ $# -eq "1" ]; then
|
||||
OUTPUTDIR=$(python -c "import os; print(os.path.realpath('.'))")
|
||||
|
||||
@ -4,6 +4,18 @@ set -e
|
||||
command -v curl >/dev/null 2>&1 || { echo >&2 "Windows packaging requires curl."; exit 1; }
|
||||
command -v makensis >/dev/null 2>&1 || { echo >&2 "Windows packaging requires makensis."; exit 1; }
|
||||
|
||||
require_variables() {
|
||||
missing=""
|
||||
for i in "$@"; do
|
||||
eval check="\$$i"
|
||||
[ -z "${check}" ] && missing="${missing} ${i}\n"
|
||||
done
|
||||
if [ ! -z "${missing}" ]; then
|
||||
echo "Required mod.config variables are missing:\n${missing}Repair your mod.config (or user.config) and try again."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
if [ $# -eq "0" ]; then
|
||||
echo "Usage: `basename $0` version [outputdir]"
|
||||
exit 1
|
||||
@ -20,6 +32,10 @@ if [ -f "${TEMPLATE_ROOT}/user.config" ]; then
|
||||
. "${TEMPLATE_ROOT}/user.config"
|
||||
fi
|
||||
|
||||
require_variables "MOD_ID" "ENGINE_DIRECTORY" "PACKAGING_DISPLAY_NAME" "PACKAGING_INSTALLER_NAME" \
|
||||
"PACKAGING_WINDOWS_LAUNCHER_NAME" "PACKAGING_WINDOWS_REGISTRY_KEY" "PACKAGING_WINDOWS_INSTALL_DIR_NAME" \
|
||||
"PACKAGING_FAQ_URL" "PACKAGING_WEBSITE_URL" "PACKAGING_AUTHORS"
|
||||
|
||||
TAG="$1"
|
||||
if [ $# -eq "1" ]; then
|
||||
OUTPUTDIR=$(python -c "import os; print(os.path.realpath('.'))")
|
||||
|
||||
12
utility.cmd
12
utility.cmd
@ -1,9 +1,14 @@
|
||||
@echo off
|
||||
setlocal EnableDelayedExpansion
|
||||
|
||||
FOR /F "tokens=1,2 delims==" %%A IN (mod.config) DO (set %%A=%%B)
|
||||
if exist user.config (FOR /F "tokens=1,2 delims==" %%A IN (user.config) DO (set %%A=%%B))
|
||||
set MOD_SEARCH_PATHS=%~dp0mods,./mods
|
||||
|
||||
if "!MOD_ID!" == "" goto badconfig
|
||||
if "!ENGINE_VERSION!" == "" goto badconfig
|
||||
if "!ENGINE_DIRECTORY!" == "" goto badconfig
|
||||
|
||||
title OpenRA.Utility.exe %MOD_ID%
|
||||
|
||||
set TEMPLATE_DIR=%CD%
|
||||
@ -32,4 +37,11 @@ goto loop
|
||||
echo Required engine files not found.
|
||||
echo Run `make all` in the mod directory to fetch and build the required files, then try again.
|
||||
pause
|
||||
exit /b
|
||||
|
||||
:badconfig
|
||||
echo Required mod.config variables are missing.
|
||||
echo Ensure that MOD_ID ENGINE_VERSION and ENGINE_DIRECTORY are
|
||||
echo defined in your mod.config (or user.config) and try again.
|
||||
pause
|
||||
exit /b
|
||||
14
utility.sh
14
utility.sh
@ -8,6 +8,18 @@ command -v make >/dev/null 2>&1 || { echo >&2 "The OpenRA mod template requires
|
||||
command -v python >/dev/null 2>&1 || { echo >&2 "The OpenRA mod template requires python."; exit 1; }
|
||||
command -v mono >/dev/null 2>&1 || { echo >&2 "The OpenRA mod template requires mono."; exit 1; }
|
||||
|
||||
require_variables() {
|
||||
missing=""
|
||||
for i in "$@"; do
|
||||
eval check="\$$i"
|
||||
[ -z "${check}" ] && missing="${missing} ${i}\n"
|
||||
done
|
||||
if [ ! -z "${missing}" ]; then
|
||||
echo "Required mod.config variables are missing:\n${missing}Repair your mod.config (or user.config) and try again."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
TEMPLATE_LAUNCHER=$(python -c "import os; print(os.path.realpath('$0'))")
|
||||
TEMPLATE_ROOT=$(dirname "${TEMPLATE_LAUNCHER}")
|
||||
MOD_SEARCH_PATHS="${TEMPLATE_ROOT}/mods,./mods"
|
||||
@ -20,6 +32,8 @@ if [ -f "${TEMPLATE_ROOT}/user.config" ]; then
|
||||
. "${TEMPLATE_ROOT}/user.config"
|
||||
fi
|
||||
|
||||
require_variables "MOD_ID" "ENGINE_VERSION" "ENGINE_DIRECTORY"
|
||||
|
||||
LAUNCH_MOD="${Mod:-"${MOD_ID}"}"
|
||||
|
||||
cd "${TEMPLATE_ROOT}"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user