Skip to content

Commit

Permalink
Update build scripts to support x64 builds and changing builtin wchar…
Browse files Browse the repository at this point in the history
…_t type
  • Loading branch information
mmdanggg2 committed Jan 2, 2025
1 parent d1aa942 commit 1b98782
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 35 deletions.
28 changes: 24 additions & 4 deletions D3D9Drv.vcxproj.user
Original file line number Diff line number Diff line change
@@ -1,22 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerCommand>$(UNREAL_SYSTEM_DIR)\$(UNREAL_EXE_NAME)</LocalDebuggerCommand>
<LocalDebuggerCommand>$(UNREAL_INSTALL_DIR)\System\$(UNREAL_EXE_NAME)</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments></LocalDebuggerCommandArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerCommand>$(UNREAL_INSTALL_DIR)\System64\$(UNREAL_EXE_NAME)</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments></LocalDebuggerCommandArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='EditContinue|Win32'">
<LocalDebuggerCommand>$(UNREAL_SYSTEM_DIR)\$(UNREAL_EXE_NAME)</LocalDebuggerCommand>
<LocalDebuggerCommand>$(UNREAL_INSTALL_DIR)\System\$(UNREAL_EXE_NAME)</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments></LocalDebuggerCommandArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='EditContinue|x64'">
<LocalDebuggerCommand>$(UNREAL_INSTALL_DIR)\System64\$(UNREAL_EXE_NAME)</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments></LocalDebuggerCommandArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommand>$(UNREAL_SYSTEM_DIR)\$(UNREAL_EXE_NAME)</LocalDebuggerCommand>
<LocalDebuggerCommand>$(UNREAL_INSTALL_DIR)\System\$(UNREAL_EXE_NAME)</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments></LocalDebuggerCommandArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerCommand>$(UNREAL_INSTALL_DIR)\System64\$(UNREAL_EXE_NAME)</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments></LocalDebuggerCommandArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ASAN|Win32'">
<LocalDebuggerCommand>$(UNREAL_SYSTEM_DIR)\$(UNREAL_EXE_NAME)</LocalDebuggerCommand>
<LocalDebuggerCommand>$(UNREAL_INSTALL_DIR)\System\$(UNREAL_EXE_NAME)</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments></LocalDebuggerCommandArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ASAN|x64'">
<LocalDebuggerCommand>$(UNREAL_INSTALL_DIR)\System64\$(UNREAL_EXE_NAME)</LocalDebuggerCommand>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments></LocalDebuggerCommandArguments>
</PropertyGroup>
Expand Down
14 changes: 11 additions & 3 deletions scripts/BuildAll.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ def switch_game(game_code: str):
print(f"Switching to '{colored(game_code, 'cyan')}'")
subprocess.run([f"{game_code}.bat"], shell=True, check=True)

def build(version: str | None = None):
def build(version: str | None = None, x64: bool = False):
solution_path = VS_PROJECT_PATH / "D3D9Drv.sln"
configuration = "Release"
platform = "x64" if x64 else "Win32"

# Build the Visual Studio solution
build_command = [
Expand All @@ -50,17 +51,18 @@ def build(version: str | None = None):
"-target:Rebuild",
"-m",
f"-p:Configuration={configuration}",
f"-p:Platform={platform}"
]
if version:
# Eww stinky, just shove this in here since the rc has it anyway.
with (VS_PROJECT_PATH / "gamename.h").open("a") as f:
f.write(f'\n#define VERSION_EXTRA "{version}"\n')
subprocess.run(build_command, shell=True, check=True)

