Exemple #1
0
 def build_win32_proj(self, cmd_path, sln_path, proj_name):
     build_cmd = " ".join([
         "\"%s\"" % cmd_path,
         "\"%s\"" % sln_path,
         "/t:%s" % proj_name, "/property:Configuration=Release", "/m"
     ])
     utils_cocos.execute_command(build_cmd)
Exemple #2
0
 def build_win32_proj(self, cmd_path, sln_path, proj_name, mode):
     build_cmd = " ".join([
         "\"%s\"" % cmd_path,
         "\"%s\"" % sln_path,
         "/%s \"Release|Win32\"" % mode,
         "/Project \"%s\"" % proj_name
     ])
     utils_cocos.execute_command(build_cmd)
Exemple #3
0
 def build_win32_proj(self, cmd_path, sln_path, proj_name, mode):
     build_cmd = " ".join([
         "\"%s\"" % cmd_path,
         "\"%s\"" % sln_path,
         "/%s \"Release|Win32\"" % mode,
         "/Project \"%s\"" % proj_name
     ])
     utils_cocos.execute_command(build_cmd)
 def build_win32_proj(self, cmd_path, sln_path, proj_name):
     build_cmd = " ".join([
         "\"%s\"" % cmd_path,
         "\"%s\"" % sln_path,
         "/t:%s" % proj_name,
         "/property:Configuration=Release",
         "/m"
     ])
     utils_cocos.execute_command(build_cmd)
    def trip_libs(self, strip_cmd, folder):
        if not os.path.isdir(folder):
            return

        if utils_cocos.os_is_win32():
            for name in os.listdir(folder):
                basename, ext = os.path.splitext(name)
                if ext == ".a":
                    full_name = os.path.join(folder, name)
                    command = "%s -S %s" % (strip_cmd, full_name)
                    utils_cocos.execute_command(command)
        else:
            strip_cmd = "%s -S %s/*.a" % (strip_cmd, folder)
            utils_cocos.execute_command(strip_cmd)
