diff --git a/.gitignore b/.gitignore index 8a2ec572a52..f413654f8a8 100644 --- a/.gitignore +++ b/.gitignore @@ -265,3 +265,6 @@ __pycache__/ # Release package files go here: release/ + +# Apple please go. +.DS_Store diff --git a/BuildFiles/Mac/Space Station 14.app/Contents/Info.plist b/BuildFiles/Mac/Space Station 14.app/Contents/Info.plist new file mode 100644 index 00000000000..4c1070941b7 --- /dev/null +++ b/BuildFiles/Mac/Space Station 14.app/Contents/Info.plist @@ -0,0 +1,20 @@ + + + + + CFBundleName + SS14 + CFBundleDisplayName + Space Station 14 + CFBundleExecutable + SS14 + + CFBundleIconFile + ss14 + + diff --git a/BuildFiles/Mac/Space Station 14.app/Contents/MacOS/SS14 b/BuildFiles/Mac/Space Station 14.app/Contents/MacOS/SS14 new file mode 100755 index 00000000000..e364a852561 --- /dev/null +++ b/BuildFiles/Mac/Space Station 14.app/Contents/MacOS/SS14 @@ -0,0 +1,9 @@ +#!/usr/bin/env -i bash + +# cd to file containing script or something? +BASEDIR=$(dirname "$0") +echo "$BASEDIR" +cd "$BASEDIR" + +# TODO: unhardcode this, probably ship Mono with SS14. +/Library/Frameworks/Mono.framework/Versions/Current/Commands/mono ./SS14.Client.exe diff --git a/BuildFiles/Mac/Space Station 14.app/Contents/Resources/ss14.icns b/BuildFiles/Mac/Space Station 14.app/Contents/Resources/ss14.icns new file mode 100644 index 00000000000..ea22dc64c71 Binary files /dev/null and b/BuildFiles/Mac/Space Station 14.app/Contents/Resources/ss14.icns differ diff --git a/RUN_THIS.py b/RUN_THIS.py index b0298b570ee..b7a8fcaa35e 100755 --- a/RUN_THIS.py +++ b/RUN_THIS.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 # Import future so people on py2 still get the clear error that they need to upgrade. from __future__ import print_function diff --git a/package_release_build.py b/package_release_build.py index ff7a7c0d635..b7688b3d892 100755 --- a/package_release_build.py +++ b/package_release_build.py @@ -4,10 +4,12 @@ import os import shutil import subprocess +import sys import zipfile +import argparse try: - from colorama import init, Fore, Back, Style + from colorama import init, Fore, Style init() except ImportError: @@ -18,27 +20,40 @@ def __getattr__(self, name): Fore = ColorDummy() Style = ColorDummy() - Back = ColorDummy() def main(): - # Wipe out old build directory. Cleans potential leftovers to make sure we have a clean build. - if os.path.exists("bin"): - print(Fore.BLUE + Style.DIM + "Clearing old build artifacts (bin/)..." + Style.RESET_ALL) - shutil.rmtree("bin") + parser = argparse.ArgumentParser( + description="Packages the SS14 content repo for release on all platforms.") + parser.add_argument("--platform", + action="store", + choices=["windows", "mac", "linux", "all"], + help="Which platform to build for.", + default="all") + args = parser.parse_args() if os.path.exists("release"): - print(Fore.BLUE + Style.DIM + "Cleaning old release packages (release/)..." + Style.RESET_ALL) + print(Fore.BLUE+Style.DIM + "Cleaning old release packages (release/)..." + Style.RESET_ALL) shutil.rmtree("release") + os.mkdir("release") - build_windows() + if args.platform == "all" or args.platform == "windows": + wipe_bin() + build_windows() + + if args.platform == "all" or args.platform == "linux": + wipe_bin() + build_linux() + + if args.platform == "all" or args.platform == "mac": + wipe_bin() + build_macos() +def wipe_bin(): if os.path.exists("bin"): print(Fore.BLUE + Style.DIM + "Clearing old build artifacts..." + Style.RESET_ALL) shutil.rmtree("bin") - build_linux() - def build_windows(): # Run a full build. print(Fore.GREEN + "Building project for Windows x86..." + Style.RESET_ALL) @@ -49,16 +64,19 @@ def build_windows(): "/p:Platform=x86", "/nologo", "/v:m", - "/p:TargetOS=Windows_NT", + "/p:TargetOS=Windows", "/t:Rebuild" - ], check=True) + ], check=True) # Package client. print(Fore.GREEN + "Packaging Windows x86 client..." + Style.RESET_ALL) - package_zip(os.path.join("bin", "Client"), os.path.join("release", "SS14.Client_windows_x86.zip")) + package_zip(os.path.join("bin", "Client"), + os.path.join("release", "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("release", "SS14.Server_windows_x86.zip")) + package_zip(os.path.join("bin", "Server"), + os.path.join("release", "SS14.Server_windows_x86.zip")) + def build_linux(): print(Fore.GREEN + "Building project for Linux x86..." + Style.RESET_ALL) @@ -71,7 +89,7 @@ def build_linux(): "/v:m", "/p:TargetOS=Linux", "/t:Rebuild" - ], check=True) + ], check=True) # Package client. print(Fore.GREEN + "Packaging Linux x86 client..." + Style.RESET_ALL) @@ -80,28 +98,69 @@ def build_linux(): print(Fore.GREEN + "Packaging Linux x86 server..." + Style.RESET_ALL) package_zip(os.path.join("bin", "Server"), os.path.join("release", "SS14.Server_linux_x86.zip")) + +def build_macos(): + # Haha this is gonna suck. + print(Fore.GREEN + "Building project for MacOS x86..." + Style.RESET_ALL) + subprocess.run(["msbuild", + "SpaceStation14Content.sln", + "/m", + "/p:Configuration=Release", + "/p:Platform=x86", + "/nologo", + "/v:m", + "/p:TargetOS=MacOS", + "/t:Rebuild" + ], check=True) + + print(Fore.GREEN + "Packaging MacOS x86 client..." + Style.RESET_ALL) + # Client has to go in an app bundle. + bundle = os.path.join("bin", "app", "Space Station 14.app") + shutil.copytree(os.path.join("BuildFiles", "Mac", "Space Station 14.app"), + bundle) + + _copytree(os.path.join("bin", "Client"), + os.path.join(bundle, "Contents", "MacOS")) + + package_zip(os.path.join("bin", "app"), + os.path.join("release", "SS14.Client_MacOS_x86.zip")) + + print(Fore.GREEN + "Packaging MacOS x86 server..." + Style.RESET_ALL) + package_zip(os.path.join("bin", "Server"), + os.path.join("release", "SS14.Server_MacOS_x86.zip")) + +# Hack copied from Stack Overflow to get around the fact that +# shutil.copytree doesn't allow copying into existing directories. +def _copytree(src, dst, symlinks=False, ignore=None): + for item in os.listdir(src): + s = os.path.join(src, item) + d = os.path.join(dst, item) + if os.path.isdir(s): + shutil.copytree(s, d, symlinks, ignore) + else: + shutil.copy2(s, d) + 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) + with zipfile.ZipFile(zipname, "w") as zipf: + for dirs, _, files in os.walk(directory): + relpath = os.path.relpath(dirs, directory) if relpath != ".": # Write directory node except for root level. - f.write(dir, relpath) + zipf.write(dirs, 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) + filepath = os.path.join(dirs, filename) + + message = "{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)) + + print(Fore.CYAN + message + Style.RESET_ALL) + zipf.write(filepath, zippath) if __name__ == '__main__': main()