Exemplo n.º 1
0
    def _filter_platforms(self, platforms):
        ret = []
        platforms_for_os = {
            "linux": [
                Platforms.WEB, Platforms.LINUX, Platforms.ANDROID,
                Platforms.TIZEN
            ],
            "mac": [
                Platforms.WEB, Platforms.IOS, Platforms.MAC, Platforms.ANDROID,
                Platforms.TIZEN
            ],
            "win32": [
                Platforms.WEB, Platforms.WIN32, Platforms.ANDROID,
                Platforms.METRO, Platforms.TIZEN
            ]
        }
        for p in platforms:
            if cocos.os_is_linux():
                if p in platforms_for_os["linux"]:
                    ret.append(p)
            if cocos.os_is_mac():
                if p in platforms_for_os["mac"]:
                    ret.append(p)
            if cocos.os_is_win32():
                if p in platforms_for_os["win32"]:
                    ret.append(p)

        return ret
Exemplo n.º 2
0
    def get_luajit_path(self):
        ret = None
        if cocos.os_is_win32():
            ret = os.path.join(self._workingdir, "bin", "luajit.exe")
        elif cocos.os_is_mac():
            ret = os.path.join(self._workingdir, "bin", "luajit-mac")
        elif cocos.os_is_linux():
            ret = os.path.join(self._workingdir, "bin", "luajit-linux")

        return ret
Exemplo n.º 3
0
    def get_luajit_path(self):
        ret = None
        if cocos.os_is_win32():
            ret = os.path.join(self._workingdir, "bin", "luajit.exe")
        elif cocos.os_is_mac():
            ret = os.path.join(self._workingdir, "bin", "luajit-mac")
        elif cocos.os_is_linux():
            ret = os.path.join(self._workingdir, "bin", "luajit-linux")

        return ret
Exemplo n.º 4
0
    def get_luajit_path(self):
        ret = None

        bit_prefix = "64bit" if self._bytecode_64bit else "32bit"
        if cocos.os_is_win32():
            ret = os.path.join(self._workingdir, "bin", bit_prefix, "luajit-win32.exe")
        elif cocos.os_is_mac():
            ret = os.path.join(self._workingdir, "bin", bit_prefix, "luajit-mac")
        elif cocos.os_is_linux():
            ret = os.path.join(self._workingdir, "bin", bit_prefix, "luajit-linux")

        print("luajit bin path: " + ret)
        return ret
Exemplo n.º 5
0
    def _filter_platforms(self, platforms):
        ret = []
        for p in platforms:
            if cocos.os_is_linux():
                if p == Platforms.WEB or p == Platforms.LINUX or p == Platforms.ANDROID:
                    ret.append(p)
            if cocos.os_is_mac():
                if p == Platforms.WEB or p == Platforms.IOS or p == Platforms.MAC or p == Platforms.ANDROID:
                    ret.append(p)
            if cocos.os_is_win32():
                if p == Platforms.WEB or p == Platforms.WIN32 or p == Platforms.ANDROID:
                    ret.append(p)

        return ret
Exemplo n.º 6
0
    def _filter_platforms(self, platforms):
        ret = []
        for p in platforms:
            if cocos.os_is_linux():
                if p == Platforms.WEB or p == Platforms.LINUX or p == Platforms.ANDROID:
                    ret.append(p)
            if cocos.os_is_mac():
                if p == Platforms.WEB or p == Platforms.IOS or p == Platforms.MAC or p == Platforms.ANDROID:
                    ret.append(p)
            if cocos.os_is_win32():
                if p == Platforms.WEB or p == Platforms.WIN32 or p == Platforms.ANDROID:
                    ret.append(p)

        return ret
Exemplo n.º 7
0
def get_system_info():
    if cocos.os_is_win32():
        ret_str = "windows"
        ret_str += "_%s" % platform.release()
        if cocos.os_is_32bit_windows():
            ret_str += "_%s" % "32bit"
        else:
            ret_str += "_%s" % "64bit"
    elif cocos.os_is_mac():
        ret_str = "mac_%s" % (platform.mac_ver()[0]).replace(".", "_")
    elif cocos.os_is_linux():
        ret_str = "linux_%s" % platform.linux_distribution()[0]
    else:
        ret_str = "unknown"

    return ret_str