Exemple #6
0
    def trip_libs(self, strip_cmd, folder):
        if not os.path.isdir(folder):
            return

        if utils_cocos.os_is_win32():
            for name in os.listdir(folder):
                basename, ext = os.path.splitext(name)
                if ext == ".a":
                    full_name = os.path.join(folder, name)
                    command = "%s -S %s" % (strip_cmd, full_name)
                    utils_cocos.execute_command(command)
        else:
            strip_cmd = "%s -S %s/*.a" % (strip_cmd, folder)
            utils_cocos.execute_command(strip_cmd)
    def compile_for_win32(self):
        win32_output_dir = os.path.join(self.simulator_output_dir, "win32")
        win32_output_dir = self.convert_path_to_win32(win32_output_dir)
        utils_cocos.mkdir(win32_output_dir)

        lang_file_path = os.path.join(self.simulator_abs_path,"frameworks/runtime-src/Classes/ide-support/lang")
        lang_copy_command = "xcopy /Y %s %s" % (self.convert_path_to_win32(lang_file_path), win32_output_dir)

        # get the vs version should be used
        if self.vs_version is None:
            ver_param = ''
        else:
            ver_param = '--vs %d' % self.vs_version

        if self.mode == 'debug':
            win32_src_dir = os.path.join(self.simulator_abs_path,"runtime/win32/")
            win32_src_dir = self.convert_path_to_win32(win32_src_dir)
            win32_dll_dir = self.convert_path_to_win32(os.path.join(os.path.dirname(self.cur_dir),"dll/"))
            command = ' '.join([
                " %s compile -p win32 -m debug --no-res --compile-script 0 %s" % (self.cocos_bin, ver_param),
                " && xcopy /Y %s*.dll %s" % (win32_src_dir, win32_output_dir),
                " && xcopy /Y %s*.exe %s" % (win32_src_dir, win32_output_dir),
                " && %s" % (lang_copy_command),
                " && if exist %s*.dll xcopy /Y %s*.dll %s" % (win32_dll_dir,win32_dll_dir,win32_output_dir)
            ])
        else:
            command = ' '.join([
                " %s compile -p win32 -m release --no-res --compile-script 0 -o %s %s" % (self.cocos_bin,win32_output_dir,ver_param),
                " && %s" % (lang_copy_command),
                ])

        ret = utils_cocos.execute_command(command, self.simulator_abs_path, use_py_path=False)

        self.build_log += "Build win32 %s %s\n" % (self.mode, "success" if ret == 0 else "failed")
        return ret
    def compile_for_ios(self):
        if self.is_clean_before_build:
            project_directory = os.path.join(self.simulator_abs_path, "frameworks/runtime-src/proj.ios_mac/")

            command = "xcodebuild -alltargets -configuration %s clean" % ("Debug" if self.mode =='debug' else 'Release')
            utils_cocos.execute_command(command, project_directory)

        command = ' '.join([
            " %s compile -p ios -m %s -o \"%s\" --no-res --compile-script 0" % (self.cocos_bin
                , "debug" if self.mode == 'debug' else "release"
                , os.path.join(self.simulator_output_dir,"ios")),
            " && strip %s" % (os.path.join(self.simulator_output_dir,"ios","Simulator.app/Simulator")),
            " && rm -fr %s" % (os.path.join(self.simulator_output_dir,"ios","Simulator.app.dSYM")),
            ])

        ret = utils_cocos.execute_command(command, self.simulator_abs_path)
        self.build_log += "Build ios %s %s\n" % (self.mode, "success" if ret == 0 else "failed")
        return ret
    def compile_for_ios(self):
        if self.is_clean_before_build:
            project_directory = os.path.join(
                self.simulator_abs_path,
                "frameworks/runtime-src/proj.ios_mac/")

            command = "xcodebuild -alltargets -configuration %s clean" % (
                "Debug" if self.mode == 'debug' else 'Release')
            utils_cocos.execute_command(command, project_directory)

        command = ' '.join([
            " %s compile -p ios -m %s -o \"%s\" --no-res --compile-script 0" %
            (self.cocos_bin, "debug" if self.mode == 'debug' else "release",
             os.path.join(self.simulator_output_dir, "ios")),
            " && strip %s" % (os.path.join(self.simulator_output_dir, "ios",
                                           "Simulator.app/Simulator")),
            " && rm -fr %s" % (os.path.join(self.simulator_output_dir, "ios",
                                            "Simulator.app.dSYM")),
        ])

        ret = utils_cocos.execute_command(command, self.simulator_abs_path)
        self.build_log += "Build ios %s %s\n" % (self.mode, "success"
                                                 if ret == 0 else "failed")
        return ret
    def compile_for_android(self):
        rename_command = ' '.join([
                "mv %s %s" % (os.path.join(self.simulator_output_dir,"android","simulator-debug.apk"),
                              os.path.join(self.simulator_output_dir,"android","Simulator.apk"))
            ])

        command = ' '.join([
            " %s compile -p android --ndk-mode %s -o \"%s\" --no-res --compile-script 0" % (self.cocos_bin
                 , "debug" if self.mode == 'debug' else "release"
                 , os.path.join(self.simulator_output_dir,"android")),
            "&& %s" % (rename_command),
            ])

        ret = utils_cocos.execute_command(command, self.simulator_abs_path)
        self.build_log += "Build android %s %s\n" % (self.mode, "success" if ret == 0 else "failed")
        return ret
    def compile_for_win32(self):
        win32_output_dir = os.path.join(self.simulator_output_dir, "win32")
        win32_output_dir = self.convert_path_to_win32(win32_output_dir)
        utils_cocos.mkdir(win32_output_dir)

        lang_file_path = os.path.join(
            self.simulator_abs_path,
            "frameworks/runtime-src/Classes/ide-support/lang")
        lang_copy_command = "xcopy /Y %s %s" % (
            self.convert_path_to_win32(lang_file_path), win32_output_dir)

        # get the vs version should be used
        if self.vs_version is None:
            ver_param = ''
        else:
            ver_param = '--vs %d' % self.vs_version

        if self.mode == 'debug':
            win32_src_dir = os.path.join(self.simulator_abs_path,
                                         "runtime/win32/")
            win32_src_dir = self.convert_path_to_win32(win32_src_dir)
            win32_dll_dir = self.convert_path_to_win32(
                os.path.join(os.path.dirname(self.cur_dir), "dll/"))
            command = ' '.join([
                " %s compile -p win32 -m debug --no-res --compile-script 0 %s"
                % (self.cocos_bin, ver_param),
                " && xcopy /Y %s*.dll %s" % (win32_src_dir, win32_output_dir),
                " && xcopy /Y %s*.exe %s" % (win32_src_dir, win32_output_dir),
                " && %s" % (lang_copy_command),
                " && if exist %s*.dll xcopy /Y %s*.dll %s" %
                (win32_dll_dir, win32_dll_dir, win32_output_dir)
            ])
        else:
            command = ' '.join([
                " %s compile -p win32 -m release --no-res --compile-script 0 -o %s %s"
                % (self.cocos_bin, win32_output_dir, ver_param),
                " && %s" % (lang_copy_command),
            ])

        ret = utils_cocos.execute_command(command,
                                          self.simulator_abs_path,
                                          use_py_path=False)

        self.build_log += "Build win32 %s %s\n" % (self.mode, "success"
                                                   if ret == 0 else "failed")
        return ret
    def compile_for_android(self):
        rename_command = ' '.join([
            "mv %s %s" % (os.path.join(self.simulator_output_dir, "android",
                                       "simulator-debug.apk"),
                          os.path.join(self.simulator_output_dir, "android",
                                       "Simulator.apk"))
        ])

        command = ' '.join([
            " %s compile -p android --ndk-mode %s -o \"%s\" --no-res --compile-script 0"
            % (self.cocos_bin, "debug" if self.mode == 'debug' else "release",
               os.path.join(self.simulator_output_dir, "android")),
            "&& %s" % (rename_command),
        ])

        ret = utils_cocos.execute_command(command, self.simulator_abs_path)
        self.build_log += "Build android %s %s\n" % (self.mode, "success"
                                                     if ret == 0 else "failed")
        return ret