def zip_build(build_name: str, version_path: Path):
def zip_build(build_name: str, version_path: Path, x64: bool = False):
# Set the files to include in the ZIP file
files_to_zip = [
VS_PROJECT_PATH / "install" / "System" / "D3D9DrvRTX.dll",
VS_PROJECT_PATH / "install" / ("System64" if x64 else "System") / "D3D9DrvRTX.dll",
VS_PROJECT_PATH / "Config" / "D3D9DrvRTX.ini",
VS_PROJECT_PATH / "Config" / "D3D9DrvRTX.int",
VS_PROJECT_PATH / "Config" / "D3D9DrvRTX_hash_tex_blacklist.txt",
Expand Down Expand Up @@ -94,6 +96,7 @@ def zip_build(build_name: str, version_path: Path):
"UT_469d",
"UT_436",
"Unreal_226",
"Unreal_227k_12",
"DeusEx",
"Nerf",
"Rune",
Expand All @@ -107,3 +110,8 @@ def zip_build(build_name: str, version_path: Path):
build_name = f"D3D9DrvRTX-{game_code}-{version}"
zip_build(build_name, version_path)
print()
if game_code == "Unreal_227k_12":
build(args.version_extra, x64=True)
build_name = f"D3D9DrvRTX-{game_code}-x64-{version}"
zip_build(build_name, version_path, x64=True)
print()
2 changes: 1 addition & 1 deletion scripts/DeusEx.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@ECHO OFF
call ChangeLinks.bat dx1112f
python SetDebug.py DeusEx.exe
python SetProperties.py --debug-exe DeusEx.exe
echo #define GAME_NAME "DeusEx v1112fm"> ..\gamename.h
2 changes: 1 addition & 1 deletion scripts/HP1.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@ECHO OFF
call ChangeLinks.bat hp1
python SetDebug.py HP.exe
python SetProperties.py --debug-exe HP.exe
echo #define GAME_NAME "Harry Potter Sourcerer's Stone v433"> ..\gamename.h
2 changes: 1 addition & 1 deletion scripts/HP2.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@ECHO OFF
call ChangeLinks.bat hp2
python SetDebug.py Game.exe
python SetProperties.py --debug-exe Game.exe
echo #define GAME_NAME "Harry Potter Chamber of Secrets v433"> ..\gamename.h
2 changes: 1 addition & 1 deletion scripts/Nerf.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@ECHO OFF
call ChangeLinks.bat nerf
python SetDebug.py Nerf.exe
python SetProperties.py --debug-exe Nerf.exe
echo #define GAME_NAME "Nerf Arena Blast v300"> ..\gamename.h
2 changes: 1 addition & 1 deletion scripts/Rune.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@ECHO OFF
call ChangeLinks.bat rune107
python SetDebug.py Rune.exe
python SetProperties.py --debug-exe Rune.exe
echo #define GAME_NAME "Rune v107"> ..\gamename.h
19 changes: 0 additions & 19 deletions scripts/SetDebug.py

This file was deleted.

29 changes: 29 additions & 0 deletions scripts/SetProperties.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from pathlib import Path
import re
import argparse

parse = argparse.ArgumentParser()
parse.add_argument("--debug-exe")
parse.add_argument("--wchar", action="store_true")

args = parse.parse_args()

exe_name = args.debug_exe

SCRIPTS_DIR = Path(__file__).parent
VS_PROJECT_PATH = SCRIPTS_DIR.parent

prop_path = VS_PROJECT_PATH / "PropertySheet.props"

props = prop_path.read_text()

def replace_tag(tag: str, new_value: str, xml: str):
return re.sub(fr"(?<=<{tag}>)(.*)(?=</{tag}>)", new_value, xml)

props = replace_tag("UNREAL_EXE_NAME", exe_name, props)
props = replace_tag("TreatWChar_tAsBuiltInType", "true" if args.wchar else "false", props)

prop_path.write_text(props)

sln_path = VS_PROJECT_PATH / "D3D9Drv.sln"
sln_path.touch(exist_ok=True)
2 changes: 1 addition & 1 deletion scripts/UT_436.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@ECHO OFF
call ChangeLinks.bat ut436
python SetDebug.py UnrealTournament.exe
python SetProperties.py --debug-exe UnrealTournament.exe
echo #define GAME_NAME "Unreal Tournament v436"> ..\gamename.h
2 changes: 1 addition & 1 deletion scripts/UT_469d.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@ECHO OFF
call ChangeLinks.bat ut469d
python SetDebug.py UnrealTournament.exe
python SetProperties.py --debug-exe UnrealTournament.exe
echo #define GAME_NAME "Unreal Tournament v469d"> ..\gamename.h
2 changes: 1 addition & 1 deletion scripts/Unreal_226.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@ECHO OFF
call ChangeLinks.bat unreal226
python SetDebug.py Unreal.exe
python SetProperties.py --debug-exe Unreal.exe
echo #define GAME_NAME "Unreal v226"> ..\gamename.h
2 changes: 1 addition & 1 deletion scripts/Unreal_227k_12.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@ECHO OFF
call ChangeLinks.bat unreal227k_12
python SetDebug.py Unreal.exe
python SetProperties.py --debug-exe Unreal.exe --wchar
echo #define GAME_NAME "Unreal v227k_12"> ..\gamename.h

0 comments on commit 1b98782

Please sign in to comment.