Exemplo n.º 8
0
    def get_luajit_path(self):
        ret = None

        bit_prefix = "64bit" if self._bytecode_64bit else "32bit"
        if cocos.os_is_win32():
            ret = os.path.join(self._workingdir, "bin", bit_prefix,
                               "luajit-win.exe")
        elif cocos.os_is_mac():
            ret = os.path.join(self._workingdir, "bin", bit_prefix,
                               "luajit-mac")
        elif cocos.os_is_linux():
            ret = os.path.join(self._workingdir, "bin", bit_prefix,
                               "luajit-linux")

        print("luajit bin path: " + ret)
        return ret
Exemplo n.º 9
0
def get_system_info():
    if cocos.os_is_win32():
        ret_str = "windows"
        ret_str += "_%s" % platform.release()
        if cocos.os_is_32bit_windows():
            ret_str += "_%s" % "32bit"
        else:
            ret_str += "_%s" % "64bit"
    elif cocos.os_is_mac():
        ret_str = "mac_%s" % (platform.mac_ver()[0]).replace('.', '_')
    elif cocos.os_is_linux():
        ret_str = "linux_%s" % platform.linux_distribution()[0]
    else:
        ret_str = "unknown"

    return ret_str
Exemplo n.º 10
0
    def compile_js(self, jsfile, output_file):
        """
        Compiles js file
        """
        cocos.Logging.debug(MultiLanguage.get_string('JSCOMPILE_DEBUG_COMPILE_FILE_FMT', jsfile))

        jsbcc_exe_path = ""
        if(cocos.os_is_linux()):
            if(platform.architecture()[0] == "32bit"):
                jsbcc_exe_path = os.path.join(self._workingdir, "bin", "linux", "jsbcc_x86")
            else:
                jsbcc_exe_path = os.path.join(self._workingdir, "bin", "linux", "jsbcc_x64")
        else:
            jsbcc_exe_path = os.path.join(self._workingdir, "bin", "jsbcc")

        cmd_str = "\"%s\" \"%s\" \"%s\"" % (jsbcc_exe_path, jsfile, output_file)
        self._run_cmd(cmd_str)
    def compile_js(self, jsfile, output_file):
        """
        Compiles js file
        """
        cocos.Logging.debug("compiling js (%s) to bytecode..." % jsfile)

        jsbcc_exe_path = ""
        if(cocos.os_is_linux()):
            if(platform.architecture()[0] == "32bit"):
                jsbcc_exe_path = os.path.join(self._workingdir, "bin", "linux", "jsbcc_x86")
            else:
                jsbcc_exe_path = os.path.join(self._workingdir, "bin", "linux", "jsbcc_x64")
        else:
            jsbcc_exe_path = os.path.join(self._workingdir, "bin", "jsbcc")

        cmd_str = "\"%s\" \"%s\" \"%s\"" % (jsbcc_exe_path, jsfile, output_file)
        self._run_cmd(cmd_str)
Exemplo n.º 12
0
    def init(self, options, workingdir):
        """
        Arguments:
        - `options`:
        """
        self._current_src_dir = None
        self._src_dir_arr = self.normalize_path_in_list(options.src_dir_arr)
        self._dst_dir = options.dst_dir
        self._use_closure_compiler = options.use_closure_compiler
        self._verbose = not options.quiet
        self._config = None
        self._workingdir = workingdir
        self._closure_params = ''
        if options.compiler_config != None:
            f = open(options.compiler_config)
            self._config = json.load(f)
            f.close()

            self._pre_order = self._config["pre_order"]
            self.normalize_path_in_list(self._pre_order)
            self._post_order = self._config["post_order"]
            self.normalize_path_in_list(self._post_order)
            self._skip = self._config["skip"]
            self.normalize_path_in_list(self._skip)
            self._closure_params = self._config["closure_params"]

        if options.closure_params is not None:
            self._closure_params = options.closure_params

        self._js_files = {}
        self._compressed_js_path = os.path.join(self._dst_dir,
                                                options.compressed_filename)
        self._compressed_jsc_path = os.path.join(
            self._dst_dir, options.compressed_filename + "c")

        if (cocos.os_is_linux()):
            if (platform.architecture()[0] == "32bit"):
                self.jsbcc_exe_path = os.path.join(self._workingdir, "bin",
                                                   "linux", "jsbcc_x86")
            else:
                self.jsbcc_exe_path = os.path.join(self._workingdir, "bin",
                                                   "linux", "jsbcc_x64")
        else:
            self.jsbcc_exe_path = os.path.join(self._workingdir, "bin",
                                               "jsbcc")