Exemple #13
0
    def compile_android(self):
        print("compile android")
        # build .so for android
        CONSOLE_PATH = "tools/cocos2d-console/bin"
        ANDROID_A_PATH = "frameworks/runtime-src/proj.android/obj/local"

        android_out_dir = os.path.join(self.lib_dir, "android")
        engine_dir = self.repo_x
        console_dir = os.path.join(engine_dir, CONSOLE_PATH)
        if utils_cocos.os_is_win32():
            cmd_path = os.path.join(console_dir, "cocos.bat")
        else:
            cmd_path = os.path.join(console_dir, "cocos")

        # build the simulator project
        proj_path = os.path.join(engine_dir, 'tools/simulator')
        build_cmd = "%s compile -s %s -p android --ndk-mode release --app-abi %s" % (
            cmd_path, proj_path, self.app_abi)
        utils_cocos.execute_command(build_cmd)

        # copy .a to prebuilt dir
        obj_dir = os.path.join(proj_path, ANDROID_A_PATH)
        copy_cfg = {
            "from": obj_dir,
            "to": android_out_dir,
            "include": ["*.a$"]
        }
        excopy.copy_files_with_config(copy_cfg, obj_dir, android_out_dir)

        if not self.disable_strip:
            # strip the android libs
            ndk_root = os.environ["NDK_ROOT"]
            if utils_cocos.os_is_win32():
                if utils_cocos.is_32bit_windows():
                    bit_str = ""
                else:
                    bit_str = "-x86_64"
                sys_folder_name = "windows%s" % bit_str
            elif utils_cocos.os_is_mac():
                sys_folder_name = "darwin-x86_64"

            # set strip execute file name
            if utils_cocos.os_is_win32():
                strip_execute_name = "strip.exe"
            else:
                strip_execute_name = "strip"

            # strip arm libs
            strip_cmd_path = os.path.join(
                ndk_root,
                "toolchains/arm-linux-androideabi-4.8/prebuilt/%s/arm-linux-androideabi/bin/%s"
                % (sys_folder_name, strip_execute_name))
            if not os.path.exists(strip_cmd_path):
                strip_cmd_path = os.path.join(
                    ndk_root,
                    "toolchains/arm-linux-androideabi-4.8/prebuilt/%s/arm-linux-androideabi/bin/%s"
                    %
                    (sys_folder_name.replace(bit_str, ""), strip_execute_name))
            if os.path.exists(strip_cmd_path):
                armlibs = ["armeabi", "armeabi-v7a"]
                for fold in armlibs:
                    self.trip_libs(strip_cmd_path,
                                   os.path.join(android_out_dir, fold))

            # strip x86 libs
            strip_cmd_path = os.path.join(
                ndk_root,
                "toolchains/x86-4.8/prebuilt/%s/i686-linux-android/bin/%s" %
                (sys_folder_name, strip_execute_name))
            if os.path.exists(strip_cmd_path) and os.path.exists(
                    os.path.join(android_out_dir, "x86")):
                self.trip_libs(strip_cmd_path,
                               os.path.join(android_out_dir, 'x86'))
