edit extract_assets script to support freebsd (#520)

Co-authored-by: ezntek <ezntek@xflymusic.com>
This commit is contained in:
ezntek 2023-10-16 16:28:06 +08:00 committed by GitHub
parent 54cd27ccee
commit 2256c014c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 11 deletions

View File

@ -2,14 +2,13 @@
import sys import sys
import os import os
import json import json
import platform
def read_asset_map(): def read_asset_map():
with open("assets.json") as f: with open("assets.json") as f:
ret = json.load(f) ret = json.load(f)
return ret return ret
def read_local_asset_list(f): def read_local_asset_list(f):
if f is None: if f is None:
return [] return []
@ -18,7 +17,6 @@ def read_local_asset_list(f):
ret.append(line.strip()) ret.append(line.strip())
return ret return ret
def asset_needs_update(asset, version): def asset_needs_update(asset, version):
if version <= 5 and asset == "textures/spooky/bbh_textures.00800.rgba16.png": if version <= 5 and asset == "textures/spooky/bbh_textures.00800.rgba16.png":
return True return True
@ -34,7 +32,6 @@ def asset_needs_update(asset, version):
return True return True
return False return False
def remove_file(fname): def remove_file(fname):
os.remove(fname) os.remove(fname)
print("deleting", fname) print("deleting", fname)
@ -43,7 +40,6 @@ def remove_file(fname):
except OSError: except OSError:
pass pass
def clean_assets(local_asset_file): def clean_assets(local_asset_file):
assets = set(read_asset_map().keys()) assets = set(read_asset_map().keys())
assets.update(read_local_asset_list(local_asset_file)) assets.update(read_local_asset_list(local_asset_file))
@ -55,7 +51,6 @@ def clean_assets(local_asset_file):
except FileNotFoundError: except FileNotFoundError:
pass pass
def main(): def main():
# In case we ever need to change formats of generated files, we keep a # In case we ever need to change formats of generated files, we keep a
# revision ID in the local asset file. # revision ID in the local asset file.
@ -153,9 +148,14 @@ def main():
sys.exit(1) sys.exit(1)
# Make sure tools exist # Make sure tools exist
subprocess.check_call( if platform.system() == "FreeBSD":
["make", "-s", "-C", "tools/", "n64graphics", "skyconv", "mio0", "aifc_decode"] subprocess.check_call(
) ["gmake", "-s", "-C", "tools/", "n64graphics", "skyconv", "mio0", "aifc_decode"]
)
else:
subprocess.check_call(
["make", "-s", "-C", "tools/", "n64graphics", "skyconv", "mio0", "aifc_decode"]
)
# Go through the assets in roughly alphabetical order (but assets in the same # Go through the assets in roughly alphabetical order (but assets in the same
# mio0 file still go together). # mio0 file still go together).
@ -282,5 +282,4 @@ def main():
with open(".assets-local.txt", "w") as f: with open(".assets-local.txt", "w") as f:
f.write(output) f.write(output)
main() if __name__ == "__main__" else None
main()