Skip to content

Commit 41f217e

Browse files
committed
python script for file copy
1 parent 3bcbef0 commit 41f217e

File tree

2 files changed

+62
-6
lines changed

2 files changed

+62
-6
lines changed

.yamato/project-builders/project-builders.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,7 @@ build_{{ netcodeProject[0] }}_project:
5656
# Add BuilderScript.cs to the project so we can modify and build the project using Unity Editor.
5757
# This is a bit tricky step, notice that we also need to include proper assembly definition in order for those scripts to compile properly.
5858
# TODO: the asmdef file can be simplified
59-
# Remove the directory if it exists to ensure we start with a clean slate
60-
- |
61-
python -c "import os, shutil; d = 'C:/ClonedProject/{{ netcodeProject[1].projectPath }}/Assets/Scripts/Editor'; if os.path.exists(d): shutil.rmtree(d)"
62-
- python -c "import os; os.makedirs('C:/ClonedProject/{{ netcodeProject[1].projectPath }}/Assets/Scripts/Editor', exist_ok=True)" # --> Create the directory if it doesn't exist
63-
- python -c "import shutil; shutil.copy('Tools/CI/scripts/BuildAutomation/Unity.ProjectBuild.Editor.asmdef', 'C:/ClonedProject/{{ netcodeProject[1].projectPath }}/Assets/Scripts/Editor/')" # --> Copy the asmdef file to the directory
64-
- python -c "import shutil; shutil.copy('Tools/CI/scripts/BuildAutomation/BuilderScripts.cs', 'C:/ClonedProject/{{ netcodeProject[1].projectPath }}/Assets/Scripts/Editor/')" # --> Copy the BuilderScripts.cs file to the directory (for build configuration setup)
59+
- python Tools/CI/scripts/ileCopy.py "C:/ClonedProject/{{ netcodeProject[1].projectPath }}"
6560

6661
# Build the project using Unity Editor. This will call the given static BuilderScripts method.
6762
# Ideally, it would be nice to parametrize the BuilderScripts (for example to pass scripting backend as parameter) but -executeMethod only calls static methods without parameters so for now we will have multiple configurations
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Filename: Tools/CI/scripts/prepare_build_scripts.py
2+
3+
import os
4+
import shutil
5+
import sys
6+
7+
def main():
8+
"""
9+
Cleans and prepares the 'Assets/Scripts/Editor' directory for build automation scripts.
10+
It deletes the directory if it exists, recreates it, and copies in the necessary
11+
assembly definition and C# script files.
12+
"""
13+
# --- 1. Argument Validation ---
14+
if len(sys.argv) < 2:
15+
print("Error: Missing required argument.")
16+
print("Usage: python prepare_build_scripts.py <path_to_project_root>")
17+
sys.exit(1)
18+
19+
project_root = sys.argv[1]
20+
21+
# --- 2. Define File Paths ---
22+
# The target directory inside the Unity project
23+
target_dir = os.path.join(project_root, 'Assets', 'Scripts', 'Editor')
24+
25+
# The source files for build automation
26+
source_asmdef = 'Tools/CI/scripts/BuildAutomation/Unity.ProjectBuild.Editor.asmdef'
27+
source_script = 'Tools/CI/scripts/BuildAutomation/BuilderScripts.cs'
28+
29+
print(f"Preparing build scripts for project at: {project_root}")
30+
print(f"Target editor script directory: {target_dir}")
31+
32+
# --- 3. Clean and Recreate Directory ---
33+
try:
34+
if os.path.exists(target_dir):
35+
print(f"Directory '{target_dir}' exists. Removing it.")
36+
shutil.rmtree(target_dir)
37+
38+
print(f"Creating directory: {target_dir}")
39+
os.makedirs(target_dir)
40+
41+
except OSError as e:
42+
print(f"Error managing directory: {e}")
43+
sys.exit(1)
44+
45+
# --- 4. Copy Build Automation Files ---
46+
try:
47+
print(f"Copying '{source_asmdef}' to '{target_dir}'")
48+
shutil.copy(source_asmdef, target_dir)
49+
50+
print(f"Copying '{source_script}' to '{target_dir}'")
51+
shutil.copy(source_script, target_dir)
52+
53+
except IOError as e:
54+
print(f"Error copying files: {e}")
55+
sys.exit(1)
56+
57+
print("\nSuccessfully prepared build automation scripts.")
58+
59+
if __name__ == "__main__":
60+
main()
61+

0 commit comments

Comments
 (0)