Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5 #15

Closed
wants to merge 9 commits into from
Closed

5 #15

Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix 2
OCOtheOmega authored and GeneralGaws committed Jan 27, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 6759d350a99d07ec85a86e1620d3b358ff5d5796
4 changes: 3 additions & 1 deletion BuildChecker/BuildChecker.csproj
Original file line number Diff line number Diff line change
@@ -14,6 +14,8 @@ https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild
-->
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Python>python3</Python>
<Python Condition="'$(OS)'=='Windows_NT' Or '$(OS)'=='Windows'">py -3</Python>
<ProjectGuid>{C899FCA4-7037-4E49-ABC2-44DE72487110}</ProjectGuid>
<TargetFrameworkMoniker>.NETFramework, Version=v4.7.2</TargetFrameworkMoniker>
<RestorePackages>false</RestorePackages>
@@ -37,7 +39,7 @@ https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild
<OutputPath>bin\DebugOpt\</OutputPath>
</PropertyGroup>
<Target Name="Build">
<Exec Command="git submodule update --init --recursive"/>
<Exec Command="$(Python) git_helper.py" CustomErrorRegularExpression="^Error" />
</Target>
<Target Name="Rebuild" DependsOnTargets="Build" />
<Target Name="Clean">
110 changes: 110 additions & 0 deletions BuildChecker/git_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/usr/bin/env python3
# Installs git hooks, updates them, updates submodules, that kind of thing.

import subprocess
import sys
import os
import shutil
from pathlib import Path
from typing import List

SOLUTION_PATH = Path("..") / "SpaceStation14.sln"
# If this doesn't match the saved version we overwrite them all.
CURRENT_HOOKS_VERSION = "2"
QUIET = len(sys.argv) == 2 and sys.argv[1] == "--quiet"


def run_command(command: List[str], capture: bool = False) -> subprocess.CompletedProcess:
"""
Runs a command with pretty output.
"""
text = ' '.join(command)
if not QUIET:
print("$ {}".format(text))

sys.stdout.flush()

completed = None

if capture:
completed = subprocess.run(command, cwd="..", stdout=subprocess.PIPE)
else:
completed = subprocess.run(command, cwd="..")

if completed.returncode != 0:
print("Error: command exited with code {}!".format(completed.returncode))

return completed


def update_submodules():
"""
Updates all submodules.
"""

if ('GITHUB_ACTIONS' in os.environ):
return

if os.path.isfile("DISABLE_SUBMODULE_AUTOUPDATE"):
return

if shutil.which("git") is None:
raise FileNotFoundError("git not found in PATH")

# If the status doesn't match, force VS to reload the solution.
# status = run_command(["git", "submodule", "status"], capture=True)
run_command(["git", "submodule", "update", "--init", "--recursive"])
# status2 = run_command(["git", "submodule", "status"], capture=True)

# Something changed.
# if status.stdout != status2.stdout:
# print("Git submodules changed. Reloading solution.")
# reset_solution()


def install_hooks():
"""
Installs the necessary git hooks into .git/hooks.
"""

# Read version file.
if os.path.isfile("INSTALLED_HOOKS_VERSION"):
with open("INSTALLED_HOOKS_VERSION", "r") as f:
if f.read() == CURRENT_HOOKS_VERSION:
if not QUIET:
print("No hooks change detected.")
return

with open("INSTALLED_HOOKS_VERSION", "w") as f:
f.write(CURRENT_HOOKS_VERSION)

print("Hooks need updating.")

hooks_target_dir = Path("..")/".git"/"hooks"
hooks_source_dir = Path("hooks")

# Clear entire tree since we need to kill deleted files too.
for filename in os.listdir(str(hooks_target_dir)):
os.remove(str(hooks_target_dir/filename))

for filename in os.listdir(str(hooks_source_dir)):
print("Copying hook {}".format(filename))
shutil.copy2(str(hooks_source_dir/filename),
str(hooks_target_dir/filename))


def reset_solution():
"""
Force VS to think the solution has been changed to prompt the user to reload it, thus fixing any load errors.
"""

with SOLUTION_PATH.open("r") as f:
content = f.read()

with SOLUTION_PATH.open("w") as f:
f.write(content)


if __name__ == '__main__':
install_hooks()
update_submodules()
13 changes: 13 additions & 0 deletions BuildChecker/hooks/post-checkout
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

gitroot=`git rev-parse --show-toplevel`

cd "$gitroot/BuildChecker"

if [[ `uname` == MINGW* || `uname` == CYGWIN* ]]; then
# Windows
py -3 git_helper.py --quiet
else
# Not Windows, so probably some other Unix thing.
python3 git_helper.py --quiet
fi
5 changes: 5 additions & 0 deletions BuildChecker/hooks/post-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

# Just call post-checkout since it does the same thing.
gitroot=`git rev-parse --show-toplevel`
bash "$gitroot/.git/hooks/post-checkout"
10 changes: 8 additions & 2 deletions Content.Packaging/ClientPackaging.cs
Original file line number Diff line number Diff line change
@@ -61,7 +61,13 @@ public static async Task WriteResources(
var graph = new RobustClientAssetGraph();
pass.Dependencies.Add(new AssetPassDependency(graph.Output.Name));

AssetGraph.CalculateGraph(graph.AllPasses.Append(pass).ToArray(), logger);
var dropSvgPass = new AssetPassFilterDrop(f => f.Path.EndsWith(".svg"))
{
Name = "DropSvgPass",
};
dropSvgPass.AddDependency(graph.Input).AddBefore(graph.PresetPasses);

AssetGraph.CalculateGraph([pass, dropSvgPass, ..graph.AllPasses], logger);

var inputPass = graph.Input;

@@ -72,7 +78,7 @@ await RobustSharedPackaging.WriteContentAssemblies(
new[] { "Content.Client", "Content.Shared", "Content.Shared.Database" },
cancel: cancel);

await RobustClientPackaging.WriteClientResources(contentDir, pass, cancel);
await RobustClientPackaging.WriteClientResources(contentDir, inputPass, cancel);

inputPass.InjectFinished();
}
5 changes: 5 additions & 0 deletions Content.Packaging/Program.cs
Original file line number Diff line number Diff line change
@@ -11,6 +11,11 @@

if (parsed.WipeRelease)
WipeRelease();
else
{
// Ensure the release directory exists. Otherwise, the packaging will fail.
Directory.CreateDirectory("release");
}

if (!parsed.SkipBuild)
WipeBin();
3 changes: 3 additions & 0 deletions Content.Packaging/ServerPackaging.cs
Original file line number Diff line number Diff line change
@@ -13,13 +13,16 @@ public static class ServerPackaging
private static readonly List<PlatformReg> Platforms = new()
{
new PlatformReg("win-x64", "Windows", true),
new PlatformReg("win-arm64", "Windows", true),
new PlatformReg("linux-x64", "Linux", true),
new PlatformReg("linux-arm64", "Linux", true),
new PlatformReg("osx-x64", "MacOS", true),
new PlatformReg("osx-arm64", "MacOS", true),
// Non-default platforms (i.e. for Watchdog Git)
new PlatformReg("win-x86", "Windows", false),
new PlatformReg("linux-x86", "Linux", false),
new PlatformReg("linux-arm", "Linux", false),
new PlatformReg("freebsd-x64", "FreeBSD", false),
};

private static List<string> PlatformRids => Platforms