Exemple #14
0
    def compile_mac_ios(self):
        if not utils_cocos.os_is_mac():
            print("this is not mac platform, needn't compile")
            return
        print("to compile mac")

        xcode_proj_info = self.cfg_info[CocosLibsCompiler.KEY_XCODE_PROJS_INFO]

        XCODE_CMD_FMT = "xcodebuild -project \"%s\" -configuration Release -target \"%s\" %s CONFIGURATION_BUILD_DIR=%s"
        for key in xcode_proj_info.keys():
            proj_path = os.path.join(self.repo_x, key)
            ios_out_dir = os.path.join(self.lib_dir, "ios")
            mac_out_dir = os.path.join(self.lib_dir, "mac")
            ios_sim_libs_dir = os.path.join(ios_out_dir, "simulator")
            ios_dev_libs_dir = os.path.join(ios_out_dir, "device")

            target = xcode_proj_info[key][CocosLibsCompiler.KEY_XCODE_TARGETS]

            # compile ios simulator
            build_cmd = XCODE_CMD_FMT % (
                proj_path, "%s iOS" % target,
                "-sdk iphonesimulator ARCHS=\"i386 x86_64\" VALID_ARCHS=\"i386 x86_64\"",
                ios_sim_libs_dir)
            retVal = utils_cocos.execute_command(build_cmd)
            if 0 != retVal:
                print("[ERROR] compile ios simulator fail")
                return retVal

            # compile ios device
            build_cmd = XCODE_CMD_FMT % (proj_path, "%s iOS" % target,
                                         "-sdk iphoneos", ios_dev_libs_dir)
            retVal = utils_cocos.execute_command(build_cmd)
            if 0 != retVal:
                print("[ERROR] compile ios device fail")
                return retVal

            # compile mac
            build_cmd = XCODE_CMD_FMT % (proj_path, "%s Mac" % target, "",
                                         mac_out_dir)
            retVal = utils_cocos.execute_command(build_cmd)
            if 0 != retVal:
                print("[ERROR] compile mac fail")
                return retVal

            # generate fat libs for iOS
            for lib in os.listdir(ios_sim_libs_dir):
                sim_lib = os.path.join(ios_sim_libs_dir, lib)
                dev_lib = os.path.join(ios_dev_libs_dir, lib)
                output_lib = os.path.join(ios_out_dir, lib)
                lipo_cmd = "lipo -create -output \"%s\" \"%s\" \"%s\"" % (
                    output_lib, sim_lib, dev_lib)

                utils_cocos.execute_command(lipo_cmd)

            # remove the simulator & device libs in iOS
            utils_cocos.rmdir(ios_sim_libs_dir)
            utils_cocos.rmdir(ios_dev_libs_dir)

            if not self.disable_strip:
                # strip the libs
                ios_strip_cmd = "xcrun -sdk iphoneos strip -S %s/*.a" % ios_out_dir
                utils_cocos.execute_command(ios_strip_cmd)
                mac_strip_cmd = "xcrun strip -S %s/*.a" % mac_out_dir
                utils_cocos.execute_command(mac_strip_cmd)
