Esempio n. 1
0
def show_version():
    import utils
    cur_path = get_current_path()
    engine_path = os.path.normpath(os.path.join(cur_path, '../../../'))
    engine_ver = utils.get_engine_version(engine_path)
    print(engine_ver)
    print("Cocos Console %s" % COCOS2D_CONSOLE_VERSION)
Esempio n. 2
0
def show_version():
    import utils
    cur_path = get_current_path()
    engine_path = os.path.normpath(os.path.join(cur_path, '../../../'))
    engine_ver = utils.get_engine_version(engine_path)
    print(engine_ver)
    print("Cocos Console %s" % COCOS2D_CONSOLE_VERSION)
Esempio n. 3
0
    def _create_from_cmd(self):
        # check the dst project dir exists
        if os.path.exists(self._projdir):
            message = MultiLanguage.get_string('NEW_ERROR_FOLDER_EXISTED_FMT',
                                               self._projdir)
            raise cocos.CCPluginError(message,
                                      cocos.CCPluginError.ERROR_PATH_NOT_FOUND)

        creator = TPCreator(self._lang, self._cocosroot, self._projname,
                            self._projdir, self._tpname, self._tpdir,
                            self._package, self._mac_bundleid,
                            self._ios_bundleid)
        # do the default creating step
        creator.do_default_step()

        data = None
        cfg_path = os.path.join(self._projdir, cocos_project.Project.CONFIG)
        if os.path.isfile(cfg_path):
            f = open(cfg_path)
            data = json.load(f)
            f.close()

        if data is None:
            data = {}

        if cocos_project.Project.KEY_PROJ_TYPE not in data:
            data[cocos_project.Project.KEY_PROJ_TYPE] = self._lang

        # script project may add native support
        if self._lang in (cocos_project.Project.LUA, cocos_project.Project.JS):
            # REMOVE the option --no-native. Because it's added for Cocos Code IDE.
            # It will cause confusion: https://github.com/cocos2d/cocos2d-console/issues/401
            # if self._other_opts.no_native is not self._other_opts.no_native:
            #     creator.do_other_step('do_add_native_support')
            #     data[cocos_project.Project.KEY_HAS_NATIVE] = True
            # else:
            #     data[cocos_project.Project.KEY_HAS_NATIVE] = False
            creator.do_other_step('do_add_native_support')
            data[cocos_project.Project.KEY_HAS_NATIVE] = True

        # record the engine version if not predefined
        if not data.has_key(cocos_project.Project.KEY_ENGINE_VERSION):
            engine_version = utils.get_engine_version(self._cocosroot)
            if engine_version is not None:
                data[cocos_project.Project.KEY_ENGINE_VERSION] = engine_version

        # if --portrait is specified, change the orientation
        if self._other_opts.portrait:
            creator.do_other_step("change_orientation",
                                  not_existed_error=False)

        # write config files
        with open(cfg_path, 'w') as outfile:
            json.dump(data, outfile, sort_keys=True, indent=4)
Esempio n. 4
0
    def _create_from_cmd(self):
        # check the dst project dir exists
        if os.path.exists(self._projdir):
            message = MultiLanguage.get_string('NEW_ERROR_FOLDER_EXISTED_FMT', self._projdir)
            raise cocos.CCPluginError(message, cocos.CCPluginError.ERROR_PATH_NOT_FOUND)

        creator = TPCreator(self._lang, self._cocosroot, self._projname, self._projdir,
                            self._tpname, self._tpdir, self._package, self._mac_bundleid, self._ios_bundleid)
        # do the default creating step
        creator.do_default_step()

        data = None
        cfg_path = os.path.join(self._projdir, cocos_project.Project.CONFIG)
        if os.path.isfile(cfg_path):
            f = open(cfg_path)
            data = json.load(f)
            f.close()

        if data is None:
            data = {}

        if cocos_project.Project.KEY_PROJ_TYPE not in data:
            data[cocos_project.Project.KEY_PROJ_TYPE] = self._lang

        # script project may add native support
        if self._lang in (cocos_project.Project.LUA, cocos_project.Project.JS):
            # REMOVE the option --no-native. Because it's added for Cocos Code IDE.
            # It will cause confusion: https://github.com/cocos2d/cocos2d-console/issues/401
            # if self._other_opts.no_native is not self._other_opts.no_native:
            #     creator.do_other_step('do_add_native_support')
            #     data[cocos_project.Project.KEY_HAS_NATIVE] = True
            # else:
            #     data[cocos_project.Project.KEY_HAS_NATIVE] = False
            creator.do_other_step('do_add_native_support')
            data[cocos_project.Project.KEY_HAS_NATIVE] = True

        # record the engine version if not predefined
        if not data.has_key(cocos_project.Project.KEY_ENGINE_VERSION):
            engine_version = utils.get_engine_version(self._cocosroot)
            if engine_version is not None:
                data[cocos_project.Project.KEY_ENGINE_VERSION] = engine_version

        # if --portrait is specified, change the orientation
        if self._other_opts.portrait:
            creator.do_other_step("change_orientation", not_existed_error=False)

        # write config files
        with open(cfg_path, 'w') as outfile:
            json.dump(data, outfile, sort_keys=True, indent=4)
    def get_engine_version_num(self):
        # 1. get engine version from .cocos_project.json
        engine_ver_str = self._project.get_proj_config(
            cocos_project.Project.KEY_ENGINE_VERSION)

        # 2. engine version is not found. find from source file
        if engine_ver_str is None:
            engine_dir = self.get_engine_dir()
            if engine_dir is not None:
                engine_ver_str = utils.get_engine_version(engine_dir)

        if engine_ver_str is None:
            return None

        version_pattern = r'cocos2d-x-([\d]+)\.([\d]+)'
        match = re.match(version_pattern, engine_ver_str)
        if match:
            return ((int)(match.group(1)), (int)(match.group(2)))
        else:
            return None
