mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Merge branch 'dont-skip-leg-day'
This commit is contained in:
@@ -9,6 +9,7 @@ import sys
|
||||
import zipfile
|
||||
import argparse
|
||||
import glob
|
||||
from enum import StrEnum
|
||||
|
||||
from typing import List, Optional
|
||||
|
||||
@@ -28,12 +29,34 @@ except ImportError:
|
||||
|
||||
p = os.path.join
|
||||
|
||||
PLATFORM_WINDOWS = "windows"
|
||||
PLATFORM_WIN = "win"
|
||||
PLATFORM_LINUX = "linux"
|
||||
PLATFORM_LINUX_ARM64 = "linux-arm64"
|
||||
PLATFORM_MACOS = "mac"
|
||||
PLATFORM_OSX = "osx"
|
||||
PLATFORM_FREEBSD = "freebsd"
|
||||
|
||||
TARGET_OS_WINDOWS = "Windows"
|
||||
TARGET_OS_MACOS = "MacOS"
|
||||
TARGET_OS_LINUX = "Linux"
|
||||
TARGET_OS_FREEBSD = "FreeBSD"
|
||||
|
||||
class TargetOS(StrEnum):
|
||||
Windows = "Windows"
|
||||
MacOS = "MacOS"
|
||||
Linux = "Linux"
|
||||
FreeBSD = "FreeBSD"
|
||||
|
||||
RID_WIN_X64 = f"{PLATFORM_WIN}-x64"
|
||||
RID_WIN_ARM64 = f"{PLATFORM_WIN}-arm64"
|
||||
RID_LINUX_X64 = f"{PLATFORM_LINUX}-x64"
|
||||
RID_LINUX_ARM64 = f"{PLATFORM_LINUX}-arm64"
|
||||
RID_OSX_X64 = f"{PLATFORM_OSX}-x64"
|
||||
RID_OSX_ARM64 = f"{PLATFORM_OSX}-arm64"
|
||||
RID_FREEBSD_X64 = f"{PLATFORM_FREEBSD}-x64"
|
||||
RID_FREEBSD_ARM64 = f"{PLATFORM_FREEBSD}-arm64"
|
||||
|
||||
DEFAULT_RIDS = [RID_WIN_X64, RID_LINUX_X64, RID_OSX_X64, RID_FREEBSD_X64]
|
||||
ALL_RIDS = [RID_WIN_X64, RID_WIN_ARM64, RID_LINUX_X64, RID_LINUX_ARM64, RID_OSX_X64, RID_OSX_ARM64, RID_FREEBSD_X64, RID_FREEBSD_ARM64]
|
||||
|
||||
IGNORED_RESOURCES = {
|
||||
".gitignore",
|
||||
".directory",
|
||||
@@ -88,7 +111,7 @@ def main() -> None:
|
||||
parser.add_argument("--platform",
|
||||
"-p",
|
||||
action="store",
|
||||
choices=[PLATFORM_WINDOWS, PLATFORM_MACOS, PLATFORM_LINUX, PLATFORM_FREEBSD],
|
||||
choices=ALL_RIDS,
|
||||
nargs="*",
|
||||
help="Which platform to build for. If not provided, all platforms will be built")
|
||||
|
||||
@@ -97,11 +120,17 @@ def main() -> None:
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
args = parser.parse_args()
|
||||
platforms = args.platform
|
||||
skip_build = args.skip_build
|
||||
platforms: list[str] = args.platform
|
||||
skip_build: bool = args.skip_build
|
||||
|
||||
if not platforms:
|
||||
platforms = [PLATFORM_WINDOWS, PLATFORM_MACOS, PLATFORM_LINUX, PLATFORM_FREEBSD]
|
||||
platforms = DEFAULT_RIDS
|
||||
|
||||
# Validate that nobody put invalid platform names in.
|
||||
for rid in platforms:
|
||||
if rid not in ALL_RIDS:
|
||||
print(Fore.RED + f"Invalid platform specified: '{rid}'" + Style.RESET_ALL)
|
||||
exit(1)
|
||||
|
||||
if os.path.exists("release"):
|
||||
print(Fore.BLUE + Style.DIM +
|
||||
@@ -111,32 +140,25 @@ def main() -> None:
|
||||
else:
|
||||
os.mkdir("release")
|
||||
|
||||
for platform in platforms:
|
||||
build_for_platform(platform, skip_build)
|
||||
|
||||
if PLATFORM_WINDOWS in platforms:
|
||||
if not skip_build:
|
||||
wipe_bin()
|
||||
build_windows(skip_build)
|
||||
|
||||
if PLATFORM_LINUX in platforms:
|
||||
if not skip_build:
|
||||
wipe_bin()
|
||||
build_linux(skip_build, "linux", "Linux")
|
||||
def build_for_platform(rid: str, skip_build: bool):
|
||||
print(Fore.GREEN + f"Building for platform '{rid}'..." + Style.RESET_ALL)
|
||||
|
||||
if PLATFORM_LINUX_ARM64 in platforms:
|
||||
if not skip_build:
|
||||
wipe_bin()
|
||||
build_linux_arm64(skip_build)
|
||||
|
||||
if PLATFORM_MACOS in platforms:
|
||||
if not skip_build:
|
||||
wipe_bin()
|
||||
build_macos(skip_build)
|
||||
|
||||
if PLATFORM_FREEBSD in platforms:
|
||||
if not skip_build:
|
||||
wipe_bin()
|
||||
build_linux(skip_build, "freebsd", "FreeBSD")
|
||||
if not skip_build:
|
||||
wipe_bin()
|
||||
|
||||
platform = rid.split('-', maxsplit=2)[0]
|
||||
if platform == PLATFORM_WIN:
|
||||
build_windows(rid, skip_build)
|
||||
elif platform == PLATFORM_LINUX:
|
||||
build_linux_like(rid, TargetOS.Linux, skip_build)
|
||||
elif platform == PLATFORM_OSX:
|
||||
build_macos(rid, skip_build)
|
||||
elif platform == PLATFORM_FREEBSD:
|
||||
build_linux_like(rid, TargetOS.FreeBSD, skip_build)
|
||||
|
||||
def wipe_bin():
|
||||
print(Fore.BLUE + Style.DIM +
|
||||
@@ -146,53 +168,42 @@ def wipe_bin():
|
||||
shutil.rmtree("bin")
|
||||
|
||||
|
||||
def build_windows(skip_build: bool) -> None:
|
||||
# Run a full build.
|
||||
print(Fore.GREEN + "Building project for Windows x64..." + Style.RESET_ALL)
|
||||
|
||||
def build_windows(rid: str, skip_build: bool) -> None:
|
||||
if not skip_build:
|
||||
publish_client("win-x64", "Windows")
|
||||
publish_client(rid, TargetOS.Windows)
|
||||
if sys.platform != "win32":
|
||||
subprocess.run(["Tools/exe_set_subsystem.py", p("bin", "Client", "win-x64", "publish", "Robust.Client"), "2"])
|
||||
subprocess.run(["Tools/exe_set_subsystem.py", p("bin", "Client", rid, "publish", "Robust.Client"), "2"])
|
||||
|
||||
|
||||
print(Fore.GREEN + "Packaging Windows x64 client..." + Style.RESET_ALL)
|
||||
print(Fore.GREEN + f"Packaging {rid} client..." + Style.RESET_ALL)
|
||||
|
||||
client_zip = zipfile.ZipFile(
|
||||
p("release", "Robust.Client_win-x64.zip"), "w",
|
||||
p("release", f"Robust.Client_{rid}.zip"), "w",
|
||||
compression=zipfile.ZIP_DEFLATED)
|
||||
|
||||
copy_dir_into_zip(p("bin", "Client", "win-x64", "publish"), "", client_zip, IGNORED_FILES_WINDOWS)
|
||||
copy_dir_into_zip(p("bin", "Client", rid, "publish"), "", client_zip, IGNORED_FILES_WINDOWS)
|
||||
copy_resources("Resources", client_zip)
|
||||
# Cool we're done.
|
||||
client_zip.close()
|
||||
|
||||
def build_macos(skip_build: bool) -> None:
|
||||
print(Fore.GREEN + "Building project for macOS x64..." + Style.RESET_ALL)
|
||||
|
||||
def build_macos(rid: str, skip_build: bool) -> None:
|
||||
if not skip_build:
|
||||
publish_client("osx-x64", "MacOS")
|
||||
publish_client(rid, TargetOS.MacOS)
|
||||
|
||||
print(Fore.GREEN + "Packaging macOS x64 client..." + Style.RESET_ALL)
|
||||
print(Fore.GREEN + f"Packaging {rid} client..." + Style.RESET_ALL)
|
||||
# Client has to go in an app bundle.
|
||||
client_zip = zipfile.ZipFile(p("release", "Robust.Client_osx-x64.zip"), "a",
|
||||
client_zip = zipfile.ZipFile(p("release", f"Robust.Client_{rid}.zip"), "a",
|
||||
compression=zipfile.ZIP_DEFLATED)
|
||||
|
||||
contents = p("Space Station 14.app", "Contents", "Resources")
|
||||
copy_dir_into_zip(p("BuildFiles", "Mac", "Space Station 14.app"), "Space Station 14.app", client_zip)
|
||||
copy_dir_into_zip(p("bin", "Client", "osx-x64", "publish"), contents, client_zip, IGNORED_FILES_MACOS)
|
||||
copy_dir_into_zip(p("bin", "Client", rid, "publish"), contents, client_zip, IGNORED_FILES_MACOS)
|
||||
copy_resources(p(contents, "Resources"), client_zip)
|
||||
client_zip.close()
|
||||
|
||||
|
||||
def build_linux(skip_build: bool, platform, name) -> None:
|
||||
"""Build on Unix-like platforms including Linux and FreeBSD."""
|
||||
# Run a full build.
|
||||
rid = "%s-x64" % platform
|
||||
print(Fore.GREEN + "Building project for %s..." % rid + Style.RESET_ALL)
|
||||
|
||||
def build_linux_like(rid: str, target_os: TargetOS, skip_build: bool) -> None:
|
||||
if not skip_build:
|
||||
publish_client(rid, name)
|
||||
publish_client(rid, target_os)
|
||||
|
||||
print(Fore.GREEN + "Packaging %s client..." % rid + Style.RESET_ALL)
|
||||
|
||||
@@ -206,37 +217,7 @@ def build_linux(skip_build: bool, platform, name) -> None:
|
||||
client_zip.close()
|
||||
|
||||
|
||||
|
||||
def build_linux_arm64(skip_build: bool) -> None:
|
||||
# Run a full build.
|
||||
# TODO: Linux-arm64 is currently server-only.
|
||||
pass
|
||||
""" print(Fore.GREEN + "Building project for Linux ARM64 (SERVER ONLY)..." + Style.RESET_ALL)
|
||||
|
||||
if not skip_build:
|
||||
subprocess.run([
|
||||
"dotnet",
|
||||
"build",
|
||||
"SpaceStation14.sln",
|
||||
"-c", "Release",
|
||||
"--nologo",
|
||||
"/v:m",
|
||||
"/p:TargetOS=Linux",
|
||||
"/t:Rebuild",
|
||||
"/p:FullRelease=True"
|
||||
], check=True)
|
||||
|
||||
publish_client("linux-arm64", "Linux", True)
|
||||
|
||||
print(Fore.GREEN + "Packaging Linux ARM64 server..." + Style.RESET_ALL)
|
||||
server_zip = zipfile.ZipFile(p("release", "SS14.Server_Linux_ARM64.zip"), "w",
|
||||
compression=zipfile.ZIP_DEFLATED)
|
||||
copy_dir_into_zip(p("RobustToolbox", "bin", "Server", "linux-arm64", "publish"), "", server_zip)
|
||||
copy_resources(p("Resources"), server_zip, server=True)
|
||||
server_zip.close()"""
|
||||
|
||||
|
||||
def publish_client(runtime: str, target_os: str) -> None:
|
||||
def publish_client(runtime: str, target_os: TargetOS) -> None:
|
||||
base = [
|
||||
"dotnet", "publish",
|
||||
"--runtime", runtime,
|
||||
|
||||
Reference in New Issue
Block a user