Skip to content

Commit

Permalink
Update packaging scripts.
Browse files Browse the repository at this point in the history
  • Loading branch information
MustaphaTR committed Mar 26, 2022
1 parent 0aa75ec commit e2bc9e9
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 50 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -3,7 +3,7 @@
# to compile, run:
# make
#
# to compile using Mono (version 6.4 or greater) instead of .NET 5, run:
# to compile using Mono (version 6.4 or greater) instead of .NET 6, run:
# make RUNTIME=mono
#
# to compile using system libraries for native dependencies, run:
Expand Down
2 changes: 1 addition & 1 deletion mod.config
Expand Up @@ -95,7 +95,7 @@ PACKAGING_WINDOWS_REGISTRY_KEY="ShatteredParadise"
PACKAGING_WINDOWS_LICENSE_FILE="./COPYING"

# Space delimited list of additional files/directories to copy from the engine directory
# when packaging your mod. e.g. "./mods/modcontent"
# when packaging your mod. e.g. "AUTHORS.AS ./mods/modcontent"
PACKAGING_COPY_ENGINE_FILES="./mods/modcontent ./mods/ts/mod.yaml ./mods/ts/cursors.yaml ./mods/ts/chrome/ingame-observer.yaml ./mods/ts/chrome/ingame-debug.yaml ./mods/ts/chrome/color-picker.yaml ./mods/ts/chrome/dropdowns.yaml ./mods/ts/chrome/settings-hotkeys.yaml ./mods/ts/metrics.yaml mods/ts/installer/downloads.yaml ./mods/ts/installer/firestorm.yaml ./mods/ts/installer/firstdecade.yaml ./mods/ts/installer/origin.yaml ./mods/ts/installer/tibsun.yaml"

# Overwrite the version in mod.yaml with the tag used for the SDK release
Expand Down
63 changes: 28 additions & 35 deletions packaging/functions.sh
Expand Up @@ -6,55 +6,48 @@
# Copy-paste the entire script into http://shellcheck.net to check.
####