Exemplo n.º 13
0
def get_user_agent():
    ret_str = None
    if cocos.os_is_win32():
        ver_info = sys.getwindowsversion()
        ver_str = '%d.%d' % (ver_info[0], ver_info[1])
        if cocos.os_is_32bit_windows():
            arch_str = "WOW32"
        else:
            arch_str = "WOW64"
        ret_str = "Mozilla/5.0 (Windows NT %s; %s) Chrome/33.0.1750.154 Safari/537.36" % (ver_str, arch_str)
    elif cocos.os_is_mac():
        ver_str = (platform.mac_ver()[0]).replace('.', '_')
        ret_str = "Mozilla/5.0 (Macintosh; Intel Mac OS X %s) Chrome/35.0.1916.153 Safari/537.36" % ver_str
    elif cocos.os_is_linux():
        arch_str = platform.machine()
        ret_str = "Mozilla/5.0 (X11; Linux %s) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1636.0 Safari/537.36" % arch_str

    return ret_str
Exemplo n.º 14
0
def get_user_agent():
    ret_str = None
    if cocos.os_is_win32():
        ver_info = sys.getwindowsversion()
        ver_str = '%d.%d' % (ver_info[0], ver_info[1])
        if cocos.os_is_32bit_windows():
            arch_str = "WOW32"
        else:
            arch_str = "WOW64"
        ret_str = "Mozilla/5.0 (Windows NT %s; %s) Chrome/33.0.1750.154 Safari/537.36" % (ver_str, arch_str)
    elif cocos.os_is_mac():
        ver_str = (platform.mac_ver()[0]).replace('.', '_')
        ret_str = "Mozilla/5.0 (Macintosh; Intel Mac OS X %s) Chrome/35.0.1916.153 Safari/537.36" % ver_str
    elif cocos.os_is_linux():
        arch_str = platform.machine()
        ret_str = "Mozilla/5.0 (X11; Linux %s) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1636.0 Safari/537.36" % arch_str

    return ret_str
Exemplo n.º 15
0
def get_bi_params(events, event_value, multi_events=False, engine_versio=''):
    if cocos.os_is_win32():
        system_str = 'windows'
        ver_info = sys.getwindowsversion()
        ver_str = '%d.%d' % (ver_info[0], ver_info[1])
        if cocos.os_is_32bit_windows():
            arch_str = "_32bit"
        else:
            arch_str = "_64bit"
        system_ver = '%s%s' % (ver_str, arch_str)
    elif cocos.os_is_mac():
        system_str = 'mac'
        system_ver = (platform.mac_ver()[0])
    elif cocos.os_is_linux():
        system_str = 'linux'
        system_ver = platform.machine()
    else:
        system_str = 'unknown'
        system_ver = 'unknown'

    events_param = []
    if multi_events:
        for e in events:
            events_param.append(gen_bi_event(e, event_value))
    else:
        events_param.append(gen_bi_event(events, event_value))

    params = {
        'device': {
            '10' : system_ver,
            '11' : system_str
        },
        'app': {
            '7' : BI_APPID,
            '8' : engine_version,
            '9' : get_language()
        },
        'time' : get_time_stamp(),
        'events' : events_param
    }

    return params
