axmol/tools/console/plugins/plugin_clean.py

66 lines
1.7 KiB
Python

#!/usr/bin/python
# ----------------------------------------------------------------------------
# adxe "clean" plugin
#
# Author: Luis Parravicini
#
# License: MIT
# ----------------------------------------------------------------------------
'''
"clean" plugin for adxe command line tool
'''
__docformat__ = 'restructuredtext'
import os
import shutil
import adxe
from plugin_dist import CCPluginDist
class CCPluginClean(adxe.CCPlugin):
"""
cleans a project
"""
@staticmethod
def plugin_name():
return "clean"
@staticmethod
def brief_description():
return "removes files produced by compilation"
def clean_android(self):
if not self._platforms.is_android_active():
return
project_dir = self._platforms.project_path()
adxe.Logging.info("cleaning native")
obj_path = os.path.join(project_dir, 'obj')
self._rmdir(obj_path)
adxe.Logging.info("cleaning java")
self._run_cmd("cd \"%s\" && ant clean" % project_dir)
def clean_ios(self):
if not self._platforms.is_ios_active():
return
project_dir = self._platforms.project_path()
adxe.Logging.info("removing intermediate files")
self._run_cmd("cd \"%s\" && xcodebuild clean" % project_dir)
self._rmdir(CCPluginDist.target_path(project_dir))
def _rmdir(self, path):
if os.path.exists(path):
try:
shutil.rmtree(path)
except OSError as e:
raise adxe.CCPluginError("Error removing directory: " + str(e.args))
def run(self, argv, dependencies):
self.parse_args(argv)
self.clean_android()
self.clean_ios()