# Compile and publish (using Mono) any mod assemblies to the target directory
# Compile and publish any mod assemblies to the target directory
# Arguments:
# SRC_PATH: Path to the root OpenRA directory
# SRC_PATH: Path to the root SDK directory
# DEST_PATH: Path to the root of the install destination (will be created if necessary)
# TARGETPLATFORM: Platform type (win-x86, win-x64, osx-x64, linux-x64, unix-generic)
install_mod_assemblies_mono() {
# RUNTIME: Runtime type (net6, mono)
# ENGINE_PATH: Path to the engine root directory
install_mod_assemblies() {
SRC_PATH="${1}"
DEST_PATH="${2}"
TARGETPLATFORM="${3}"
ENGINE_PATH="${4}"
RUNTIME="${4}"
ENGINE_PATH="${5}"

echo "Building assemblies"
ORIG_PWD=$(pwd)
cd "${SRC_PATH}" || exit 1

rm -rf "${ENGINE_PATH:?}/bin"
if [ "${RUNTIME}" = "mono" ]; then
echo "Building assemblies"

find . -maxdepth 1 -name '*.sln' -exec msbuild -verbosity:m -nologo -t:Build -restore -p:Configuration=Release -p:TargetPlatform="${TARGETPLATFORM}" -p:Mono=true \;
rm -rf "${ENGINE_PATH:?}/bin"

cd "${ORIG_PWD}" || exit 1
for LIB in "${ENGINE_PATH}/bin/"*.dll "${ENGINE_PATH}/bin/"*.dll.config; do
install -m644 "${LIB}" "${DEST_PATH}"
done
find . -maxdepth 1 -name '*.sln' -exec msbuild -verbosity:m -nologo -t:Build -restore -p:Configuration=Release -p:TargetPlatform="${TARGETPLATFORM}" -p:Mono=true \;

if [ "${TARGETPLATFORM}" = "linux-x64" ]; then
for LIB in "${ENGINE_PATH}/bin/"*.so; do
install -m755 "${LIB}" "${DEST_PATH}"
cd "${ORIG_PWD}" || exit 1
for LIB in "${ENGINE_PATH}/bin/"*.dll "${ENGINE_PATH}/bin/"*.dll.config; do
install -m644 "${LIB}" "${DEST_PATH}"
done
fi

if [ "${TARGETPLATFORM}" = "osx-x64" ]; then
for LIB in "${ENGINE_PATH}/bin/"*.dylib; do
install -m755 "${LIB}" "${DEST_PATH}"
done
if [ "${TARGETPLATFORM}" = "linux-x64" ]; then
for LIB in "${ENGINE_PATH}/bin/"*.so; do
install -m755 "${LIB}" "${DEST_PATH}"
done
fi

if [ "${TARGETPLATFORM}" = "osx-x64" ]; then
for LIB in "${ENGINE_PATH}/bin/"*.dylib; do
install -m755 "${LIB}" "${DEST_PATH}"
done
fi
else
find . -maxdepth 1 -name '*.sln' -exec dotnet publish -c Release -p:TargetPlatform="${TARGETPLATFORM}" -r "${TARGETPLATFORM}" -o "${DEST_PATH}" --self-contained true \;
cd "${ORIG_PWD}" || exit 1
fi
}

# Compile and publish any mod assemblies to the target directory
# Arguments:
# SRC_PATH: Path to the root SDK directory
# DEST_PATH: Path to the root of the install destination (will be created if necessary)
# TARGETPLATFORM: Platform type (win-x86, win-x64, osx-x64, linux-x64, unix-generic)
install_mod_assemblies() {
SRC_PATH="${1}"
DEST_PATH="${2}"
TARGETPLATFORM="${3}"

ORIG_PWD=$(pwd)
cd "${SRC_PATH}" || exit 1
find . -maxdepth 1 -name '*.sln' -exec dotnet publish -c Release -p:TargetPlatform="${TARGETPLATFORM}" -p:PublishTrimmed=true -r "${TARGETPLATFORM}" -o "${DEST_PATH}" --self-contained true \;
cd "${ORIG_PWD}" || exit 1
}
4 changes: 2 additions & 2 deletions packaging/linux/buildpackage.sh
Expand Up @@ -65,7 +65,7 @@ if [ ! -d "${OUTPUTDIR}" ]; then
fi

echo "Building core files"
install_assemblies "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}" "${APPDIR}/usr/lib/openra" "linux-x64" "True" "${PACKAGING_COPY_CNC_DLL}" "${PACKAGING_COPY_D2K_DLL}" "${PACKAGING_COPY_AS_DLL}"
install_assemblies "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}" "${APPDIR}/usr/lib/openra" "linux-x64" "net6" "True" "${PACKAGING_COPY_CNC_DLL}" "${PACKAGING_COPY_D2K_DLL}" "${PACKAGING_COPY_AS_DLL}"
install_data "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}" "${APPDIR}/usr/lib/openra"

for f in ${PACKAGING_COPY_ENGINE_FILES}; do
Expand All @@ -74,7 +74,7 @@ for f in ${PACKAGING_COPY_ENGINE_FILES}; do
done

echo "Building mod files"
install_mod_assemblies "${TEMPLATE_ROOT}" "${APPDIR}/usr/lib/openra" "linux-x64"
install_mod_assemblies "${TEMPLATE_ROOT}" "${APPDIR}/usr/lib/openra" "linux-x64" "net6" "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}"

cp -Lr "${TEMPLATE_ROOT}/mods/"* "${APPDIR}/usr/lib/openra/mods"

Expand Down
18 changes: 9 additions & 9 deletions packaging/macos/buildpackage.sh
Expand Up @@ -126,17 +126,17 @@ build_platform() {
modify_plist "<string>{DISCORD_URL_SCHEME}</string>" "" "${LAUNCHER_CONTENTS_DIR}/Info.plist"
fi

if [ "${PLATFORM}" = "compat" ]; then
if [ "${PLATFORM}" = "mono" ]; 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_ASSEMBLY_DIR}/Launcher" -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_ASSEMBLY_DIR}/Launcher" -framework AppKit -mmacosx-version-min=10.13
modify_plist "{MINIMUM_SYSTEM_VERSION}" "10.14" "${LAUNCHER_CONTENTS_DIR}/Info.plist"
clang -m64 "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}/packaging/macos/launcher.m" -o "${LAUNCHER_ASSEMBLY_DIR}/Launcher" -framework AppKit -mmacosx-version-min=10.14
fi

echo "Building core files"
RUNTIME="net5"
if [ "${PLATFORM}" = "compat" ]; then
RUNTIME="net6"
if [ "${PLATFORM}" = "mono" ]; then
RUNTIME="mono"
fi

Expand Down Expand Up @@ -281,7 +281,7 @@ finalize_package() {
INPUT_PATH="${2}"
OUTPUT_PATH="${3}"

if [ "${PLATFORM}" = "compat" ]; then
if [ "${PLATFORM}" = "mono" ]; then
hdiutil convert "${INPUT_PATH}" -format UDZO -imagekey zlib-level=9 -ov -o "${OUTPUT_PATH}"
else
# ULFO offers better compression and faster decompression speeds, but is only supported by 10.11+
Expand All @@ -291,7 +291,7 @@ finalize_package() {
}

build_platform "standard" "build.dmg"
build_platform "compat" "build-compat.dmg"
build_platform "mono" "build-mono.dmg"

if [ -n "${MACOS_DEVELOPER_CERTIFICATE_BASE64}" ] && [ -n "${MACOS_DEVELOPER_CERTIFICATE_PASSWORD}" ] && [ -n "${MACOS_DEVELOPER_IDENTITY}" ]; then
security delete-keychain build.keychain
Expand All @@ -300,9 +300,9 @@ fi
if [ -n "${MACOS_DEVELOPER_USERNAME}" ] && [ -n "${MACOS_DEVELOPER_PASSWORD}" ]; then
# Parallelize processing
(notarize_package "build.dmg") &
(notarize_package "build-compat.dmg") &
(notarize_package "build-mono.dmg") &
wait
fi

finalize_package "standard" "build.dmg" "${OUTPUTDIR}/${PACKAGING_INSTALLER_NAME}-${TAG}.dmg"
finalize_package "compat" "build-compat.dmg" "${OUTPUTDIR}/${PACKAGING_INSTALLER_NAME}-${TAG}-compat.dmg"
finalize_package "mono" "build-mono.dmg" "${OUTPUTDIR}/${PACKAGING_INSTALLER_NAME}-${TAG}-mono.dmg"
4 changes: 2 additions & 2 deletions packaging/windows/buildpackage.sh
Expand Up @@ -85,7 +85,7 @@ function build_platform()
fi

echo "Building core files (${PLATFORM})"
install_assemblies "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}" "${BUILTDIR}" "win-${PLATFORM}" "False" "${PACKAGING_COPY_CNC_DLL}" "${PACKAGING_COPY_D2K_DLL}" "${PACKAGING_COPY_AS_DLL}"
install_assemblies "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}" "${BUILTDIR}" "win-${PLATFORM}" "net6" "False" "${PACKAGING_COPY_CNC_DLL}" "${PACKAGING_COPY_D2K_DLL}" "${PACKAGING_COPY_AS_DLL}"
install_data "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}" "${BUILTDIR}"

for f in ${PACKAGING_COPY_ENGINE_FILES}; do
Expand All @@ -94,7 +94,7 @@ function build_platform()
done

echo "Building mod files (${PLATFORM})"
install_mod_assemblies "${TEMPLATE_ROOT}" "${BUILTDIR}" "win-${PLATFORM}"
install_mod_assemblies "${TEMPLATE_ROOT}" "${BUILTDIR}" "win-${PLATFORM}" "net6" "${TEMPLATE_ROOT}/${ENGINE_DIRECTORY}"

cp -Lr "${TEMPLATE_ROOT}/mods/"* "${BUILTDIR}/mods"

Expand Down

0 comments on commit e2bc9e9

Please sign in to comment.