package_release_build mac support.
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -265,3 +265,6 @@ __pycache__/
|
|||||||
|
|
||||||
# Release package files go here:
|
# Release package files go here:
|
||||||
release/
|
release/
|
||||||
|
|
||||||
|
# Apple please go.
|
||||||
|
.DS_Store
|
||||||
|
|||||||
20
BuildFiles/Mac/Space Station 14.app/Contents/Info.plist
Normal file
20
BuildFiles/Mac/Space Station 14.app/Contents/Info.plist
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleName</key>
|
||||||
|
<string>SS14</string>
|
||||||
|
<key>CFBundleDisplayName</key>
|
||||||
|
<string>Space Station 14</string>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>SS14</string>
|
||||||
|
<!--
|
||||||
|
Just a note about this icon.
|
||||||
|
MacOS seems REALLY iffy about this and even when the file is correct,
|
||||||
|
it can take forever before it decides to actually update it and display it.
|
||||||
|
TL;DR Apple is stupid.
|
||||||
|
-->
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string>ss14</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
9
BuildFiles/Mac/Space Station 14.app/Contents/MacOS/SS14
Executable file
9
BuildFiles/Mac/Space Station 14.app/Contents/MacOS/SS14
Executable file
@@ -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
|
||||||
BIN
BuildFiles/Mac/Space Station 14.app/Contents/Resources/ss14.icns
Normal file
BIN
BuildFiles/Mac/Space Station 14.app/Contents/Resources/ss14.icns
Normal file
Binary file not shown.
@@ -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.
|
# Import future so people on py2 still get the clear error that they need to upgrade.
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|||||||
@@ -4,10 +4,12 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
import zipfile
|
import zipfile
|
||||||
|
import argparse
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from colorama import init, Fore, Back, Style
|
from colorama import init, Fore, Style
|
||||||
init()
|
init()
|
||||||
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -18,27 +20,40 @@ except ImportError:
|
|||||||
|
|
||||||
Fore = ColorDummy()
|
Fore = ColorDummy()
|
||||||
Style = ColorDummy()
|
Style = ColorDummy()
|
||||||
Back = ColorDummy()
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# Wipe out old build directory. Cleans potential leftovers to make sure we have a clean build.
|
parser = argparse.ArgumentParser(
|
||||||
if os.path.exists("bin"):
|
description="Packages the SS14 content repo for release on all platforms.")
|
||||||
print(Fore.BLUE + Style.DIM + "Clearing old build artifacts (bin/)..." + Style.RESET_ALL)
|
parser.add_argument("--platform",
|
||||||
shutil.rmtree("bin")
|
action="store",
|
||||||
|
choices=["windows", "mac", "linux", "all"],
|
||||||
|
help="Which platform to build for.",
|
||||||
|
default="all")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
if os.path.exists("release"):
|
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")
|
shutil.rmtree("release")
|
||||||
|
|
||||||
os.mkdir("release")
|
os.mkdir("release")
|
||||||
|
|
||||||
|
if args.platform == "all" or args.platform == "windows":
|
||||||
|
wipe_bin()
|
||||||
build_windows()
|
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"):
|
if os.path.exists("bin"):
|
||||||
print(Fore.BLUE + Style.DIM + "Clearing old build artifacts..." + Style.RESET_ALL)
|
print(Fore.BLUE + Style.DIM + "Clearing old build artifacts..." + Style.RESET_ALL)
|
||||||
shutil.rmtree("bin")
|
shutil.rmtree("bin")
|
||||||
|
|
||||||
build_linux()
|
|
||||||
|
|
||||||
def build_windows():
|
def build_windows():
|
||||||
# Run a full build.
|
# Run a full build.
|
||||||
print(Fore.GREEN + "Building project for Windows x86..." + Style.RESET_ALL)
|
print(Fore.GREEN + "Building project for Windows x86..." + Style.RESET_ALL)
|
||||||
@@ -49,16 +64,19 @@ def build_windows():
|
|||||||
"/p:Platform=x86",
|
"/p:Platform=x86",
|
||||||
"/nologo",
|
"/nologo",
|
||||||
"/v:m",
|
"/v:m",
|
||||||
"/p:TargetOS=Windows_NT",
|
"/p:TargetOS=Windows",
|
||||||
"/t:Rebuild"
|
"/t:Rebuild"
|
||||||
], check=True)
|
], check=True)
|
||||||
|
|
||||||
# Package client.
|
# Package client.
|
||||||
print(Fore.GREEN + "Packaging Windows x86 client..." + Style.RESET_ALL)
|
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)
|
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():
|
def build_linux():
|
||||||
print(Fore.GREEN + "Building project for Linux x86..." + Style.RESET_ALL)
|
print(Fore.GREEN + "Building project for Linux x86..." + Style.RESET_ALL)
|
||||||
@@ -80,28 +98,69 @@ def build_linux():
|
|||||||
print(Fore.GREEN + "Packaging Linux x86 server..." + Style.RESET_ALL)
|
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"))
|
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):
|
def package_zip(directory, zipname):
|
||||||
with zipfile.ZipFile(zipname, "w") as f:
|
with zipfile.ZipFile(zipname, "w") as zipf:
|
||||||
for dir, _, files in os.walk(directory):
|
for dirs, _, files in os.walk(directory):
|
||||||
relpath = os.path.relpath(dir, directory)
|
relpath = os.path.relpath(dirs, directory)
|
||||||
if relpath != ".":
|
if relpath != ".":
|
||||||
# Write directory node except for root level.
|
# Write directory node except for root level.
|
||||||
f.write(dir, relpath)
|
zipf.write(dirs, relpath)
|
||||||
|
|
||||||
for filename in files:
|
for filename in files:
|
||||||
zippath = os.path.join(relpath, filename)
|
zippath = os.path.join(relpath, filename)
|
||||||
filepath = os.path.join(dir, filename)
|
filepath = os.path.join(dirs, filename)
|
||||||
|
|
||||||
print(Fore.CYAN + "{dim}{diskroot}{sep}{zipfile}{dim} -> {ziproot}{sep}{zipfile}"
|
message = "{dim}{diskroot}{sep}{zipfile}{dim} -> {ziproot}{sep}{zipfile}".format(
|
||||||
.format(
|
|
||||||
sep=os.sep + Style.NORMAL,
|
sep=os.sep + Style.NORMAL,
|
||||||
dim=Style.DIM,
|
dim=Style.DIM,
|
||||||
diskroot=directory,
|
diskroot=directory,
|
||||||
ziproot=zipname,
|
ziproot=zipname,
|
||||||
zipfile = os.path.normpath(zippath)
|
zipfile=os.path.normpath(zippath))
|
||||||
) + Style.RESET_ALL)
|
|
||||||
|
|
||||||
f.write(filepath, zippath)
|
print(Fore.CYAN + message + Style.RESET_ALL)
|
||||||
|
zipf.write(filepath, zippath)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user