Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions PolyEngine/Scripts/commands/clean_engine_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import argparse
import sys

import common.project_mgr as project_mgr

def execute(*args):
PARSER = argparse.ArgumentParser(description='PolyEngine project build folder cleaner')

PARSER.add_argument("-b", "--build-postfix", action='store', dest='build_postfix',
default=None,
help='postfix of the build folder')

ARGS = PARSER.parse_args([*args])

mgr = project_mgr.EngineProject(build_postfix=ARGS.build_postfix)
mgr.clean_build()

if __name__ == '__main__':
execute(*sys.argv[1:])
20 changes: 20 additions & 0 deletions PolyEngine/Scripts/commands/clean_game_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import argparse
import sys

import common.project_mgr as project_mgr

def execute(*args):
PARSER = argparse.ArgumentParser(description='PolyEngine game build folder cleaner')

PARSER.add_argument("-b", "--build-postfix", action='store', dest='build_postfix',
default=None,
help='postfix of the game build folder')
PARSER.add_argument('project_path', action='store', help='Path to the project root')

ARGS = PARSER.parse_args([*args])

mgr = project_mgr.GameProject(ARGS.project_path, create_if_absent=False, build_postfix=ARGS.build_postfix)
mgr.clean_build()

if __name__ == '__main__':
execute(*sys.argv[1:])
8 changes: 4 additions & 4 deletions PolyEngine/Scripts/common/project_mgr/game_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
SLN_CMAKE_IN_FILE = 'Sln-CMakeLists.txt.in'
PROJ_CMAKE_IN_FILE = 'Proj-CMakeLists.txt.in'
IN_FILE_REGEX = r'(\S+)\.(\S+)\.in'
CMKAE_LISTS_FILE_NAME = 'CMakeLists.txt'
CMAKE_LISTS_FILE_NAME = 'CMakeLists.txt'

PROJECT_INIT_RESOURCES_DIR_NAME = 'project-init'
PROJECT_INIT_RESOURCES_PATH = os.path.join(common.SCRIPT_ENV.script_resources_path, PROJECT_INIT_RESOURCES_DIR_NAME)
Expand Down Expand Up @@ -241,8 +241,8 @@ def _create_fast_update_script(self):
def _update_cmake_files(self):
sln_cmake_in_file_path = os.path.join(PROJECT_INIT_RESOURCES_PATH, SLN_CMAKE_IN_FILE)
proj_cmake_in_file_path = os.path.join(PROJECT_INIT_RESOURCES_PATH, PROJ_CMAKE_IN_FILE)
sln_cmake_out_file_path = os.path.join(self._root_path, CMKAE_LISTS_FILE_NAME)
proj_cmake_out_file_path = os.path.join(self._project_path, CMKAE_LISTS_FILE_NAME)
sln_cmake_out_file_path = os.path.join(self._root_path, CMAKE_LISTS_FILE_NAME)
proj_cmake_out_file_path = os.path.join(self._project_path, CMAKE_LISTS_FILE_NAME)

shutil.copy(sln_cmake_in_file_path, sln_cmake_out_file_path)
shutil.copy(proj_cmake_in_file_path, proj_cmake_out_file_path)
Expand Down Expand Up @@ -278,4 +278,4 @@ def _replace_tags_in_file(self, file_to_search, tags_and_values):
for line in file:
for tag, val in tags_and_values.items():
line = line.replace(tag, val)
print(line, end='')
print(line, end='')
17 changes: 16 additions & 1 deletion PolyEngine/Scripts/common/project_mgr/project_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import shutil

BUILD_DIR_NAME = 'Build'
COMMON_BUILD_DIR_NAME = 'CommonBuild'
Expand All @@ -13,6 +14,7 @@ def __init__(self, project_root_path, project_name, build_postfix=None):

self._build_path = os.path.join(project_root_path, build_dir_fullname)
self._build_postfix = build_postfix
self._common_build_path = os.path.join(project_root_path, COMMON_BUILD_DIR_NAME)
self._dist_path = os.path.join(project_root_path, dist_dir_fullname)
self._project_name = project_name

Expand All @@ -29,6 +31,19 @@ def build(self):
def save(self):
self._save()

def clean_build(self):
print(f"Cleaning build files in {self._project_name}")
if os.path.exists(self._build_path):
print(f"Removing Build directory in {self._project_name}")
shutil.rmtree(self._build_path)
# CommonBuild is not present in games
if os.path.exists(self._common_build_path):
print(f"Removing CommonBuild directory in {self._project_name}")
shutil.rmtree(self._common_build_path)
if os.path.exists(self._dist_path):
print(f"Removing Dist directory in {self._project_name}")
shutil.rmtree(self._dist_path)

@property
def name(self):
return self._project_name
Expand Down Expand Up @@ -65,4 +80,4 @@ def _run_cmake_generator(self):
for k, v in cmake_kv_defines.items():
cmake_cmd += '-D{}={} '.format(k, v)

os.system(cmake_cmd)
os.system(cmake_cmd)