From 4454525e6d50a711ebc62569b4ec76ccd5cdd3e3 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Sun, 6 Aug 2017 23:15:39 +0200 Subject: [PATCH] Add script to zip up release builds. --- Content.Client/Content.Client.csproj | 3 +- Content.Server/Content.Server.csproj | 3 +- Content.Shared/Content.Shared.csproj | 3 +- package_release_build.py | 66 ++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 6 deletions(-) create mode 100644 package_release_build.py diff --git a/Content.Client/Content.Client.csproj b/Content.Client/Content.Client.csproj index d4dc29a563..ae8c4a6e09 100644 --- a/Content.Client/Content.Client.csproj +++ b/Content.Client/Content.Client.csproj @@ -33,7 +33,6 @@ ..\bin\Content.Client\ TRACE true - pdbonly x86 prompt MinimumRecommendedRules.ruleset @@ -82,7 +81,7 @@ if not exist "..\Client\Assemblies" ( mkdir ..\Client\Assemblies\ ) - copy Content.* ..\Client\Assemblies\ + copy Content.* ..\Client\Assemblies\ > NUL diff --git a/Content.Server/Content.Server.csproj b/Content.Server/Content.Server.csproj index 13f5203249..42c2eee4ed 100644 --- a/Content.Server/Content.Server.csproj +++ b/Content.Server/Content.Server.csproj @@ -33,7 +33,6 @@ ..\bin\Content.Server\ TRACE true - pdbonly x86 prompt MinimumRecommendedRules.ruleset @@ -78,7 +77,7 @@ if not exist "..\Server\Assemblies" ( mkdir ..\Server\Assemblies\ ) - copy Content.* ..\Server\Assemblies\ + copy Content.* ..\Server\Assemblies\ > NUL diff --git a/Content.Shared/Content.Shared.csproj b/Content.Shared/Content.Shared.csproj index 52907b3168..f5aef92e08 100644 --- a/Content.Shared/Content.Shared.csproj +++ b/Content.Shared/Content.Shared.csproj @@ -25,7 +25,6 @@ bin\x86\Release\ TRACE true - pdbonly x86 prompt MinimumRecommendedRules.ruleset @@ -55,4 +54,4 @@ - \ No newline at end of file + diff --git a/package_release_build.py b/package_release_build.py new file mode 100644 index 0000000000..7024e870e4 --- /dev/null +++ b/package_release_build.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python3 +# Packages a full release build that can be unzipped and you'll have your SS14 client and server. + +import os +import shutil +import subprocess +import zipfile + +try: + from colorama import init, Fore, Back, Style + init() + +except ImportError: + # Just give an empty string for everything, no colored logging. + class ColorDummy(object): + def __getattr__(self, name): + return "" + + Fore = ColorDummy() + Style = ColorDummy() + Back = ColorDummy() + +def main(): + # Wipe out old build directory. + print(Fore.BLUE + Style.DIM + "Clearing old build artifacts..." + Style.RESET_ALL) + shutil.rmtree("bin") + + build_windows() + +def build_windows(): + # Run a full build. + print(Fore.GREEN + "Building project for Windows x86..." + Style.RESET_ALL) + subprocess.run(["msbuild", "SpaceStation14Content.sln", "/m", "/p:Configuration=Release", "/p:Platform=x86", "/nologo", "/v:m"], check=True) + + # Package client. + print(Fore.GREEN + "Packaging Windows x86 client..." + Style.RESET_ALL) + package_zip(os.path.join("bin", "Client"), os.path.join("bin", "SS14.Client_windows_x86.zip")) + + print(Fore.GREEN + "Packaging Windows x86 server..." + Style.RESET_ALL) + package_zip(os.path.join("bin", "Server"), os.path.join("bin", "SS14.Server_windows_x86.zip")) + +def package_zip(directory, zipname): + with zipfile.ZipFile(zipname, "w") as f: + for dir, _, files in os.walk(directory): + relpath = os.path.relpath(dir, directory) + if relpath != ".": + # Write directory node except for root level. + f.write(dir, relpath) + + for filename in files: + zippath = os.path.join(relpath, filename) + filepath = os.path.join(dir, filename) + + print(Fore.CYAN + "{dim}{diskroot}{sep}{zipfile}{dim} -> {ziproot}{sep}{zipfile}" + .format( + sep = os.sep + Style.NORMAL, + dim = Style.DIM, + diskroot = directory, + ziproot = zipname, + zipfile = os.path.normpath(zippath) + ) + Style.RESET_ALL) + + f.write(filepath, zippath) + +if __name__ == '__main__': + main()