Skip to content

Commit

Permalink
[build_scripts] some additional fixes and clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
PanosK92 committed Jan 20, 2025
1 parent 8046e53 commit 850f34d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
5 changes: 3 additions & 2 deletions build_scripts/download_assets.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Copyright(c) 2016-2024 Panos Karabelas
#Copyright(c) 2016-2025 Panos Karabelas
#
#Permission is hereby granted, free of charge, to any person obtaining a copy
#of this software and associated documentation files (the "Software"), to deal
Expand All @@ -25,7 +25,8 @@

def main():
file_utilities.download_file(file_url, file_destination, file_expected_hash)
file_utilities.extract_archive(file_destination, "project/", True, True)
file_utilities.extract_archive(file_destination, "project/")
input()

if __name__ == "__main__":
main()
33 changes: 18 additions & 15 deletions build_scripts/file_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,33 +73,36 @@ def download_file(url, destination, expected_hash):
if calculate_file_hash(destination) != expected_hash:
print(f"ERROR, hash mismatch for {destination}")
return

def extract_archive(archive_path, destination_path):
# Check if 7z.exe exists locally
current_dir_7z = Path("7z.exe")
if current_dir_7z.exists():
seven_zip_exe = current_dir_7z
else:
# define the path where 7z.exe should be if not in the current directory
seven_zip_exe = Path("build_scripts") / "7z.exe"
seven_zip_exe = seven_zip_exe.resolve()

def extract_archive(archive_path, destination_path, is_windows, use_working_dir=False):
# determine the path to 7z based on the use_working_dir flag
seven_zip_exe = Path("build_scripts") / ("7z.exe" if is_windows else "7za")
seven_zip_exe = seven_zip_exe.resolve() if use_working_dir else seven_zip_exe
# check if the 7z executable exists
if not os.path.exists(seven_zip_exe):
raise FileNotFoundError(f"The 7z executable was not found at {seven_zip_exe}. Please check the path or installation.")

# convert paths to string for subprocess, ensuring they are quoted if they contain spaces
archive_path_str = f'"{Path(archive_path).resolve()}"'
destination_path_str = f'"{Path(destination_path).resolve()}"'
archive_path_str = str(Path(archive_path).resolve())
destination_path_str = str(Path(destination_path).resolve())

# construct the command as a string with quoted paths
cmd = f'{str(seven_zip_exe)} x {archive_path_str} -o{destination_path_str} -aoa'
cmd = [str(seven_zip_exe), 'x', archive_path_str, '-o'+destination_path_str, '-aoa']

print(f"Extracting {archive_path} to {destination_path} using: {seven_zip_exe}")

try:
# execute the command with shell=True to handle paths with spaces
result = subprocess.run(cmd, check=True, shell=True, capture_output=True, text=True)
result = subprocess.run(cmd, check=True, capture_output=True, text=True)
print(result.stdout)
except subprocess.CalledProcessError as e:
print(f"An error occurred while extracting: {e}")
print(f"Error output: {e.stderr}")
raise # re-raise the exception for higher-level error handling if needed
except FileNotFoundError:
print(f"The 7z executable was not found at {seven_zip_exe}. Please check the path or installation.")
raise

def copy(source, destination):
def on_rm_error(func, path, exc_info):
os.chmod(path, stat.S_IWRITE)
Expand Down
2 changes: 1 addition & 1 deletion build_scripts/generate_project_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def main():
library_destination = Path("third_party") / "libraries" / "libraries.7z"
library_expected_hash = '8a20305ee9658dfdfba2aea88f26e6ee3d1330d7e6d26f42bc07bb76150ff1c5'
file_utilities.download_file(library_url, str(library_destination), library_expected_hash)
file_utilities.extract_archive(str(library_destination), str(Path("third_party") / "libraries"), sys.argv[1] == "vs2022", False)
file_utilities.extract_archive(str(library_destination), str(Path("third_party") / "libraries"))

print("3. Copying required DLLs to the binary directory...")
for lib in paths["third_party_libs"].values():
Expand Down
2 changes: 1 addition & 1 deletion runtime/RHI/Vulkan/Vulkan_FidelityFX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ namespace spartan
}

// release static resources now so that they register
// themselfs with the RHI for deletion before engine shutdown
// themselves with the RHI for deletion before engine shutdown
brixelizer_gi::texture_sdf_atlas = nullptr;
brixelizer_gi::buffer_brick_aabbs = nullptr;
brixelizer_gi::buffer_scratch = nullptr;
Expand Down

0 comments on commit 850f34d

Please sign in to comment.