Skip to content

Commit

Permalink
ModSDK update including Linux install support
Browse files Browse the repository at this point in the history
  • Loading branch information
SoScared committed May 6, 2018
1 parent ef98aae commit 1af1d53
Show file tree
Hide file tree
Showing 28 changed files with 477 additions and 69 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ deploy:
- build/${PACKAGING_INSTALLER_NAME}-${TRAVIS_TAG}.exe
- build/${PACKAGING_INSTALLER_NAME}-${TRAVIS_TAG}-macOS.zip
- build/${PACKAGING_INSTALLER_NAME}-${TRAVIS_TAG}-winportable.zip
- build/${PACKAGING_INSTALLER_NAME}-${TRAVIS_TAG}.AppImage
skip_cleanup: true
on:
tags: true
26 changes: 17 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@
VERSION = $(shell git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || echo git-`git rev-parse --short HEAD`)
MOD_ID = $(shell cat user.config mod.config 2> /dev/null | awk -F= '/MOD_ID/ { print $$2; exit }')
ENGINE_DIRECTORY = $(shell cat user.config mod.config 2> /dev/null | awk -F= '/ENGINE_DIRECTORY/ { print $$2; exit }')
INCLUDE_DEFAULT_MODS = $(shell cat user.config mod.config 2> /dev/null | awk -F= '/INCLUDE_DEFAULT_MODS/ { print $$2; exit }')

MOD_SEARCH_PATHS = "$(shell python -c "import os; print(os.path.realpath('.'))")/mods"
ifeq ($(INCLUDE_DEFAULT_MODS),"True")
MOD_SEARCH_PATHS := "$(MOD_SEARCH_PATHS),./mods"
endif
MOD_SEARCH_PATHS = "$(shell python -c "import os; print(os.path.realpath('.'))")/mods,./mods"

MANIFEST_PATH = "mods/$(MOD_ID)/mod.yaml"

Expand All @@ -39,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

Expand All @@ -65,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
Expand Down
17 changes: 17 additions & 0 deletions fetch-engine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@
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}")

Expand All @@ -16,13 +29,17 @@ 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
exit 0
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
Expand Down
17 changes: 13 additions & 4 deletions launch-dedicated.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ 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

set MOD_SEARCH_PATHS=%~dp0mods
if %INCLUDE_DEFAULT_MODS% neq "True" goto start
set MOD_SEARCH_PATHS=%MOD_SEARCH_PATHS%,./mods
if "!MOD_ID!" == "" goto badconfig
if "!ENGINE_VERSION!" == "" goto badconfig
if "!ENGINE_DIRECTORY!" == "" goto badconfig

:start
if not exist %ENGINE_DIRECTORY%\OpenRA.Game.exe goto noengine
>nul find %ENGINE_VERSION% %ENGINE_DIRECTORY%\VERSION || goto noengine
cd %ENGINE_DIRECTORY%

:loop
Expand All @@ -31,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
20 changes: 15 additions & 5 deletions launch-dedicated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,21 @@ 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"

# shellcheck source=mod.config
. "${TEMPLATE_ROOT}/mod.config"
Expand All @@ -19,10 +32,7 @@ if [ -f "${TEMPLATE_ROOT}/user.config" ]; then
. "${TEMPLATE_ROOT}/user.config"
fi

MOD_SEARCH_PATHS="${TEMPLATE_ROOT}/mods"
if [ "${INCLUDE_DEFAULT_MODS}" = "True" ]; then
MOD_SEARCH_PATHS="${MOD_SEARCH_PATHS},./mods"
fi
require_variables "MOD_ID" "ENGINE_VERSION" "ENGINE_DIRECTORY"

NAME="${Name:-"Dedicated Server"}"
LAUNCH_MOD="${Mod:-"${MOD_ID}"}"
Expand All @@ -33,7 +43,7 @@ ENABLE_SINGLE_PLAYER="${EnableSingleplayer:-"False"}"
PASSWORD="${Password:-""}"