Exemple #15
0
    def compile_win(self):
        if not utils_cocos.os_is_win32():
            print("this is not win platform, needn't compile")
            return

        # get the VS versions will be used for compiling
        support_vs_versions = self.cfg_info[
            CocosLibsCompiler.KEY_SUPPORT_VS_VERSIONS]
        compile_vs_versions = support_vs_versions
        if self.vs_version is not None:
            if self.vs_version not in support_vs_versions:
                raise CustomError('Not support VS%d' % self.vs_version)
            else:
                compile_vs_versions = [self.vs_version]

        vs_cmd_info = {}
        for vs_version in compile_vs_versions:
            # get the vs command with specified version
            vs_command = utils_cocos.get_vs_cmd_path(vs_version)
            if vs_command is None:
                Logging.warning('Not found VS%d' % vs_version)
            else:
                vs_cmd_info[vs_version] = vs_command

        if len(vs_cmd_info) == 0:
            raise CustomError('Not found available VS.',
                              CustomError.ERROR_TOOLS_NOT_FOUND)

        cocos2d_proj_file = os.path.join(self.repo_x,
                                         'cocos/2d/libcocos2d.vcxproj')

        # get the VS projects info
        win32_proj_info = self.cfg_info[CocosLibsCompiler.KEY_VS_PROJS_INFO]
        for vs_version in compile_vs_versions:
            if not vs_version in vs_cmd_info.keys():
                continue

            # rename the cocos2d project out dll name
            f = open(cocos2d_proj_file, 'r')
            old_file_content = f.read()
            f.close()

            new_file_content = old_file_content.replace(
                '$(OutDir)$(ProjectName).dll',
                '$(OutDir)$(ProjectName)_%d.dll' % vs_version)
            f = open(cocos2d_proj_file, 'w')
            f.write(new_file_content)
            f.close()

            try:
                vs_command = vs_cmd_info[vs_version]
                for key in win32_proj_info.keys():
                    # clean solutions
                    proj_path = os.path.join(self.repo_x, key)
                    clean_cmd = " ".join([
                        "\"%s\"" % vs_command,
                        "\"%s\"" % proj_path, "/clean \"Release|Win32\""
                    ])
                    utils_cocos.execute_command(clean_cmd)

                for key in win32_proj_info.keys():
                    output_dir = os.path.join(self.lib_dir, "win32")
                    proj_path = os.path.join(self.repo_x, key)

                    # get the build folder & win32 output folder
                    build_folder_path = os.path.join(
                        os.path.dirname(proj_path), "Release.win32")
                    win32_output_dir = os.path.join(self.repo_x, output_dir)
                    if not os.path.exists(win32_output_dir):
                        os.makedirs(win32_output_dir)

                    # build project
                    if self.use_incredibuild:
                        # use incredibuild, build whole sln
                        build_cmd = " ".join([
                            "BuildConsole",
                            "%s" % proj_path, "/build",
                            "/cfg=\"Release|Win32\""
                        ])
                        utils_cocos.execute_command(build_cmd)
                    else:
                        for proj_name in win32_proj_info[key][
                                CocosLibsCompiler.KEY_VS_BUILD_TARGETS]:
                            # build the projects
                            self.build_win32_proj(vs_command, proj_path,
                                                  proj_name, "build")

                            lib_file_path = os.path.join(
                                build_folder_path, "%s.lib" % proj_name)
                            if not os.path.exists(lib_file_path):
                                # if the lib is not generated, rebuild the project
                                self.build_win32_proj(vs_command, proj_path,
                                                      proj_name, "rebuild")

                            if not os.path.exists(lib_file_path):
                                raise Exception(
                                    "Library %s not generated as expected!" %
                                    lib_file_path)

                    # copy the libs into prebuilt dir
                    for file_name in os.listdir(build_folder_path):
                        name, ext = os.path.splitext(file_name)
                        if ext != ".lib" and ext != ".dll":
                            continue

                        file_path = os.path.join(build_folder_path, file_name)
                        shutil.copy(file_path, win32_output_dir)

                    # rename the specified libs
                    suffix = "_%d" % vs_version
                    for proj_name in win32_proj_info[key][
                            CocosLibsCompiler.KEY_VS_RENAME_TARGETS]:
                        src_name = os.path.join(win32_output_dir,
                                                "%s.lib" % proj_name)
                        dst_name = os.path.join(
                            win32_output_dir, "%s%s.lib" % (proj_name, suffix))
                        if os.path.exists(src_name):
                            if os.path.exists(dst_name):
                                os.remove(dst_name)
                            os.rename(src_name, dst_name)
            except Exception as e:
                raise e
            finally:
                f = open(cocos2d_proj_file, 'w')
                f.write(old_file_content)
                f.close()

        print("Win32 build succeeded.")
    def compile_mac_ios(self):
        if not utils_cocos.os_is_mac():
            print("this is not mac platform, needn't compile")
            return
        print("to compile mac")

        xcode_proj_info = self.cfg_info[CocosLibsCompiler.KEY_XCODE_PROJS_INFO]

        XCODE_CMD_FMT = "xcodebuild -project \"%s\" -configuration Release -target \"%s\" %s CONFIGURATION_BUILD_DIR=%s"
        ios_out_dir = os.path.join(self.lib_dir, "ios")
        mac_out_dir = os.path.join(self.lib_dir, "mac")
        ios_sim_libs_dir = os.path.join(ios_out_dir, "simulator")
        ios_dev_libs_dir = os.path.join(ios_out_dir, "device")
        for key in xcode_proj_info.keys():
            proj_path = os.path.join(self.repo_x, key)
            target = xcode_proj_info[key][CocosLibsCompiler.KEY_XCODE_TARGETS]

            if self.build_mac:
                # compile mac
                build_cmd = XCODE_CMD_FMT % (proj_path, "%s Mac" % target, "", mac_out_dir)
                retVal = utils_cocos.execute_command(build_cmd)
                if 0 != retVal:
                    print("[ERROR] compile mac fail")
                    return retVal

            if self.build_ios:
                # compile ios simulator
                build_cmd = XCODE_CMD_FMT % (proj_path, "%s iOS" % target, "-sdk iphonesimulator ARCHS=\"i386 x86_64\" VALID_ARCHS=\"i386 x86_64\"", ios_sim_libs_dir)
                retVal = utils_cocos.execute_command(build_cmd)
                if 0 != retVal:
                    print("[ERROR] compile ios simulator fail")
                    return retVal

                # compile ios device
                build_cmd = XCODE_CMD_FMT % (proj_path, "%s iOS" % target, "-sdk iphoneos", ios_dev_libs_dir)
                retVal = utils_cocos.execute_command(build_cmd)
                if 0 != retVal:
                    print("[ERROR] compile ios device fail")
                    return retVal

        if self.build_ios:
            # generate fat libs for iOS
            for lib in os.listdir(ios_sim_libs_dir):
                sim_lib = os.path.join(ios_sim_libs_dir, lib)
                dev_lib = os.path.join(ios_dev_libs_dir, lib)
                output_lib = os.path.join(ios_out_dir, lib)
                lipo_cmd = "lipo -create -output \"%s\" \"%s\" \"%s\"" % (output_lib, sim_lib, dev_lib)

                utils_cocos.execute_command(lipo_cmd)

            # remove the simulator & device libs in iOS
            utils_cocos.rmdir(ios_sim_libs_dir)
            utils_cocos.rmdir(ios_dev_libs_dir)

        if not self.disable_strip:
            # strip the libs
            if self.build_ios:
                ios_strip_cmd = "xcrun -sdk iphoneos strip -S %s/*.a" % ios_out_dir
                utils_cocos.execute_command(ios_strip_cmd)
            if self.build_mac:
                mac_strip_cmd = "xcrun strip -S %s/*.a" % mac_out_dir
                utils_cocos.execute_command(mac_strip_cmd)
    def compile_win(self):
        if not utils_cocos.os_is_win32():
            print("this is not win platform, needn't compile")
            return

        # get the VS versions will be used for compiling
        support_vs_versions = self.cfg_info[CocosLibsCompiler.KEY_SUPPORT_VS_VERSIONS]
        compile_vs_versions = support_vs_versions
        if self.vs_version is not None:
            if self.vs_version not in support_vs_versions:
                raise CustomError('Not support VS%d' % self.vs_version)
            else:
                compile_vs_versions = [ self.vs_version ]

        vs_cmd_info = {}
        for vs_version in compile_vs_versions:
            # get the vs command with specified version
            vs_command = utils_cocos.get_vs_cmd_path(vs_version)
            if vs_command is None:
                Logging.warning('Not found VS%d' % vs_version)
            else:
                vs_cmd_info[vs_version] = vs_command

        if len(vs_cmd_info) == 0:
            raise CustomError('Not found available VS.', CustomError.ERROR_TOOLS_NOT_FOUND)

        cocos2d_proj_file = os.path.join(self.repo_x, 'cocos/2d/libcocos2d.vcxproj')

        # get the VS projects info
        win32_proj_info = self.cfg_info[CocosLibsCompiler.KEY_VS_PROJS_INFO]
        for vs_version in compile_vs_versions:
            if not vs_version in vs_cmd_info.keys():
                continue

            # rename the cocos2d project out dll name
            f = open(cocos2d_proj_file, 'r')
            old_file_content = f.read()
            f.close()

            new_file_content = old_file_content.replace('$(OutDir)$(ProjectName).dll', '$(OutDir)$(ProjectName)_%d.dll' % vs_version)
            f = open(cocos2d_proj_file, 'w')
            f.write(new_file_content)
            f.close()

            try:
                vs_command = vs_cmd_info[vs_version]
                for key in win32_proj_info.keys():
                    # clean solutions
                    proj_path = os.path.join(self.repo_x, key)
                    clean_cmd = " ".join([
                        "\"%s\"" % vs_command,
                        "\"%s\"" % proj_path,
                        "/t:Clean /p:Configuration=Release"
                    ])
                    utils_cocos.execute_command(clean_cmd)

                for key in win32_proj_info.keys():
                    output_dir = os.path.join(self.lib_dir, "win32")
                    proj_path = os.path.join(self.repo_x, key)

                    # get the build folder & win32 output folder
                    build_folder_path = os.path.join(os.path.dirname(proj_path), "Release.win32")
                    win32_output_dir = os.path.join(self.repo_x, output_dir)
                    if not os.path.exists(win32_output_dir):
                        os.makedirs(win32_output_dir)

                    # build project
                    if self.use_incredibuild:
                        # use incredibuild, build whole sln
                        build_cmd = " ".join([
                            "BuildConsole",
                            "%s" % proj_path,
                            "/build",
                            "/cfg=\"Release|Win32\""
                        ])
                        utils_cocos.execute_command(build_cmd)
                    else:
                        for proj_name in win32_proj_info[key][CocosLibsCompiler.KEY_VS_BUILD_TARGETS]:
                            # build the projects
                            self.build_win32_proj(vs_command, proj_path, proj_name)

                    # copy the libs into prebuilt dir
                    for file_name in os.listdir(build_folder_path):
                        name, ext = os.path.splitext(file_name)
                        if ext != ".lib" and ext != ".dll":
                            continue

                        file_path = os.path.join(build_folder_path, file_name)
                        shutil.copy(file_path, win32_output_dir)

                    # rename the specified libs
                    suffix = "_%d" % vs_version
                    for proj_name in win32_proj_info[key][CocosLibsCompiler.KEY_VS_RENAME_TARGETS]:
                        src_name = os.path.join(win32_output_dir, "%s.lib" % proj_name)
                        dst_name = os.path.join(win32_output_dir, "%s%s.lib" % (proj_name, suffix))
                        if not os.path.exists(src_name):
                            raise Exception("Library %s not generated as expected!" % src_name)

                        if os.path.exists(dst_name):
                            os.remove(dst_name)
                        os.rename(src_name, dst_name)
            except Exception as e:
                raise e
            finally:
                f = open(cocos2d_proj_file, 'w')
                f.write(old_file_content)
                f.close()


        print("Win32 build succeeded.")
    def compile_android(self):
        print("compile android")
        # build .so for android
        CONSOLE_PATH = "tools/cocos2d-console/bin"
        ANDROID_A_PATH = "frameworks/runtime-src/proj.android/obj/local"

        android_out_dir = os.path.join(self.lib_dir, "android")
        engine_dir = self.repo_x
        console_dir = os.path.join(engine_dir, CONSOLE_PATH)
        if utils_cocos.os_is_win32():
            cmd_path = os.path.join(console_dir, "cocos.bat")
        else:
            cmd_path = os.path.join(console_dir, "cocos")

        # build the simulator project
        proj_path = os.path.join(engine_dir, 'tools/simulator')
        build_cmd = "%s compile -s %s -p android --ndk-mode release --app-abi %s" % (cmd_path, proj_path, self.app_abi)
        utils_cocos.execute_command(build_cmd)

        # copy .a to prebuilt dir
        obj_dir = os.path.join(proj_path, ANDROID_A_PATH)
        copy_cfg = {
            "from": obj_dir,
            "to": android_out_dir,
            "include": [
                "*.a$"
            ]
        }
        excopy.copy_files_with_config(copy_cfg, obj_dir, android_out_dir)

        if not self.disable_strip:
            # strip the android libs
            ndk_root = os.environ["NDK_ROOT"]
            if utils_cocos.os_is_win32():
                if utils_cocos.is_32bit_windows():
                    bit_str = ""
                else:
                    bit_str = "-x86_64"
                sys_folder_name = "windows%s" % bit_str
            elif utils_cocos.os_is_mac():
                sys_folder_name = "darwin-x86_64"

            # set strip execute file name
            if utils_cocos.os_is_win32():
                strip_execute_name = "strip.exe"
            else:
                strip_execute_name = "strip"

            # strip arm libs
            strip_cmd_path = os.path.join(ndk_root, "toolchains/arm-linux-androideabi-4.8/prebuilt/%s/arm-linux-androideabi/bin/%s"
                % (sys_folder_name, strip_execute_name))
            if not os.path.exists(strip_cmd_path):
                strip_cmd_path = os.path.join(ndk_root, "toolchains/arm-linux-androideabi-4.8/prebuilt/%s/arm-linux-androideabi/bin/%s"
                    % (sys_folder_name.replace(bit_str, ""), strip_execute_name))
            if os.path.exists(strip_cmd_path):
                armlibs = ["armeabi", "armeabi-v7a"]
                for fold in armlibs:
                    self.trip_libs(strip_cmd_path, os.path.join(android_out_dir, fold))

            # strip x86 libs
            strip_cmd_path = os.path.join(ndk_root, "toolchains/x86-4.8/prebuilt/%s/i686-linux-android/bin/%s" % (sys_folder_name, strip_execute_name))
            if os.path.exists(strip_cmd_path) and os.path.exists(os.path.join(android_out_dir, "x86")):
                self.trip_libs(strip_cmd_path, os.path.join(android_out_dir, 'x86'))