Skip to content

Commit

Permalink
Update BuildAll.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mmdanggg2 authored Nov 12, 2024
1 parent 94f9d5f commit fb240ea
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions scripts/BuildAll.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ def get_version():
# Skip the BOM if present
if rc_file_content.startswith('\ufeff'):
rc_file_content = rc_file_content[1:]
version_match = re.search(r"FILEVERSION\s+(\d+),(\d+),(\d+)", rc_file_content)
if version_match:
version_parts = version_match.groups()
version_major_match = re.search(r"#define\s+VERSION_MAJOR\s+(\d+)", rc_file_content)
version_minor_match = re.search(r"#define\s+VERSION_MINOR\s+(\d+)", rc_file_content)
version_patch_match = re.search(r"#define\s+VERSION_PATCH\s+(\d+)", rc_file_content)
if version_major_match and version_minor_match and version_patch_match:
version_parts = [
version_major_match.group(1),
version_minor_match.group(1),
version_patch_match.group(1),
]
version_number = ".".join(version_parts)
print(f"Version number extracted: {colored(version_number, 'green')}")
return version_number
Expand All @@ -32,7 +38,7 @@ def switch_game(game_code):
print(f"Switching to '{colored(game_code, 'cyan')}'")
subprocess.run([f"{game_code}.bat"], shell=True, check=True)

def build(version_extra: str | None = None):
def build(version: str | None = None):
solution_path = VS_PROJECT_PATH / "D3D9Drv.sln"
configuration = "Release"

Expand All @@ -45,10 +51,10 @@ def build(version_extra: str | None = None):
"-m",
f"-p:Configuration={configuration}",
]
if version_extra:
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_extra}"\n')
f.write(f'\n#define VERSION_EXTRA "{version}"\n')
subprocess.run(build_command, shell=True, check=True)

def zip_build(build_name, version_path):
Expand All @@ -73,6 +79,7 @@ def zip_build(build_name, version_path):

parser = argparse.ArgumentParser()
parser.add_argument("--version-extra", required=False)
parser.add_argument("-o", "--overwrite", action="store_true", required=False)
args = parser.parse_args()

if args.version_extra:
Expand All @@ -81,7 +88,7 @@ def zip_build(build_name, version_path):
version = get_version()

version_path = VS_PROJECT_PATH / "Releases" / version
version_path.mkdir(parents=True, exist_ok=False)
version_path.mkdir(parents=True, exist_ok=args.overwrite)

games_codes = [
"UT_469d",
Expand Down

0 comments on commit fb240ea

Please sign in to comment.