-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Deprecates RUN_THIS.py in favor of manually doin' it (#3930)"…
… (#3933) This reverts commit 94082e0.
- Loading branch information
1 parent
94082e0
commit ce67371
Showing
7 changed files
with
175 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
INSTALLED_HOOKS_VERSION | ||
DISABLE_SUBMODULE_AUTOUPDATE | ||
*.nuget* | ||
project.assets.json | ||
project.packagespec.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
This is a dummy .csproj file to check things like submodules. | ||
Better this than other errors. | ||
If you want to create this kind of file yourself, you have to create an empty .NET application, | ||
Then strip it of everything until you have the <Project> tags. | ||
VS refuses to load the project if you make a bare project file and use Add -> Existing Project... for some reason. | ||
You want to handle the Build, Clean and Rebuild tasks to prevent missing task errors on build. | ||
If you want to learn more about these kinds of things, check out Microsoft's official documentation about MSBuild: | ||
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> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<OutputType>Library</OutputType> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<StartupObject /> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<OutputPath>bin\Release\</OutputPath> | ||
</PropertyGroup> | ||
<Target Name="Build"> | ||
<Exec Command="$(Python) git_helper.py" CustomErrorRegularExpression="^Error" /> | ||
</Target> | ||
<Target Name="Rebuild" DependsOnTargets="Build" /> | ||
<Target Name="Clean"> | ||
<Message Importance="low" Text="Ignoring 'Clean' target." /> | ||
</Target> | ||
<Target Name="Compile"> | ||
</Target> | ||
<Target Name="CoreCompile"> | ||
</Target> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#!/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 os.path.isfile("DISABLE_SUBMODULE_AUTOUPDATE"): | ||
return | ||
|
||
# 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() |
0
Hooks/post-checkout → BuildChecker/hooks/post-checkout
100644 → 100755
File renamed without changes.
0
Hooks/post-merge → BuildChecker/hooks/post-merge
100644 → 100755
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/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 | ||
import sys | ||
import subprocess | ||
|
||
IS_WINDOWS = sys.platform in ("win32", "cygwin") | ||
|
||
version = sys.version_info | ||
if version.major < 3 or (version.major == 3 and version.minor < 5): | ||
print("ERROR: You need at least Python 3.5 to build SS14.") | ||
sys.exit(1) | ||
|
||
if IS_WINDOWS: | ||
subprocess.run(["py", "-3", "git_helper.py"], cwd="BuildChecker") | ||
else: | ||
subprocess.run(["python3", "git_helper.py"], cwd="BuildChecker") |