cd "${TEMPLATE_ROOT}"
if [ ! -f "${ENGINE_DIRECTORY}/OpenRA.Game.exe" ]; then
if [ ! -f "${ENGINE_DIRECTORY}/OpenRA.Game.exe" ] || [ "$(cat "${ENGINE_DIRECTORY}/VERSION")" != "${ENGINE_VERSION}" ]; then
echo "Required engine files not found."
echo "Run \`make\` in the mod directory to fetch and build the required files, then try again.";
exit 1
Expand Down
22 changes: 16 additions & 6 deletions launch-game.cmd
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
@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
if %INCLUDE_DEFAULT_MODS% neq "True" goto launch
set MOD_SEARCH_PATHS=%MOD_SEARCH_PATHS%,./mods
set MOD_SEARCH_PATHS=%~dp0mods,./mods

if "!MOD_ID!" == "" goto badconfig
if "!ENGINE_VERSION!" == "" goto badconfig
if "!ENGINE_DIRECTORY!" == "" goto badconfig

:launch
set TEMPLATE_DIR=%CD%
if not exist %ENGINE_DIRECTORY%\OpenRA.Game.exe goto noengine

>nul find %ENGINE_VERSION% %ENGINE_DIRECTORY%\VERSION || goto noengine
cd %ENGINE_DIRECTORY%

OpenRA.Game.exe Game.Mod=%MOD_ID% Engine.LaunchPath="%TEMPLATE_LAUNCHER%" "Engine.ModSearchPaths=%MOD_SEARCH_PATHS%" "%*"
set ERROR=%errorlevel%
cd %TEMPLATE_DIR%
Expand All @@ -26,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.
Expand Down
20 changes: 15 additions & 5 deletions launch-game.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,21 @@ 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"

# shellcheck source=mod.config
. "${TEMPLATE_ROOT}/mod.config"
Expand All @@ -15,13 +28,10 @@ if [ -f "${TEMPLATE_ROOT}/user.config" ]; then
. "${TEMPLATE_ROOT}/user.config"
fi

MOD_SEARCH_PATHS="${TEMPLATE_ROOT}/mods"
if [ "${INCLUDE_DEFAULT_MODS}" = "True" ]; then
MOD_SEARCH_PATHS="${MOD_SEARCH_PATHS},./mods"
fi
require_variables "MOD_ID" "ENGINE_VERSION" "ENGINE_DIRECTORY"

cd "${TEMPLATE_ROOT}"
if [ ! -f "${ENGINE_DIRECTORY}/OpenRA.Game.exe" ]; then
if [ ! -f "${ENGINE_DIRECTORY}/OpenRA.Game.exe" ] || [ "$(cat "${ENGINE_DIRECTORY}/VERSION")" != "${ENGINE_VERSION}" ]; then
echo "Required engine files not found."
echo "Run \`make\` in the mod directory to fetch and build the required files, then try again.";
exit 1
Expand Down
29 changes: 23 additions & 6 deletions make.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ function ReadConfigLine($line, $name)

function ParseConfigFile($fileName)
{
$names = @("MOD_ID", "INCLUDE_DEFAULT_MODS", "ENGINE_VERSION", "AUTOMATIC_ENGINE_MANAGEMENT", "AUTOMATIC_ENGINE_SOURCE",
$names = @("MOD_ID", "ENGINE_VERSION", "AUTOMATIC_ENGINE_MANAGEMENT", "AUTOMATIC_ENGINE_SOURCE",
"AUTOMATIC_ENGINE_EXTRACT_DIRECTORY", "AUTOMATIC_ENGINE_TEMP_ARCHIVE_NAME", "ENGINE_DIRECTORY")

$reader = [System.IO.File]::OpenText($fileName)
Expand All @@ -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
}
}

###############################################################
Expand Down Expand Up @@ -272,11 +293,7 @@ if (Test-Path "user.config")

$modID = $env:MOD_ID

