0.1.0-0-pre.9
This commit is contained in:
40
scripts/stage_game_assets.py
Normal file
40
scripts/stage_game_assets.py
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python3
|
||||
# file: scripts/stage_game_assets.py
|
||||
# version: 1
|
||||
|
||||
"""Stage common and game-specific source assets into the canonical runtime layout."""
|
||||
|
||||
import argparse
|
||||
import pathlib
|
||||
import shutil
|
||||
|
||||
GAME_DIRECTORIES = {
|
||||
"reflex": "game-reflex-poc",
|
||||
"snake": "game-snake-poc",
|
||||
}
|
||||
|
||||
def copy_tree(source: pathlib.Path, destination: pathlib.Path) -> None:
|
||||
"""Copy one source asset tree into one generated destination tree."""
|
||||
if destination.exists():
|
||||
shutil.rmtree(destination)
|
||||
shutil.copytree(source, destination)
|
||||
|
||||
def main() -> int:
|
||||
"""Stage one game's assets and print the generated root."""
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("game", choices=sorted(GAME_DIRECTORIES))
|
||||
parser.add_argument("--output")
|
||||
arguments = parser.parse_args()
|
||||
root = pathlib.Path(__file__).resolve().parent.parent
|
||||
game_directory = GAME_DIRECTORIES[arguments.game]
|
||||
output = pathlib.Path(arguments.output).resolve() if arguments.output else (root.parent / "builds" / "sasedev-games" / "assets" / game_directory)
|
||||
if output.exists():
|
||||
shutil.rmtree(output)
|
||||
output.mkdir(parents=True, exist_ok=True)
|
||||
copy_tree(root / "assets" / "common", output / "common")
|
||||
copy_tree(root / "assets" / game_directory, output / "game")
|
||||
print(output)
|
||||
return 0
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Reference in New Issue
Block a user