Exemplo n.º 16
0
def get_bi_params(events, event_value, multi_events=False):
    if cocos.os_is_win32():
        system_str = 'windows'
        ver_info = sys.getwindowsversion()
        ver_str = '%d.%d' % (ver_info[0], ver_info[1])
        if cocos.os_is_32bit_windows():
            arch_str = "_32bit"
        else:
            arch_str = "_64bit"
        system_ver = '%s%s' % (ver_str, arch_str)
    elif cocos.os_is_mac():
        system_str = 'mac'
        system_ver = (platform.mac_ver()[0])
    elif cocos.os_is_linux():
        system_str = 'linux'
        system_ver = platform.machine()
    else:
        system_str = 'unknown'
        system_ver = 'unknown'

    events_param = []
    if multi_events:
        for e in events:
            events_param.append(gen_bi_event(e, event_value))
    else:
        events_param.append(gen_bi_event(events, event_value))

    params = {
        'device': {
            '10': system_ver,
            '11': system_str
        },
        'app': {
            '7': BI_APPID,
            '8': cocos.COCOS2D_CONSOLE_VERSION,
            '9': get_language()
        },
        'time': get_time_stamp(),
        'events': events_param
    }

    return params
    def _filter_platforms(self, platforms):
        ret = []
        platforms_for_os = {
            "linux" : [ Platforms.WEB, Platforms.LINUX, Platforms.ANDROID, Platforms.TIZEN ],
            "mac" : [ Platforms.WEB, Platforms.IOS, Platforms.MAC, Platforms.ANDROID, Platforms.TIZEN ],
            "win32" : [ Platforms.WEB, Platforms.WIN32, Platforms.ANDROID,
                        Platforms.METRO, Platforms.TIZEN ]
        }
        for p in platforms:
            if cocos.os_is_linux():
                if p in platforms_for_os["linux"]:
                    ret.append(p)
            if cocos.os_is_mac():
                if p in platforms_for_os["mac"]:
                    ret.append(p)
            if cocos.os_is_win32():
                if p in platforms_for_os["win32"]:
                    ret.append(p)

        return ret
Exemplo n.º 18
0
    def init(self, options, workingdir):
        """
        Arguments:
        - `options`:
        """
        self._current_src_dir = None
        self._src_dir_arr = self.normalize_path_in_list(options.src_dir_arr)
        self._dst_dir = options.dst_dir
        self._use_closure_compiler = options.use_closure_compiler
        self._verbose = options.verbose
        self._config = None
        self._workingdir = workingdir
        self._closure_params = ''
        if options.compiler_config != None:
            f = open(options.compiler_config)
            self._config = json.load(f)
            f.close()

            self._pre_order = self._config["pre_order"]
            self.normalize_path_in_list(self._pre_order)
            self._post_order = self._config["post_order"]
            self.normalize_path_in_list(self._post_order)
            self._skip = self._config["skip"]
            self.normalize_path_in_list(self._skip)
            self._closure_params = self._config["closure_params"]

        
        if options.closure_params is not None:
            self._closure_params = options.closure_params

        self._js_files = {}
        self._compressed_js_path = os.path.join(self._dst_dir, options.compressed_filename)
        self._compressed_jsc_path = os.path.join(self._dst_dir, options.compressed_filename+"c")

        if(cocos.os_is_linux()):
            if(platform.architecture()[0] == "32bit"):
                self.jsbcc_exe_path = os.path.join(self._workingdir, "bin", "linux", "jsbcc_x86")
            else:
                self.jsbcc_exe_path = os.path.join(self._workingdir, "bin", "linux", "jsbcc_x64")
        else:
            self.jsbcc_exe_path = os.path.join(self._workingdir, "bin", "jsbcc")
Exemplo n.º 19
0
    def compile_js(self, jsfile, output_file):
        """
        Compiles js file
        """
        cocos.Logging.debug(
            MultiLanguage.get_string('JSCOMPILE_DEBUG_COMPILE_FILE_FMT',
                                     jsfile))

        jsbcc_exe_path = ""
        if (cocos.os_is_linux()):
            if (platform.architecture()[0] == "32bit"):
                jsbcc_exe_path = os.path.join(self._workingdir, "bin", "linux",
                                              "jsbcc_x86")
            else:
                jsbcc_exe_path = os.path.join(self._workingdir, "bin", "linux",
                                              "jsbcc_x64")
        else:
            jsbcc_exe_path = os.path.join(self._workingdir, "bin", "jsbcc")

        cmd_str = "\"%s\" \"%s\" \"%s\"" % (jsbcc_exe_path, jsfile,
                                            output_file)
        self._run_cmd(cmd_str)