$env:MOD_SEARCH_PATHS = (Get-Item -Path ".\" -Verbose).FullName + "\mods"
if ($env:INCLUDE_DEFAULT_MODS -eq "True")
{
$env:MOD_SEARCH_PATHS = $env:MOD_SEARCH_PATHS + ",./mods"
}
$env:MOD_SEARCH_PATHS = (Get-Item -Path ".\" -Verbose).FullName + "\mods,./mods"

# Run the same command on the engine's make file
if ($command -eq "all" -or $command -eq "clean")
Expand Down
27 changes: 18 additions & 9 deletions mod.config
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@
MOD_ID="ura"

# The OpenRA engine version to use for this project.
ENGINE_VERSION="39aa1a9"

# Enable this to make the default OpenRA mods available for use in your mod.yaml
# Packages list (via $mod references). Accepts values "True" or "False".
# WARNING: This setting is provided to simplify early project development,
# and must be disabled before you can package installers for your project!
INCLUDE_DEFAULT_MODS="False"
ENGINE_VERSION="3febae1"

##############################################################################
# Continuous Integration
Expand All @@ -30,7 +24,7 @@ TRAVIS_TEST_MOD="True"

# Perform a dry run of the installer generation when a new commit is pushed to the GitHub repository
# Accepts values "True" or "False".
TRAVIS_TEST_PACKAGING="False"
TRAVIS_TEST_PACKAGING="True"

##############################################################################
# Packaging
Expand All @@ -41,6 +35,7 @@ TRAVIS_TEST_PACKAGING="False"
# The prefix used for the installer filenames.
# - Windows installers will be named as {PACKAGING_INSTALLER_NAME}-{TAG}.exe
# - macOS installers will be named as {PACKAGING_INSTALLER_NAME}-{TAG}.zip
# - Linux .appimages will be named as {PACKAGING_INSTALLER_NAME}-${TAG}.AppImage
PACKAGING_INSTALLER_NAME="RedAlertUnplugged"

# The human-readable name for this project.
Expand All @@ -53,14 +48,15 @@ PACKAGING_INSTALLER_NAME="RedAlertUnplugged"
# - Windows start menu
# - Windows desktop shortcut
# - Windows "Programs and Features" list
# - Linux launcher shortcut
PACKAGING_DISPLAY_NAME="Red Alert Unplugged"

# The URL for the project homepage.
# This is used in:
# - Windows "Add/Remove Programs" list
PACKAGING_WEBSITE_URL="https://github.com/RAunplugged/uRA/wiki"

# The URL that is opened when a player presses the "FAQ" button in the crash dialog.
# The URL that is displayed in the crash dialog.
PACKAGING_FAQ_URL="http://wiki.openra.net/FAQ"

# The human-readable project authors.
Expand All @@ -81,6 +77,13 @@ PACKAGING_WINDOWS_INSTALL_DIR_NAME="Red Alert Unplugged"
# This should not contain spaces or special characters.
PACKAGING_WINDOWS_REGISTRY_KEY="RedAlertUnplugged"

# The git tag to use for the AppImage dependencies.
PACKAGING_APPIMAGE_DEPENDENCIES_TAG="20180408"

# Space delimited list of additional files/directories to copy from the engine directory
# when packaging your mod. e.g. "./mods/modcontent" or "./mods/d2k/OpenRA.Mods.D2k.dll"
PACKAGING_COPY_ENGINE_FILES="./mods/modcontent"

##############################################################################
# Advanced Configuration
#
Expand All @@ -105,3 +108,9 @@ PACKAGING_OSX_LAUNCHER_SOURCE="https://github.com/OpenRA/OpenRALauncherOSX/relea

# Temporary file name used when downloading the OpenRA macOS launcher files.
PACKAGING_OSX_LAUNCHER_TEMP_ARCHIVE_NAME="launcher.zip"

# The url to download the OpenRA AppImage dependencies.
PACKAGING_APPIMAGE_DEPENDENCIES_SOURCE="https://github.com/OpenRA/AppImageSupport/releases/download/${PACKAGING_APPIMAGE_DEPENDENCIES_TAG}/libs.tar.bz2"

# Temporary file name used when downloading the OpenRA AppImage dependencies.
PACKAGING_APPIMAGE_DEPENDENCIES_TEMP_ARCHIVE_NAME="libs.tar.bz2"
Loading

0 comments on commit 1af1d53

Please sign in to comment.