2020-07-20 18:46:15 +08:00
|
|
|
#!/usr/bin/python
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# cocos2d "version" plugin
|
|
|
|
#
|
|
|
|
# Author: Ricardo Quesada
|
|
|
|
# Copyright 2013 (C) Zynga, Inc
|
|
|
|
#
|
|
|
|
# License: MIT
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
'''
|
|
|
|
"version" plugin for cocos2d command line tool
|
|
|
|
'''
|
|
|
|
|
|
|
|
__docformat__ = 'restructuredtext'
|
|
|
|
|
|
|
|
import re
|
|
|
|
import os
|
|
|
|
import cocos2d
|
|
|
|
import inspect
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Plugins should be a sublass of CCJSPlugin
|
|
|
|
#
|
|
|
|
class CCPluginVersion(cocos2d.CCPlugin):
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def plugin_name():
|
|
|
|
return "version"
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def brief_description():
|
|
|
|
return "prints the version of the installed components"
|
|
|
|
|
|
|
|
def _show_versions(self):
|
2023-06-12 09:14:23 +08:00
|
|
|
path = os.path.join(self._src_dir, "axmol", "axmolver.h")
|
2020-07-20 18:46:15 +08:00
|
|
|
if not os.path.exists(path):
|
2023-06-12 09:14:23 +08:00
|
|
|
path = os.path.join(self._src_dir, "axmol", "2d", "axmolver.h")
|
2020-07-20 18:46:15 +08:00
|
|
|
if not os.path.exists(path):
|
|
|
|
raise cocos2d.CCPluginError("Couldn't find file with version information")
|
|
|
|
|
|
|
|
with open(path, 'r') as f:
|
|
|
|
data = f.read()
|
2023-06-12 09:14:23 +08:00
|
|
|
match = re.search(r".*AX_VERSION_STR[ \t]+\"(.*)\"", data)
|
2020-07-20 18:46:15 +08:00
|
|
|
if match:
|
2023-06-12 09:14:23 +08:00
|
|
|
print 'axmol %s' % match.group(1)
|
2020-07-20 18:46:15 +08:00
|
|
|
else:
|
|
|
|
raise cocos2d.CCPluginError("Couldn't find version info")
|
|
|
|
|
|
|
|
def run(self, argv, dependencies):
|
|
|
|
self.parse_args(argv)
|
|
|
|
self._show_versions()
|
|
|
|
|