29TEMPLATE_ROOT = os.path.join(
"RenderingEngine",
"Scripts",
"Templates")
30DEST_ROOT = os.path.join(
"UserApplications")
33def copy_template(src_dir, dst_dir, project_name):
34 for root, dirs, files
in os.walk(src_dir):
35 rel_path = os.path.relpath(root, src_dir)
36 target_root = os.path.join(dst_dir, rel_path)
37 os.makedirs(target_root, exist_ok=
True)
40 src_file = os.path.join(root, file)
41 dst_file = os.path.join(target_root, file)
43 dst_file = os.path.join(target_root, file.replace(
".in",
""))
45 with open(src_file,
"r")
as f:
46 content = f.read().replace(
"@PROJECT_NAME@", project_name)
48 with open(dst_file,
"w")
as f:
51 shutil.copyfile(src_file, dst_file)
53 if dst_file.endswith(
".sh")
and os.name ==
'posix':
55 st = os.stat(dst_file)
56 os.chmod(dst_file, st.st_mode | stat.S_IEXEC)
61 @brief Create a new Rendering Engine test/demo project.
63 Generates the folder structure, copies template files, and appends
64 'add_subdirectory()' to TestApplications/CMakeLists.txt.
66 @param name Name of the project to create.
68 project_dir = os.path.join(DEST_ROOT, name)
69 if os.path.exists(project_dir):
70 print(f
"Error: Project '{name}' already exists.")
73 os.makedirs(project_dir)
74 copy_template(TEMPLATE_ROOT, project_dir, name)
75 FILE_PATH = os.path.join(DEST_ROOT,
"CMakeLists.txt")
76 CMAKE_ADD_PROJECT =
"\n" +
"add_subdirectory(" + name +
")"
77 with open(FILE_PATH,
"a")
as cmake_file:
78 cmake_file.write(CMAKE_ADD_PROJECT)
79 print(f
"Created new project at {project_dir}")
81if __name__ ==
"__main__":
83 print(
"Usage: create_project.py <ProjectName>")