Esempio n. 6
0
        # get the argument value
        agree_value = sys.argv[idx + 1]
        if agree_value.lower() == 'n':
            skip_agree_value = False
        else:
            skip_agree_value = True

        # remove the argument '--agreement' & the value
        sys.argv.pop(idx)
        sys.argv.pop(idx)

    # Get the engine version for the DataStat
    cur_path = get_current_path()
    engine_path = os.path.normpath(os.path.join(cur_path,
                                                '../../GxFramework/'))
    COCOS_ENGINE_VERSION = utils.get_engine_version(engine_path)
    STAT_VERSION = COCOS_ENGINE_VERSION
    ver_pattern = r"cocos2d-x-(.*)"
    match = re.match(ver_pattern, COCOS_ENGINE_VERSION)
    if match:
        STAT_VERSION = match.group(1)

    DataStatistic.show_stat_agreement(skip_agree_value)
    DataStatistic.stat_event('cocos', 'start', 'invoked')

    if not _check_python_version():
        DataStatistic.terminate_stat()
        sys.exit(CCPluginError.ERROR_TOOLS_NOT_FOUND)

    parser = Cocos2dIniParser()
    plugins_path = parser.get_plugins_path()
Esempio n. 7
0
    def init(self, args):
        if getattr(sys, 'frozen', None):
            self.cur_dir = os.path.realpath(os.path.dirname(sys.executable))
            self.default_engine_path = os.path.join(self.cur_dir, os.pardir, os.pardir, os.pardir)
        else:
            self.cur_dir = os.path.realpath(os.path.dirname(__file__))
            self.default_engine_path = os.path.join(self.cur_dir, os.pardir, os.pardir, os.pardir, os.pardir)
        self.default_engine_path = os.path.normpath(self.default_engine_path)

        if args.engine_path is None:
            self.engine_root = self.default_engine_path
        else:
            engine_path = os.path.expanduser(args.engine_path)
            if os.path.isabs(engine_path):
                self.engine_root = os.path.normpath(engine_path)
            else:
                self.engine_root = os.path.normpath(os.path.abspath(engine_path))

        if not os.path.isdir(self.engine_root):
            raise CCPluginError(MultiLanguage.get_string('GEN_SIM_ERROR_WRONG_PATH_FMT', self.engine_root),
                                CCPluginError.ERROR_WRONG_ARGS)

        self.simulator_abs_path = os.path.join(self.engine_root, SimulatorCompiler.SIMULATOR_PROJ_PATH)
        self.cocos_bin = os.path.join(self.engine_root, SimulatorCompiler.COCOS_CMD_PATH)
        engine_version = utils.get_engine_version(self.engine_root)
        # get the short version after "cocos2d-x-"
        self.engine_version = engine_version[10:]

        # get the full path of output dir.
        if args.out_dir is None:
            self.simulator_output_dir = os.path.join(self.engine_root, SimulatorCompiler.DEFAULT_OUTPUT_FOLDER_NAME)
        else:
            out_dir = os.path.expanduser(args.out_dir)
            if os.path.isabs(out_dir):
                self.simulator_output_dir = os.path.normpath(out_dir)
            else:
                self.simulator_output_dir = os.path.normpath(os.path.abspath(out_dir))

        # get arguments
        self.is_clean_before_build = args.do_clean
        if args.compile_mode is None:
            self.mode = 'debug'
        else:
            self.mode = args.compile_mode

        if args.platform is None:
            self.build_ios = True
            self.build_mac = True
            self.build_win = True
            self.build_android = True
        else:
            self.build_ios = False
            self.build_mac = False
            self.build_win = False
            self.build_android = False
            if 'win32' in args.platform:
                self.build_win = True
            if 'ios' in args.platform:
                self.build_ios = True
            if 'mac' in args.platform:
                self.build_mac = True
            if 'android' in args.platform:
                self.build_android = True

        self.build_log = ""
        self.vs_version = args.vs_version
        self._verbose = True
Esempio n. 8
0
if language is not None:
    filename = "language_%s.mo" % language[0:2]
    try:
        trans = gettext.GNUTranslations(open(filename, "rb"))
    except IOError:
        trans = gettext.NullTranslations()
    trans.install()
    _ = trans.gettext
else:
    _ = MultiLanguage.get_string

if __name__ == "__main__":
    # Get the engine version for the DataStat
    cur_path = get_current_path()
    engine_path = os.path.normpath(os.path.join(cur_path, '../../../'))
    STAT_VERSION = utils.get_engine_version(engine_path)
    if STAT_VERSION is not None:
        ver_pattern = r"(.*)-lite$"
        match = re.match(ver_pattern, STAT_VERSION)
        if match:
            STAT_VERSION = match.group(1)
    else:
        STAT_VERSION = 'unknown'

    DataStatistic.stat_event('cocos', 'start', 'invoked')

    # Parse the arguments, specify the language
    language_arg = '--ol'
    if language_arg in sys.argv:
        idx = sys.argv.index(language_arg)
        if idx == (len(sys.argv) - 1):