From 58103b4bdbc4968ac15477361c9643241c1d536f Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 24 Jan 2021 13:17:18 +0000 Subject: [PATCH] Update scripts, packaging, and example mod for playtest-20201213. --- .github/workflows/ci.yaml | 51 +++ .github/workflows/packaging.yml | 94 +++++ .travis.yml | 51 --- Makefile | 61 ++-- .../OpenRA.Mods.Example.csproj | 13 +- launch-dedicated.cmd | 4 +- launch-dedicated.sh | 2 +- launch-game.cmd | 4 +- launch-game.sh | 4 +- make.ps1 | 61 ++-- mod.config | 59 ++-- mods/example/audio/notifications.yaml | 1 + mods/example/mod.yaml | 8 +- packaging/linux/buildpackage.sh | 147 ++++---- packaging/linux/include/AppRun.in | 34 -- packaging/linux/include/gtk-dialog.py | 48 --- packaging/linux/include/mod-mimeinfo.xml.in | 8 - packaging/linux/include/mod-server.in | 6 - packaging/linux/include/mod-utility.in | 5 - packaging/linux/include/mod.desktop.in | 11 - packaging/linux/include/mod.in | 54 --- packaging/macos/buildpackage.sh | 332 ++++++++++-------- packaging/macos/entitlements.plist | 16 - packaging/windows/buildpackage.nsi | 65 ++-- packaging/windows/buildpackage.sh | 97 ++--- utility.cmd | 8 +- utility.sh | 4 +- 27 files changed, 580 insertions(+), 668 deletions(-) create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/packaging.yml delete mode 100644 .travis.yml delete mode 100755 packaging/linux/include/AppRun.in delete mode 100644 packaging/linux/include/gtk-dialog.py delete mode 100644 packaging/linux/include/mod-mimeinfo.xml.in delete mode 100755 packaging/linux/include/mod-server.in delete mode 100755 packaging/linux/include/mod-utility.in delete mode 100644 packaging/linux/include/mod.desktop.in delete mode 100755 packaging/linux/include/mod.in delete mode 100644 packaging/macos/entitlements.plist diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..60b304705 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,51 @@ +name: Continuous Integration + +on: + push: + pull_request: + +jobs: + linux-mono: + name: Linux (mono) + runs-on: ubuntu-20.04 + + steps: + - name: Clone Repository + uses: actions/checkout@v2 + + - name: Prepare Environment + run: | + . mod.config; + awk '/\r$$/ { exit(1); }' mod.config || (printf "Invalid mod.config format. File must be saved using unix-style (LF, not CRLF or CR) line endings.\n"; exit 1); + + - name: Check Code + run: | + make check + make check-packaging-scripts + + - name: Check Mod + run: | + sudo apt-get install lua5.1 + make check-scripts + make test + + windows: + name: Windows (Framework 4.7) + runs-on: windows-2019 + + steps: + - name: Clone Repository + uses: actions/checkout@v2 + + - name: Check Code + shell: powershell + run: | + dotnet nuget locals all --clear + .\make.ps1 check + + - name: Check Mods + run: | + chocolatey install lua --version 5.1.5.52 + $ENV:Path = $ENV:Path + ";C:\Program Files (x86)\Lua\5.1\" + .\make.ps1 check-scripts + .\make.ps1 test diff --git a/.github/workflows/packaging.yml b/.github/workflows/packaging.yml new file mode 100644 index 000000000..dd8290550 --- /dev/null +++ b/.github/workflows/packaging.yml @@ -0,0 +1,94 @@ +name: Release Packaging + +on: + push: + tags: + - '*' + +jobs: + linux: + name: Linux AppImages + runs-on: ubuntu-20.04 + + steps: + - name: Clone Repository + uses: actions/checkout@v2 + + - name: Prepare Environment + run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> ${GITHUB_ENV} + + - name: Package AppImage + run: | + make engine + mkdir -p build/linux + ./packaging/linux/buildpackage.sh "${GIT_TAG}" "${PWD}/build/linux" + + - name: Upload Packages + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref }} + overwrite: true + file_glob: true + file: build/linux/* + + macos: + name: macOS Disk Images + runs-on: macos-10.15 + + steps: + - name: Clone Repository + uses: actions/checkout@v2 + + - name: Prepare Environment + run: echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> ${GITHUB_ENV} + + - name: Package Disk Images + env: + MACOS_DEVELOPER_IDENTITY: ${{ secrets.MACOS_DEVELOPER_IDENTITY }} + MACOS_DEVELOPER_CERTIFICATE_BASE64: ${{ secrets.MACOS_DEVELOPER_CERTIFICATE_BASE64 }} + MACOS_DEVELOPER_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_DEVELOPER_CERTIFICATE_PASSWORD }} + MACOS_DEVELOPER_USERNAME: ${{ secrets.MACOS_DEVELOPER_USERNAME }} + MACOS_DEVELOPER_PASSWORD: ${{ secrets.MACOS_DEVELOPER_PASSWORD }} + run: | + make engine + mkdir -p build/macos + ./packaging/macos/buildpackage.sh "${GIT_TAG}" "${PWD}/build/macos" + + - name: Upload Packages + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref }} + overwrite: true + file_glob: true + file: build/macos/* + + windows: + name: Windows Installers + runs-on: ubuntu-20.04 + + steps: + - name: Clone Repository + uses: actions/checkout@v2 + + - name: Prepare Environment + run: | + echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> ${GITHUB_ENV} + sudo apt-get update + sudo apt-get install nsis + + - name: Package Installers + run: | + make engine + mkdir -p build/windows + ./packaging/windows/buildpackage.sh "${GIT_TAG}" "${PWD}/build/windows" + + - name: Upload Packages + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref }} + overwrite: true + file_glob: true + file: build/windows/* diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6cf0d72bc..000000000 --- a/.travis.yml +++ /dev/null @@ -1,51 +0,0 @@ -# Travis-CI Build for OpenRAModSDK -# see travis-ci.org for details - -language: csharp -mono: 6.4.0 - -jobs: - include: - - os: linux - dist: xenial - - os: osx - if: tag IS present - osx_image: xcode10 - -addons: - apt: - packages: - - dpkg - - liblua5.1-0 - - imagemagick - -script: - - make - - | - . mod.config; - awk '/\r$$/ { exit(1); }' mod.config || (printf "Invalid mod.config format. File must be saved using unix-style (LF, not CRLF or CR) line endings.\n"; travis_terminate 1); - if [ "${TRAVIS_TEST_MOD}" == "True" ]; then - make test || travis_terminate 1; - fi; - if [ "${TRAVIS_OS_NAME}" == "linux" ] && ( [ "${TRAVIS_TEST_PACKAGING}" == "True" ] || [ -n "${TRAVIS_TAG}" ] ); then - wget https://mirrors.edge.kernel.org/ubuntu/pool/universe/n/nsis/nsis-common_3.04-1_all.deb || travis_terminate 1; - wget https://mirrors.edge.kernel.org/ubuntu/pool/universe/n/nsis/nsis_3.04-1_amd64.deb || travis_terminate 1; - sudo dpkg -i nsis-common_3.04-1_all.deb || travis_terminate 1; - sudo dpkg -i nsis_3.04-1_amd64.deb || travis_terminate 1; - fi - if [ "${TRAVIS_OS_NAME}" == "linux" ] && [ "${TRAVIS_TEST_PACKAGING}" == "True" ] && [ -z "${TRAVIS_TAG}" ]; then - make check-packaging-scripts && ./packaging/package-all.sh test-0 || travis_terminate 1; - fi - -before_deploy: - - mkdir build - - make check-packaging-scripts && cd build && ../packaging/package-all.sh ${TRAVIS_TAG} ${PWD} && cd .. - -deploy: - provider: releases - api_key: ${GH_DEPLOY_API_KEY} - file_glob: true - file: build/* - skip_cleanup: true - on: - tags: true diff --git a/Makefile b/Makefile index dae1cc2af..5a9dcb686 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ # make check-sdk-scripts # make check-packaging-scripts -.PHONY: utility stylecheck build clean engine version check check-scripts check-sdk-scripts check-packaging-scripts check-variables +.PHONY: check-sdk-scripts check-packaging-scripts check-variables engine all clean version check-scripts check test .DEFAULT_GOAL := all PYTHON = $(shell command -v python3 2> /dev/null) @@ -48,8 +48,19 @@ MOD_SOLUTION_FILES = $(shell find . -maxdepth 1 -iname '*.sln' 2> /dev/null) MSBUILD = msbuild -verbosity:m -nologo -# Enable 32 bit builds while generating the windows installer -WIN32 = false +ifndef TARGETPLATFORM +UNAME_S := $(shell uname -s) +UNAME_M := $(shell uname -m) +ifeq ($(UNAME_S),Darwin) +TARGETPLATFORM = osx-x64 +else +ifeq ($(UNAME_M),x86_64) +TARGETPLATFORM = linux-x64 +else +TARGETPLATFORM = unix-generic +endif +endif +endif check-sdk-scripts: @awk '/\r$$/ { exit(1); }' mod.config || (printf "Invalid mod.config format: file must be saved using unix-style (CR, not CRLF) line endings.\n"; exit 1) @@ -110,43 +121,25 @@ check-variables: exit 1; \ fi -engine-dependencies: check-variables check-sdk-scripts - @./fetch-engine.sh || (printf "Unable to continue without engine files\n"; exit 1) - @cd $(ENGINE_DIRECTORY) && make dependencies WIN32=$(WIN32) - engine: check-variables check-sdk-scripts @./fetch-engine.sh || (printf "Unable to continue without engine files\n"; exit 1) - @cd $(ENGINE_DIRECTORY) && make core WIN32=$(WIN32) - -utility: engine-dependencies engine - @test -f "$(ENGINE_DIRECTORY)/OpenRA.Utility.exe" || (printf "OpenRA.Utility.exe not found!\n"; exit 1) + @cd $(ENGINE_DIRECTORY) && make TARGETPLATFORM=$(TARGETPLATFORM) all -core: - @command -v $(MSBUILD) >/dev/null || (echo "OpenRA requires the '$(MSBUILD)' tool provided by Mono >= 5.4."; exit 1) +all: engine + @command -v $(MSBUILD) >/dev/null || (echo "OpenRA requires the '$(MSBUILD)' tool provided by Mono >= 5.18."; exit 1) ifneq ("$(MOD_SOLUTION_FILES)","") - @find . -maxdepth 1 -name '*.sln' -exec $(MSBUILD) -t:restore \; -ifeq ($(WIN32), $(filter $(WIN32),true yes y on 1)) - @find . -maxdepth 1 -name '*.sln' -exec $(MSBUILD) -t:build -p:Configuration="Release-x86" \; -else - @$(MSBUILD) -t:build -p:Configuration=Release - @find . -maxdepth 1 -name '*.sln' -exec $(MSBUILD) -t:build -p:Configuration=Release \; + @find . -maxdepth 1 -name '*.sln' -exec $(MSBUILD) -t:Build -restore -p:Configuration=Release -p:TargetPlatform=$(TARGETPLATFORM) \; endif -endif - -all: engine-dependencies engine core clean: engine - @command -v $(MSBUILD) >/dev/null || (echo "OpenRA requires the '$(MSBUILD)' tool provided by Mono >= 5.4."; exit 1) + @command -v $(MSBUILD) >/dev/null || (echo "OpenRA requires the '$(MSBUILD)' tool provided by Mono >= 5.18."; exit 1) ifneq ("$(MOD_SOLUTION_FILES)","") @find . -maxdepth 1 -name '*.sln' -exec $(MSBUILD) -t:clean \; endif @cd $(ENGINE_DIRECTORY) && make clean - @printf "The engine has been cleaned.\n" version: check-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 + @sh -c '. $(ENGINE_DIRECTORY)/packaging/functions.sh; set_mod_version $(VERSION) $(MANIFEST_PATH)' @printf "Version changed to $(VERSION).\n" check-scripts: check-variables @@ -159,18 +152,18 @@ ifneq ("$(LUA_FILES)","") @luac -p $(LUA_FILES) endif -check: utility +check: engine ifneq ("$(MOD_SOLUTION_FILES)","") @echo "Compiling in debug mode..." - @$(MSBUILD) -t:build -p:Configuration=Debug + @find . -maxdepth 1 -name '*.sln' -exec $(MSBUILD) -t:Build -restore -p:Configuration=Debug -p:TargetPlatform=$(TARGETPLATFORM) \; endif @echo "Checking runtime assemblies..." - @MOD_SEARCH_PATHS="$(MOD_SEARCH_PATHS)" mono --debug "$(ENGINE_DIRECTORY)/OpenRA.Utility.exe" $(MOD_ID) --check-runtime-assemblies $(WHITELISTED_OPENRA_ASSEMBLIES) $(WHITELISTED_THIRDPARTY_ASSEMBLIES) $(WHITELISTED_CORE_ASSEMBLIES) $(WHITELISTED_MOD_ASSEMBLIES) + @./utility.sh --check-runtime-assemblies $(WHITELISTED_OPENRA_ASSEMBLIES) $(WHITELISTED_THIRDPARTY_ASSEMBLIES) $(WHITELISTED_CORE_ASSEMBLIES) $(WHITELISTED_MOD_ASSEMBLIES) @echo "Checking for explicit interface violations..." - @MOD_SEARCH_PATHS="$(MOD_SEARCH_PATHS)" mono --debug "$(ENGINE_DIRECTORY)/OpenRA.Utility.exe" $(MOD_ID) --check-explicit-interfaces + @./utility.sh --check-explicit-interfaces @echo "Checking for incorrect conditional trait interface overrides..." - @MOD_SEARCH_PATHS="$(MOD_SEARCH_PATHS)" mono --debug "$(ENGINE_DIRECTORY)/OpenRA.Utility.exe" $(MOD_ID) --check-conditional-trait-interface-overrides + @./utility.sh --check-conditional-trait-interface-overrides -test: utility +test: all @echo "Testing $(MOD_ID) mod MiniYAML..." - @MOD_SEARCH_PATHS="$(MOD_SEARCH_PATHS)" mono --debug "$(ENGINE_DIRECTORY)/OpenRA.Utility.exe" $(MOD_ID) --check-yaml + @./utility.sh --check-yaml diff --git a/OpenRA.Mods.Example/OpenRA.Mods.Example.csproj b/OpenRA.Mods.Example/OpenRA.Mods.Example.csproj index ee8afb653..a788688ca 100644 --- a/OpenRA.Mods.Example/OpenRA.Mods.Example.csproj +++ b/OpenRA.Mods.Example/OpenRA.Mods.Example.csproj @@ -1,12 +1,12 @@ - net461 + net472 true true - 5 + 7.3 true true - ../mods/example + ../engine/bin false AnyCPU false @@ -21,10 +21,6 @@ false - - ../engine/thirdparty/download/Eluant.dll - False - False @@ -32,6 +28,7 @@ False + @@ -40,4 +37,4 @@ - \ No newline at end of file + diff --git a/launch-dedicated.cmd b/launch-dedicated.cmd index 694d1b410..0434cf99f 100644 --- a/launch-dedicated.cmd +++ b/launch-dedicated.cmd @@ -28,12 +28,12 @@ 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 +if not exist %ENGINE_DIRECTORY%\bin\OpenRA.exe goto noengine >nul find %ENGINE_VERSION% %ENGINE_DIRECTORY%\VERSION || goto noengine cd %ENGINE_DIRECTORY% :loop -OpenRA.Server.exe Game.Mod=%MOD_ID% Server.Name=%Name% Server.ListenPort=%ListenPort% Server.AdvertiseOnline=%AdvertiseOnline% Server.EnableSingleplayer=%EnableSingleplayer% Server.Password=%Password% Server.RequireAuthentication=%RequireAuthentication% Server.ProfileIDBlacklist=%ProfileIDBlacklist% Server.ProfileIDWhitelist=%ProfileIDWhitelist% Server.EnableSyncReports=%EnableSyncReports% Server.EnableGeoIP=%EnableGeoIP% Server.ShareAnonymizedIPs=%ShareAnonymizedIPs% Engine.SupportDir=%SupportDir% +bin\OpenRA.Server.exe Game.Mod=%MOD_ID% Engine.EngineDir=".." Server.Name=%Name% Server.ListenPort=%ListenPort% Server.AdvertiseOnline=%AdvertiseOnline% Server.EnableSingleplayer=%EnableSingleplayer% Server.Password=%Password% Server.RequireAuthentication=%RequireAuthentication% Server.ProfileIDBlacklist=%ProfileIDBlacklist% Server.ProfileIDWhitelist=%ProfileIDWhitelist% Server.EnableSyncReports=%EnableSyncReports% Server.EnableGeoIP=%EnableGeoIP% Server.ShareAnonymizedIPs=%ShareAnonymizedIPs% Engine.SupportDir=%SupportDir% goto loop :noengine diff --git a/launch-dedicated.sh b/launch-dedicated.sh index e2cdc5900..afd4284e9 100755 --- a/launch-dedicated.sh +++ b/launch-dedicated.sh @@ -66,7 +66,7 @@ fi cd "${ENGINE_DIRECTORY}" while true; do - MOD_SEARCH_PATHS="${MOD_SEARCH_PATHS}" mono --debug OpenRA.Server.exe Game.Mod="${LAUNCH_MOD}" \ + MOD_SEARCH_PATHS="${MOD_SEARCH_PATHS}" mono --debug bin/OpenRA.Server.exe Engine.EngineDir=".." Game.Mod="${LAUNCH_MOD}" \ Server.Name="${NAME}" Server.ListenPort="${LISTEN_PORT}" \ Server.AdvertiseOnline="${ADVERTISE_ONLINE}" \ Server.Password="${PASSWORD}" \ diff --git a/launch-game.cmd b/launch-game.cmd index 2c98fda32..b3cd4567b 100644 --- a/launch-game.cmd +++ b/launch-game.cmd @@ -12,11 +12,11 @@ if "!ENGINE_VERSION!" == "" goto badconfig if "!ENGINE_DIRECTORY!" == "" goto badconfig set TEMPLATE_DIR=%CD% -if not exist %ENGINE_DIRECTORY%\OpenRA.Game.exe goto noengine +if not exist %ENGINE_DIRECTORY%\bin\OpenRA.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%" "%*" +bin\OpenRA.exe Game.Mod=%MOD_ID% Engine.EngineDir=".." Engine.LaunchPath="%TEMPLATE_LAUNCHER%" "Engine.ModSearchPaths=%MOD_SEARCH_PATHS%" "%*" set ERROR=%errorlevel% cd %TEMPLATE_DIR% diff --git a/launch-game.sh b/launch-game.sh index c0d67b6a0..1d2586f28 100755 --- a/launch-game.sh +++ b/launch-game.sh @@ -36,11 +36,11 @@ 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 +if [ ! -f "${ENGINE_DIRECTORY}/bin/OpenRA.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 fi cd "${ENGINE_DIRECTORY}" -mono OpenRA.Game.exe Engine.LaunchPath="${TEMPLATE_LAUNCHER}" "Engine.ModSearchPaths=${MOD_SEARCH_PATHS}" Game.Mod="${MOD_ID}" "$@" +mono --debug bin/OpenRA.exe Engine.EngineDir=".." Engine.LaunchPath="${TEMPLATE_LAUNCHER}" "Engine.ModSearchPaths=${MOD_SEARCH_PATHS}" Game.Mod="${MOD_ID}" "$@" diff --git a/make.ps1 b/make.ps1 index 92b0d064d..bbc3d0191 100644 --- a/make.ps1 +++ b/make.ps1 @@ -39,27 +39,9 @@ function Clean-Command } dotnet clean /nologo - rm *.dll - rm mods/*/*.dll - rm *.dll.config - rm *.pdb - rm mods/*/*.pdb - rm *.exe - rm ./*/bin -r rm ./*/obj -r - - rm $env:ENGINE_DIRECTORY/*.dll - rm $env:ENGINE_DIRECTORY/mods/*/*.dll - rm env:ENGINE_DIRECTORY/*.config - rm env:ENGINE_DIRECTORY/*.pdb - rm mods/*/*.pdb - rm env:ENGINE_DIRECTORY/*.exe - rm env:ENGINE_DIRECTORY/*/bin -r + rm env:ENGINE_DIRECTORY/bin -r rm env:ENGINE_DIRECTORY/*/obj -r - if (Test-Path env:ENGINE_DIRECTORY/thirdparty/download/) - { - rmdir env:ENGINE_DIRECTORY/thirdparty/download -Recurse -Force - } Write-Host "Clean complete." -ForegroundColor Green } @@ -117,7 +99,7 @@ function Test-Command } Write-Host "Testing $modID mod MiniYAML..." -ForegroundColor Cyan - Invoke-Expression "$utilityPath $modID --check-yaml" + InvokeCommand "$utilityPath $modID --check-yaml" } function Check-Command @@ -137,11 +119,14 @@ function Check-Command if ((CheckForUtility) -eq 0) { + Write-Host "Checking runtime assemblies..." -ForegroundColor Cyan + InvokeCommand "$utilityPath $modID --check-runtime-assemblies $env:WHITELISTED_OPENRA_ASSEMBLIES $env:WHITELISTED_THIRDPARTY_ASSEMBLIES $env:WHITELISTED_CORE_ASSEMBLIES $env:WHITELISTED_MOD_ASSEMBLIES" + Write-Host "Checking for explicit interface violations..." -ForegroundColor Cyan - Invoke-Expression "$utilityPath $modID --check-explicit-interfaces" + InvokeCommand "$utilityPath $modID --check-explicit-interfaces" Write-Host "Checking for incorrect conditional trait interface overrides..." -ForegroundColor Cyan - Invoke-Expression "$utilityPath $modID --check-conditional-trait-interface-overrides" + InvokeCommand "$utilityPath $modID --check-conditional-trait-interface-overrides" } } @@ -170,9 +155,9 @@ function Docs-Command } ./make.ps1 version - Invoke-Expression "$utilityPath $modID --docs | Out-File -Encoding 'UTF8' DOCUMENTATION.md" - Invoke-Expression "$utilityPath $modID --weapon-docs | Out-File -Encoding "UTF8" WEAPONS.md" - Invoke-Expression "$utilityPath $modID --lua-docs | Out-File -Encoding 'UTF8' Lua-API.md" + InvokeCommand "$utilityPath $modID --docs | Out-File -Encoding 'UTF8' DOCUMENTATION.md" + InvokeCommand "$utilityPath $modID --weapon-docs | Out-File -Encoding "UTF8" WEAPONS.md" + InvokeCommand "$utilityPath $modID --lua-docs | Out-File -Encoding 'UTF8' Lua-API.md" echo "Docs generated." -ForegroundColor Green } @@ -223,7 +208,9 @@ function ReadConfigLine($line, $name) function ParseConfigFile($fileName) { $names = @("MOD_ID", "ENGINE_VERSION", "AUTOMATIC_ENGINE_MANAGEMENT", "AUTOMATIC_ENGINE_SOURCE", - "AUTOMATIC_ENGINE_EXTRACT_DIRECTORY", "AUTOMATIC_ENGINE_TEMP_ARCHIVE_NAME", "ENGINE_DIRECTORY") + "AUTOMATIC_ENGINE_EXTRACT_DIRECTORY", "AUTOMATIC_ENGINE_TEMP_ARCHIVE_NAME", "ENGINE_DIRECTORY", + "WHITELISTED_OPENRA_ASSEMBLIES", "WHITELISTED_THIRDPARTY_ASSEMBLIES", "WHITELISTED_CORE_ASSEMBLIES", + "WHITELISTED_MOD_ASSEMBLIES") $reader = [System.IO.File]::OpenText($fileName) while($null -ne ($line = $reader.ReadLine())) @@ -257,6 +244,20 @@ function ParseConfigFile($fileName) } } +function InvokeCommand +{ + param($expression) + # $? is the return value of the called expression + # Invoke-Expression itself will always succeed, even if the invoked expression fails + # So temporarily store the return value in $success + $expression += '; $success = $?' + Invoke-Expression $expression + if ($success -eq $False) + { + exit 1 + } +} + ############################################################### ############################ Main ############################# ############################################################### @@ -300,9 +301,10 @@ if (Test-Path "user.config") $modID = $env:MOD_ID $env:MOD_SEARCH_PATHS = (Get-Item -Path ".\" -Verbose).FullName + "\mods,./mods" +$env:ENGINE_DIR = ".." -# Run the same command on the engine's make file -if ($command -eq "all" -or $command -eq "clean") +# Fetch the engine if required +if ($command -eq "all" -or $command -eq "clean" -or $command -eq "check") { $templateDir = $pwd.Path $versionFile = $env:ENGINE_DIRECTORY + "/VERSION" @@ -381,8 +383,7 @@ if ($command -eq "all" -or $command -eq "clean") } } -$utilityPath = $env:ENGINE_DIRECTORY + "/OpenRA.Utility.exe" -$styleCheckPath = $env:ENGINE_DIRECTORY + "/OpenRA.StyleCheck.exe" +$utilityPath = $env:ENGINE_DIRECTORY + "/bin/OpenRA.Utility.exe" $execute = $command if ($command.Length -gt 1) diff --git a/mod.config b/mod.config index bea1f0467..5580974fd 100644 --- a/mod.config +++ b/mod.config @@ -9,26 +9,11 @@ MOD_ID="example" # The OpenRA engine version to use for this project. -ENGINE_VERSION="release-20200503" +ENGINE_VERSION="playtest-20201213" # .dll filenames compiled by the mod solution for use by the runtime assembly check WHITELISTED_MOD_ASSEMBLIES="OpenRA.Mods.Example.dll" -############################################################################## -# Continuous Integration -# -# Settings controlling the behaviour of Travis CI -# (if it has been enabled on your GitHub repository) -############################################################################## - -# Enable tests for common errors when a new commit is pushed to the GitHub repository -# Accepts values "True" or "False". -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" - ############################################################################## # Packaging # @@ -68,8 +53,27 @@ PACKAGING_FAQ_URL="http://wiki.openra.net/FAQ" # - Windows "Add/Remove Programs" list PACKAGING_AUTHORS="Example Mod authors" +# Space delimited list of dll files compiled by the mod, which +# should be copied from the bin directory into your installers +PACKAGING_COPY_MOD_BINARIES="OpenRA.Mods.Example.dll" + +# If your mod depends on OpenRA.Mods.Cnc.dll from the engine set +# this to "True" to package the dll in your installers. +# Accepts values "True" or "False". +PACKAGING_COPY_CNC_DLL="False" + +# If your mod depends on OpenRA.Mods.D2k.dll from the engine set +# this to "True" to package the dll in your installers. +# Accepts values "True" or "False". +PACKAGING_COPY_D2K_DLL="False" + +# If you wish to enable Discord integration, register an +# application at https://discord.com/developers/applications +# and define the client id here and in your mod.yaml +PACKAGING_DISCORD_APPID="" + # The git tag to use for the macOS Launcher files. -PACKAGING_OSX_LAUNCHER_TAG="osx-launcher-20200316" +PACKAGING_OSX_MONO_TAG="osx-launcher-20200830" # The macOS disk image icon positions, matched to the background artwork PACKAGING_OSX_DMG_MOD_ICON_POSITION="190, 210" @@ -90,10 +94,10 @@ PACKAGING_WINDOWS_REGISTRY_KEY="OpenRAExampleMod" PACKAGING_WINDOWS_LICENSE_FILE="./COPYING" # The git tag to use for the AppImage dependencies. -PACKAGING_APPIMAGE_DEPENDENCIES_TAG="20200222" +PACKAGING_APPIMAGE_DEPENDENCIES_TAG="20200328" # 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" +# when packaging your mod. e.g. "./mods/modcontent" PACKAGING_COPY_ENGINE_FILES="" # Overwrite the version in mod.yaml with the tag used for the SDK release @@ -119,25 +123,24 @@ AUTOMATIC_ENGINE_EXTRACT_DIRECTORY="./engine_temp" AUTOMATIC_ENGINE_TEMP_ARCHIVE_NAME="engine.zip" ENGINE_DIRECTORY="./engine" -# The url to download the OpenRA macOS launcher files. -PACKAGING_OSX_LAUNCHER_SOURCE="https://github.com/OpenRA/OpenRALauncherOSX/releases/download/${PACKAGING_OSX_LAUNCHER_TAG}/launcher.zip" +# The url to download the OpenRA macOS mono runtime. +PACKAGING_OSX_MONO_SOURCE="https://github.com/OpenRA/OpenRALauncherOSX/releases/download/${PACKAGING_OSX_MONO_TAG}/mono.zip" # Temporary file name used when downloading the OpenRA macOS launcher files. -PACKAGING_OSX_LAUNCHER_TEMP_ARCHIVE_NAME="launcher.zip" +PACKAGING_OSX_MONO_TEMP_ARCHIVE_NAME="mono.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" +PACKAGING_APPIMAGE_DEPENDENCIES_SOURCE="https://github.com/OpenRA/AppImageSupport/releases/download/${PACKAGING_APPIMAGE_DEPENDENCIES_TAG}/mono.tar.bz2" # Temporary file name used when downloading the OpenRA AppImage dependencies. -PACKAGING_APPIMAGE_DEPENDENCIES_TEMP_ARCHIVE_NAME="libs.tar.bz2" +PACKAGING_APPIMAGE_DEPENDENCIES_TEMP_ARCHIVE_NAME="mono.tar.bz2" # List of .NET assemblies that we can guarantee exist -# OpenRA.Game.dll is a harmless false positive that we can ignore -WHITELISTED_OPENRA_ASSEMBLIES="OpenRA.Game.exe OpenRA.Utility.exe OpenRA.Platforms.Default.dll OpenRA.Mods.Common.dll OpenRA.Game.dll" +WHITELISTED_OPENRA_ASSEMBLIES="OpenRA.exe OpenRA.Utility.exe OpenRA.Server.exe OpenRA.Platforms.Default.dll OpenRA.Game.dll OpenRA.Mods.Common.dll OpenRA.Mods.Cnc.dll OpenRA.Mods.D2k.dll" # These are explicitly shipped alongside our core files by the packaging script -WHITELISTED_THIRDPARTY_ASSEMBLIES="ICSharpCode.SharpZipLib.dll FuzzyLogicLibrary.dll MaxMind.Db.dll Eluant.dll rix0rrr.BeaconLib.dll Open.Nat.dll SDL2-CS.dll OpenAL-CS.dll" +WHITELISTED_THIRDPARTY_ASSEMBLIES="ICSharpCode.SharpZipLib.dll FuzzyLogicLibrary.dll Eluant.dll BeaconLib.dll Open.Nat.dll SDL2-CS.dll OpenAL-CS.Core.dll DiscordRPC.dll Newtonsoft.Json.dll" # These are shipped in our custom minimal mono runtime and also available in the full system-installed .NET/mono stack # This list *must* be kept in sync with the files packaged by the AppImageSupport and OpenRALauncherOSX repositories -WHITELISTED_CORE_ASSEMBLIES="mscorlib.dll System.dll System.Configuration.dll System.Core.dll System.Numerics.dll System.Security.dll System.Xml.dll Mono.Security.dll" +WHITELISTED_CORE_ASSEMBLIES="mscorlib.dll System.dll System.Configuration.dll System.Core.dll System.Numerics.dll System.Security.dll System.Xml.dll Mono.Security.dll netstandard.dll" diff --git a/mods/example/audio/notifications.yaml b/mods/example/audio/notifications.yaml index 7ab7c1f71..94a911bf4 100644 --- a/mods/example/audio/notifications.yaml +++ b/mods/example/audio/notifications.yaml @@ -6,3 +6,4 @@ Speech: Sounds: DefaultVariant: .wav Notifications: + ClickSound: diff --git a/mods/example/mod.yaml b/mods/example/mod.yaml index 7ecc43f3b..12a5eb889 100644 --- a/mods/example/mod.yaml +++ b/mods/example/mod.yaml @@ -3,9 +3,9 @@ Metadata: Version: {DEV_VERSION} Packages: - . + ^EngineDir $example: example - ./mods/common: common + ^EngineDir|mods/common: common example|bits MapFolders: @@ -24,8 +24,8 @@ Chrome: example|chrome.yaml Assemblies: - common|OpenRA.Mods.Common.dll - example|OpenRA.Mods.Example.dll + ^BinDir|OpenRA.Mods.Common.dll + ^BinDir|OpenRA.Mods.Example.dll ChromeLayout: example|mainmenu.yaml diff --git a/packaging/linux/buildpackage.sh b/packaging/linux/buildpackage.sh index 3b159d7e1..bc9d55999 100755 --- a/packaging/linux/buildpackage.sh +++ b/packaging/linux/buildpackage.sh @@ -13,14 +13,14 @@ require_variables() { 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." + if [ -n "${missing}" ]; then + printf "Required mod.config variables are missing:\n%sRepair your mod.config (or user.config) and try again.\n" "${missing}" exit 1 fi } if [ $# -eq "0" ]; then - echo "Usage: `basename $0` version [outputdir]" + echo "Usage: $(basename "$0") version [outputdir]" exit 1 fi @@ -36,7 +36,7 @@ if [ -f "${TEMPLATE_ROOT}/user.config" ]; then . "${TEMPLATE_ROOT}/user.config" fi -require_variables "MOD_ID" "ENGINE_DIRECTORY" "PACKAGING_DISPLAY_NAME" "PACKAGING_INSTALLER_NAME" \ +require_variables "MOD_ID" "ENGINE_DIRECTORY" "PACKAGING_DISPLAY_NAME" "PACKAGING_INSTALLER_NAME" "PACKAGING_COPY_CNC_DLL" "PACKAGING_COPY_D2K_DLL" \ "PACKAGING_APPIMAGE_DEPENDENCIES_TAG" "PACKAGING_APPIMAGE_DEPENDENCIES_SOURCE" "PACKAGING_APPIMAGE_DEPENDENCIES_TEMP_ARCHIVE_NAME" \ "PACKAGING_FAQ_URL" "PACKAGING_OVERWRITE_MOD_VERSION" @@ -47,58 +47,52 @@ else OUTPUTDIR=$(python3 -c "import os; print(os.path.realpath('$2'))") fi -BUILTDIR="${PACKAGING_DIR}/${PACKAGING_INSTALLER_NAME}.appdir" +APPDIR="${PACKAGING_DIR}/${PACKAGING_INSTALLER_NAME}.appdir" # Set the working dir to the location of this script cd "${PACKAGING_DIR}" -pushd "${TEMPLATE_ROOT}" > /dev/null - -if [ ! -f "${ENGINE_DIRECTORY}/Makefile" ]; then +if [ ! -f "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/Makefile" ]; 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 fi +. "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/packaging/functions.sh" + if [ ! -d "${OUTPUTDIR}" ]; then echo "Output directory '${OUTPUTDIR}' does not exist."; exit 1 fi echo "Building core files" - -MOD_VERSION=$(grep 'Version:' mods/${MOD_ID}/mod.yaml | awk '{print $2}') - -if [ "${PACKAGING_OVERWRITE_MOD_VERSION}" == "True" ]; then - make version VERSION="${TAG}" -else - echo "Mod version ${MOD_VERSION} will remain unchanged."; -fi - -pushd "${ENGINE_DIRECTORY}" > /dev/null -make clean - -# linux-dependencies target will trigger the lua detection script, which we don't want during packaging -make cli-dependencies -sed "s/@LIBLUA51@/liblua5.1.so.0/" thirdparty/Eluant.dll.config.in > Eluant.dll.config - -make core -make version VERSION="${ENGINE_VERSION}" -make install-engine prefix="usr" DESTDIR="${BUILTDIR}/" -make install-common-mod-files prefix="usr" DESTDIR="${BUILTDIR}/" +install_assemblies_mono "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}" "${APPDIR}/usr/lib/openra" "linux-x64" "True" "${PACKAGING_COPY_CNC_DLL}" "${PACKAGING_COPY_D2K_DLL}" +install_data "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}" "${APPDIR}/usr/lib/openra" for f in ${PACKAGING_COPY_ENGINE_FILES}; do - mkdir -p "${BUILTDIR}/usr/lib/openra/$(dirname "${f}")" - cp -r "${f}" "${BUILTDIR}/usr/lib/openra/${f}" + mkdir -p "${APPDIR}/usr/lib/openra/$(dirname "${f}")" + cp -r "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/${f}" "${APPDIR}/usr/lib/openra/${f}" done +echo "Building mod files" +pushd "${TEMPLATE_ROOT}" > /dev/null +make all popd > /dev/null -echo "Building mod files" -make core -cp -Lr mods/* "${BUILTDIR}/usr/lib/openra/mods" +cp -Lr "${TEMPLATE_ROOT}/mods/"* "${APPDIR}/usr/lib/openra/mods" -popd > /dev/null +for f in ${PACKAGING_COPY_MOD_BINARIES}; do + mkdir -p "${APPDIR}/usr/lib/openra/$(dirname "${f}")" + cp "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/bin/${f}" "${APPDIR}/usr/lib/openra/${f}" +done + +set_engine_version "${ENGINE_VERSION}" "${APPDIR}/usr/lib/openra" +if [ "${PACKAGING_OVERWRITE_MOD_VERSION}" == "True" ]; then + set_mod_version "${TAG}" "${APPDIR}/usr/lib/openra/mods/${MOD_ID}/mod.yaml" +else + MOD_VERSION=$(grep 'Version:' "${APPDIR}/usr/lib/openra/mods/${MOD_ID}/mod.yaml" | awk '{print $2}') + echo "Mod version ${MOD_VERSION} will remain unchanged."; +fi # Add native libraries echo "Downloading dependencies" @@ -110,63 +104,68 @@ else wget -cq https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage || exit 3 fi -tar xf "${PACKAGING_APPIMAGE_DEPENDENCIES_TEMP_ARCHIVE_NAME}" -chmod a+x appimagetool-x86_64.AppImage - echo "Building AppImage" -install -d "${BUILTDIR}/usr/bin" -install -d "${BUILTDIR}/etc/mono/4.5" -install -d "${BUILTDIR}/usr/lib/mono/4.5" +tar xf "${PACKAGING_APPIMAGE_DEPENDENCIES_TEMP_ARCHIVE_NAME}" -C "${APPDIR}" +chmod 0755 "${APPDIR}/usr/bin/mono" +chmod 0644 "${APPDIR}/etc/mono/config" +chmod 0644 "${APPDIR}/etc/mono/4.5/machine.config" +chmod 0644 "${APPDIR}/usr/lib/mono/4.5/Facades/"*.dll +chmod 0644 "${APPDIR}/usr/lib/mono/4.5/"*.dll "${APPDIR}/usr/lib/mono/4.5/"*.exe +chmod 0755 "${APPDIR}/usr/lib/"*.so -install -Dm 0755 usr/bin/mono "${BUILTDIR}/usr/bin/" - -install -Dm 0644 /etc/mono/config "${BUILTDIR}/etc/mono/" -install -Dm 0644 /etc/mono/4.5/machine.config "${BUILTDIR}/etc/mono/4.5" - -for f in $(ls usr/lib/mono/4.5/*.dll usr/lib/mono/4.5/*.exe); do install -Dm 0644 "$f" "${BUILTDIR}/usr/lib/mono/4.5/"; done -for f in $(ls usr/lib/*.so usr/lib/*.so.*); do install -Dm 0755 "$f" "${BUILTDIR}/usr/lib/"; done - -rm -rf libs libs.tar.bz2 +rm -rf "${PACKAGING_APPIMAGE_DEPENDENCIES_SOURCE}" # Add launcher and icons -sed "s/{MODID}/${MOD_ID}/g" include/AppRun.in | sed "s/{MODNAME}/${PACKAGING_DISPLAY_NAME}/g" > AppRun.temp -install -m 0755 AppRun.temp "${BUILTDIR}/AppRun" +sed "s/{MODID}/${MOD_ID}/g" "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/packaging/linux/AppRun.in" | sed "s/{MODNAME}/${PACKAGING_DISPLAY_NAME}/g" > "${APPDIR}/AppRun" +chmod 0755 "${APPDIR}/AppRun" + +if [ -n "${PACKAGING_DISCORD_APPID}" ]; then + sed "s/{DISCORDAPPID}/${PACKAGING_DISCORD_APPID}/g" "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/packaging/linux/openra.desktop.discord.in" > temp.desktop.in + sed "s/{DISCORDAPPID}/${PACKAGING_DISCORD_APPID}/g" "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/packaging/linux/openra-mimeinfo.xml.discord.in" > temp.xml.in +else + cp "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/packaging/linux/openra.desktop.in" temp.desktop.in + cp "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/packaging/linux/openra-mimeinfo.xml.in" temp.xml.in +fi -sed "s/{MODID}/${MOD_ID}/g" include/mod.desktop.in | sed "s/{MODNAME}/${PACKAGING_DISPLAY_NAME}/g" | sed "s/{TAG}/${TAG}/g" > temp.desktop -install -Dm 0755 temp.desktop "${BUILTDIR}/usr/share/applications/openra-${MOD_ID}.desktop" -install -m 0755 temp.desktop "${BUILTDIR}/openra-${MOD_ID}.desktop" +mkdir -p "${APPDIR}/usr/share/applications" +chmod 0755 temp.desktop.in +sed "s/{MODID}/${MOD_ID}/g" temp.desktop.in | sed "s/{MODNAME}/${PACKAGING_DISPLAY_NAME}/g" | sed "s/{TAG}/${TAG}/g" > "${APPDIR}/usr/share/applications/openra-${MOD_ID}.desktop" +cp "${APPDIR}/usr/share/applications/openra-${MOD_ID}.desktop" "${APPDIR}/openra-${MOD_ID}.desktop" +rm temp.desktop.in -sed "s/{MODID}/${MOD_ID}/g" include/mod-mimeinfo.xml.in | sed "s/{TAG}/${TAG}/g" > temp.xml -install -Dm 0755 temp.xml "${BUILTDIR}/usr/share/mime/packages/openra-${MOD_ID}.xml" +mkdir -p "${APPDIR}/usr/share/mime/packages" +chmod 0644 temp.xml.in +sed "s/{MODID}/${MOD_ID}/g" temp.xml.in | sed "s/{TAG}/${TAG}/g" > "${APPDIR}/usr/share/mime/packages/openra-${MOD_ID}.xml" +rm temp.xml.in -if [ -f "${PACKAGING_DIR}/mod_scalable.svg" ]; then - install -Dm644 "${PACKAGING_DIR}/mod_scalable.svg" "${BUILTDIR}/usr/share/icons/hicolor/scalable/apps/openra-${MOD_ID}.svg" +if [ -f "${ARTWORK_DIR}/icon_scalable.svg" ]; then + install -Dm644 "${ARTWORK_DIR}/icon_scalable.svg" "${APPDIR}/usr/share/icons/hicolor/scalable/apps/openra-${MOD_ID}.svg" fi for i in 16x16 32x32 48x48 64x64 128x128 256x256 512x512 1024x1024; do - if [ -f "${ARTWORK_DIR}/icon_${i}.png" ]; then - install -Dm644 "${ARTWORK_DIR}/icon_${i}.png" "${BUILTDIR}/usr/share/icons/hicolor/${i}/apps/openra-${MOD_ID}.png" - install -m644 "${ARTWORK_DIR}/icon_${i}.png" "${BUILTDIR}/openra-${MOD_ID}.png" - fi + if [ -f "${ARTWORK_DIR}/icon_${i}.png" ]; then + install -Dm644 "${ARTWORK_DIR}/icon_${i}.png" "${APPDIR}/usr/share/icons/hicolor/${i}/apps/openra-${MOD_ID}.png" + install -m644 "${ARTWORK_DIR}/icon_${i}.png" "${APPDIR}/openra-${MOD_ID}.png" + fi done -install -d "${BUILTDIR}/usr/bin" +install -d "${APPDIR}/usr/bin" -sed "s/{MODID}/${MOD_ID}/g" include/mod.in | sed "s/{TAG}/${TAG}/g" | sed "s/{MODNAME}/${PACKAGING_DISPLAY_NAME}/g" | sed "s/{MODINSTALLERNAME}/${PACKAGING_INSTALLER_NAME}/g" | sed "s|{MODFAQURL}|${PACKAGING_FAQ_URL}|g" > openra-mod.temp -install -m 0755 openra-mod.temp "${BUILTDIR}/usr/bin/openra-${MOD_ID}" +sed "s/{MODID}/${MOD_ID}/g" "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/packaging/linux/openra.appimage.in" | sed "s/{TAG}/${TAG}/g" | sed "s/{MODNAME}/${PACKAGING_DISPLAY_NAME}/g" | sed "s/{MODINSTALLERNAME}/${PACKAGING_INSTALLER_NAME}/g" | sed "s|{MODFAQURL}|${PACKAGING_FAQ_URL}|g" > "${APPDIR}/usr/bin/openra-${MOD_ID}" +chmod 0755 "${APPDIR}/usr/bin/openra-${MOD_ID}" -sed "s/{MODID}/${MOD_ID}/g" include/mod-server.in > openra-mod-server.temp -install -m 0755 openra-mod-server.temp "${BUILTDIR}/usr/bin/openra-${MOD_ID}-server" +sed "s/{MODID}/${MOD_ID}/g" "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/packaging/linux/openra-server.appimage.in" > "${APPDIR}/usr/bin/openra-${MOD_ID}-server" +chmod 0755 "${APPDIR}/usr/bin/openra-${MOD_ID}-server" -sed "s/{MODID}/${MOD_ID}/g" include/mod-utility.in > openra-mod-utility.temp -install -m 0755 openra-mod-utility.temp "${BUILTDIR}/usr/bin/openra-${MOD_ID}-utility" +sed "s/{MODID}/${MOD_ID}/g" "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/packaging/linux/openra-utility.appimage.in" > "${APPDIR}/usr/bin/openra-${MOD_ID}-utility" +chmod 0755 "${APPDIR}/usr/bin/openra-${MOD_ID}-utility" -install -m 0755 include/gtk-dialog.py "${BUILTDIR}/usr/bin/gtk-dialog.py" +install -m 0755 "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/packaging/linux/gtk-dialog.py" "${APPDIR}/usr/bin/gtk-dialog.py" +install -m 0755 "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/packaging/linux/restore-environment.sh" "${APPDIR}/usr/bin/restore-environment.sh" -# travis-ci doesn't support mounting FUSE filesystems so extract and run the contents manually -./appimagetool-x86_64.AppImage --appimage-extract -ARCH=x86_64 ./squashfs-root/AppRun "${BUILTDIR}" "${OUTPUTDIR}/${PACKAGING_INSTALLER_NAME}-${TAG}-x86_64.AppImage" +chmod a+x appimagetool-x86_64.AppImage +ARCH=x86_64 ./appimagetool-x86_64.AppImage "${APPDIR}" "${OUTPUTDIR}/${PACKAGING_INSTALLER_NAME}-${TAG}-x86_64.AppImage" # Clean up -rm -rf openra-mod.temp openra-mod-server.temp openra-mod-utility.temp temp.desktop temp.xml AppRun.temp appimagetool-x86_64.AppImage squashfs-root "${PACKAGING_APPIMAGE_DEPENDENCIES_TEMP_ARCHIVE_NAME}" "${BUILTDIR}" +rm -rf appimagetool-x86_64.AppImage "${PACKAGING_APPIMAGE_DEPENDENCIES_TEMP_ARCHIVE_NAME}" "${APPDIR}" diff --git a/packaging/linux/include/AppRun.in b/packaging/linux/include/AppRun.in deleted file mode 100755 index f854ec7e9..000000000 --- a/packaging/linux/include/AppRun.in +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -HERE="$(dirname "$(readlink -f "${0}")")" - -# Override runtime paths -export PATH="${HERE}/usr/bin:${PATH}" -export XDG_DATA_DIRS="${HERE}/usr/share:${XDG_DATA_DIRS}" -export DYLD_LIBRARY_PATH="${HERE}/usr/lib:$DYLD_LIBRARY_PATH" -export LD_LIBRARY_PATH="${HERE}/usr/lib:$LD_LIBRARY_PATH" -export MONO_PATH="${HERE}/usr/lib/mono/4.5" -export MONO_CFG_DIR="${HERE}/etc" -export MONO_CONFIG="${HERE}/etc/mono/config" - -# Update/create the mono certificate store to enable https web queries -if [ -f "/etc/pki/tls/certs/ca-bundle.crt" ]; then - mono "${HERE}/usr/lib/mono/4.5/cert-sync.exe" --quiet --user /etc/pki/tls/certs/ca-bundle.crt -elif [ -f "/etc/ssl/certs/ca-certificates.crt" ]; then - mono "${HERE}/usr/lib/mono/4.5/cert-sync.exe" --quiet --user /etc/ssl/certs/ca-certificates.crt -else - echo "WARNING: Unable to sync system certificate store - https requests will fail" -fi - -# Run the game or server -if [ -n "$1" ] && [ "$1" = "--server" ]; then - # Drop the --server argument - shift - exec "openra-{MODID}-server" "$@" -elif [ -n "$1" ] && [ "$1" = "--utility" ]; then - # Drop the --utility argument - shift - exec "openra-{MODID}-utility" "$@" -else - exec "openra-{MODID}" "$@" -fi \ No newline at end of file diff --git a/packaging/linux/include/gtk-dialog.py b/packaging/linux/include/gtk-dialog.py deleted file mode 100644 index 337f9b94f..000000000 --- a/packaging/linux/include/gtk-dialog.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/python -"""A simple GTK3 graphical dialog helper that can be used as a fallback if zenity is not available - Compatible with python 2 or 3 with the gi bindings. - - Three modes are available: - test: accepts no arguments, returns 0 if the python dependencies are available, or 1 if not - error: show a gtk-3 error dialog - accepts arguments --title and --text - question: show a gtk-3 question dialog - accepts arguments --title and --text - returns 0 on Yes, or 1 on No -""" - -import sys - -try: - import argparse - import gi - gi.require_version('Gtk', '3.0') - from gi.repository import Gtk -except ImportError: - sys.exit(1) - -class Error(): - def __init__(self, title, text): - dialog = Gtk.MessageDialog(None, 0, Gtk.MessageType.ERROR, Gtk.ButtonsType.OK, title) - dialog.format_secondary_text(text) - dialog.run() - dialog.destroy() - -class Question(): - def __init__(self, title, text): - dialog = Gtk.MessageDialog(None, 0, Gtk.MessageType.QUESTION, Gtk.ButtonsType.YES_NO, title) - dialog.format_secondary_text(text) - response = dialog.run() - dialog.destroy() - sys.exit(0 if response == Gtk.ResponseType.YES else 1) - -if __name__ == "__main__": - parser = argparse.ArgumentParser() - parser.add_argument('type', choices=['error', 'question', 'test']) - parser.add_argument('--title', type=str, required=False, default='') - parser.add_argument('--text', type=str, required=False, default='') - args = parser.parse_args() - if args.type == 'question': - Question(args.title, args.text.replace('\\n', '\n')) - elif args.type == 'error': - Error(args.title, args.text.replace('\\n', '\n')) diff --git a/packaging/linux/include/mod-mimeinfo.xml.in b/packaging/linux/include/mod-mimeinfo.xml.in deleted file mode 100644 index a1e8c19ce..000000000 --- a/packaging/linux/include/mod-mimeinfo.xml.in +++ /dev/null @@ -1,8 +0,0 @@ - - - - - Join OpenRA server - - - diff --git a/packaging/linux/include/mod-server.in b/packaging/linux/include/mod-server.in deleted file mode 100755 index a2798c215..000000000 --- a/packaging/linux/include/mod-server.in +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -HERE="$(dirname "$(readlink -f "${0}")")" -cd "${HERE}/../lib/openra" || exit 1 - -mono --debug OpenRA.Server.exe Game.Mod={MODID} "$@" diff --git a/packaging/linux/include/mod-utility.in b/packaging/linux/include/mod-utility.in deleted file mode 100755 index 6eb4e1613..000000000 --- a/packaging/linux/include/mod-utility.in +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -# OpenRA.Utility relies on keeping the original working directory, so don't change directory -HERE="$(dirname "$(readlink -f "${0}")")" -mono --debug "${HERE}/../lib/openra/OpenRA.Utility.exe" {MODID} "$@" \ No newline at end of file diff --git a/packaging/linux/include/mod.desktop.in b/packaging/linux/include/mod.desktop.in deleted file mode 100644 index bb4c2a422..000000000 --- a/packaging/linux/include/mod.desktop.in +++ /dev/null @@ -1,11 +0,0 @@ -[Desktop Entry] -Type=Application -Version=1.0 -Name=OpenRA - {MODNAME} -GenericName=Real Time Strategy Game -Icon=openra-{MODID} -Exec=openra-{MODID} %u -Terminal=false -Categories=Game;StrategyGame; -StartupWMClass=openra-{MODID}-{TAG} -MimeType=x-scheme-handler/openra-{MODID}-{TAG}; diff --git a/packaging/linux/include/mod.in b/packaging/linux/include/mod.in deleted file mode 100755 index fa424b157..000000000 --- a/packaging/linux/include/mod.in +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh - -LAUNCHER=$(readlink -f "${0}") -HERE="$(dirname "${LAUNCHER}")" -cd "${HERE}/../lib/openra" || exit 1 - -# APPIMAGE is an environment variable set by the runtime -# defining the absolute path to the .AppImage file -if [ ! -z "${APPIMAGE}" ]; then - LAUNCHER=${APPIMAGE} - - # appimaged doesn't update the mime or icon caches when registering AppImages. - # Run update-desktop-database and gtk-update-icon-cache ourselves if we detect - # that the desktop file has been installed but the handler is not cached - if command -v update-desktop-database > /dev/null; then - APPIMAGEID=$(printf "file://%s" "${APPIMAGE}" | md5sum | cut -d' ' -f1) - LAUNCHER_NAME="appimagekit_${APPIMAGEID}-openra-{MODID}.desktop" - LAUNCHER_PATH="${HOME}/.local/share/applications/${LAUNCHER_NAME}" - MIMECACHE_PATH="${HOME}/.local/share/applications/mimeinfo.cache" - SCHEME="x-scheme-handler/openra-{MODID}-{TAG}" - if [ -f "${LAUNCHER_PATH}" ] && ! grep -qs "${SCHEME}=" "${MIMECACHE_PATH}"; then - update-desktop-database "${HOME}/.local/share/applications" - if command -v gtk-update-icon-cache > /dev/null; then - gtk-update-icon-cache ~/.local/share/icons/hicolor/ -t - fi - fi - fi -fi - -# Search for server connection -PROTOCOL_PREFIX="openra-{MODID}-{TAG}://" -JOIN_SERVER="" -if [ "${1#${PROTOCOL_PREFIX}}" != "${1}" ]; then - JOIN_SERVER="Launch.Connect=${1#${PROTOCOL_PREFIX}}" -fi - -# Run the game -export SDL_VIDEO_X11_WMCLASS="openra-{MODID}-{TAG}" -mono --debug OpenRA.Game.exe Game.Mod={MODID} Engine.LaunchPath="${LAUNCHER}" "${JOIN_SERVER}" "$@" - -# Show a crash dialog if something went wrong -if [ $? != 0 ] && [ $? != 1 ]; then - ERROR_MESSAGE="{MODNAME} has encountered a fatal error.\nPlease refer to the crash logs and FAQ for more information.\n\nLog files are located in ~/.openra/Logs\nThe FAQ is available at {MODFAQURL}" - if command -v zenity > /dev/null; then - zenity --no-wrap --error --title "{MODNAME}" --text "${ERROR_MESSAGE}" 2> /dev/null - elif command -v kdialog > /dev/null; then - kdialog --title "{MODNAME}" --error "${ERROR_MESSAGE}" - elif "${HERE}/gtk-dialog.py" test > /dev/null; then - "${HERE}/gtk-dialog.py" error --title "{MODNAME}" --text "${ERROR_MESSAGE}" 2> /dev/null - else - printf "${ERROR_MESSAGE}\n" - fi - exit 1 -fi diff --git a/packaging/macos/buildpackage.sh b/packaging/macos/buildpackage.sh index f8f4915e8..59aa360b6 100755 --- a/packaging/macos/buildpackage.sh +++ b/packaging/macos/buildpackage.sh @@ -1,8 +1,9 @@ #!/bin/bash # OpenRA Mod SDK packaging script for macOS # -# The application bundles will be signed if the following environment variable is defined: -# MACOS_DEVELOPER_IDENTITY: Certificate name, of the form `Developer\ ID\ Application:\ ` +# The application bundles will be signed if the following environment variables are defined: +# MACOS_DEVELOPER_IDENTITY: The alphanumeric identifier listed in the certificate name ("Developer ID Application: ()") +# or as Team ID in your Apple Developer account Membership Details. # If the identity is not already in the default keychain, specify the following environment variables to import it: # MACOS_DEVELOPER_CERTIFICATE_BASE64: base64 content of the exported .p12 developer ID certificate. # Generate using `base64 certificate.p12 | pbcopy` @@ -28,14 +29,14 @@ require_variables() { 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." + if [ -n "${missing}" ]; then + printf "Required mod.config variables are missing:\n%sRepair your mod.config (or user.config) and try again.\n" "${missing}" exit 1 fi } if [ $# -eq "0" ]; then - echo "Usage: `basename $0` version [outputdir]" + echo "Usage: $(basename "$0") version [outputdir]" exit 1 fi @@ -51,11 +52,19 @@ 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" \ +require_variables "MOD_ID" "ENGINE_DIRECTORY" "PACKAGING_DISPLAY_NAME" "PACKAGING_INSTALLER_NAME" "PACKAGING_COPY_CNC_DLL" "PACKAGING_COPY_D2K_DLL" \ + "PACKAGING_OSX_MONO_TAG" "PACKAGING_OSX_MONO_SOURCE" "PACKAGING_OSX_MONO_TEMP_ARCHIVE_NAME" \ "PACKAGING_OSX_DMG_MOD_ICON_POSITION" "PACKAGING_OSX_DMG_APPLICATION_ICON_POSITION" "PACKAGING_OSX_DMG_HIDDEN_ICON_POSITION" \ "PACKAGING_FAQ_URL" "PACKAGING_OVERWRITE_MOD_VERSION" +if [ ! -f "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/Makefile" ]; 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 +fi + +. "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/packaging/functions.sh" + # Import code signing certificate if [ -n "${MACOS_DEVELOPER_CERTIFICATE_BASE64}" ] && [ -n "${MACOS_DEVELOPER_CERTIFICATE_PASSWORD}" ] && [ -n "${MACOS_DEVELOPER_IDENTITY}" ]; then echo "Importing signing certificate" @@ -75,6 +84,11 @@ else OUTPUTDIR=$(python3 -c "import os; print(os.path.realpath('$2'))") fi +if [ ! -d "${OUTPUTDIR}" ]; then + echo "Output directory '${OUTPUTDIR}' does not exist."; + exit 1 +fi + BUILTDIR="${PACKAGING_DIR}/build" PACKAGING_OSX_APP_NAME="OpenRA - ${PACKAGING_DISPLAY_NAME}.app" @@ -85,171 +99,181 @@ modify_plist() { sed "s|$1|$2|g" "$3" > "$3.tmp" && mv "$3.tmp" "$3" } -echo "Building launcher" -curl -s -L -o "${PACKAGING_OSX_LAUNCHER_TEMP_ARCHIVE_NAME}" -O "${PACKAGING_OSX_LAUNCHER_SOURCE}" || exit 3 -unzip -qq -d "${BUILTDIR}" "${PACKAGING_OSX_LAUNCHER_TEMP_ARCHIVE_NAME}" -rm "${PACKAGING_OSX_LAUNCHER_TEMP_ARCHIVE_NAME}" +build_platform() { + PLATFORM="${1}" + DMG_NAME="${2}" + LAUNCHER_DIR="${BUILTDIR}/${PACKAGING_OSX_APP_NAME}" + LAUNCHER_CONTENTS_DIR="${LAUNCHER_DIR}/Contents" + LAUNCHER_MACOS_DIR="${LAUNCHER_CONTENTS_DIR}/MacOS" + LAUNCHER_RESOURCES_DIR="${LAUNCHER_CONTENTS_DIR}/Resources" + + echo "Building launcher (${PLATFORM})" + + mkdir -p "${LAUNCHER_RESOURCES_DIR}" + mkdir -p "${LAUNCHER_CONTENTS_DIR}/MacOS" + echo "APPL????" > "${LAUNCHER_CONTENTS_DIR}/PkgInfo" + cp "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/packaging/macos/Info.plist.in" "${LAUNCHER_CONTENTS_DIR}/Info.plist" + + modify_plist "{DEV_VERSION}" "${TAG}" "${LAUNCHER_CONTENTS_DIR}/Info.plist" + modify_plist "{FAQ_URL}" "${PACKAGING_FAQ_URL}" "${LAUNCHER_CONTENTS_DIR}/Info.plist" + modify_plist "{MOD_ID}" "${MOD_ID}" "${LAUNCHER_CONTENTS_DIR}/Info.plist" + modify_plist "{MOD_NAME}" "${PACKAGING_DISPLAY_NAME}" "${LAUNCHER_CONTENTS_DIR}/Info.plist" + modify_plist "{JOIN_SERVER_URL_SCHEME}" "openra-${MOD_ID}-${TAG}" "${LAUNCHER_CONTENTS_DIR}/Info.plist" + + if [ -n "${DISCORD_APPID}" ]; then + modify_plist "{DISCORD_URL_SCHEME}" "discord-${DISCORD_APPID}" "${LAUNCHER_CONTENTS_DIR}/Info.plist" + else + modify_plist "{DISCORD_URL_SCHEME}" "" "${LAUNCHER_CONTENTS_DIR}/Info.plist" + fi -modify_plist "{DEV_VERSION}" "${TAG}" "${BUILTDIR}/OpenRA.app/Contents/Info.plist" -modify_plist "{FAQ_URL}" "${PACKAGING_FAQ_URL}" "${BUILTDIR}/OpenRA.app/Contents/Info.plist" + if [ "${PLATFORM}" = "compat" ]; then + modify_plist "{MINIMUM_SYSTEM_VERSION}" "10.9" "${LAUNCHER_CONTENTS_DIR}/Info.plist" + clang -m64 "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/packaging/macos/launcher-mono.m" -o "${LAUNCHER_MACOS_DIR}/OpenRA" -framework AppKit -mmacosx-version-min=10.9 + else + modify_plist "{MINIMUM_SYSTEM_VERSION}" "10.13" "${LAUNCHER_CONTENTS_DIR}/Info.plist" + clang -m64 "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/packaging/macos/launcher.m" -o "${LAUNCHER_MACOS_DIR}/OpenRA" -framework AppKit -mmacosx-version-min=10.13 -pushd "${TEMPLATE_ROOT}" > /dev/null + curl -s -L -o "${PACKAGING_OSX_MONO_TEMP_ARCHIVE_NAME}" -O "${PACKAGING_OSX_MONO_SOURCE}" || exit 3 + unzip -qq -d "${BUILTDIR}" "${PACKAGING_OSX_MONO_TEMP_ARCHIVE_NAME}" + rm "${PACKAGING_OSX_MONO_TEMP_ARCHIVE_NAME}" -if [ ! -f "${ENGINE_DIRECTORY}/Makefile" ]; 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 -fi + mv "${BUILTDIR}/mono" "${LAUNCHER_MACOS_DIR}" + mv "${BUILTDIR}/etc" "${LAUNCHER_RESOURCES_DIR}" + mv "${BUILTDIR}/lib" "${LAUNCHER_RESOURCES_DIR}" + fi -if [ ! -d "${OUTPUTDIR}" ]; then - echo "Output directory '${OUTPUTDIR}' does not exist."; - exit 1 -fi + echo "Building core files" + install_assemblies_mono "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}" "${LAUNCHER_RESOURCES_DIR}" "osx-x64" "True" "${PACKAGING_COPY_CNC_DLL}" "${PACKAGING_COPY_D2K_DLL}" + install_data "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}" "${LAUNCHER_RESOURCES_DIR}" -MOD_VERSION=$(grep 'Version:' mods/${MOD_ID}/mod.yaml | awk '{print $2}') + for f in ${PACKAGING_COPY_ENGINE_FILES}; do + mkdir -p "${LAUNCHER_RESOURCES_DIR}/$(dirname "${f}")" + cp -r "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/${f}" "${LAUNCHER_RESOURCES_DIR}/${f}" + done -if [ "${PACKAGING_OVERWRITE_MOD_VERSION}" == "True" ]; then - make version VERSION="${TAG}" -else - echo "Mod version ${MOD_VERSION} will remain unchanged."; -fi + echo "Building mod files" + pushd "${TEMPLATE_ROOT}" > /dev/null + make all + popd > /dev/null -pushd "${ENGINE_DIRECTORY}" > /dev/null -echo "Building core files" - -make clean -make osx-dependencies -make core -make version VERSION="${ENGINE_VERSION}" -make install-engine gameinstalldir="/Contents/Resources/" DESTDIR="${BUILTDIR}/OpenRA.app" -make install-common-mod-files gameinstalldir="/Contents/Resources/" DESTDIR="${BUILTDIR}/OpenRA.app" - -for f in ${PACKAGING_COPY_ENGINE_FILES}; do - mkdir -p "${BUILTDIR}/OpenRA.app/Contents/Resources/$(dirname "${f}")" - cp -r "${f}" "${BUILTDIR}/OpenRA.app/Contents/Resources/${f}" -done - -popd > /dev/null - -echo "Building mod files" -make core -cp -LR mods/* "${BUILTDIR}/OpenRA.app/Contents/Resources/mods" - -popd > /dev/null - -pushd "${BUILTDIR}" > /dev/null -mv "OpenRA.app" "${PACKAGING_OSX_APP_NAME}" - - -# Assemble multi-resolution icon -mkdir mod.iconset -cp "${ARTWORK_DIR}/icon_16x16.png" "mod.iconset/icon_16x16.png" -cp "${ARTWORK_DIR}/icon_32x32.png" "mod.iconset/icon_16x16@2.png" -cp "${ARTWORK_DIR}/icon_32x32.png" "mod.iconset/icon_32x32.png" -cp "${ARTWORK_DIR}/icon_64x64.png" "mod.iconset/icon_32x32@2x.png" -cp "${ARTWORK_DIR}/icon_128x128.png" "mod.iconset/icon_128x128.png" -cp "${ARTWORK_DIR}/icon_256x256.png" "mod.iconset/icon_128x128@2x.png" -cp "${ARTWORK_DIR}/icon_256x256.png" "mod.iconset/icon_256x256.png" -cp "${ARTWORK_DIR}/icon_512x512.png" "mod.iconset/icon_256x256@2x.png" -iconutil --convert icns "mod.iconset" -o "${PACKAGING_OSX_APP_NAME}/Contents/Resources/${MOD_ID}.icns" -rm -rf mod.iconset - -# Copy macOS specific files -modify_plist "{MOD_ID}" "${MOD_ID}" "${PACKAGING_OSX_APP_NAME}/Contents/Info.plist" -modify_plist "{MOD_NAME}" "${PACKAGING_DISPLAY_NAME}" "${PACKAGING_OSX_APP_NAME}/Contents/Info.plist" -modify_plist "{JOIN_SERVER_URL_SCHEME}" "openra-${MOD_ID}-${TAG}" "${PACKAGING_OSX_APP_NAME}/Contents/Info.plist" - -# Sign binaries with developer certificate -if [ -n "${MACOS_DEVELOPER_IDENTITY}" ]; then - codesign -s "${MACOS_DEVELOPER_IDENTITY}" --timestamp --options runtime -f --entitlements "${PACKAGING_DIR}/entitlements.plist" "${PACKAGING_OSX_APP_NAME}/Contents/Resources/"*.dylib - codesign -s "${MACOS_DEVELOPER_IDENTITY}" --timestamp --options runtime -f --entitlements "${PACKAGING_DIR}/entitlements.plist" --deep "${PACKAGING_OSX_APP_NAME}" -fi + cp -LR "${TEMPLATE_ROOT}mods/"* "${LAUNCHER_RESOURCES_DIR}/mods" -if [ -n "${MACOS_DEVELOPER_CERTIFICATE_BASE64}" ] && [ -n "${MACOS_DEVELOPER_CERTIFICATE_PASSWORD}" ] && [ -n "${MACOS_DEVELOPER_IDENTITY}" ]; then - security delete-keychain build.keychain -fi + for f in ${PACKAGING_COPY_MOD_BINARIES}; do + mkdir -p "${LAUNCHER_RESOURCES_DIR}/$(dirname "${f}")" + cp "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/bin/${f}" "${LAUNCHER_RESOURCES_DIR}/${f}" + done -echo "Packaging disk image" -hdiutil create build.dmg -format UDRW -volname "${PACKAGING_DISPLAY_NAME}" -fs HFS+ -srcfolder "${BUILTDIR}" -DMG_DEVICE=$(hdiutil attach -readwrite -noverify -noautoopen "build.dmg" | egrep '^/dev/' | sed 1q | awk '{print $1}') -sleep 2 - -# Background image is created from source svg in artsrc repository -mkdir "/Volumes/${PACKAGING_DISPLAY_NAME}/.background/" -tiffutil -cathidpicheck "${ARTWORK_DIR}/macos-background.png" "${ARTWORK_DIR}/macos-background-2x.png" -out "/Volumes/${PACKAGING_DISPLAY_NAME}/.background/background.tiff" - -cp "${BUILTDIR}/${PACKAGING_OSX_APP_NAME}/Contents/Resources/${MOD_ID}.icns" "/Volumes/${PACKAGING_DISPLAY_NAME}/.VolumeIcon.icns" - -echo ' - tell application "Finder" - tell disk "'${PACKAGING_DISPLAY_NAME}'" - open - set current view of container window to icon view - set toolbar visible of container window to false - set statusbar visible of container window to false - set the bounds of container window to {400, 100, 1000, 550} - set theViewOptions to the icon view options of container window - set arrangement of theViewOptions to not arranged - set icon size of theViewOptions to 72 - set background picture of theViewOptions to file ".background:background.tiff" - make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"} - set position of item "'${PACKAGING_OSX_APP_NAME}'" of container window to {'${PACKAGING_OSX_DMG_MOD_ICON_POSITION}'} - set position of item "Applications" of container window to {'${PACKAGING_OSX_DMG_APPLICATION_ICON_POSITION}'} - set position of item ".background" of container window to {'${PACKAGING_OSX_DMG_HIDDEN_ICON_POSITION}'} - set position of item ".fseventsd" of container window to {'${PACKAGING_OSX_DMG_HIDDEN_ICON_POSITION}'} - set position of item ".VolumeIcon.icns" of container window to {'${PACKAGING_OSX_DMG_HIDDEN_ICON_POSITION}'} - update without registering applications - delay 5 - close - end tell - end tell -' | osascript - -# HACK: Copy the volume icon again - something in the previous step seems to delete it...? -cp "${BUILTDIR}/${PACKAGING_OSX_APP_NAME}/Contents/Resources/${MOD_ID}.icns" "/Volumes/${PACKAGING_DISPLAY_NAME}/.VolumeIcon.icns" -SetFile -c icnC "/Volumes/${PACKAGING_DISPLAY_NAME}/.VolumeIcon.icns" -SetFile -a C "/Volumes/${PACKAGING_DISPLAY_NAME}" - -chmod -Rf go-w "/Volumes/${PACKAGING_DISPLAY_NAME}" -sync -sync - -hdiutil detach "${DMG_DEVICE}" - -# Submit for notarization -if [ -n "${MACOS_DEVELOPER_USERNAME}" ] && [ -n "${MACOS_DEVELOPER_PASSWORD}" ]; then - echo "Submitting disk image for notarization" + set_engine_version "${ENGINE_VERSION}" "${LAUNCHER_RESOURCES_DIR}" + if [ "${PACKAGING_OVERWRITE_MOD_VERSION}" == "True" ]; then + set_mod_version "${TAG}" "${LAUNCHER_RESOURCES_DIR}/mods/${MOD_ID}/mod.yaml" + else + MOD_VERSION=$(grep 'Version:' "${LAUNCHER_RESOURCES_DIR}/mods/${MOD_ID}/mod.yaml" | awk '{print $2}') + echo "Mod version ${MOD_VERSION} will remain unchanged."; + fi + + # Assemble multi-resolution icon + mkdir "${BUILTDIR}/mod.iconset" + cp "${ARTWORK_DIR}/icon_16x16.png" "${BUILTDIR}/mod.iconset/icon_16x16.png" + cp "${ARTWORK_DIR}/icon_32x32.png" "${BUILTDIR}/mod.iconset/icon_16x16@2.png" + cp "${ARTWORK_DIR}/icon_32x32.png" "${BUILTDIR}/mod.iconset/icon_32x32.png" + cp "${ARTWORK_DIR}/icon_64x64.png" "${BUILTDIR}/mod.iconset/icon_32x32@2x.png" + cp "${ARTWORK_DIR}/icon_128x128.png" "${BUILTDIR}/mod.iconset/icon_128x128.png" + cp "${ARTWORK_DIR}/icon_256x256.png" "${BUILTDIR}/mod.iconset/icon_128x128@2x.png" + cp "${ARTWORK_DIR}/icon_256x256.png" "${BUILTDIR}/mod.iconset/icon_256x256.png" + cp "${ARTWORK_DIR}/icon_512x512.png" "${BUILTDIR}/mod.iconset/icon_256x256@2x.png" + iconutil --convert icns "${BUILTDIR}/mod.iconset" -o "${LAUNCHER_RESOURCES_DIR}/${MOD_ID}.icns" + rm -rf "${BUILTDIR}/mod.iconset" + + # Sign binaries with developer certificate + if [ -n "${MACOS_DEVELOPER_IDENTITY}" ]; then + codesign -s "${MACOS_DEVELOPER_IDENTITY}" --timestamp --options runtime -f --entitlements "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/packaging/macos/entitlements.plist" "${LAUNCHER_RESOURCES_DIR}/"*.dylib + codesign -s "${MACOS_DEVELOPER_IDENTITY}" --timestamp --options runtime -f --entitlements "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/packaging/macos/entitlements.plist" --deep "${LAUNCHER_DIR}" + fi + + echo "Packaging disk image" + hdiutil create "${PACKAGING_DIR}/${DMG_NAME}" -format UDRW -volname "${PACKAGING_DISPLAY_NAME}" -fs HFS+ -srcfolder "${BUILTDIR}" + DMG_DEVICE=$(hdiutil attach -readwrite -noverify -noautoopen "${PACKAGING_DIR}/${DMG_NAME}" | egrep '^/dev/' | sed 1q | awk '{print $1}') + sleep 2 + + # Background image is created from source svg in artsrc repository + mkdir "/Volumes/${PACKAGING_DISPLAY_NAME}/.background/" + tiffutil -cathidpicheck "${ARTWORK_DIR}/macos-background.png" "${ARTWORK_DIR}/macos-background-2x.png" -out "/Volumes/${PACKAGING_DISPLAY_NAME}/.background/background.tiff" + + cp "${LAUNCHER_DIR}/Contents/Resources/${MOD_ID}.icns" "/Volumes/${PACKAGING_DISPLAY_NAME}/.VolumeIcon.icns" + + echo ' + tell application "Finder" + tell disk "'${PACKAGING_DISPLAY_NAME}'" + open + set current view of container window to icon view + set toolbar visible of container window to false + set statusbar visible of container window to false + set the bounds of container window to {400, 100, 1000, 550} + set theViewOptions to the icon view options of container window + set arrangement of theViewOptions to not arranged + set icon size of theViewOptions to 72 + set background picture of theViewOptions to file ".background:background.tiff" + make new alias file at container window to POSIX file "/Applications" with properties {name:"Applications"} + set position of item "'${PACKAGING_OSX_APP_NAME}'" of container window to {'${PACKAGING_OSX_DMG_MOD_ICON_POSITION}'} + set position of item "Applications" of container window to {'${PACKAGING_OSX_DMG_APPLICATION_ICON_POSITION}'} + set position of item ".background" of container window to {'${PACKAGING_OSX_DMG_HIDDEN_ICON_POSITION}'} + set position of item ".fseventsd" of container window to {'${PACKAGING_OSX_DMG_HIDDEN_ICON_POSITION}'} + set position of item ".VolumeIcon.icns" of container window to {'${PACKAGING_OSX_DMG_HIDDEN_ICON_POSITION}'} + update without registering applications + delay 5 + close + end tell + end tell + ' | osascript + + # HACK: Copy the volume icon again - something in the previous step seems to delete it...? + cp "${LAUNCHER_DIR}/Contents/Resources/${MOD_ID}.icns" "/Volumes/${PACKAGING_DISPLAY_NAME}/.VolumeIcon.icns" + SetFile -c icnC "/Volumes/${PACKAGING_DISPLAY_NAME}/.VolumeIcon.icns" + SetFile -a C "/Volumes/${PACKAGING_DISPLAY_NAME}" + + chmod -Rf go-w "/Volumes/${PACKAGING_DISPLAY_NAME}" + sync + sync + + hdiutil detach "${DMG_DEVICE}" + rm -rf "${BUILTDIR}" +} + +notarize_package() { + DMG_PATH="${1}" + NOTARIZE_DMG_PATH="${DMG_PATH%.*}"-notarization.dmg + echo "Submitting ${DMG_PATH} for notarization" # Reset xcode search path to fix xcrun not finding altool sudo xcode-select -r # Create a temporary read-only dmg for submission (notarization service rejects read/write images) - hdiutil convert build.dmg -format UDZO -imagekey zlib-level=9 -ov -o notarization.dmg + hdiutil convert "${DMG_PATH}" -format UDZO -imagekey zlib-level=9 -ov -o "${NOTARIZE_DMG_PATH}" - NOTARIZATION_UUID=$(xcrun altool --notarize-app --primary-bundle-id "net.openra.modsdk" -u "${MACOS_DEVELOPER_USERNAME}" -p "${MACOS_DEVELOPER_PASSWORD}" --file notarization.dmg 2>&1 | awk -F' = ' '/RequestUUID/ { print $2; exit }') + NOTARIZATION_UUID=$(xcrun altool --notarize-app --primary-bundle-id "net.openra.modsdk" -u "${MACOS_DEVELOPER_USERNAME}" -p "${MACOS_DEVELOPER_PASSWORD}" --file "${NOTARIZE_DMG_PATH}" 2>&1 | awk -F' = ' '/RequestUUID/ { print $2; exit }') if [ -z "${NOTARIZATION_UUID}" ]; then echo "Submission failed" exit 1 fi - echo "Submission UUID is ${NOTARIZATION_UUID}" - rm notarization.dmg + echo "${DMG_PATH} submission UUID is ${NOTARIZATION_UUID}" + rm "${NOTARIZE_DMG_PATH}" while :; do sleep 30 NOTARIZATION_RESULT=$(xcrun altool --notarization-info "${NOTARIZATION_UUID}" -u "${MACOS_DEVELOPER_USERNAME}" -p "${MACOS_DEVELOPER_PASSWORD}" 2>&1 | awk -F': ' '/Status/ { print $2; exit }') - echo "Submission status: ${NOTARIZATION_RESULT}" + echo "${DMG_PATH}: ${NOTARIZATION_RESULT}" if [ "${NOTARIZATION_RESULT}" == "invalid" ]; then NOTARIZATION_LOG_URL=$(xcrun altool --notarization-info "${NOTARIZATION_UUID}" -u "${MACOS_DEVELOPER_USERNAME}" -p "${MACOS_DEVELOPER_PASSWORD}" 2>&1 | awk -F': ' '/LogFileURL/ { print $2; exit }') - echo "Notarization failed with error:" + echo "${NOTARIZATION_UUID} failed notarization with error:" curl -s "${NOTARIZATION_LOG_URL}" -w "\n" exit 1 fi if [ "${NOTARIZATION_RESULT}" == "success" ]; then - echo "Stapling notarization ticket" - DMG_DEVICE=$(hdiutil attach -readwrite -noverify -noautoopen "build.dmg" | egrep '^/dev/' | sed 1q | awk '{print $1}') + echo "${DMG_PATH}: Stapling tickets" + DMG_DEVICE=$(hdiutil attach -readwrite -noverify -noautoopen "${DMG_PATH}" | egrep '^/dev/' | sed 1q | awk '{print $1}') sleep 2 xcrun stapler staple "/Volumes/${PACKAGING_DISPLAY_NAME}/${PACKAGING_OSX_APP_NAME}" @@ -261,11 +285,29 @@ if [ -n "${MACOS_DEVELOPER_USERNAME}" ] && [ -n "${MACOS_DEVELOPER_PASSWORD}" ]; break fi done -fi +} + +finalize_package() { + DMG_PATH="${1}" + OUTPUT_PATH="${2}" -hdiutil convert build.dmg -format UDZO -imagekey zlib-level=9 -ov -o "${OUTPUTDIR}/${PACKAGING_INSTALLER_NAME}-${TAG}.dmg" + hdiutil convert "${DMG_PATH}" -format UDZO -imagekey zlib-level=9 -ov -o "${OUTPUT_PATH}" + rm "${DMG_PATH}" +} + +build_platform "standard" "build.dmg" +build_platform "compat" "build-compat.dmg" -popd > /dev/null +if [ -n "${MACOS_DEVELOPER_CERTIFICATE_BASE64}" ] && [ -n "${MACOS_DEVELOPER_CERTIFICATE_PASSWORD}" ] && [ -n "${MACOS_DEVELOPER_IDENTITY}" ]; then + security delete-keychain build.keychain +fi + +if [ -n "${MACOS_DEVELOPER_USERNAME}" ] && [ -n "${MACOS_DEVELOPER_PASSWORD}" ]; then + # Parallelize processing + (notarize_package "build.dmg") & + (notarize_package "build-compat.dmg") & + wait +fi -# Clean up -rm -rf "${BUILTDIR}" +finalize_package "build.dmg" "${OUTPUTDIR}/${PACKAGING_INSTALLER_NAME}-${TAG}.dmg" +finalize_package "build-compat.dmg" "${OUTPUTDIR}/${PACKAGING_INSTALLER_NAME}-${TAG}-compat.dmg" diff --git a/packaging/macos/entitlements.plist b/packaging/macos/entitlements.plist deleted file mode 100644 index dcfe14ccd..000000000 --- a/packaging/macos/entitlements.plist +++ /dev/null @@ -1,16 +0,0 @@ - - - - -com.apple.security.cs.allow-jit - -com.apple.security.cs.allow-unsigned-executable-memory - -com.apple.security.cs.disable-executable-page-protection - -com.apple.security.cs.disable-library-validation - -com.apple.security.cs.allow-dyld-environment-variables - - - diff --git a/packaging/windows/buildpackage.nsi b/packaging/windows/buildpackage.nsi index 489c3a9de..6b7a8c2c8 100644 --- a/packaging/windows/buildpackage.nsi +++ b/packaging/windows/buildpackage.nsi @@ -1,4 +1,4 @@ -; Copyright 2007-2019 OpenRA developers (see AUTHORS) +; Copyright 2007-2021 OpenRA developers (see AUTHORS) ; This file is part of OpenRA. ; ; OpenRA is free software: you can redistribute it and/or modify @@ -20,7 +20,7 @@ !include "WordFunc.nsh" Name "${PACKAGING_DISPLAY_NAME}" -OutFile "OpenRA.Setup.exe" +OutFile "${OUTFILE}" ManifestDPIAware true @@ -79,36 +79,29 @@ Section "-Reg" Reg WriteRegStr HKLM "Software\Classes\openra-${MOD_ID}-${TAG}\DefaultIcon" "" "$INSTDIR\${MOD_ID}.ico,0" WriteRegStr HKLM "Software\Classes\openra-${MOD_ID}-${TAG}\Shell\Open\Command" "" "$INSTDIR\${PACKAGING_WINDOWS_LAUNCHER_NAME}.exe Launch.URI=%1" + !ifdef USE_DISCORDID + WriteRegStr HKLM "Software\Classes\discord-${USE_DISCORDID}" "" "URL:Run game ${USE_DISCORDID} protocol" + WriteRegStr HKLM "Software\Classes\discord-${USE_DISCORDID}" "URL Protocol" "" + WriteRegStr HKLM "Software\Classes\discord-${USE_DISCORDID}\DefaultIcon" "" "$INSTDIR\${MOD_ID}.ico,0" + WriteRegStr HKLM "Software\Classes\discord-${USE_DISCORDID}\Shell\Open\Command" "" "$INSTDIR\${PACKAGING_WINDOWS_LAUNCHER_NAME}.exe" + !endif + SectionEnd Section "Game" GAME SectionIn RO SetOutPath "$INSTDIR" - File /r "${SRCDIR}\mods" - File "${SRCDIR}\${PACKAGING_WINDOWS_LAUNCHER_NAME}.exe" - File "${SRCDIR}\OpenRA.Game.exe" - File "${SRCDIR}\OpenRA.Game.exe.config" - File "${SRCDIR}\OpenRA.Utility.exe" - File "${SRCDIR}\OpenRA.Server.exe" - File "${SRCDIR}\OpenRA.Platforms.Default.dll" - File "${SRCDIR}\ICSharpCode.SharpZipLib.dll" - File "${SRCDIR}\FuzzyLogicLibrary.dll" - File "${SRCDIR}\Open.Nat.dll" + File "${SRCDIR}\*.exe" + File "${SRCDIR}\*.exe.config" + File "${SRCDIR}\*.dll" + File "${SRCDIR}\*.ico" File "${SRCDIR}\VERSION" File "${SRCDIR}\AUTHORS" File "${SRCDIR}\COPYING" - File "${SRCDIR}\${MOD_ID}.ico" - File "${SRCDIR}\SDL2-CS.dll" - File "${SRCDIR}\OpenAL-CS.dll" File "${SRCDIR}\global mix database.dat" File "${SRCDIR}\IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP" - File "${SRCDIR}\eluant.dll" - File "${SRCDIR}\rix0rrr.BeaconLib.dll" - File "${DEPSDIR}\soft_oal.dll" - File "${DEPSDIR}\SDL2.dll" - File "${DEPSDIR}\freetype6.dll" - File "${DEPSDIR}\lua51.dll" + File /r "${SRCDIR}\mods" !insertmacro MUI_STARTMENU_WRITE_BEGIN Application CreateDirectory "$SMPROGRAMS\$StartMenuFolder" @@ -150,9 +143,9 @@ Section "-DotNet" DotNet ; https://docs.microsoft.com/en-us/dotnet/framework/migration-guide/how-to-determine-which-versions-are-installed ReadRegDWORD $0 HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" "Release" IfErrors error 0 - IntCmp $0 394254 done error done + IntCmp $0 461808 done error done error: - MessageBox MB_OK ".NET Framework v4.6.1 or later is required to run OpenRA." + MessageBox MB_OK ".NET Framework v4.7.2 or later is required to run OpenRA." Abort done: SectionEnd @@ -182,34 +175,24 @@ Function ${UN}Clean RMDir /r $INSTDIR\maps RMDir /r $INSTDIR\glsl RMDir /r $INSTDIR\lua - Delete "$INSTDIR\${PACKAGING_WINDOWS_LAUNCHER_NAME}.exe" - Delete $INSTDIR\OpenRA.Game.exe - Delete $INSTDIR\OpenRA.Game.exe.config - Delete $INSTDIR\OpenRA.Utility.exe - Delete $INSTDIR\OpenRA.Server.exe - Delete $INSTDIR\OpenRA.Platforms.Default.dll - Delete $INSTDIR\ICSharpCode.SharpZipLib.dll - Delete $INSTDIR\FuzzyLogicLibrary.dll - Delete $INSTDIR\Open.Nat.dll + Delete $INSTDIR\*.exe + Delete $INSTDIR\*.exe.config + Delete $INSTDIR\*.dll + Delete $INSTDIR\*.ico Delete $INSTDIR\VERSION Delete $INSTDIR\AUTHORS Delete $INSTDIR\COPYING - Delete $INSTDIR\${MOD_ID}.ico Delete "$INSTDIR\global mix database.dat" Delete $INSTDIR\IP2LOCATION-LITE-DB1.IPV6.BIN.ZIP - Delete $INSTDIR\soft_oal.dll - Delete $INSTDIR\SDL2.dll - Delete $INSTDIR\lua51.dll - Delete $INSTDIR\eluant.dll - Delete $INSTDIR\freetype6.dll - Delete $INSTDIR\SDL2-CS.dll - Delete $INSTDIR\OpenAL-CS.dll - Delete $INSTDIR\rix0rrr.BeaconLib.dll RMDir /r $INSTDIR\Support DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PACKAGING_WINDOWS_REGISTRY_KEY}" DeleteRegKey HKLM "Software\Classes\openra-${MOD_ID}-${TAG}" + !ifdef USE_DISCORDID + DeleteRegKey HKLM "Software\Classes\discord-${DISCORD_APP_ID}" + !endif + Delete $INSTDIR\uninstaller.exe RMDir $INSTDIR diff --git a/packaging/windows/buildpackage.sh b/packaging/windows/buildpackage.sh index b2d4b4dde..548bd65c0 100755 --- a/packaging/windows/buildpackage.sh +++ b/packaging/windows/buildpackage.sh @@ -10,14 +10,14 @@ require_variables() { 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." + if [ -n "${missing}" ]; then + printf "Required mod.config variables are missing:\n%sRepair your mod.config (or user.config) and try again.\n" "${missing}" exit 1 fi } if [ $# -eq "0" ]; then - echo "Usage: `basename $0` version [outputdir]" + echo "Usage: $(basename "$0") version [outputdir]" exit 1 fi @@ -33,7 +33,7 @@ if [ -f "${TEMPLATE_ROOT}/user.config" ]; then . "${TEMPLATE_ROOT}/user.config" fi -require_variables "MOD_ID" "ENGINE_DIRECTORY" "PACKAGING_DISPLAY_NAME" "PACKAGING_INSTALLER_NAME" \ +require_variables "MOD_ID" "ENGINE_DIRECTORY" "PACKAGING_DISPLAY_NAME" "PACKAGING_INSTALLER_NAME" "PACKAGING_COPY_CNC_DLL" "PACKAGING_COPY_D2K_DLL" \ "PACKAGING_WINDOWS_LAUNCHER_NAME" "PACKAGING_WINDOWS_REGISTRY_KEY" "PACKAGING_WINDOWS_INSTALL_DIR_NAME" \ "PACKAGING_WINDOWS_LICENSE_FILE" "PACKAGING_FAQ_URL" "PACKAGING_WEBSITE_URL" "PACKAGING_AUTHORS" "PACKAGING_OVERWRITE_MOD_VERSION" @@ -49,96 +49,77 @@ BUILTDIR="${PACKAGING_DIR}/build" # Set the working dir to the location of this script cd "${PACKAGING_DIR}" -LAUNCHER_LIBS="-r:System.dll -r:System.Drawing.dll -r:System.Windows.Forms.dll -r:${BUILTDIR}/OpenRA.Game.exe" - -pushd ${TEMPLATE_ROOT} > /dev/null - -if [ ! -f "${ENGINE_DIRECTORY}/Makefile" ]; then +if [ ! -f "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/Makefile" ]; 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 fi +. "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/packaging/functions.sh" + if [ ! -d "${OUTPUTDIR}" ]; then echo "Output directory '${OUTPUTDIR}' does not exist."; exit 1 fi -MOD_VERSION=$(grep 'Version:' mods/${MOD_ID}/mod.yaml | awk '{print $2}') - -if [ "${PACKAGING_OVERWRITE_MOD_VERSION}" == "True" ]; then - make version VERSION="${TAG}" -else - echo "Mod version ${MOD_VERSION} will remain unchanged."; -fi - -popd > /dev/null - function build_platform() { - if [ "$1" = "x86" ]; then - IS_WIN32="WIN32=true" + PLATFORM="${1}" + if [ "${PLATFORM}" = "x86" ]; then USE_PROGRAMFILES32="-DUSE_PROGRAMFILES32=true" else - IS_WIN32="WIN32=false" USE_PROGRAMFILES32="" fi - pushd ${TEMPLATE_ROOT} > /dev/null - - echo "Building core files ($1)" - pushd ${ENGINE_DIRECTORY} > /dev/null - - SRC_DIR="$(pwd)" + if [ -n "${PACKAGING_DISCORD_APPID}" ]; then + USE_DISCORDID="-DUSE_DISCORDID=${PACKAGING_DISCORD_APPID}" + else + USE_DISCORDID="" + fi - make clean - make windows-dependencies "${IS_WIN32}" - make core "${IS_WIN32}" - make version VERSION="${ENGINE_VERSION}" - make install-engine gameinstalldir="" DESTDIR="${BUILTDIR}" - make install-common-mod-files gameinstalldir="" DESTDIR="${BUILTDIR}" + echo "Building core files (${PLATFORM})" + install_assemblies_mono "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}" "${BUILTDIR}" "win-${PLATFORM}" "False" "${PACKAGING_COPY_CNC_DLL}" "${PACKAGING_COPY_D2K_DLL}" + install_data "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}" "${BUILTDIR}" for f in ${PACKAGING_COPY_ENGINE_FILES}; do mkdir -p "${BUILTDIR}/$(dirname "${f}")" - cp -r "${f}" "${BUILTDIR}/${f}" + cp -r "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/${f}" "${BUILTDIR}/${f}" done + echo "Building mod files (${PLATFORM})" + pushd "${TEMPLATE_ROOT}" > /dev/null + make all popd > /dev/null - echo "Building mod files ($1)" - make core + cp -Lr "${TEMPLATE_ROOT}/mods/"* "${BUILTDIR}/mods" - cp -Lr mods/* "${BUILTDIR}/mods" + for f in ${PACKAGING_COPY_MOD_BINARIES}; do + mkdir -p "${BUILTDIR}/$(dirname "${f}")" + cp "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/bin/${f}" "${BUILTDIR}/${f}" + done - popd > /dev/null + set_engine_version "${ENGINE_VERSION}" "${BUILTDIR}" + if [ "${PACKAGING_OVERWRITE_MOD_VERSION}" == "True" ]; then + set_mod_version "${TAG}" "${BUILTDIR}/mods/${MOD_ID}/mod.yaml" + else + MOD_VERSION=$(grep 'Version:' "mods/${MOD_ID}/mod.yaml" | awk '{print $2}') + echo "Mod version ${MOD_VERSION} will remain unchanged."; + fi # Create multi-resolution icon convert "${ARTWORK_DIR}/icon_16x16.png" "${ARTWORK_DIR}/icon_24x24.png" "${ARTWORK_DIR}/icon_32x32.png" "${ARTWORK_DIR}/icon_48x48.png" "${ARTWORK_DIR}/icon_256x256.png" "${BUILTDIR}/${MOD_ID}.ico" - cp "${SRC_DIR}/OpenRA.Game.exe.config" "${BUILTDIR}" - # We need to set the loadFromRemoteSources flag for the launcher, but only for the "portable" zip package. - # Windows automatically un-trusts executables that are extracted from a downloaded zip file - cp "${SRC_DIR}/OpenRA.Game.exe.config" "${BUILTDIR}/${PACKAGING_WINDOWS_LAUNCHER_NAME}.exe.config" + echo "Compiling Windows launcher (${PLATFORM})" + install_windows_launcher "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}" "${BUILTDIR}" "win-${PLATFORM}" "${MOD_ID}" "${PACKAGING_WINDOWS_LAUNCHER_NAME}" "${PACKAGING_DISPLAY_NAME}" "${BUILTDIR}/${MOD_ID}.ico" "${PACKAGING_FAQ_URL}" - echo "Compiling Windows launcher ($1)" - sed "s|DISPLAY_NAME|${PACKAGING_DISPLAY_NAME}|" "${SRC_DIR}/packaging/windows/WindowsLauncher.cs.in" | sed "s|MOD_ID|${MOD_ID}|" | sed "s|FAQ_URL|${PACKAGING_FAQ_URL}|" > "${BUILTDIR}/WindowsLauncher.cs" - csc "${BUILTDIR}/WindowsLauncher.cs" -nologo -warn:4 -warnaserror -platform:"$1" -out:"${BUILTDIR}/${PACKAGING_WINDOWS_LAUNCHER_NAME}.exe" -t:winexe ${LAUNCHER_LIBS} -win32icon:"${BUILTDIR}/${MOD_ID}.ico" - rm "${BUILTDIR}/WindowsLauncher.cs" - mono "${SRC_DIR}/OpenRA.PostProcess.exe" "${BUILTDIR}/${PACKAGING_WINDOWS_LAUNCHER_NAME}.exe" -LAA > /dev/null - - echo "Building Windows setup.exe ($1)" + echo "Building Windows setup.exe (${PLATFORM})" pushd "${PACKAGING_DIR}" > /dev/null - makensis -V2 -DSRCDIR="${BUILTDIR}" -DDEPSDIR="${SRC_DIR}/thirdparty/download/windows" -DTAG="${TAG}" -DMOD_ID="${MOD_ID}" -DPACKAGING_WINDOWS_INSTALL_DIR_NAME="${PACKAGING_WINDOWS_INSTALL_DIR_NAME}" -DPACKAGING_WINDOWS_LAUNCHER_NAME="${PACKAGING_WINDOWS_LAUNCHER_NAME}" -DPACKAGING_DISPLAY_NAME="${PACKAGING_DISPLAY_NAME}" -DPACKAGING_WEBSITE_URL="${PACKAGING_WEBSITE_URL}" -DPACKAGING_AUTHORS="${PACKAGING_AUTHORS}" -DPACKAGING_WINDOWS_REGISTRY_KEY="${PACKAGING_WINDOWS_REGISTRY_KEY}" -DPACKAGING_WINDOWS_LICENSE_FILE="${TEMPLATE_ROOT}/${PACKAGING_WINDOWS_LICENSE_FILE}" ${USE_PROGRAMFILES32} buildpackage.nsi - if [ $? -eq 0 ]; then - mv OpenRA.Setup.exe "${OUTPUTDIR}/${PACKAGING_INSTALLER_NAME}-${TAG}-${1}.exe" - fi + makensis -V2 -DSRCDIR="${BUILTDIR}" -DTAG="${TAG}" -DMOD_ID="${MOD_ID}" -DPACKAGING_WINDOWS_INSTALL_DIR_NAME="${PACKAGING_WINDOWS_INSTALL_DIR_NAME}" -DPACKAGING_WINDOWS_LAUNCHER_NAME="${PACKAGING_WINDOWS_LAUNCHER_NAME}" -DPACKAGING_DISPLAY_NAME="${PACKAGING_DISPLAY_NAME}" -DPACKAGING_WEBSITE_URL="${PACKAGING_WEBSITE_URL}" -DPACKAGING_AUTHORS="${PACKAGING_AUTHORS}" -DPACKAGING_WINDOWS_REGISTRY_KEY="${PACKAGING_WINDOWS_REGISTRY_KEY}" -DPACKAGING_WINDOWS_LICENSE_FILE="${TEMPLATE_ROOT}/${PACKAGING_WINDOWS_LICENSE_FILE}" -DOUTFILE="${OUTPUTDIR}/${PACKAGING_INSTALLER_NAME}-${TAG}-${PLATFORM}.exe" ${USE_PROGRAMFILES32} ${USE_DISCORDID} buildpackage.nsi popd > /dev/null - echo "Packaging zip archive ($1)" + echo "Packaging zip archive (${PLATFORM})" pushd "${BUILTDIR}" > /dev/null - find "${SRC_DIR}/thirdparty/download/windows/" -name '*.dll' -exec cp '{}' '.' ';' - zip "${PACKAGING_INSTALLER_NAME}-${TAG}-${1}-winportable.zip" -r -9 * --quiet - mv "${PACKAGING_INSTALLER_NAME}-${TAG}-${1}-winportable.zip" "${OUTPUTDIR}" + zip "${OUTPUTDIR}/${PACKAGING_INSTALLER_NAME}-${TAG}-${PLATFORM}-winportable.zip" -r -9 ./* --quiet popd > /dev/null # Cleanup diff --git a/utility.cmd b/utility.cmd index 0a9eee325..94fa76d8c 100644 --- a/utility.cmd +++ b/utility.cmd @@ -4,7 +4,7 @@ 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 - +set ENGINE_DIR=.. if "!MOD_ID!" == "" goto badconfig if "!ENGINE_VERSION!" == "" goto badconfig if "!ENGINE_DIRECTORY!" == "" goto badconfig @@ -12,7 +12,7 @@ if "!ENGINE_DIRECTORY!" == "" goto badconfig title OpenRA.Utility.exe %MOD_ID% set TEMPLATE_DIR=%CD% -if not exist %ENGINE_DIRECTORY%\OpenRA.Game.exe goto noengine +if not exist %ENGINE_DIRECTORY%\bin\OpenRA.exe goto noengine >nul find %ENGINE_VERSION% %ENGINE_DIRECTORY%\VERSION || goto noengine cd %ENGINE_DIRECTORY% @@ -30,7 +30,7 @@ echo. echo ---------------------------------------- echo. echo OpenRA.Utility.exe %MOD_ID% %command% -call OpenRA.Utility.exe %MOD_ID% %command% +call bin\OpenRA.Utility.exe %MOD_ID% %command% goto loop :noengine @@ -44,4 +44,4 @@ 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 \ No newline at end of file +exit /b diff --git a/utility.sh b/utility.sh index 0473046ec..1f7b38df8 100755 --- a/utility.sh +++ b/utility.sh @@ -43,11 +43,11 @@ require_variables "MOD_ID" "ENGINE_VERSION" "ENGINE_DIRECTORY" LAUNCH_MOD="${Mod:-"${MOD_ID}"}" cd "${TEMPLATE_ROOT}" -if [ ! -f "${ENGINE_DIRECTORY}/OpenRA.Game.exe" ] || [ "$(cat "${ENGINE_DIRECTORY}/VERSION")" != "${ENGINE_VERSION}" ]; then +if [ ! -f "${ENGINE_DIRECTORY}/bin/OpenRA.Utility.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 fi cd "${ENGINE_DIRECTORY}" -MOD_SEARCH_PATHS="${MOD_SEARCH_PATHS}" mono --debug OpenRA.Utility.exe "${LAUNCH_MOD}" "$@" +MOD_SEARCH_PATHS="${MOD_SEARCH_PATHS}" ENGINE_DIR=".." mono --debug bin/OpenRA.Utility.exe "${LAUNCH_MOD}" "$@"