Merge branch 'v3.7-release' of https://github.com/cocos2d/cocos2d-x into v3.7-release

This commit is contained in:
XiaoFeng 2015-07-06 10:31:09 +08:00
commit df2a2d253d
13 changed files with 476 additions and 75 deletions

View File

@ -231,6 +231,8 @@ bool TextureCube::init(const std::string& positive_x, const std::string& negativ
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
_name = handle; _name = handle;

View File

@ -265,6 +265,9 @@ bool js_cocos2dx_Node_onExitTransitionDidStart(JSContext *cx, uint32_t argc, jsv
bool js_cocos2dx_Component_onEnter(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Component_onEnter(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_Component_onExit(JSContext *cx, uint32_t argc, jsval *vp); bool js_cocos2dx_Component_onExit(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_retain(JSContext *cx, uint32_t argc, jsval *vp);
bool js_cocos2dx_release(JSContext *cx, uint32_t argc, jsval *vp);
void get_or_create_js_obj(JSContext* cx, JS::HandleObject obj, const std::string &name, JS::MutableHandleObject jsObj); void get_or_create_js_obj(JSContext* cx, JS::HandleObject obj, const std::string &name, JS::MutableHandleObject jsObj);
#endif #endif

View File

@ -879,35 +879,6 @@ bool js_cocos2dx_ext_AssetsManager_getFailedAssets(JSContext *cx, uint32_t argc,
} }
*/ */
bool js_cocos2dx_ext_retain(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *thisObj = JS_THIS_OBJECT(cx, vp);
if (thisObj) {
js_proxy_t *proxy = jsb_get_js_proxy(thisObj);
if (proxy) {
((Ref *)proxy->ptr)->retain();
return true;
}
}
JS_ReportError(cx, "Invalid Native Object.");
return false;
}
bool js_cocos2dx_ext_release(JSContext *cx, uint32_t argc, jsval *vp)
{
JSObject *thisObj = JS_THIS_OBJECT(cx, vp);
if (thisObj) {
js_proxy_t *proxy = jsb_get_js_proxy(thisObj);
if (proxy) {
((Ref *)proxy->ptr)->release();
return true;
}
}
JS_ReportError(cx, "Invalid Native Object.");
return false;
}
__JSDownloaderDelegator::__JSDownloaderDelegator(JSContext *cx, JS::HandleObject obj, const std::string &url, JS::HandleObject callback) __JSDownloaderDelegator::__JSDownloaderDelegator(JSContext *cx, JS::HandleObject obj, const std::string &url, JS::HandleObject callback)
: _cx(cx) : _cx(cx)
, _url(url) , _url(url)
@ -1077,11 +1048,11 @@ void register_all_cocos2dx_extension_manual(JSContext* cx, JS::HandleObject glob
get_or_create_js_obj(cx, global, "cc", &ccObj); get_or_create_js_obj(cx, global, "cc", &ccObj);
JS::RootedObject am(cx, jsb_cocos2d_extension_AssetsManagerEx_prototype); JS::RootedObject am(cx, jsb_cocos2d_extension_AssetsManagerEx_prototype);
JS_DefineFunction(cx, am, "retain", js_cocos2dx_ext_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, am, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
JS_DefineFunction(cx, am, "release", js_cocos2dx_ext_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, am, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
JS::RootedObject manifest(cx, jsb_cocos2d_extension_Manifest_prototype); JS::RootedObject manifest(cx, jsb_cocos2d_extension_Manifest_prototype);
JS_DefineFunction(cx, manifest, "retain", js_cocos2dx_ext_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, manifest, "retain", js_cocos2dx_retain, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
JS_DefineFunction(cx, manifest, "release", js_cocos2dx_ext_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); JS_DefineFunction(cx, manifest, "release", js_cocos2dx_release, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);
//JS_DefineFunction(cx, jsb_cocos2d_extension_AssetsManager_prototype, "updateAssets", js_cocos2dx_ext_AssetsManager_updateAssets, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT); //JS_DefineFunction(cx, jsb_cocos2d_extension_AssetsManager_prototype, "updateAssets", js_cocos2dx_ext_AssetsManager_updateAssets, 1, JSPROP_ENUMERATE | JSPROP_PERMANENT);
//JS_DefineFunction(cx, jsb_cocos2d_extension_AssetsManager_prototype, "getFailedAssets", js_cocos2dx_ext_AssetsManager_getFailedAssets, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT); //JS_DefineFunction(cx, jsb_cocos2d_extension_AssetsManager_prototype, "getFailedAssets", js_cocos2dx_ext_AssetsManager_getFailedAssets, 0, JSPROP_ENUMERATE | JSPROP_PERMANENT);

View File

@ -29,6 +29,7 @@
#include "XMLHTTPRequest.h" #include "XMLHTTPRequest.h"
#include <string> #include <string>
#include <algorithm> #include <algorithm>
#include "cocos2d_specifics.hpp"
using namespace std; using namespace std;
@ -986,6 +987,8 @@ void MinXmlHttpRequest::_js_register(JSContext *cx, JS::HandleObject global)
JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, getAllResponseHeaders), JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, getAllResponseHeaders),
JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, getResponseHeader), JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, getResponseHeader),
JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, overrideMimeType), JS_BINDED_FUNC_FOR_DEF(MinXmlHttpRequest, overrideMimeType),
JS_FN("retain", js_cocos2dx_retain, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FN("release", js_cocos2dx_release, 0, JSPROP_PERMANENT | JSPROP_ENUMERATE),
JS_FS_END JS_FS_END
}; };

View File

@ -204,6 +204,7 @@
if(!spriteFrame && plist){ if(!spriteFrame && plist){
if(cc.loader.getRes(resourcePath + plist)){ if(cc.loader.getRes(resourcePath + plist)){
cc.spriteFrameCache.addSpriteFrames(resourcePath + plist); cc.spriteFrameCache.addSpriteFrames(resourcePath + plist);
spriteFrame = cc.spriteFrameCache.getSpriteFrame(path);
}else{ }else{
cc.log("%s need to be preloaded", resourcePath + plist); cc.log("%s need to be preloaded", resourcePath + plist);
} }

View File

@ -334,13 +334,13 @@
}; };
var setLayoutComponent = function(widget, json){ var setLayoutComponent = function(widget, json){
var layoutComponent = ccui.LayoutComponent.bindLayoutComponent(widget); var layoutComponent = ccui.LayoutComponent.bindLayoutComponent(widget);
if(!layoutComponent) if(!layoutComponent)
return; return;
var positionXPercentEnabled = json["PositionPercentXEnable"] || false; var positionXPercentEnabled = json["PositionPercentXEnable"] || json["PositionPercentXEnabled"] || false;
var positionYPercentEnabled = json["PositionPercentYEnable"] || false; var positionYPercentEnabled = json["PositionPercentYEnable"] || json["PositionPercentYEnabled"] || false;
var positionXPercent = 0, var positionXPercent = 0,
positionYPercent = 0, positionYPercent = 0,
PrePosition = json["PrePosition"]; PrePosition = json["PrePosition"];

View File

@ -1,5 +1,5 @@
{ {
"version":"v3-deps-68", "version":"v3-deps-69",
"zip_file_size":"131253061", "zip_file_size":"131253061",
"repo_name":"cocos2d-x-3rd-party-libs-bin", "repo_name":"cocos2d-x-3rd-party-libs-bin",
"repo_parent":"https://github.com/cocos2d/", "repo_parent":"https://github.com/cocos2d/",

View File

@ -27,7 +27,9 @@
#include "navmesh/jsb_cocos2dx_navmesh_manual.h" #include "navmesh/jsb_cocos2dx_navmesh_manual.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#include "jsb_cocos2dx_experimental_video_auto.hpp"
#include "experimental/jsb_cocos2dx_experimental_video_manual.h" #include "experimental/jsb_cocos2dx_experimental_video_manual.h"
#include "jsb_cocos2dx_experimental_webView_auto.hpp"
#include "experimental/jsb_cocos2dx_experimental_webView_manual.h" #include "experimental/jsb_cocos2dx_experimental_webView_manual.h"
#endif #endif
@ -129,7 +131,9 @@ bool AppDelegate::applicationDidFinishLaunching()
#endif #endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
sc->addRegisterCallback(register_all_cocos2dx_experimental_video);
sc->addRegisterCallback(register_all_cocos2dx_experimental_video_manual); sc->addRegisterCallback(register_all_cocos2dx_experimental_video_manual);
sc->addRegisterCallback(register_all_cocos2dx_experimental_webView);
sc->addRegisterCallback(register_all_cocos2dx_experimental_webView_manual); sc->addRegisterCallback(register_all_cocos2dx_experimental_webView_manual);
#endif #endif

View File

@ -45,6 +45,7 @@ class CocosLibsCompiler(object):
self.clean = args.clean self.clean = args.clean
self.build_win = args.win self.build_win = args.win
self.build_mac = args.mac self.build_mac = args.mac
self.build_ios = args.ios
self.build_android = args.android self.build_android = args.android
self.disable_strip = args.disable_strip self.disable_strip = args.disable_strip
self.repo_x = args.repo_x self.repo_x = args.repo_x
@ -53,6 +54,7 @@ class CocosLibsCompiler(object):
if args.all: if args.all:
self.build_win = True self.build_win = True
self.build_mac = True self.build_mac = True
self.build_ios = True
self.build_android = True self.build_android = True
if args.app_abi is None: if args.app_abi is None:
@ -87,7 +89,7 @@ class CocosLibsCompiler(object):
self.clean_libs() self.clean_libs()
if self.build_win: if self.build_win:
self.compile_win() self.compile_win()
if self.build_mac: if self.build_mac or self.build_ios:
self.compile_mac_ios() self.compile_mac_ios()
if self.build_android: if self.build_android:
self.compile_android() self.compile_android()
@ -229,36 +231,38 @@ class CocosLibsCompiler(object):
xcode_proj_info = self.cfg_info[CocosLibsCompiler.KEY_XCODE_PROJS_INFO] 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" 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(): for key in xcode_proj_info.keys():
proj_path = os.path.join(self.repo_x, key) 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] target = xcode_proj_info[key][CocosLibsCompiler.KEY_XCODE_TARGETS]
# compile ios simulator if self.build_mac:
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) # compile mac
retVal = utils_cocos.execute_command(build_cmd) build_cmd = XCODE_CMD_FMT % (proj_path, "%s Mac" % target, "", mac_out_dir)
if 0 != retVal: retVal = utils_cocos.execute_command(build_cmd)
print("[ERROR] compile ios simulator fail") if 0 != retVal:
return retVal print("[ERROR] compile mac fail")
return retVal
# compile ios device if self.build_ios:
build_cmd = XCODE_CMD_FMT % (proj_path, "%s iOS" % target, "-sdk iphoneos", ios_dev_libs_dir) # compile ios simulator
retVal = utils_cocos.execute_command(build_cmd) 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)
if 0 != retVal: retVal = utils_cocos.execute_command(build_cmd)
print("[ERROR] compile ios device fail") if 0 != retVal:
return retVal print("[ERROR] compile ios simulator fail")
return retVal
# compile mac # compile ios device
build_cmd = XCODE_CMD_FMT % (proj_path, "%s Mac" % target, "", mac_out_dir) build_cmd = XCODE_CMD_FMT % (proj_path, "%s iOS" % target, "-sdk iphoneos", ios_dev_libs_dir)
retVal = utils_cocos.execute_command(build_cmd) retVal = utils_cocos.execute_command(build_cmd)
if 0 != retVal: if 0 != retVal:
print("[ERROR] compile mac fail") print("[ERROR] compile ios device fail")
return retVal return retVal
if self.build_ios:
# generate fat libs for iOS # generate fat libs for iOS
for lib in os.listdir(ios_sim_libs_dir): for lib in os.listdir(ios_sim_libs_dir):
sim_lib = os.path.join(ios_sim_libs_dir, lib) sim_lib = os.path.join(ios_sim_libs_dir, lib)
@ -272,10 +276,12 @@ class CocosLibsCompiler(object):
utils_cocos.rmdir(ios_sim_libs_dir) utils_cocos.rmdir(ios_sim_libs_dir)
utils_cocos.rmdir(ios_dev_libs_dir) utils_cocos.rmdir(ios_dev_libs_dir)
if not self.disable_strip: if not self.disable_strip:
# strip the libs # strip the libs
if self.build_ios:
ios_strip_cmd = "xcrun -sdk iphoneos strip -S %s/*.a" % ios_out_dir ios_strip_cmd = "xcrun -sdk iphoneos strip -S %s/*.a" % ios_out_dir
utils_cocos.execute_command(ios_strip_cmd) utils_cocos.execute_command(ios_strip_cmd)
if self.build_mac:
mac_strip_cmd = "xcrun strip -S %s/*.a" % mac_out_dir mac_strip_cmd = "xcrun strip -S %s/*.a" % mac_out_dir
utils_cocos.execute_command(mac_strip_cmd) utils_cocos.execute_command(mac_strip_cmd)
@ -378,7 +384,8 @@ if __name__ == "__main__":
parser.add_argument('-c', dest='clean', action="store_true", help='clean libs folder') parser.add_argument('-c', dest='clean', action="store_true", help='clean libs folder')
parser.add_argument('-all', dest='all', action="store_true", help='compile all platform') parser.add_argument('-all', dest='all', action="store_true", help='compile all platform')
parser.add_argument('--win', dest='win', action="store_true", help='compile windows platform') parser.add_argument('--win', dest='win', action="store_true", help='compile windows platform')
parser.add_argument('--mac', dest='mac', action="store_true", help='compile mac platform') parser.add_argument('--mac', dest='mac', action="store_true", help='compile Mac platform')
parser.add_argument('--ios', dest='ios', action="store_true", help='compile iOS platform')
parser.add_argument('--android', dest='android', action="store_true",help='complile android platform') parser.add_argument('--android', dest='android', action="store_true",help='complile android platform')
parser.add_argument('--dis-strip', "--disable-strip", dest='disable_strip', action="store_true", help='Disable the strip of the generated libs.') parser.add_argument('--dis-strip', "--disable-strip", dest='disable_strip', action="store_true", help='Disable the strip of the generated libs.')
parser.add_argument('--vs', dest='vs_version', type=int, help='visual studio version, such as 2013.', default=None) parser.add_argument('--vs', dest='vs_version', type=int, help='visual studio version, such as 2013.', default=None)

View File

@ -0,0 +1,406 @@
#!/usr/bin/python
#-*- coding: UTF-8 -*-
# ----------------------------------------------------------------------------
# Generate Cocos Simulator
#
# Copyright 2015 (C) zhangbin
#
# License: MIT
# ----------------------------------------------------------------------------
import os
import re
import shutil
import string
import utils_cocos
from datetime import date
from custom_error import Logging, CustomError
from argparse import ArgumentParser
class SimulatorCompiler(object):
SIMULATOR_PROJ_PATH = 'tools/simulator'
COCOS_CMD_PATH = 'tools/cocos2d-console/bin/cocos'
DEFAULT_OUTPUT_FOLDER_NAME = 'simulator'
SUPPORT_PLATFORMS = {
"win" : [ 'win32', 'android' ],
"mac" : [ 'ios', 'mac', 'android' ],
"other" : [ 'android' ]
}
def __init__(self, args):
self.cur_dir = os.path.realpath(os.path.dirname(__file__))
self.engine_root = os.path.abspath(os.path.join(self.cur_dir, os.pardir, os.pardir, os.pardir))
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)
# 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
self.platform = args.platform
self.build_log = ""
self.vs_version = args.vs_version
def replace_keyword_with_content(self,content,old,new):
found_string = string.find(content,old) >= 0
return found_string, string.replace(content,old,new)
def get_content_from_file(self,file_path):
if not os.path.isfile(file_path):
raise Exception("Could not find (%s)" % (file_path))
with open(file_path) as f:
return f.read()
def write_content_to_file(self,content, file_path):
if not os.path.isfile(file_path):
raise Exception("Could not find (%s)" % (file_path))
with open(file_path, 'w') as f:
f.write(content)
def replace_keyword_with_file(self,file_path,keyword_map):
content = self.get_content_from_file(file_path)
found = False
for k in keyword_map:
old, new = k, keyword_map[k]
has_found, content = self.replace_keyword_with_content(content, old, new)
if has_found :
found = has_found
if found == True:
self.write_content_to_file(content,file_path)
def get_keywords(self):
osx_keyword = {
"CC_TARGET_OS_IPHONE,":"CC_TARGET_OS_IPHONE,\n\"COCOS2D_DEBUG=1\",",
"CC_TARGET_OS_MAC,":"CC_TARGET_OS_MAC,\n\"COCOS2D_DEBUG=1\",",
"COCOS2D_DEBUG=0":"COCOS2D_DEBUG=1",
}
win_keyword = {
"_WINDOWS":"_WINDOWS;COCOS2D_DEBUG=1",
}
if utils_cocos.os_is_mac():
return osx_keyword
if utils_cocos.os_is_win32():
return win_keyword
return {}
def convert_path_to_python(self,path):
""" Convert path which include space to correct style which python can treat correctly.
eg: on mac: convert '/usr/xxx/apache-ant\ 1.9.3' to '/usr/xxx/apache-ant 1.9.3'
eg: on windows: convert '"c:\apache-ant 1.9.3"\bin' to 'c:\apache-ant 1.9.3\bin'
"""
ret = path
if utils_cocos.os_is_mac():
ret = path.replace("\ ", " ")
if utils_cocos.os_is_win32():
ret = ret.replace("\"", "")
return ret
def convert_path_to_win32(self,path):
return path.replace("/","\\")
def get_depend_project_file_list(self):
file_list = []
if utils_cocos.os_is_mac():
IOS_MAC_PROJECT_SUFFIX = "project.pbxproj"
IOS_MAC_PROJECT_REFERENCES_TAG = 'ProjectRef ='
IOS_MAC_PROJECT_NAME_RE = r'\w+.xcodeproj'
IOS_MAC_PROJECT_PATH_RE = r'name = %s; path = (.)*.xcodeproj'
project_file_path = os.path.join(self.simulator_abs_path,
"frameworks/runtime-src/proj.ios_mac/simulator.xcodeproj",
IOS_MAC_PROJECT_SUFFIX)
contents_str = self.get_content_from_file(project_file_path)
lines = re.split(r'\n', contents_str)
simulator_mac_project_path = os.path.dirname(os.path.dirname(project_file_path))
project_references = []
for l in lines:
if IOS_MAC_PROJECT_REFERENCES_TAG in l:
ret = re.search(IOS_MAC_PROJECT_NAME_RE, l)
if ret: project_references.append(ret.group(0))
for references in project_references:
re_str = IOS_MAC_PROJECT_PATH_RE % references
ret = re.search(re_str, contents_str)
if ret:
match_str = ret.group(0)
match_str = match_str.replace("name = %s; path = " % references, "")
match_str = match_str.replace('"', "")
file_list.append(os.path.join(simulator_mac_project_path, match_str, IOS_MAC_PROJECT_SUFFIX))
elif utils_cocos.os_is_win32():
WIN32_PROJECT_TAG = "Project(\""
project_file_path = os.path.join(self.simulator_abs_path, "frameworks/runtime-src/proj.win32/simulator.sln")
simulator_win32_project_path = os.path.dirname(project_file_path)
content_str = self.get_content_from_file(project_file_path)
lines = content_str.split('\n')
for l in lines:
if l.startswith(WIN32_PROJECT_TAG):
ret = re.compile('"(.*?)"').findall(l.split(',')[1])
if ret:
path = self.convert_path_to_win32(os.path.join(simulator_win32_project_path, ret[0]))
file_list.append(path)
return file_list
def compile_for_osx(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([
"mkdir -p %s" % (os.path.join(self.simulator_abs_path, "src")),
" && %s compile -p mac -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,"mac")),
" && strip %s" % (os.path.join(self.simulator_output_dir,"mac","Simulator.app/Contents/MacOS/Simulator")),
])
ret = utils_cocos.execute_command(command, self.simulator_abs_path)
self.build_log += "Build osx %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_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
def compile_all(self):
if utils_cocos.os_is_mac():
self.compile_for_android()
self.compile_for_osx()
self.compile_for_ios()
elif utils_cocos.os_is_win32():
self.compile_for_win32()
self.compile_for_android()
def do_compile(self):
if self.platform == 'all':
self.compile_all()
return
if utils_cocos.os_is_mac():
support_platforms = SimulatorCompiler.SUPPORT_PLATFORMS['mac']
elif utils_cocos.os_is_win32():
support_platforms = SimulatorCompiler.SUPPORT_PLATFORMS['win']
else:
support_platforms = SimulatorCompiler.SUPPORT_PLATFORMS['other']
if self.platform not in support_platforms:
raise CustomError('%s is not support in current system.' % self.platform,
CustomError.ERROR_WRONG_ARGS)
if self.platform == 'win32':
self.compile_for_win32()
elif self.platform == 'android':
self.compile_for_android()
elif self.platform == 'ios':
self.compile_for_ios()
elif self.platform == 'mac':
self.compile_for_osx()
def change_cocos2d_debug_macro_to_1(self, file_list):
keyword = self.get_keywords()
for file_path in file_list:
self.replace_keyword_with_file(file_path, keyword)
def update_bundle_version(self):
build_date = date.today().strftime("%Y%m%d")
if utils_cocos.os_is_mac():
# mac
info_plist_path = os.path.join(self.simulator_abs_path, "frameworks/runtime-src/proj.ios_mac/mac/Info.plist")
info_plist_content = self.get_content_from_file(info_plist_path)
match = re.compile('<key>CFBundleVersion</key>(\s)*<string>(.*?)</string>').findall(info_plist_content)
if len(match):
build_date_tag = "<string>%s</string>" % match[0][1]
keyword_map = { build_date_tag : "<string>%s</string>" % build_date }
self.replace_keyword_with_file(info_plist_path, keyword_map)
if utils_cocos.os_is_win32():
# win32
game_rc_path = os.path.join(self.simulator_abs_path,"frameworks/runtime-src/proj.win32/game.rc")
game_rc_content = self.get_content_from_file(game_rc_path)
match = re.compile('"Version[^\(]*\(.*\)"').findall(game_rc_content)
if len(match):
build_info_str = match[0]
m = re.match(r'"(Version[^\(]*)\(.*\)', build_info_str)
target_str = '"%s(%s)"' % (m.group(1), build_date)
keyword_map = { build_info_str : target_str}
self.replace_keyword_with_file(game_rc_path,keyword_map)
def backup_files(self, files):
for f in files:
full_path = os.path.abspath(f)
if not os.path.isfile(full_path):
continue
backup_file_path = '%s.bak' % full_path
shutil.copyfile(full_path, backup_file_path)
def rollback_files(self, files):
for f in files:
full_path = os.path.abspath(f)
backup_file_path = '%s.bak' % full_path
if not os.path.isfile(backup_file_path):
continue
try:
shutil.copyfile(backup_file_path, full_path)
os.remove(backup_file_path)
except:
print('Roll back file %s failed.' % full_path)
print('Please rename %s to %s manually.' % (backup_file_path, full_path))
pass
def run(self):
if self.is_clean_before_build:
utils_cocos.rmdir(self.simulator_output_dir)
# backup some files
modify_files = self.get_depend_project_file_list()
if utils_cocos.os_is_mac():
modify_files.append(os.path.join(self.simulator_abs_path, 'frameworks/runtime-src/proj.ios_mac/mac/Info.plist'))
elif utils_cocos.os_is_win32():
modify_files.append(os.path.join(self.simulator_abs_path, 'frameworks/runtime-src/proj.win32/game.rc'))
self.backup_files(modify_files)
try:
# modify bundle version
self.update_bundle_version()
# modify project config files
self.change_cocos2d_debug_macro_to_1(modify_files)
# compile simulator
self.do_compile()
except Exception as e:
raise e
finally:
# roll back modified files
self.rollback_files(modify_files)
Logging.info("")
Logging.info(self.build_log)
Logging.info("")
return 0
if __name__ == '__main__':
parser = ArgumentParser(description="Generate Cocos Simulator.")
parser.add_argument('-c', '--clean', dest='do_clean', action='store_true',
help='Clean the output directory before generating. Will remove the output directory at first.')
parser.add_argument('-m', "--mode", dest='compile_mode', type=str, choices=['debug', 'release'],
help='Generate simulator for debug or release. Default is debug.')
parser.add_argument('-o', '--output', dest='out_dir',
help='Where to save Cocos Simulator. Default is the simulator folder in the root path of engine.')
parser.add_argument('-p', '--platform', dest='platform', required=True,
choices=['ios', 'mac', 'android', 'win32', 'all'],
help='Which platform will be generated for.')
parser.add_argument('--vs', dest='vs_version', type=int,
help='Specify the Visual Studio version will be used. Such as: 2013. Default find available version automatically.')
(args, unknown) = parser.parse_known_args()
if len(unknown) > 0:
print("unknown arguments: %s" % unknown)
compiler = SimulatorCompiler(args)
compiler.run()

View File

@ -22,7 +22,7 @@ def os_is_mac():
def convert_to_python_path(path): def convert_to_python_path(path):
return path.replace("\\","/") return path.replace("\\","/")
def execute_command(cmdstring, cwd=None, timeout=None, shell=True): def execute_command(cmdstring, cwd=None, timeout=None, shell=True, use_py_path=True):
""" 执行一个SHELL命令 """ 执行一个SHELL命令
封装了subprocess的Popen方法, 支持超时判断支持读取stdout和stderr 封装了subprocess的Popen方法, 支持超时判断支持读取stdout和stderr
参数: 参数:
@ -38,7 +38,7 @@ def execute_command(cmdstring, cwd=None, timeout=None, shell=True):
import subprocess import subprocess
import time import time
if os_is_win32(): if os_is_win32() and use_py_path:
cmdstring = convert_to_python_path(cmdstring) cmdstring = convert_to_python_path(cmdstring)
print("") print("")

View File

@ -27,10 +27,12 @@
#include "jsb_cocos2dx_navmesh_auto.hpp" #include "jsb_cocos2dx_navmesh_auto.hpp"
#include "navmesh/jsb_cocos2dx_navmesh_manual.h" #include "navmesh/jsb_cocos2dx_navmesh_manual.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) // #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#include "experimental/jsb_cocos2dx_experimental_video_manual.h" // #include "experimental/jsb_cocos2dx_experimental_video_auto.hpp"
#include "experimental/jsb_cocos2dx_experimental_webView_manual.h" // #include "experimental/jsb_cocos2dx_experimental_video_manual.h"
#endif // #include "experimental/jsb_cocos2dx_experimental_webView_auto.hpp"
// #include "experimental/jsb_cocos2dx_experimental_webView_manual.h"
// #endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include "platform/android/CCJavascriptJavaBridge.h" #include "platform/android/CCJavascriptJavaBridge.h"
@ -96,10 +98,12 @@ int js_module_register()
sc->addRegisterCallback(register_all_cocos2dx_navmesh_manual); sc->addRegisterCallback(register_all_cocos2dx_navmesh_manual);
#endif #endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) // #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
sc->addRegisterCallback(register_all_cocos2dx_experimental_video_manual); // sc->addRegisterCallback(register_all_cocos2dx_experimental_video);
sc->addRegisterCallback(register_all_cocos2dx_experimental_webView_manual); // sc->addRegisterCallback(register_all_cocos2dx_experimental_video_manual);
#endif // sc->addRegisterCallback(register_all_cocos2dx_experimental_webView);
// sc->addRegisterCallback(register_all_cocos2dx_experimental_webView_manual);
// #endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
sc->addRegisterCallback(JavascriptJavaBridge::_js_register); sc->addRegisterCallback(JavascriptJavaBridge::_js_register);

View File

@ -64,7 +64,7 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSM
CAPTION "About Simulator" CAPTION "About Simulator"
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN BEGIN
CTEXT "Version 3.5beta0 (20150227)",IDC_ABOUT_VERSION,35,70,173,17 CTEXT "Version 3.7 (20150227)",IDC_ABOUT_VERSION,35,70,173,17
CTEXT "Cocos Simulator",IDC_ABOUT_TITLE,35,49,173,17 CTEXT "Cocos Simulator",IDC_ABOUT_TITLE,35,49,173,17
CTEXT "Copyright (C) 2015. All rights reserved.",IDC_STATIC,35,94,173,17 CTEXT "Copyright (C) 2015. All rights reserved.",IDC_STATIC,35,94,173,17
ICON "GLFW_ICON",IDC_STATIC,111,15,20,20 ICON "GLFW_ICON",IDC_STATIC,111,15,20,20