Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add engine build cleaning command. #229

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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_build_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:])
9 changes: 8 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,11 @@ def build(self):
def save(self):
self._save()

def clean_build(self):
shutil.rmtree(self._build_path)
shutil.rmtree(self._dist_path)
shutil.rmtree(self._common_build_path)

@property
def name(self):
return self._project_name
Expand Down Expand Up @@ -65,4 +72,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)