From 0854f980fa99594a2bd591c4497bf6a981ae80a6 Mon Sep 17 00:00:00 2001 From: kompjoefriek Date: Thu, 29 Jan 2015 01:40:19 +0100 Subject: [PATCH 1/6] fixed indentation of Python files - Changed tabs to spaces - Changed 2 spaces to 4 spaces --- .../proj.android/build_native.py | 54 +- tools/jenkins-scripts/autotest.py | 264 +++++----- tools/jenkins-scripts/cocos-console-test.py | 458 ++++++++-------- tools/jenkins-scripts/configs/autotest.py | 2 +- .../configs/cocos-2dx-develop-android.py | 12 +- .../configs/cocos-2dx-develop-base-repo.py | 22 +- .../configs/cocos-2dx-develop-ios.py | 12 +- .../configs/cocos-2dx-develop-win32.py | 14 +- .../configs/cocos-2dx-doxygen.py | 14 +- ...-2dx-pull-request-build-comment-trigger.py | 4 +- .../cocos-2dx-pull-request-build-trigger.py | 4 +- .../configs/cocos-2dx-pull-request-build.py | 30 +- .../configs/cocos2d-console-test.py | 2 +- .../configs/cocostudiox-base-repo.py | 4 +- .../configs/cocostudiox-daily-build.py | 24 +- tools/jenkins-scripts/emptytest.py | 490 +++++++++--------- tools/jenkins-scripts/github-pr-watchdog.py | 96 ++-- tools/jenkins-scripts/post-build.py | 8 +- tools/jenkins-scripts/reboot.py | 60 +-- 19 files changed, 787 insertions(+), 787 deletions(-) diff --git a/templates/cpp-template-default/proj.android/build_native.py b/templates/cpp-template-default/proj.android/build_native.py index fdcdf9b0ac..dd948d6d9b 100755 --- a/templates/cpp-template-default/proj.android/build_native.py +++ b/templates/cpp-template-default/proj.android/build_native.py @@ -9,14 +9,14 @@ import shutil from optparse import OptionParser def get_num_of_cpu(): - ''' The build process can be accelerated by running multiple concurrent job processes using the -j-option. - ''' - try: - import multiprocessing - return multiprocessing.cpu_count() - except Exception: - print "Can't know cpuinfo, use default 1 cpu" - return 1 + ''' The build process can be accelerated by running multiple concurrent job processes using the -j-option. + ''' + try: + import multiprocessing + return multiprocessing.cpu_count() + except Exception: + print "Can't know cpuinfo, use default 1 cpu" + return 1 def check_environment_variables_sdk(): ''' Checking the environment ANDROID_SDK_ROOT, which will be used for building @@ -69,17 +69,17 @@ def do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,and if os.system(command) != 0: raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!") elif android_platform is not None: - sdk_tool_path = os.path.join(sdk_root, "tools/android") - cocoslib_path = os.path.join(cocos_root, "cocos/platform/android/java") - command = '%s update lib-project -t %s -p %s' % (sdk_tool_path,android_platform,cocoslib_path) - if os.system(command) != 0: - raise Exception("update cocos lib-project [ " + cocoslib_path + " ] fails!") - command = '%s update project -t %s -p %s -s' % (sdk_tool_path,android_platform,app_android_root) - if os.system(command) != 0: - raise Exception("update project [ " + app_android_root + " ] fails!") - buildfile_path = os.path.join(app_android_root, "build.xml") - command = 'ant clean %s -f %s -Dsdk.dir=%s' % (build_mode,buildfile_path,sdk_root) - os.system(command) + sdk_tool_path = os.path.join(sdk_root, "tools/android") + cocoslib_path = os.path.join(cocos_root, "cocos/platform/android/java") + command = '%s update lib-project -t %s -p %s' % (sdk_tool_path,android_platform,cocoslib_path) + if os.system(command) != 0: + raise Exception("update cocos lib-project [ " + cocoslib_path + " ] fails!") + command = '%s update project -t %s -p %s -s' % (sdk_tool_path,android_platform,app_android_root) + if os.system(command) != 0: + raise Exception("update project [ " + app_android_root + " ] fails!") + buildfile_path = os.path.join(app_android_root, "build.xml") + command = 'ant clean %s -f %s -Dsdk.dir=%s' % (build_mode,buildfile_path,sdk_root) + os.system(command) def copy_files(src, dst): @@ -119,15 +119,15 @@ def build(ndk_build_param,android_platform,build_mode): copy_resources(app_android_root) if android_platform is not None: - sdk_root = check_environment_variables_sdk() - if android_platform.isdigit(): - android_platform = 'android-'+android_platform - else: - print 'please use vaild android platform' - exit(1) - + sdk_root = check_environment_variables_sdk() + if android_platform.isdigit(): + android_platform = 'android-'+android_platform + else: + print 'please use vaild android platform' + exit(1) + if build_mode is None: - build_mode = 'debug' + build_mode = 'debug' elif build_mode != 'release': build_mode = 'debug' diff --git a/tools/jenkins-scripts/autotest.py b/tools/jenkins-scripts/autotest.py index 74857a17cf..31ea709e1d 100755 --- a/tools/jenkins-scripts/autotest.py +++ b/tools/jenkins-scripts/autotest.py @@ -21,153 +21,153 @@ sleep_time = 1.5 # def getADBDeviceIP(): - output = os.popen("adb shell netcfg") - configs = output.read().split('\r\n') - for l in configs: - items = l.split() - if(items[1] == 'UP'): - if(items[2] != '127.0.0.1'): - return items[2] + output = os.popen("adb shell netcfg") + configs = output.read().split('\r\n') + for l in configs: + items = l.split() + if(items[1] == 'UP'): + if(items[2] != '127.0.0.1'): + return items[2] def autotest(type): - soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) - if type == TYPE_MAC: - soc.connect((HOST_MAC, PORT)) - if type == TYPE_ANDROID: - HOST_ANDROID = getADBDeviceIP() - soc.connect((HOST_ANDROID, PORT)) - if type == TYPE_IOS: - soc.connect((HOST_IOS, PORT)) - time.sleep(1) - print 'autotest run:' - soc.send('autotest run\r\n') + soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) + if type == TYPE_MAC: + soc.connect((HOST_MAC, PORT)) + if type == TYPE_ANDROID: + HOST_ANDROID = getADBDeviceIP() + soc.connect((HOST_ANDROID, PORT)) + if type == TYPE_IOS: + soc.connect((HOST_IOS, PORT)) + time.sleep(1) + print 'autotest run:' + soc.send('autotest run\r\n') - while True: - data = soc.recv(1024) - print data - if data == 'TestEnd': - lastTestInfo = True - break - global lastTestInfo - if len(data) > len('\n') : - lastTestInfo = data - if not data: break - - soc.send('director end\r\n') - print 'test end and close socket.' - soc.close() + while True: + data = soc.recv(1024) + print data + if data == 'TestEnd': + lastTestInfo = True + break + global lastTestInfo + if len(data) > len('\n') : + lastTestInfo = data + if not data: break + + soc.send('director end\r\n') + print 'test end and close socket.' + soc.close() #----------------autotest build and run----------------# def MAC_BUILD(): - def cleanProj(): - infoClean = os.system('xcodebuild -project ./build/cocos2d_tests.xcodeproj -target cpp-tests\ Mac clean') - print 'infoClean: ', infoClean - if infoClean != 0: - return False - time.sleep(sleep_time) - return True - def buildProj(): - infoBuild = os.system('xcodebuild -project ./build/cocos2d_tests.xcodeproj -target cpp-tests\ Mac') - print 'infoBuild: ', infoBuild - if infoBuild != 0: - return False - time.sleep(sleep_time) - return True - def openProj(): - cmd = 'open ./build/build/Debug/cpp-tests\ Mac.app' - print 'cmd: ', cmd - infoOpen = os.system(cmd) - print 'infoOpen: ', infoOpen - if infoOpen != 0: - return False - time.sleep(sleep_time) - return True - def buildAndRun(): - if not cleanProj(): - print '**CLEAN FAILED**' - if not buildProj(): - print '**BUILD FAILED**' - return False - if not openProj(): - return False - time.sleep(sleep_time) - return True - return buildAndRun() + def cleanProj(): + infoClean = os.system('xcodebuild -project ./build/cocos2d_tests.xcodeproj -target cpp-tests\ Mac clean') + print 'infoClean: ', infoClean + if infoClean != 0: + return False + time.sleep(sleep_time) + return True + def buildProj(): + infoBuild = os.system('xcodebuild -project ./build/cocos2d_tests.xcodeproj -target cpp-tests\ Mac') + print 'infoBuild: ', infoBuild + if infoBuild != 0: + return False + time.sleep(sleep_time) + return True + def openProj(): + cmd = 'open ./build/build/Debug/cpp-tests\ Mac.app' + print 'cmd: ', cmd + infoOpen = os.system(cmd) + print 'infoOpen: ', infoOpen + if infoOpen != 0: + return False + time.sleep(sleep_time) + return True + def buildAndRun(): + if not cleanProj(): + print '**CLEAN FAILED**' + if not buildProj(): + print '**BUILD FAILED**' + return False + if not openProj(): + return False + time.sleep(sleep_time) + return True + return buildAndRun() #----------------autotest build and run end----------------# PATH_ANDROID_SRC = 'tests/cpp-tests/proj.android/' FILE_ANDROID_DELETE = ['libs','gen','assets','bin','obj'] #----------------autotest-android build and run----------------# def ANDROID_BUILD(): - def checkDevice(): - cmd = 'adb devices' - infoDev = os.popen(cmd).readlines() - firstDev = infoDev[1] - if len(firstDev) < 5 or firstDev.find('device') < 0: - print 'no android device.' - return False - else: - print 'device info:', firstDev - return True - def cleanProj(): - for strFile in FILE_ANDROID_DELETE: - infoClean = os.system('rm -rf '+PATH_ANDROID_SRC+strFile) - infoClean = os.system('adb uninstall org.cocos2dx.cpp_tests'); - print 'infoClean: ', infoClean - if infoClean != 0: - print 'clean **CLEAN FAILED**' - time.sleep(sleep_time) - def updateProperty(): - infoUpdate = os.system('android update project -p ./cocos/platform/android/java/ -t 12') - print 'cocos update:', infoUpdate - infoUpdate = os.system('android update project -p '+PATH_ANDROID_SRC+' -t 12') - print 'test update:', infoUpdate - def buildProj(): - infoBuild = os.system('./build/android-build.py -p 13 cpp-tests') - print 'infoBuild cpp_tests: ', infoBuild - infoBuild = os.system('ant -buildfile '+PATH_ANDROID_SRC+' debug') - print 'infoBuild: ', infoBuild - if infoBuild != 0: - print 'build **BUILD FAILED**' - time.sleep(sleep_time) - return infoBuild - def installProj(): - cmd = 'adb install '+PATH_ANDROID_SRC+'bin/CppTests-debug.apk' - infoInstall = os.system(cmd) - print 'infoInstall:', infoInstall - if infoInstall != 0: - print 'install **INSTALL FAILED**' - return infoInstall - def openProj(): - cmd = 'adb shell am start -n org.cocos2dx.cpp_tests/org.cocos2dx.cpp_tests.Cocos2dxActivity' - print 'cmd: ', cmd - infoOpen = os.system(cmd) - print 'infoOpen: ', infoOpen - if infoOpen != 0: - return False - time.sleep(sleep_time) - return True - def buildAndRun(): - if not checkDevice(): - return False - cleanProj() - updateProperty() - buildProj() - installProj() - return openProj() - return buildAndRun() + def checkDevice(): + cmd = 'adb devices' + infoDev = os.popen(cmd).readlines() + firstDev = infoDev[1] + if len(firstDev) < 5 or firstDev.find('device') < 0: + print 'no android device.' + return False + else: + print 'device info:', firstDev + return True + def cleanProj(): + for strFile in FILE_ANDROID_DELETE: + infoClean = os.system('rm -rf '+PATH_ANDROID_SRC+strFile) + infoClean = os.system('adb uninstall org.cocos2dx.cpp_tests'); + print 'infoClean: ', infoClean + if infoClean != 0: + print 'clean **CLEAN FAILED**' + time.sleep(sleep_time) + def updateProperty(): + infoUpdate = os.system('android update project -p ./cocos/platform/android/java/ -t 12') + print 'cocos update:', infoUpdate + infoUpdate = os.system('android update project -p '+PATH_ANDROID_SRC+' -t 12') + print 'test update:', infoUpdate + def buildProj(): + infoBuild = os.system('./build/android-build.py -p 13 cpp-tests') + print 'infoBuild cpp_tests: ', infoBuild + infoBuild = os.system('ant -buildfile '+PATH_ANDROID_SRC+' debug') + print 'infoBuild: ', infoBuild + if infoBuild != 0: + print 'build **BUILD FAILED**' + time.sleep(sleep_time) + return infoBuild + def installProj(): + cmd = 'adb install '+PATH_ANDROID_SRC+'bin/CppTests-debug.apk' + infoInstall = os.system(cmd) + print 'infoInstall:', infoInstall + if infoInstall != 0: + print 'install **INSTALL FAILED**' + return infoInstall + def openProj(): + cmd = 'adb shell am start -n org.cocos2dx.cpp_tests/org.cocos2dx.cpp_tests.Cocos2dxActivity' + print 'cmd: ', cmd + infoOpen = os.system(cmd) + print 'infoOpen: ', infoOpen + if infoOpen != 0: + return False + time.sleep(sleep_time) + return True + def buildAndRun(): + if not checkDevice(): + return False + cleanProj() + updateProperty() + buildProj() + installProj() + return openProj() + return buildAndRun() #----------------autotest-android build and run end----------------# def main(): - print 'will build mac project.' - suc_build_mac = MAC_BUILD() - # print 'will build android project.' - # suc_build_android = ANDROID_BUILD() - if suc_build_mac: - autotest(TYPE_MAC) - if suc_build_android: - print 'will run android autotest.' - autotest(TYPE_ANDROID) + print 'will build mac project.' + suc_build_mac = MAC_BUILD() + # print 'will build android project.' + # suc_build_android = ANDROID_BUILD() + if suc_build_mac: + autotest(TYPE_MAC) + if suc_build_android: + print 'will run android autotest.' + autotest(TYPE_ANDROID) # -------------- main -------------- diff --git a/tools/jenkins-scripts/cocos-console-test.py b/tools/jenkins-scripts/cocos-console-test.py index 4623cdc83b..b76ec22444 100755 --- a/tools/jenkins-scripts/cocos-console-test.py +++ b/tools/jenkins-scripts/cocos-console-test.py @@ -20,10 +20,10 @@ from os.path import join, getsize console_param = '[console run]' # get param from commit. if os.environ.has_key('payload'): - payload_str = os.environ['payload'] - payload = json.loads(payload_str) - if payload.has_key('console'): - console_param = payload['console'] + payload_str = os.environ['payload'] + payload = json.loads(payload_str) + if payload.has_key('console'): + console_param = payload['console'] console_param = console_param[1:len(console_param)-1] print 'console_param:',console_param @@ -31,34 +31,34 @@ console_param_arr = console_param.split(' ') # enum command type class ENUM_PARAM: - new = 0 - compile = 1 - deploy = 2 - run = 3 + new = 0 + compile = 1 + deploy = 2 + run = 3 # partition different level LEVEL_COCOS = { - ENUM_PARAM.new : 1, - ENUM_PARAM.compile : 2, - ENUM_PARAM.deploy : 4, - ENUM_PARAM.run : 8 + ENUM_PARAM.new : 1, + ENUM_PARAM.compile : 2, + ENUM_PARAM.deploy : 4, + ENUM_PARAM.run : 8 } # level's cocos command COCOS_CMD = { - ENUM_PARAM.new:'new', - ENUM_PARAM.compile:'compile', - ENUM_PARAM.deploy:'deploy', - ENUM_PARAM.run:'run' + ENUM_PARAM.new:'new', + ENUM_PARAM.compile:'compile', + ENUM_PARAM.deploy:'deploy', + ENUM_PARAM.run:'run' } # set cocos_param for run different command cocos_param = 0 for level in LEVEL_COCOS: - if console_param_arr.count(COCOS_CMD[level]): - cocos_param = cocos_param + LEVEL_COCOS[level] + if console_param_arr.count(COCOS_CMD[level]): + cocos_param = cocos_param + LEVEL_COCOS[level] if cocos_param < LEVEL_COCOS[ENUM_PARAM.new]: - cocos_param = LEVEL_COCOS[ENUM_PARAM.new] + cocos_param = LEVEL_COCOS[ENUM_PARAM.new] print 'cocos_param:', cocos_param # project types @@ -73,109 +73,109 @@ cocos_console_dir = 'tools/cocos2d-console/bin/' # now cocos2d-console suport different run on Platforms, e.g: only run android on win runSupport = { - 'darwin' : {'mac':1,'ios':1,'android':1}, - 'win' : {'mac':0,'ios':0,'android':1}, - 'linux' : {'mac':0,'ios':0,'android':1} + 'darwin' : {'mac':1,'ios':1,'android':1}, + 'win' : {'mac':0,'ios':0,'android':1}, + 'linux' : {'mac':0,'ios':0,'android':1} } # get current running system curPlat = sys.platform if curPlat.find('linux') >= 0: - curPlat = 'linux' + curPlat = 'linux' elif curPlat.find('darwin') >= 0: - curPlat = 'darwin' + curPlat = 'darwin' else: - curPlat = 'win' + curPlat = 'win' print 'current platform is:', curPlat # delete project.(will use different system command to delete.just mac now.) def clean_project(): - print 'delete older project.' - for proj in project_types: - cmd = 'rm -rf '+proj+PROJ_SUFFIX - os.system(cmd) + print 'delete older project.' + for proj in project_types: + cmd = 'rm -rf '+proj+PROJ_SUFFIX + os.system(cmd) # file path.(for add console listen command.) FILE_PATH = '/Classes/AppDelegate.cpp' FILE_DIR = { - 'cpp':'', - 'lua':'/frameworks/runtime-src' + 'cpp':'', + 'lua':'/frameworks/runtime-src' } PARSE_WORD = 'director->setDisplayStats(true);' CONSOLE_COMMAND = 'director->getConsole()->listenOnTCP(5678);' # add console listenOnTCP to AppDelegate.cpp. def addConsoleListenOnTCP(name): - filePath = name+PROJ_SUFFIX+FILE_DIR[name]+FILE_PATH - print 'filePath:',filePath - strCont = '' - if os.path.isfile(filePath): - file_object = open(filePath, 'r') - strLine = file_object.readline() - while strLine: - strCont = strCont + strLine - if strLine.find(PARSE_WORD) > -1: - print 'add console listenOnTCP command.' - strCont = strCont+'\n\t' + CONSOLE_COMMAND + '\n' - strLine = file_object.readline() - - file_object.close() - file_object = open(filePath, 'w') - file_object.write(strCont) - file_object.close() - time.sleep(2) - else: - print 'file is not exist.' + filePath = name+PROJ_SUFFIX+FILE_DIR[name]+FILE_PATH + print 'filePath:',filePath + strCont = '' + if os.path.isfile(filePath): + file_object = open(filePath, 'r') + strLine = file_object.readline() + while strLine: + strCont = strCont + strLine + if strLine.find(PARSE_WORD) > -1: + print 'add console listenOnTCP command.' + strCont = strCont+'\n\t' + CONSOLE_COMMAND + '\n' + strLine = file_object.readline() + + file_object.close() + file_object = open(filePath, 'w') + file_object.write(strCont) + file_object.close() + time.sleep(2) + else: + print 'file is not exist.' # console result, for record result console_result = 'the result of cocos-console-test is:\n\r' # get current android devices count. def getAndroidDevices(): - cmd = 'adb devices' - info_devices = os.popen(cmd).read() - arrDevices = info_devices.split('\n') - del arrDevices[0] - count = 0 - for device in arrDevices: - # e.g: emulator-5554 device, contains 'device', so, min length is len('device') - if len(device) > len('device') and (device.find('device') >= 0): - count += 1 - return count + cmd = 'adb devices' + info_devices = os.popen(cmd).read() + arrDevices = info_devices.split('\n') + del arrDevices[0] + count = 0 + for device in arrDevices: + # e.g: emulator-5554 device, contains 'device', so, min length is len('device') + if len(device) > len('device') and (device.find('device') >= 0): + count += 1 + return count # close running app or exe by using console command. IP_PHONE = { - 'mac':'localhost', - 'ios':'localhost' + 'mac':'localhost', + 'ios':'localhost' } PORT = 5678 def close_proj(proj, phone): - print 'close running project' - # connect socket - strClose = 'close ' + proj + ' on ' + phone - if IP_PHONE.has_key(phone): - soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) - print proj, phone, IP_PHONE[phone] - try: - soc.connect((IP_PHONE[phone], PORT)) - cmd = 'director end\r\n' - print 'cmd close:', cmd - soc.send(cmd) - time.sleep(2) - strClose = strClose + ' success.' - except Exception, e: - print 'socket is not connect.' - strClose = strClose + ' failed.' + ' socket is not connect.' - else: - strClose = strClose + ' failed.' + ' no ' +phone+ ' type.' - time.sleep(2) - return strClose + print 'close running project' + # connect socket + strClose = 'close ' + proj + ' on ' + phone + if IP_PHONE.has_key(phone): + soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) + print proj, phone, IP_PHONE[phone] + try: + soc.connect((IP_PHONE[phone], PORT)) + cmd = 'director end\r\n' + print 'cmd close:', cmd + soc.send(cmd) + time.sleep(2) + strClose = strClose + ' success.' + except Exception, e: + print 'socket is not connect.' + strClose = strClose + ' failed.' + ' socket is not connect.' + else: + strClose = strClose + ' failed.' + ' no ' +phone+ ' type.' + time.sleep(2) + return strClose # appendToResult def appendToResult(content): - global console_result - console_result = console_result + content + global console_result + console_result = console_result + content info_of_close_app = {} cur_test_name = '' @@ -186,194 +186,194 @@ class myThread(threading.Thread): run_name = self.getName() print 'run_name:', run_name if run_name == 'close': - while True: - soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) - try: - soc.connect(('localhost', PORT)) - cmd_close = 'director end\r\n' - print 'cmd close:', cmd_close - soc.send(cmd_close) - time.sleep(2) - global cur_test_name - print 'cur_test_name:', cur_test_name - info_of_close_app[cur_test_name] = True - break - except Exception, e: - time.sleep(5) + while True: + soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) + try: + soc.connect(('localhost', PORT)) + cmd_close = 'director end\r\n' + print 'cmd close:', cmd_close + soc.send(cmd_close) + time.sleep(2) + global cur_test_name + print 'cur_test_name:', cur_test_name + info_of_close_app[cur_test_name] = True + break + except Exception, e: + time.sleep(5) # if any error ANY_ERROR_IN_RUN = 0 # excute cocos command def cocos_project(level): - global ANY_ERROR_IN_RUN - print 'will excute cocos_command: ', COCOS_CMD[level], level - appendToResult('will excute ' + COCOS_CMD[level] + ' command:'+"\n\r\t") - for proj in project_types: - print 'proj: ', proj - if level == ENUM_PARAM.new: - cmd = './'+cocos_console_dir+'cocos new -l '+proj+' '+proj+PROJ_SUFFIX - print proj,'cmd:',cmd - info_create = os.system(cmd) #call cmd on win is diff - if info_create == 0: - time.sleep(12) - addConsoleListenOnTCP(proj) - print 'create project',proj,' is:', not info_create - ANY_ERROR_IN_RUN = ANY_ERROR_IN_RUN + info_create - appendToResult(' '+cmd +': ' + str(not info_create) + ".\n\r\t") - else: - for phone in phonePlats: - print 'platform is: ', phone - cmd = './'+cocos_console_dir+'cocos '+COCOS_CMD[level]+' -s '+proj+PROJ_SUFFIX+' -p '+phone - print 'cmd:',cmd - info_cmd = '' - if level == ENUM_PARAM.compile: - if runSupport[curPlat][phone]: - info_cmd = os.system(cmd) - print 'info '+COCOS_CMD[level]+':', not info_cmd - appendToResult(' '+cmd +': ' + str(not info_cmd) + ".\n\r\t") - else: - if runSupport[curPlat][phone]: - print 'in desploy or run:', phone, getAndroidDevices() - if phone == 'android' and getAndroidDevices() == 0: - strInfo = 'no android device, please checkout the device is running ok.' - print strInfo - else: - if level == ENUM_PARAM.run: - global cur_test_name - cur_test_name = proj+','+phone - thread_close = myThread('close') - thread_close.start() - info_cmd = os.system(cmd) - time.sleep(5) - appendToResult(' '+cmd +': ' + str(not info_cmd) + ".\n\r\t") + global ANY_ERROR_IN_RUN + print 'will excute cocos_command: ', COCOS_CMD[level], level + appendToResult('will excute ' + COCOS_CMD[level] + ' command:'+"\n\r\t") + for proj in project_types: + print 'proj: ', proj + if level == ENUM_PARAM.new: + cmd = './'+cocos_console_dir+'cocos new -l '+proj+' '+proj+PROJ_SUFFIX + print proj,'cmd:',cmd + info_create = os.system(cmd) #call cmd on win is diff + if info_create == 0: + time.sleep(12) + addConsoleListenOnTCP(proj) + print 'create project',proj,' is:', not info_create + ANY_ERROR_IN_RUN = ANY_ERROR_IN_RUN + info_create + appendToResult(' '+cmd +': ' + str(not info_create) + ".\n\r\t") + else: + for phone in phonePlats: + print 'platform is: ', phone + cmd = './'+cocos_console_dir+'cocos '+COCOS_CMD[level]+' -s '+proj+PROJ_SUFFIX+' -p '+phone + print 'cmd:',cmd + info_cmd = '' + if level == ENUM_PARAM.compile: + if runSupport[curPlat][phone]: + info_cmd = os.system(cmd) + print 'info '+COCOS_CMD[level]+':', not info_cmd + appendToResult(' '+cmd +': ' + str(not info_cmd) + ".\n\r\t") + else: + if runSupport[curPlat][phone]: + print 'in desploy or run:', phone, getAndroidDevices() + if phone == 'android' and getAndroidDevices() == 0: + strInfo = 'no android device, please checkout the device is running ok.' + print strInfo + else: + if level == ENUM_PARAM.run: + global cur_test_name + cur_test_name = proj+','+phone + thread_close = myThread('close') + thread_close.start() + info_cmd = os.system(cmd) + time.sleep(5) + appendToResult(' '+cmd +': ' + str(not info_cmd) + ".\n\r\t") # build and run according to params of provided.(lv_ignore: e.g:ignore new) def build_run(lv_ignore): - print 'will build and run, in function build_run' - for level in LEVEL_COCOS: - print 'level:', level, cocos_param, LEVEL_COCOS[level] - if cocos_param >= LEVEL_COCOS[level] and level > lv_ignore: - if level == ENUM_PARAM.new: - clean_project() - cocos_project(level) + print 'will build and run, in function build_run' + for level in LEVEL_COCOS: + print 'level:', level, cocos_param, LEVEL_COCOS[level] + if cocos_param >= LEVEL_COCOS[level] and level > lv_ignore: + if level == ENUM_PARAM.new: + clean_project() + cocos_project(level) # android simulator name. ANDROID_SIMULATOR_NAME = 'console-test' # start android simulator if no android devices connected. def start_android_simulator(): - print 'in function start_android_simulator.' - if getAndroidDevices() > 0: - print 'already connected android device.' - return - if cocos_param >= LEVEL_COCOS[ENUM_PARAM.deploy]: - cmd_start = [ 'emulator -avd '+ANDROID_SIMULATOR_NAME ] - # print 'cmd_start:', cmd_start - # info_start = subprocess.Popen(cmd_start, stdin=subprocess.PIPE, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - # print 'start an android simulator:', not info_start + print 'in function start_android_simulator.' + if getAndroidDevices() > 0: + print 'already connected android device.' + return + if cocos_param >= LEVEL_COCOS[ENUM_PARAM.deploy]: + cmd_start = [ 'emulator -avd '+ANDROID_SIMULATOR_NAME ] + # print 'cmd_start:', cmd_start + # info_start = subprocess.Popen(cmd_start, stdin=subprocess.PIPE, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + # print 'start an android simulator:', not info_start # send email EMAIL_KEYS={ - 0:'EMAIL_HOST', - 1:'EMAIL_USER', - 2:'EMAIL_PWD', - 3:'EMAIL_POSTFIX', - 4:'EMAIL_LIST', - 5:'NEED_SEND_EMAIL' + 0:'EMAIL_HOST', + 1:'EMAIL_USER', + 2:'EMAIL_PWD', + 3:'EMAIL_POSTFIX', + 4:'EMAIL_LIST', + 5:'NEED_SEND_EMAIL' } OBJ_EMAIL_INFO = {} print 'will get env info.' for key in EMAIL_KEYS: - if os.environ.has_key(EMAIL_KEYS[key]): - OBJ_EMAIL_INFO[EMAIL_KEYS[key]] = os.environ[EMAIL_KEYS[key]] - if key == 4: - # string to list by ' ', for separate users. - OBJ_EMAIL_INFO[EMAIL_KEYS[4]] = OBJ_EMAIL_INFO[EMAIL_KEYS[4]].split(' ') + if os.environ.has_key(EMAIL_KEYS[key]): + OBJ_EMAIL_INFO[EMAIL_KEYS[key]] = os.environ[EMAIL_KEYS[key]] + if key == 4: + # string to list by ' ', for separate users. + OBJ_EMAIL_INFO[EMAIL_KEYS[4]] = OBJ_EMAIL_INFO[EMAIL_KEYS[4]].split(' ') print 'will send email.', OBJ_EMAIL_INFO def send_mail(to_list,sub,title,content): - mail_user = OBJ_EMAIL_INFO[ EMAIL_KEYS[1] ] - mail_postfix = OBJ_EMAIL_INFO[ EMAIL_KEYS[3] ] - mail_host = OBJ_EMAIL_INFO[ EMAIL_KEYS[0] ] - mail_pass = OBJ_EMAIL_INFO[ EMAIL_KEYS[2] ] - me = mail_user+"<"+mail_user+"@"+mail_postfix+">" - msg = MIMEText(content,_subtype='plain',_charset='gb2312') - msg['Subject'] = sub - msg['From'] = me - msg['To'] = " ".join(to_list) - print 'to users:', msg['To'] - msg['Content'] = 'test' - try: - s = smtplib.SMTP() - s.connect(mail_host) - s.login(mail_user,mail_pass) - s.sendmail(me, to_list, str(msg)) - print 'info:', me, to_list, str(msg) - s.close() - appendToResult( 'send email true:' + str(msg) ) - return True - except Exception, e: - appendToResult( 'send email false:' + str(e) ) + mail_user = OBJ_EMAIL_INFO[ EMAIL_KEYS[1] ] + mail_postfix = OBJ_EMAIL_INFO[ EMAIL_KEYS[3] ] + mail_host = OBJ_EMAIL_INFO[ EMAIL_KEYS[0] ] + mail_pass = OBJ_EMAIL_INFO[ EMAIL_KEYS[2] ] + me = mail_user+"<"+mail_user+"@"+mail_postfix+">" + msg = MIMEText(content,_subtype='plain',_charset='gb2312') + msg['Subject'] = sub + msg['From'] = me + msg['To'] = " ".join(to_list) + print 'to users:', msg['To'] + msg['Content'] = 'test' + try: + s = smtplib.SMTP() + s.connect(mail_host) + s.login(mail_user,mail_pass) + s.sendmail(me, to_list, str(msg)) + print 'info:', me, to_list, str(msg) + s.close() + appendToResult( 'send email true:' + str(msg) ) + return True + except Exception, e: + appendToResult( 'send email false:' + str(e) ) print str(e) return False def sendEmail(msg): - send_mail(OBJ_EMAIL_INFO[EMAIL_KEYS[4]], "cocos-console-test result", 'for error.', msg) + send_mail(OBJ_EMAIL_INFO[EMAIL_KEYS[4]], "cocos-console-test result", 'for error.', msg) # get package size def getdirsize(dir): - size = 0L - for root, dirs, files in os.walk(dir): - size += sum([getsize(join(root, name)) for name in files]) - return size + size = 0L + for root, dirs, files in os.walk(dir): + size += sum([getsize(join(root, name)) for name in files]) + return size APP_FILE_DIR = { - 'cpp':'bin/debug/', - 'lua':'runtime/' + 'cpp':'bin/debug/', + 'lua':'runtime/' } APP_FILE_SUFFIX = { - 'mac':'.app', - 'ios':'.app', - 'android':'-debug-unaligned.apk' + 'mac':'.app', + 'ios':'.app', + 'android':'-debug-unaligned.apk' } if os.environ.has_key('APP_FILE_SUFFIX'): - str_app_suffix = os.environ['APP_FILE_SUFFIX'] - APP_FILE_SUFFIX = eval(str_app_suffix) + str_app_suffix = os.environ['APP_FILE_SUFFIX'] + APP_FILE_SUFFIX = eval(str_app_suffix) def getPackageSize(): - for proj in project_types: - for phone in phonePlats: - # if runSupport[curPlat][phone]: - package_path = './'+proj+PROJ_SUFFIX+'/'+APP_FILE_DIR[proj]+phone+'/'+proj+PROJ_SUFFIX+APP_FILE_SUFFIX[phone] - print 'package_path', package_path - package_size = 0 - if os.path.isfile(package_path): - package_size = os.path.getsize(package_path); - else: - package_size = getdirsize(package_path); - strSize = 'size of '+proj+PROJ_SUFFIX+' '+phone+' is:'+str(package_size/(1024))+'KB'+'\n\t' - print 'strSize:', strSize - appendToResult(strSize) + for proj in project_types: + for phone in phonePlats: + # if runSupport[curPlat][phone]: + package_path = './'+proj+PROJ_SUFFIX+'/'+APP_FILE_DIR[proj]+phone+'/'+proj+PROJ_SUFFIX+APP_FILE_SUFFIX[phone] + print 'package_path', package_path + package_size = 0 + if os.path.isfile(package_path): + package_size = os.path.getsize(package_path); + else: + package_size = getdirsize(package_path); + strSize = 'size of '+proj+PROJ_SUFFIX+' '+phone+' is:'+str(package_size/(1024))+'KB'+'\n\t' + print 'strSize:', strSize + appendToResult(strSize) def main(): - print 'in main:' - # start_android_simulator() - print 'will build_run:' - build_run(-1) - print 'ANY_ERROR_IN_RUN:', ANY_ERROR_IN_RUN - print 'end build run. and get package size.' - getPackageSize() - print 'will send email:' - print 'console_result:', console_result - if OBJ_EMAIL_INFO[ EMAIL_KEYS[5] ] or ANY_ERROR_IN_RUN: - sendEmail(console_result) + print 'in main:' + # start_android_simulator() + print 'will build_run:' + build_run(-1) + print 'ANY_ERROR_IN_RUN:', ANY_ERROR_IN_RUN + print 'end build run. and get package size.' + getPackageSize() + print 'will send email:' + print 'console_result:', console_result + if OBJ_EMAIL_INFO[ EMAIL_KEYS[5] ] or ANY_ERROR_IN_RUN: + sendEmail(console_result) # -------------- main -------------- if __name__ == '__main__': sys_ret = 0 try: - sys_ret = main() + sys_ret = main() except: - traceback.print_exc() - sys_ret = 1 + traceback.print_exc() + sys_ret = 1 finally: - sys.exit(sys_ret) + sys.exit(sys_ret) diff --git a/tools/jenkins-scripts/configs/autotest.py b/tools/jenkins-scripts/configs/autotest.py index 5e6a6098a8..ea57782db7 100644 --- a/tools/jenkins-scripts/configs/autotest.py +++ b/tools/jenkins-scripts/configs/autotest.py @@ -6,5 +6,5 @@ ret = os.system('python -u tools/jenkins-scripts/autotest.py') os.system('git reset --hard') print ret if(ret > 0): - ret = 1 + ret = 1 exit(ret) diff --git a/tools/jenkins-scripts/configs/cocos-2dx-develop-android.py b/tools/jenkins-scripts/configs/cocos-2dx-develop-android.py index e632c330c5..60bdd4a173 100644 --- a/tools/jenkins-scripts/configs/cocos-2dx-develop-android.py +++ b/tools/jenkins-scripts/configs/cocos-2dx-develop-android.py @@ -5,10 +5,10 @@ print ' Branch:develop' print ' Target:Android' print ' build script:python build/android-build.py all' if(os.path.exists('build/android-build.py') == False): - node_name = os.environ['NODE_NAME'] - source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name + "/." - os.system("cp -r" + source_dir + " .") - os.system('git pull origin develop') + node_name = os.environ['NODE_NAME'] + source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name + "/." + os.system("cp -r" + source_dir + " .") + os.system('git pull origin develop') os.system('git submodule update --init --force') ret = os.system('python build/android-build.py -n -j8 all') @@ -16,6 +16,6 @@ os.system('git clean -xdf -f') print 'build exit' print ret if ret == 0: - exit(0) + exit(0) else: - exit(1) + exit(1) diff --git a/tools/jenkins-scripts/configs/cocos-2dx-develop-base-repo.py b/tools/jenkins-scripts/configs/cocos-2dx-develop-base-repo.py index f70b31d568..c7cd0f2fd3 100644 --- a/tools/jenkins-scripts/configs/cocos-2dx-develop-base-repo.py +++ b/tools/jenkins-scripts/configs/cocos-2dx-develop-base-repo.py @@ -2,20 +2,20 @@ import os import sys def check_ret(ret): - if(ret != 0): - os.system('git checkout -B develop remotes/origin/develop') - os.system('git clean -xdf -f') - sys.exit(1) + if(ret != 0): + os.system('git checkout -B develop remotes/origin/develop') + os.system('git clean -xdf -f') + sys.exit(1) branchs = ['develop', 'master'] for item in branchs: - os.system('git clean -xdf -f') - os.system('git checkout -B ' + item + ' remotes/origin/' + item) - os.system('git clean -xdf -f') - ret = os.system('git pull origin') - check_ret(ret) - ret = os.system('git submodule update --init --force') - check_ret(ret) + os.system('git clean -xdf -f') + os.system('git checkout -B ' + item + ' remotes/origin/' + item) + os.system('git clean -xdf -f') + ret = os.system('git pull origin') + check_ret(ret) + ret = os.system('git submodule update --init --force') + check_ret(ret) #back to develop os.system('git checkout -B develop remotes/origin/develop') diff --git a/tools/jenkins-scripts/configs/cocos-2dx-develop-ios.py b/tools/jenkins-scripts/configs/cocos-2dx-develop-ios.py index 7a0c672f47..0dedd56b3c 100644 --- a/tools/jenkins-scripts/configs/cocos-2dx-develop-ios.py +++ b/tools/jenkins-scripts/configs/cocos-2dx-develop-ios.py @@ -4,10 +4,10 @@ print ' Host:MAC' print ' Branch:develop' print ' Target:iOS' if(os.path.exists('tools/jenkins-scripts/ios-build.sh') == False): - node_name = os.environ['NODE_NAME'] - source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name + "/." - os.system("cp -r " + source_dir + " .") - os.system('git pull origin develop') + node_name = os.environ['NODE_NAME'] + source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name + "/." + os.system("cp -r " + source_dir + " .") + os.system('git pull origin develop') os.system('git submodule update --init --force') ret = os.system('tools/jenkins-scripts/ios-build.sh') @@ -15,6 +15,6 @@ os.system('git clean -xdf -f') print 'build exit' print ret if ret == 0: - exit(0) + exit(0) else: - exit(1) + exit(1) diff --git a/tools/jenkins-scripts/configs/cocos-2dx-develop-win32.py b/tools/jenkins-scripts/configs/cocos-2dx-develop-win32.py index 801874494e..1e55080898 100644 --- a/tools/jenkins-scripts/configs/cocos-2dx-develop-win32.py +++ b/tools/jenkins-scripts/configs/cocos-2dx-develop-win32.py @@ -7,11 +7,11 @@ print ' Branch:develop' print ' Target:win32' print ' "%VS110COMNTOOLS%..\IDE\devenv.com" "build\cocos2d-win32.vc2012.sln" /Build "Debug|Win32"' if(os.path.exists('build/cocos2d-win32.vc2012.sln') == False): - node_name = os.environ['NODE_NAME'] - source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name - source_dir = source_dir.replace("/", os.sep) - os.system("xcopy " + source_dir + " . /E /Y /H") - os.system('git pull origin develop') + node_name = os.environ['NODE_NAME'] + source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name + source_dir = source_dir.replace("/", os.sep) + os.system("xcopy " + source_dir + " . /E /Y /H") + os.system('git pull origin develop') os.system('git submodule update --init --force') ret = subprocess.call('"%VS110COMNTOOLS%..\IDE\devenv.com" "build\cocos2d-win32.vc2012.sln" /Build "Debug|Win32"', shell=True) @@ -19,6 +19,6 @@ os.system('git clean -xdf -f') print 'build exit' print ret if ret == 0: - exit(0) + exit(0) else: - exit(1) + exit(1) diff --git a/tools/jenkins-scripts/configs/cocos-2dx-doxygen.py b/tools/jenkins-scripts/configs/cocos-2dx-doxygen.py index 4367230caf..2dadb80233 100644 --- a/tools/jenkins-scripts/configs/cocos-2dx-doxygen.py +++ b/tools/jenkins-scripts/configs/cocos-2dx-doxygen.py @@ -5,11 +5,11 @@ print ' Branch:develop' print ' Target:Doxygen' print ' doxygen doxygen.config' if(os.path.exists('docs/doxygen.config') == False): - node_name = os.environ['NODE_NAME'] - source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name - source_dir = source_dir.replace("/", os.sep) - os.system("xcopy " + source_dir + " . /E /Y /H") - os.system('git pull origin develop') + node_name = os.environ['NODE_NAME'] + source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name + source_dir = source_dir.replace("/", os.sep) + os.system("xcopy " + source_dir + " . /E /Y /H") + os.system('git pull origin develop') os.system('git submodule update --init --force') os.chdir('docs/') @@ -19,6 +19,6 @@ os.system('git clean -xdf -f') print 'build exit' print ret if ret == 0: - exit(0) + exit(0) else: - exit(1) + exit(1) diff --git a/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build-comment-trigger.py b/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build-comment-trigger.py index e7817809c5..3cc1053ce3 100644 --- a/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build-comment-trigger.py +++ b/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build-comment-trigger.py @@ -3,6 +3,6 @@ import os #os.system('git pull origin develop') ret = os.system('python -u tools/jenkins-scripts/job-comment-trigger.py') if ret == 0: - exit(0) + exit(0) else: - exit(1) + exit(1) diff --git a/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build-trigger.py b/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build-trigger.py index 60c79ddc94..fcdca42b38 100644 --- a/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build-trigger.py +++ b/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build-trigger.py @@ -3,6 +3,6 @@ import os #os.system('git pull origin develop') ret = os.system('python -u tools/jenkins-scripts/job-trigger.py') if ret == 0: - exit(0) + exit(0) else: - exit(1) + exit(1) diff --git a/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build.py b/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build.py index a09fdf2b79..6783e89cb9 100644 --- a/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build.py +++ b/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build.py @@ -1,17 +1,17 @@ import os import platform if(os.path.exists('tools/jenkins-scripts/pull-request-builder.py') == False): - node_name = os.environ['NODE_NAME'] - source_dir = '../../../cocos-2dx-develop-base-repo/node/' + node_name - if(platform.system() == 'Windows'): - source_dir = source_dir.replace("/", os.sep) - os.system("xcopy " + source_dir + ' . /E /Y /H') - else: - os.system("cp -r " + source_dir + "/. .") + node_name = os.environ['NODE_NAME'] + source_dir = '../../../cocos-2dx-develop-base-repo/node/' + node_name + if(platform.system() == 'Windows'): + source_dir = source_dir.replace("/", os.sep) + os.system("xcopy " + source_dir + ' . /E /Y /H') + else: + os.system("cp -r " + source_dir + "/. .") def clean_workspace(): - os.system('git reset --hard') - os.system('git clean -xdf -f') + os.system('git reset --hard') + os.system('git clean -xdf -f') clean_workspace() os.system('git checkout develop') @@ -19,14 +19,14 @@ clean_workspace() os.system('git pull origin develop') for i in range(0, 3): - ret = os.system('python -u tools/jenkins-scripts/pull-request-builder.py') - if(ret > 255): - ret >>= 8 - if(ret == 0) or (ret == 1): - break + ret = os.system('python -u tools/jenkins-scripts/pull-request-builder.py') + if(ret > 255): + ret >>= 8 + if(ret == 0) or (ret == 1): + break clean_workspace() print ret if(ret > 0): - ret = 1 + ret = 1 exit(ret) diff --git a/tools/jenkins-scripts/configs/cocos2d-console-test.py b/tools/jenkins-scripts/configs/cocos2d-console-test.py index 26a2492a2f..9e58f9f1ec 100644 --- a/tools/jenkins-scripts/configs/cocos2d-console-test.py +++ b/tools/jenkins-scripts/configs/cocos2d-console-test.py @@ -8,5 +8,5 @@ ret = os.system('python -u tools/jenkins-scripts/cocos-console-test.py') os.system('git reset --hard') print ret if(ret > 0): - ret = 1 + ret = 1 exit(ret) diff --git a/tools/jenkins-scripts/configs/cocostudiox-base-repo.py b/tools/jenkins-scripts/configs/cocostudiox-base-repo.py index 91aeb02ee0..8c264bc7df 100644 --- a/tools/jenkins-scripts/configs/cocostudiox-base-repo.py +++ b/tools/jenkins-scripts/configs/cocostudiox-base-repo.py @@ -2,7 +2,7 @@ import os import sys ret = os.system('git pull origin master') if(ret != 0): - sys.exit(1) + sys.exit(1) ret = os.system('git submodule update --init --force') if(ret != 0): - sys.exit(1) + sys.exit(1) diff --git a/tools/jenkins-scripts/configs/cocostudiox-daily-build.py b/tools/jenkins-scripts/configs/cocostudiox-daily-build.py index 00cf754f82..b7f0e04a5c 100644 --- a/tools/jenkins-scripts/configs/cocostudiox-daily-build.py +++ b/tools/jenkins-scripts/configs/cocostudiox-daily-build.py @@ -1,13 +1,13 @@ import os import platform if(os.path.exists('CocoStudio/CSX/CSX/CSX.pro') == False): - node_name = os.environ['NODE_NAME'] - source_dir = '../../../cocostudiox-base-repo/node/' + node_name - if(platform.system() == 'Windows'): - source_dir = source_dir.replace("/", os.sep) - os.system("xcopy " + source_dir + ' . /E /Y /H') - else: - os.system("cp -r " + source_dir + "/. .") + node_name = os.environ['NODE_NAME'] + source_dir = '../../../cocostudiox-base-repo/node/' + node_name + if(platform.system() == 'Windows'): + source_dir = source_dir.replace("/", os.sep) + os.system("xcopy " + source_dir + ' . /E /Y /H') + else: + os.system("cp -r " + source_dir + "/. .") os.system('git pull origin') os.system('git submodule update --init --force') @@ -16,15 +16,15 @@ node_name = os.environ['NODE_NAME'] os.chdir('CocoStudio/CSX/CSX') ret = os.system('qmake -r') if(ret == 0): - if(node_name == 'android_mac'): - ret = os.system('make -j8') - elif(node_name == 'win32_win7'): - ret = os.system('mingw32-make -j8') + if(node_name == 'android_mac'): + ret = os.system('make -j8') + elif(node_name == 'win32_win7'): + ret = os.system('mingw32-make -j8') os.chdir('../../..') os.system('git clean -xdf') os.system('git reset --hard') print ret if(ret > 0): - ret = 1 + ret = 1 exit(ret) diff --git a/tools/jenkins-scripts/emptytest.py b/tools/jenkins-scripts/emptytest.py index d5cc7e3f9a..86d671981a 100644 --- a/tools/jenkins-scripts/emptytest.py +++ b/tools/jenkins-scripts/emptytest.py @@ -19,290 +19,290 @@ import paramiko payload = {} #get payload from os env if os.environ.has_key('payload'): - payload_str = os.environ['payload'] - #parse to json obj - payload = json.loads(payload_str) + payload_str = os.environ['payload'] + #parse to json obj + payload = json.loads(payload_str) print 'payload:',payload pr_num = 6326 #get pull number if payload.has_key('number'): - pr_num = payload['number'] + pr_num = payload['number'] print 'pr_num:' + str(pr_num) run_app_time = 5 if os.environ.has_key('RUN_APP_TIME'): - run_app_time = os.environ['RUN_APP_TIME'] + run_app_time = os.environ['RUN_APP_TIME'] print 'run_app_time:', run_app_time test_name = ['cpp_empty_test'] if os.environ.has_key('TESTS_NAME'): - temp_var = os.environ['TESTS_NAME'] - test_name = temp_var.split(', ') + temp_var = os.environ['TESTS_NAME'] + test_name = temp_var.split(', ') package_name = ['org.cocos2dx.cpp_empty_test'] if os.environ.has_key('PACKAGE_NAME'): - temp_var = os.environ['PACKAGE_NAME'] - package_name = temp_var.split(', ') + temp_var = os.environ['PACKAGE_NAME'] + package_name = temp_var.split(', ') activity_name = ['org.cocos2dx.cpp_empty_test.AppActivity'] if os.environ.has_key('ACTIVITY_NAME'): - temp_var = os.environ['ACTIVITY_NAME'] - activity_name = temp_var.split(', ') + temp_var = os.environ['ACTIVITY_NAME'] + activity_name = temp_var.split(', ') gIdx = 0 if os.environ.has_key('TEST_INDEX'): - gIdx = os.environ('TEST_INDEX') + gIdx = os.environ('TEST_INDEX') current_platform = platform.system() print 'current platform is:', current_platform arrDevices = [] def getDevices(): - cmd = 'adb devices' - info_devices = os.popen(cmd).read() - arr_info = info_devices.split('\n') - del arr_info[0] - count = 0 - for device in arr_info: - if len(device) > 0: - count += 1 - print 'device ', count,device - deviceInfo = device.split(' ') - global arrDevices - obj = {} - obj['name'] = deviceInfo[0] - arrDevices.append(obj) - return count + cmd = 'adb devices' + info_devices = os.popen(cmd).read() + arr_info = info_devices.split('\n') + del arr_info[0] + count = 0 + for device in arr_info: + if len(device) > 0: + count += 1 + print 'device ', count,device + deviceInfo = device.split(' ') + global arrDevices + obj = {} + obj['name'] = deviceInfo[0] + arrDevices.append(obj) + return count def getADBDeviceIP(device_name): - output = os.popen("adb -s "+device_name+" shell netcfg") - configs = output.read().split('\r\n') - output.close() - for l in configs: - items = l.split() - if len(items)>1 and items[1] == 'UP': - if items[2].find('127.0.0.1') < 0 and items[2].find('0.0.0.0') < 0: - return items[2] - return False + output = os.popen("adb -s "+device_name+" shell netcfg") + configs = output.read().split('\r\n') + output.close() + for l in configs: + items = l.split() + if len(items)>1 and items[1] == 'UP': + if items[2].find('127.0.0.1') < 0 and items[2].find('0.0.0.0') < 0: + return items[2] + return False def mapIP(): - for device in arrDevices: - ip_d = getADBDeviceIP(device['name']) - device['ip'] = ip_d + for device in arrDevices: + ip_d = getADBDeviceIP(device['name']) + device['ip'] = ip_d allThreadIsRunning = {} def setThreadStatus(): - for device in arrDevices: - allThreadIsRunning[device['name']] = 1 + for device in arrDevices: + allThreadIsRunning[device['name']] = 1 devices_info = {} info_list = '{"product":["model","brand","name","cpu.abi","cpu.abi2","manufacturer","locale.language","locale.region"],"build":["id","version.sdk","version.release"]}' if os.environ.has_key('DEVICE_INFO_LIST'): - info_list = os.environ['DEVICE_INFO_LIST'] + info_list = os.environ['DEVICE_INFO_LIST'] info_list = eval(info_list) def getDeviceInfoByName(name): - cmd = '' - dev_name = name - if len(name) > 0: - cmd = 'adb -s '+name+' shell cat /system/build.prop' - else: - cmd = 'adb shell cat /system/build.prop' - dev_name = 'device one' - pip_cat = os.popen(cmd) - read_info = pip_cat.read() - read_info_list = read_info.split('\r\n') - device_info_one = {} - def checkProperty(item_str, device_name): - for argv in info_list: - for item in info_list[argv]: - prop = argv+'.'+item - if item_str.find(prop) > -1: - arr_item = item_str.split('=') - device_info_one[prop] = arr_item[1] - break - for item in read_info_list: - checkProperty(item, dev_name) - devices_info[dev_name] = device_info_one + cmd = '' + dev_name = name + if len(name) > 0: + cmd = 'adb -s '+name+' shell cat /system/build.prop' + else: + cmd = 'adb shell cat /system/build.prop' + dev_name = 'device one' + pip_cat = os.popen(cmd) + read_info = pip_cat.read() + read_info_list = read_info.split('\r\n') + device_info_one = {} + def checkProperty(item_str, device_name): + for argv in info_list: + for item in info_list[argv]: + prop = argv+'.'+item + if item_str.find(prop) > -1: + arr_item = item_str.split('=') + device_info_one[prop] = arr_item[1] + break + for item in read_info_list: + checkProperty(item, dev_name) + devices_info[dev_name] = device_info_one #getDeviceInfoByName('') #print 'device_info:',device_info def getDeviceInfomation(): - for device in arrDevices: - getDeviceInfoByName(device['name']) + for device in arrDevices: + getDeviceInfoByName(device['name']) info_empty_test = {} info_empty_test_pro = ['install','open','socket','uninstall'] def init_info_empty_test(): - for item in info_empty_test_pro: - info_empty_test[item] = {} + for item in info_empty_test_pro: + info_empty_test[item] = {} init_info_empty_test() apk_name = 'apks/'+test_name[gIdx]+'/'+test_name[gIdx]+'_'+str(pr_num)+'.apk' def install_apk_on_device(device): - name = device['name'] - cmd = 'adb -s '+name+' install '+apk_name - print 'install on '+name - info_install = os.popen(cmd).read() - print 'infomation of install apk:', info_install - info_install_arr = info_install.split('\r\n') - info_install_result = False - for item in info_install_arr: - if item.find('Success') > -1: - info_install_result = True - info_empty_test['install'][name] = info_install_result - return True + name = device['name'] + cmd = 'adb -s '+name+' install '+apk_name + print 'install on '+name + info_install = os.popen(cmd).read() + print 'infomation of install apk:', info_install + info_install_arr = info_install.split('\r\n') + info_install_result = False + for item in info_install_arr: + if item.find('Success') > -1: + info_install_result = True + info_empty_test['install'][name] = info_install_result + return True def open_apk_on_device(device): - print 'will open activity:' - name = device['name'] - cmd = 'adb -s '+name+' shell am start -n '+package_name[gIdx]+'/'+activity_name[gIdx] - # print 'start activity:', cmd - info_start = os.popen(cmd).read() - info_start = info_start.split('\r\n') - # print 'info_start:', info_start - info_start_result = True - for info in info_start: - if info.find('Error:') > -1: - print 'infomation of open activity:',info - info_start_result = False - info_empty_test['open'][name] = info_start_result - return True + print 'will open activity:' + name = device['name'] + cmd = 'adb -s '+name+' shell am start -n '+package_name[gIdx]+'/'+activity_name[gIdx] + # print 'start activity:', cmd + info_start = os.popen(cmd).read() + info_start = info_start.split('\r\n') + # print 'info_start:', info_start + info_start_result = True + for info in info_start: + if info.find('Error:') > -1: + print 'infomation of open activity:',info + info_start_result = False + info_empty_test['open'][name] = info_start_result + return True PORT = 5678 def socket_status_on_device(device): - name = device['name'] - ip = device['ip'] - soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) - status_socket = False - info_of_socket_result = '' - try: - print 'telnet ', ip, PORT - soc.connect((ip, PORT)) - cmd = 'resolution\r\n' - print 'connected successfully.' - print 'send console command: resolution' - soc.send(cmd) - while True: - data = soc.recv(1024) - if len(data): - print data - if data.find('size:') > -1: - info_of_socket_result = 'OK' - print 'close', test_name[gIdx] - soc.send('director end') - status_socket = True - break - if not data: - info_of_socket_result = test_name[gIdx]+' is crashed!' - break - except Exception, e: - info_of_socket_result = test_name[gIdx]+' is crashed!' - time.sleep(2) - soc.close() - time.sleep(2) - info_empty_test['socket'][name] = info_of_socket_result - return status_socket + name = device['name'] + ip = device['ip'] + soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) + status_socket = False + info_of_socket_result = '' + try: + print 'telnet ', ip, PORT + soc.connect((ip, PORT)) + cmd = 'resolution\r\n' + print 'connected successfully.' + print 'send console command: resolution' + soc.send(cmd) + while True: + data = soc.recv(1024) + if len(data): + print data + if data.find('size:') > -1: + info_of_socket_result = 'OK' + print 'close', test_name[gIdx] + soc.send('director end') + status_socket = True + break + if not data: + info_of_socket_result = test_name[gIdx]+' is crashed!' + break + except Exception, e: + info_of_socket_result = test_name[gIdx]+' is crashed!' + time.sleep(2) + soc.close() + time.sleep(2) + info_empty_test['socket'][name] = info_of_socket_result + return status_socket def uninstall_apk_on_device(device): - # adb shell pm uninstall -n org.cocos2dx.hellolua - print 'uninstall ', test_name[gIdx] - name = device['name'] - cmd = 'adb -s '+name+' shell pm uninstall -n '+package_name[gIdx] - info_uninstall = os.popen(cmd).read() - info_uninstall_result = '' - if info_uninstall.find('Success') > -1: - info_uninstall_result = 'OK' - else: - info_uninstall_result = 'uninstall Failed!' - info_empty_test['uninstall'][name] = info_uninstall_result - return True + # adb shell pm uninstall -n org.cocos2dx.hellolua + print 'uninstall ', test_name[gIdx] + name = device['name'] + cmd = 'adb -s '+name+' shell pm uninstall -n '+package_name[gIdx] + info_uninstall = os.popen(cmd).read() + info_uninstall_result = '' + if info_uninstall.find('Success') > -1: + info_uninstall_result = 'OK' + else: + info_uninstall_result = 'uninstall Failed!' + info_empty_test['uninstall'][name] = info_uninstall_result + return True def excute_test_on_device(device): - uninstall_apk_on_device(device) - print device - info_install = install_apk_on_device(device) - print 'install:', info_install - info_open = open_apk_on_device(device) - print 'open:', info_open - time.sleep(3) - info_socket = socket_status_on_device(device) - print 'socket:', info_socket - info_uninstall = uninstall_apk_on_device(device) - print 'uninstall:', info_uninstall - allThreadIsRunning[device['name']] = 0 + uninstall_apk_on_device(device) + print device + info_install = install_apk_on_device(device) + print 'install:', info_install + info_open = open_apk_on_device(device) + print 'open:', info_open + time.sleep(3) + info_socket = socket_status_on_device(device) + print 'socket:', info_socket + info_uninstall = uninstall_apk_on_device(device) + print 'uninstall:', info_uninstall + allThreadIsRunning[device['name']] = 0 address_of_result_html = '' def send_result_to_master(): - if not os.environ.has_key('REMOTE_IP'): - return false - remote_ip = os.environ['REMOTE_IP'] - remote_port = os.environ['REMOTE_PORT'] - remote_user = os.environ['REMOTE_USER'] - remote_pwd = os.environ['REMOTE_PWD'] - remote_dir = os.environ['REMOTE_DIR'] - remote_dir = remote_dir + str(pr_num)+'/' - print remote_dir - ssh = paramiko.SSHClient() - print 'ssh:',ssh - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - ssh.connect(remote_ip, int(remote_port), remote_user, remote_pwd) - # create dir - stdin, stdout, stderr = ssh.exec_command("mkdir "+remote_dir) - ssh.close() - trans = paramiko.Transport((remote_ip,int(remote_port))) - trans.connect(username = remote_user, password = remote_pwd) - sftp = paramiko.SFTPClient.from_transport(trans) - remotepath = remote_dir+test_name[gIdx]+'_'+str(pr_num)+'.html' - localpath = 'html/cpp_empty_test/cpp_empty_test_'+str(pr_num)+'.html' - sftp.put(localpath, remotepath) - sftp.close() - result_dir = remote_dir.replace('/data',':9000') - global address_of_result_html - address_of_result_html = 'http://'+remote_ip+result_dir+test_name[gIdx]+'_'+str(pr_num)+'.html' - + if not os.environ.has_key('REMOTE_IP'): + return false + remote_ip = os.environ['REMOTE_IP'] + remote_port = os.environ['REMOTE_PORT'] + remote_user = os.environ['REMOTE_USER'] + remote_pwd = os.environ['REMOTE_PWD'] + remote_dir = os.environ['REMOTE_DIR'] + remote_dir = remote_dir + str(pr_num)+'/' + print remote_dir + ssh = paramiko.SSHClient() + print 'ssh:',ssh + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + ssh.connect(remote_ip, int(remote_port), remote_user, remote_pwd) + # create dir + stdin, stdout, stderr = ssh.exec_command("mkdir "+remote_dir) + ssh.close() + trans = paramiko.Transport((remote_ip,int(remote_port))) + trans.connect(username = remote_user, password = remote_pwd) + sftp = paramiko.SFTPClient.from_transport(trans) + remotepath = remote_dir+test_name[gIdx]+'_'+str(pr_num)+'.html' + localpath = 'html/cpp_empty_test/cpp_empty_test_'+str(pr_num)+'.html' + sftp.put(localpath, remotepath) + sftp.close() + result_dir = remote_dir.replace('/data',':9000') + global address_of_result_html + address_of_result_html = 'http://'+remote_ip+result_dir+test_name[gIdx]+'_'+str(pr_num)+'.html' + def check_thread_is_running(): - while 1: - in_running = 0 - for key in allThreadIsRunning: - in_running = in_running + allThreadIsRunning[key] - # print 'in_running:', in_running - time.sleep(3) - if not in_running: - break - print 'all cpp emptytest is finished.' - log_emptytest_result() - print 'will send result:' - send_result_to_master() - print 'end of check thread is running.' - print 'address of result is:',address_of_result_html + while 1: + in_running = 0 + for key in allThreadIsRunning: + in_running = in_running + allThreadIsRunning[key] + # print 'in_running:', in_running + time.sleep(3) + if not in_running: + break + print 'all cpp emptytest is finished.' + log_emptytest_result() + print 'will send result:' + send_result_to_master() + print 'end of check thread is running.' + print 'address of result is:',address_of_result_html def generate_html_with_result(result): - target_path = 'html/cpp_empty_test/cpp_empty_test_'+str(pr_num)+'.html' - data = codecs.open('hello.html', encoding='UTF-8').read() - data = re.sub("content", result, data) - codecs.open(target_path, 'wb', encoding='UTF-8').write(data) + target_path = 'html/cpp_empty_test/cpp_empty_test_'+str(pr_num)+'.html' + data = codecs.open('hello.html', encoding='UTF-8').read() + data = re.sub("content", result, data) + codecs.open(target_path, 'wb', encoding='UTF-8').write(data) empty_test_result = True str_result = '' def log_emptytest_result(): - def appendToResult(one_str): - global str_result - str_result = str_result + one_str + '\r\n' - appendToResult('
')
-	appendToResult('empty test start:')
-	for device in arrDevices:
-		name = device['name']
-		appendToResult('device infomation of : '+name)
-		for key in devices_info[name]:
-			appendToResult('\t'+key+':'+devices_info[name][key])
-		appendToResult('install: ' + str(info_empty_test['install'][name]))
-		appendToResult('open: ' + str(info_empty_test['open'][name]))
-		appendToResult('telnet ' + str(device['ip'])+' : ' + str(info_empty_test['socket'][name]))
-		appendToResult('close: ' + str(info_empty_test['socket'][name]))
-		appendToResult('uninstall: ' + str(info_empty_test['uninstall'][name]))
-		if not info_empty_test['install'][name] or not info_empty_test['open'][name] or not info_empty_test['socket'][name] or not info_empty_test['uninstall'][name]:
-			empty_test_result = False
-			appendToResult('run failed!')
-		else: appendToResult('run successfully!')
-		appendToResult('')
-	appendToResult('empty test end.
') - generate_html_with_result(str_result) - print 'log empty test end' + def appendToResult(one_str): + global str_result + str_result = str_result + one_str + '\r\n' + appendToResult('
')
+    appendToResult('empty test start:')
+    for device in arrDevices:
+        name = device['name']
+        appendToResult('device infomation of : '+name)
+        for key in devices_info[name]:
+            appendToResult('\t'+key+':'+devices_info[name][key])
+        appendToResult('install: ' + str(info_empty_test['install'][name]))
+        appendToResult('open: ' + str(info_empty_test['open'][name]))
+        appendToResult('telnet ' + str(device['ip'])+' : ' + str(info_empty_test['socket'][name]))
+        appendToResult('close: ' + str(info_empty_test['socket'][name]))
+        appendToResult('uninstall: ' + str(info_empty_test['uninstall'][name]))
+        if not info_empty_test['install'][name] or not info_empty_test['open'][name] or not info_empty_test['socket'][name] or not info_empty_test['uninstall'][name]:
+            empty_test_result = False
+            appendToResult('run failed!')
+        else: appendToResult('run successfully!')
+        appendToResult('')
+    appendToResult('empty test end.
') + generate_html_with_result(str_result) + print 'log empty test end' class myThread(threading.Thread): def __init__(self,threadname): @@ -316,39 +316,39 @@ class myThread(threading.Thread): excute_test_on_device(device) def run_emptytest(): - for device in arrDevices: - th = myThread(device) - th.start() + for device in arrDevices: + th = myThread(device) + th.start() def main(): - print 'in main:' - getDevices() - if len(arrDevices): - mapIP() - setThreadStatus() - print 'arrDevices:',arrDevices - time.sleep(1) - else: - print 'there is no device for emptytest, please check devices!' - return 1 - if len(arrDevices): - getDeviceInfomation() - run_emptytest() - check_thread_is_running() - print 'info_empty_test:', info_empty_test - print 'empty test end', empty_test_result - if empty_test_result: - return 0 - else: - return 1 + print 'in main:' + getDevices() + if len(arrDevices): + mapIP() + setThreadStatus() + print 'arrDevices:',arrDevices + time.sleep(1) + else: + print 'there is no device for emptytest, please check devices!' + return 1 + if len(arrDevices): + getDeviceInfomation() + run_emptytest() + check_thread_is_running() + print 'info_empty_test:', info_empty_test + print 'empty test end', empty_test_result + if empty_test_result: + return 0 + else: + return 1 # -------------- main -------------- if __name__ == '__main__': sys_ret = 0 try: - sys_ret = main() + sys_ret = main() except: - traceback.print_exc() - sys_ret = 1 + traceback.print_exc() + sys_ret = 1 finally: - sys.exit(sys_ret) + sys.exit(sys_ret) diff --git a/tools/jenkins-scripts/github-pr-watchdog.py b/tools/jenkins-scripts/github-pr-watchdog.py index d5c417730e..0f38b46117 100644 --- a/tools/jenkins-scripts/github-pr-watchdog.py +++ b/tools/jenkins-scripts/github-pr-watchdog.py @@ -12,61 +12,61 @@ job_trigger_url=os.environ['JOB_PULL_REQUEST_BUILD_TRIGGER_URL'] access_token = os.environ['GITHUB_ACCESS_TOKEN'] Headers = {"Authorization":"token " + access_token} def main(): - r = requests.get(url,headers=Headers) - payload = r.json() - #print payload - for pr in payload: - pr_num = pr['number'] - r = requests.get(pr['url']+"/commits",headers=Headers) - commits = r.json() - #print commits - last_commit = commits[len(commits)-1] - message = last_commit['commit']['message'] - - #print message - pattern = re.compile("\[ci(\s+)skip\]", re.I) - result_commit_title = pattern.search(message) + r = requests.get(url,headers=Headers) + payload = r.json() + #print payload + for pr in payload: + pr_num = pr['number'] + r = requests.get(pr['url']+"/commits",headers=Headers) + commits = r.json() + #print commits + last_commit = commits[len(commits)-1] + message = last_commit['commit']['message'] + + #print message + pattern = re.compile("\[ci(\s+)skip\]", re.I) + result_commit_title = pattern.search(message) - title = pr['title'] - result_pr_title = pattern.search(title) - if result_commit_title is not None or result_pr_title is not None: - print 'skip build for pull request #' + str(pr_num) - break - #return(0) - s = pr['statuses_url'] - update_time = pr['updated_at'] - #print pr_num - #print s - #print update_time - t = datetime.datetime.strptime(update_time, "%Y-%m-%dT%H:%M:%SZ") - now = datetime.datetime.utcnow() - three_minutes = datetime.timedelta(seconds=3*60) - if (t + three_minutes < now): - #print pr_num - statuses = requests.get(s, headers=Headers) - #print statuses.json() - if(len(statuses.json()) < 1): - print pr_num - payload_forward = {} - payload_forward['number']=pr_num - payload_forward['action']=pr['state'] - payload_forward['html_url']=pr['html_url'] - payload_forward['statuses_url']=pr['statuses_url'] - payload_forward['branch']=pr['base']['ref'] - print payload_forward - post_data = {'payload':""} - post_data['payload']= json.dumps(payload_forward) + title = pr['title'] + result_pr_title = pattern.search(title) + if result_commit_title is not None or result_pr_title is not None: + print 'skip build for pull request #' + str(pr_num) + break + #return(0) + s = pr['statuses_url'] + update_time = pr['updated_at'] + #print pr_num + #print s + #print update_time + t = datetime.datetime.strptime(update_time, "%Y-%m-%dT%H:%M:%SZ") + now = datetime.datetime.utcnow() + three_minutes = datetime.timedelta(seconds=3*60) + if (t + three_minutes < now): + #print pr_num + statuses = requests.get(s, headers=Headers) + #print statuses.json() + if(len(statuses.json()) < 1): + print pr_num + payload_forward = {} + payload_forward['number']=pr_num + payload_forward['action']=pr['state'] + payload_forward['html_url']=pr['html_url'] + payload_forward['statuses_url']=pr['statuses_url'] + payload_forward['branch']=pr['base']['ref'] + print payload_forward + post_data = {'payload':""} + post_data['payload']= json.dumps(payload_forward) - requests.post(job_trigger_url, data=post_data) + requests.post(job_trigger_url, data=post_data) # -------------- main -------------- if __name__ == '__main__': sys_ret = 0 try: - main() + main() except: - traceback.print_exc() - sys_ret = 1 + traceback.print_exc() + sys_ret = 1 finally: - sys.exit(sys_ret) + sys.exit(sys_ret) diff --git a/tools/jenkins-scripts/post-build.py b/tools/jenkins-scripts/post-build.py index 2efc346ded..68d9055111 100644 --- a/tools/jenkins-scripts/post-build.py +++ b/tools/jenkins-scripts/post-build.py @@ -33,10 +33,10 @@ def send_mail(sub,title,content): return False def sendEmail(pr, html_url, target_url): - sub = "Pull request #" + str(pr) + " build is failed!" - title = "build failed!" - content = 'to view build result, check:\r\n'+target_url + '\r\nYou can view the failed pr at:\r\n'+html_url - send_mail(sub, title, content) + sub = "Pull request #" + str(pr) + " build is failed!" + title = "build failed!" + content = 'to view build result, check:\r\n'+target_url + '\r\nYou can view the failed pr at:\r\n'+html_url + send_mail(sub, title, content) payload_str = os.environ['payload'] payload_str = payload_str.decode('utf-8','ignore') diff --git a/tools/jenkins-scripts/reboot.py b/tools/jenkins-scripts/reboot.py index 8d21c6d175..22f6a1b05c 100755 --- a/tools/jenkins-scripts/reboot.py +++ b/tools/jenkins-scripts/reboot.py @@ -25,40 +25,40 @@ print 'remote_port',int(remote_port[0]) all_machines = {} def set_default_value_to_all_machines(): - for idx, item in enumerate(remote_machines): - all_machines[item]={} - all_machines[item]['ip']=remote_ip[idx] - all_machines[item]['dir']=remote_dir[idx] - all_machines[item]['port']=remote_port[idx] - all_machines[item]['user']=remote_user[idx] - all_machines[item]['pwd']=os.environ[item+'_PWD'] + for idx, item in enumerate(remote_machines): + all_machines[item]={} + all_machines[item]['ip']=remote_ip[idx] + all_machines[item]['dir']=remote_dir[idx] + all_machines[item]['port']=remote_port[idx] + all_machines[item]['user']=remote_user[idx] + all_machines[item]['pwd']=os.environ[item+'_PWD'] def reboot_machine(machine, item): - print 'machine:',machine, 'item:', item - remote_ip = machine['ip'] - remote_port = machine['port'] - remote_user = machine['user'] - remote_pwd = machine['pwd'] - remote_dir = os.path.join(machine['dir'],'workspace','reboot', 'reboot.py') - print remote_dir - ssh = paramiko.SSHClient() - print 'ssh:',ssh - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - ssh.connect(remote_ip, int(remote_port), remote_user, remote_pwd) - # excute reboot.py on machine - cmd = 'python '+remote_dir - if item == 'win32_win7': - cmd = 'cmd.exe /c "python '+remote_dir+'"' - stdin, stdout, stderr = ssh.exec_command(cmd) - print stdout.readlines() - ssh.close() - print 'OK' + print 'machine:',machine, 'item:', item + remote_ip = machine['ip'] + remote_port = machine['port'] + remote_user = machine['user'] + remote_pwd = machine['pwd'] + remote_dir = os.path.join(machine['dir'],'workspace','reboot', 'reboot.py') + print remote_dir + ssh = paramiko.SSHClient() + print 'ssh:',ssh + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + ssh.connect(remote_ip, int(remote_port), remote_user, remote_pwd) + # excute reboot.py on machine + cmd = 'python '+remote_dir + if item == 'win32_win7': + cmd = 'cmd.exe /c "python '+remote_dir+'"' + stdin, stdout, stderr = ssh.exec_command(cmd) + print stdout.readlines() + ssh.close() + print 'OK' def main(): - print 'in main' - set_default_value_to_all_machines() - for item in all_machines: - reboot_machine( all_machines[item], item ) + print 'in main' + set_default_value_to_all_machines() + for item in all_machines: + reboot_machine( all_machines[item], item ) # -------------- main -------------- if __name__ == '__main__': From ee259f19b7fac021c9661d3f4173818f236d98c5 Mon Sep 17 00:00:00 2001 From: kompjoefriek Date: Tue, 10 Feb 2015 21:31:16 +0100 Subject: [PATCH 2/6] Merged with upstream/v3 --- CHANGELOG | 4 +- CMakeLists.txt | 46 ++- cmake/Modules/CocosUsePrebuiltLibs.cmake | 2 +- cocos/2d/CCClippingNode.cpp | 3 +- cocos/2d/CCDrawNode.cpp | 2 + cocos/2d/CCLabel.cpp | 2 +- cocos/2d/libcocos2d.vcxproj | 5 +- cocos/2d/libcocos2d.vcxproj.filters | 15 +- .../libcocos2d_8_1.Windows.vcxproj | 12 +- .../libcocos2d_8_1.WindowsPhone.vcxproj | 8 +- cocos/2d/libcocos2d_wp8.vcxproj | 8 +- cocos/3d/CCBillBoard.cpp | 15 +- cocos/3d/CCBillBoard.h | 1 + cocos/3d/CCObjLoader.cpp | 2 +- cocos/CMakeLists.txt | 8 +- cocos/network/HttpClient-android.cpp | 1 + cocos/network/HttpClient-ios.mm | 7 +- cocos/platform/win32/CCDevice-win32.cpp | 45 ++- cocos/renderer/CCGLProgram.cpp | 17 +- cocos/renderer/CCGLProgram.h | 2 +- cocos/renderer/CCGroupCommand.cpp | 12 +- cocos/renderer/CCGroupCommand.h | 2 + cocos/renderer/CCMeshCommand.cpp | 61 ++-- cocos/renderer/CCMeshCommand.h | 3 +- cocos/renderer/CCRenderer.cpp | 5 - cocos/scripting/lua-bindings/CMakeLists.txt | 9 +- .../lua-bindings/auto/api/AsyncTaskPool.lua | 26 ++ .../lua-bindings/auto/api/Sprite3D.lua | 11 - .../lua-bindings/auto/api/Sprite3DCache.lua | 31 +++ .../auto/api/lua_cocos2dx_3d_auto_api.lua | 5 + .../auto/api/lua_cocos2dx_auto_api.lua | 5 + .../auto/lua_cocos2dx_3d_auto.cpp | 263 +++++++++++++----- .../auto/lua_cocos2dx_3d_auto.hpp | 4 + .../lua-bindings/auto/lua_cocos2dx_auto.cpp | 142 ++++++++++ .../lua-bindings/auto/lua_cocos2dx_auto.hpp | 4 + .../manual/3d/lua_cocos2dx_3d_manual.cpp | 84 ++++++ .../proj.win32/libluacocos2d.vcxproj | 4 +- .../script/cocos2d/Cocos2dConstants.lua | 9 + docs/RELEASE_NOTES.md | 11 +- extensions/assets-manager/AssetsManagerEx.cpp | 3 - templates/cocos2dx_files.json | 2 + tests/cpp-tests/CMakeLists.txt | 5 + .../Classes/Camera3DTest/Camera3DTest.cpp | 1 + .../cpp-tests/Classes/LabelTest/LabelTest.cpp | 6 +- .../Classes/Sprite3DTest/Sprite3DTest.cpp | 39 ++- .../Classes/Sprite3DTest/Sprite3DTest.h | 9 + tests/lua-tests/src/BugsTest/BugsTest.lua | 3 - .../src/ParallaxTest/ParallaxTest.lua | 1 - .../src/Sprite3DTest/Sprite3DTest.lua | 108 +++++++ tools/tolua/cocos2dx.ini | 4 +- tools/tolua/cocos2dx_3d.ini | 7 +- 51 files changed, 876 insertions(+), 208 deletions(-) create mode 100644 cocos/scripting/lua-bindings/auto/api/AsyncTaskPool.lua create mode 100644 cocos/scripting/lua-bindings/auto/api/Sprite3DCache.lua diff --git a/CHANGELOG b/CHANGELOG index e728782803..fa834df3ff 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,13 +1,15 @@ -cocos2d-x-3.4 xxx +cocos2d-x-3.4 Jan.30 2015 [FIX] Animate3D: `setSpeed` has not effect if `Animate3D` is used in Sequence [FIX] C++: will crash if built with armeabi-v7a enabled on Android devices that with armeabi-v7a architecture but doesn't support NEON instructions [FIX] C++: may crash if VAO is not supported [FIX] EditBox: content is not clipped correctly on windows [FIX] GLProgram: will cause crash on some devices that don't support more than 8 atrributes + [FIX] HttpClient: not set response code when connecting failed on Android [FIX] Label: alpha channel of text color of system font has not effect [FIX] Label: use int for dimensions that will lose the precision [FIX] Label: labels will become white block after resume from background on some Android devices, such as xiaomi3 [FIX] Label: improved parsing performance of bitmap font + [FIX] Label: can not display `&` if using system font on windows [FIX] Lua-binding:studio-support: AnimationInfo is not binded [FIX] New audio: not close file descriptor leads to that may causes game freeze if playing two many times(may be more than 1000) on Android [FIX] Node: anchor point has not effect to rotation, it always rotate along (0, 0) diff --git a/CMakeLists.txt b/CMakeLists.txt index 60325ad8c5..694dae692a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,12 @@ cmake_minimum_required(VERSION 2.8) # also from cmake's Modules dir, to not clash with per-project files. cmake_policy(SET CMP0017 NEW) +# Use new behaviour with cmake >= 3.0: +# Only interpret if() arguments as variables or keywords when unquoted. +if(CMAKE_VERSION VERSION_GREATER 3) + cmake_policy(SET CMP0054 NEW) +endif() + project (Cocos2d-X) # The version number @@ -49,6 +55,16 @@ if(MINGW) set(USE_PREBUILT_LIBS_DEFAULT OFF) endif() +set(BUILD_CPP_TESTS_DEFAULT ON) +set(BUILD_LUA_LIBS_DEFAULT ON) +set(BUILD_LUA_TESTS_DEFAULT ON) +# TODO: fix test samples for MSVC +if(MSVC) + set(BUILD_CPP_TESTS_DEFAULT OFF) + set(BUILD_LUA_LIBS_DEFAULT OFF) + set(BUILD_LUA_TESTS_DEFAULT OFF) +endif() + option(USE_CHIPMUNK "Use chipmunk for physics library" ON) option(USE_BOX2D "Use box2d for physics library" OFF) option(USE_WEBP "Use WebP codec" ${USE_WEBP_DEFAULT}) @@ -58,9 +74,9 @@ option(BUILD_EXTENSIONS "Build extension library" ON) option(BUILD_EDITOR_SPINE "Build editor support for spine" ON) option(BUILD_EDITOR_COCOSTUDIO "Build editor support for cocostudio" ON) option(BUILD_EDITOR_COCOSBUILDER "Build editor support for cocosbuilder" ON) -option(BUILD_CPP_TESTS "Build TestCpp samples" ON) -option(BUILD_LUA_LIBS "Build lua libraries" ON) -option(BUILD_LUA_TESTS "Build TestLua samples" ON) +option(BUILD_CPP_TESTS "Build TestCpp samples" ${BUILD_CPP_TESTS_DEFAULT}) +option(BUILD_LUA_LIBS "Build lua libraries" ${BUILD_LUA_LIBS_DEFAULT}) +option(BUILD_LUA_TESTS "Build TestLua samples" ${BUILD_LUA_TESTS_DEFAULT}) option(USE_PREBUILT_LIBS "Use prebuilt libraries in external directory" ${USE_PREBUILT_LIBS_DEFAULT}) if(USE_PREBUILT_LIBS AND MINGW) @@ -81,6 +97,14 @@ if(MSVC) ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -wd4251 -wd4244 -wd4334 -wd4005 -wd4820 -wd4710 -wd4514 -wd4056 -wd4996 -wd4099) + + # Use inline debug info (/Z7) format. Or internal error may occur. + # Errors looks like: "xmemory0(592): error C3130: Internal Compiler Error: failed to write injected code block to PDB" + foreach(lang C CXX) + string(REGEX REPLACE "/Z[iI7]" "" CMAKE_${lang}_FLAGS_DEBUG "${CMAKE_${lang}_FLAGS_DEBUG}") + set(CMAKE_${lang}_FLAGS_DEBUG "${CMAKE_${lang}_FLAGS_DEBUG} /Z7") + endforeach() + else() set(CMAKE_C_FLAGS_DEBUG "-g -Wall -DCOCOS2D_DEBUG=1") set(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) @@ -150,12 +174,14 @@ if(USE_PREBUILT_LIBS) include(CocosUsePrebuiltLibs) endif() -# GLFW3 used on Mac, Windows and Linux desktop platforms +# desktop platforms if(LINUX OR MACOSX OR WINDOWS) cocos_find_package(OpenGL OPENGL REQUIRED) if(LINUX OR WINDOWS) cocos_find_package(GLEW GLEW REQUIRED) + #TODO: implement correct schema for pass cocos2d specific requirements to projects + include_directories(${GLEW_INCLUDE_DIRS}) endif() cocos_find_package(GLFW3 GLFW3 REQUIRED) @@ -236,9 +262,11 @@ cocos_find_package(ZLIB ZLIB REQUIRED) # moreover our embedded version modified to quick provide # functionality needed by cocos. if(USE_PREBUILT_LIBS OR NOT MINGW) + #TODO: hack! should be in external/unzip/CMakeLists.txt + include_directories(${ZLIB_INCLUDE_DIRS}) add_subdirectory(external/unzip) - set(MINIZIP_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/unzip) - set(MINIZIP_LIBRARIES unzip) + set(MINIZIP_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/unzip ${ZLIB_INCLUDE_DIRS}) + set(MINIZIP_LIBRARIES unzip ${ZLIB_LIBRARIES}) message(STATUS "MINIZIP include dirs: ${MINIZIP_INCLUDE_DIRS}") else() cocos_find_package(MINIZIP MINIZIP REQUIRED) @@ -261,10 +289,10 @@ set(FLATBUFFERS_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external) message(STATUS "Flatbuffers include dirs: ${FLATBUFFERS_INCLUDE_DIRS}") -# build for 3rd party libraries -if(LINUX OR APPLE) +# build xxhash add_subdirectory(external/xxhash) -endif() +set(XXHASH_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/external/xxhash) +set(XXHASH_LIBRARIES xxhash) # libcocos2d.a add_subdirectory(cocos) diff --git a/cmake/Modules/CocosUsePrebuiltLibs.cmake b/cmake/Modules/CocosUsePrebuiltLibs.cmake index 15344102f3..8be727e40f 100644 --- a/cmake/Modules/CocosUsePrebuiltLibs.cmake +++ b/cmake/Modules/CocosUsePrebuiltLibs.cmake @@ -36,7 +36,7 @@ set(_sqlite3_inc sqlite3.h) set(_sqlite3_libs sqlite3) set(_gles_prefix GLEW) -set(_gles_inc glew.h) +set(_gles_inc GL/glew.h) set(_gles_inc_paths OGLES) set(_gles_libs glew32) diff --git a/cocos/2d/CCClippingNode.cpp b/cocos/2d/CCClippingNode.cpp index 4cb2180915..de31dba134 100644 --- a/cocos/2d/CCClippingNode.cpp +++ b/cocos/2d/CCClippingNode.cpp @@ -218,7 +218,8 @@ void ClippingNode::drawFullScreenQuadClearStencil() glProgram->use(); glProgram->setUniformsForBuiltins(); glProgram->setUniformLocationWith4fv(colorLocation, (GLfloat*) &color.r, 1); - + + glBindBuffer(GL_ARRAY_BUFFER, 0); GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION ); glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); diff --git a/cocos/2d/CCDrawNode.cpp b/cocos/2d/CCDrawNode.cpp index 91cd48152e..e72f5c9e21 100644 --- a/cocos/2d/CCDrawNode.cpp +++ b/cocos/2d/CCDrawNode.cpp @@ -274,6 +274,8 @@ bool DrawNode::init() glGenBuffers(1, &_vboGLPoint); glBindBuffer(GL_ARRAY_BUFFER, _vboGLPoint); glBufferData(GL_ARRAY_BUFFER, sizeof(V2F_C4B_T2F)*_bufferCapacityGLPoint, _bufferGLPoint, GL_STREAM_DRAW); + + glBindBuffer(GL_ARRAY_BUFFER, 0); } CHECK_GL_ERROR_DEBUG(); diff --git a/cocos/2d/CCLabel.cpp b/cocos/2d/CCLabel.cpp index 2135ad75eb..42a78e22c5 100644 --- a/cocos/2d/CCLabel.cpp +++ b/cocos/2d/CCLabel.cpp @@ -896,8 +896,8 @@ void Label::drawShadowWithoutBlur() void Label::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) { // Don't do calculate the culling if the transform was not updated -#if CC_USE_CULLING bool transformUpdated = flags & FLAGS_TRANSFORM_DIRTY; +#if CC_USE_CULLING _insideBounds = transformUpdated ? renderer->checkVisibility(transform, _contentSize) : _insideBounds; if(_insideBounds) diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index fb0b1f4062..4df8209fb3 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -587,7 +587,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - @@ -658,8 +657,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - - @@ -825,6 +822,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + + diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index 7862cbe2c6..98fedbaec1 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -1639,12 +1639,6 @@ base - - base - - - base - base @@ -1876,9 +1870,6 @@ base - - 3d - 3d @@ -2548,6 +2539,12 @@ physics + + platform + + + platform + diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj index 934482d522..0054ce136d 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.Windows/libcocos2d_8_1.Windows.vcxproj @@ -144,7 +144,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) @@ -162,7 +162,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) @@ -180,7 +180,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) @@ -198,7 +198,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) @@ -216,7 +216,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) @@ -234,7 +234,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\winrt_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\winrt_8.1;$(EngineRoot)external\websockets\include\winrt_8.1;$(EngineRoot)external\curl\include\winrt_8.1;$(EngineRoot)external\tiff\include\winrt_8.1;$(EngineRoot)external\jpeg\include\winrt_8.1;$(EngineRoot)external\png\include\winrt_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) _USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) diff --git a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj index 5bc2b1b499..97c1d2e342 100644 --- a/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj +++ b/cocos/2d/libcocos2d_8_1/libcocos2d_8_1/libcocos2d_8_1.WindowsPhone/libcocos2d_8_1.WindowsPhone.vcxproj @@ -106,7 +106,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) CC_NO_GL_POINTSIZE;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) @@ -124,7 +124,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) CC_NO_GL_POINTSIZE;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) @@ -142,7 +142,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) CC_NO_GL_POINTSIZE;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) @@ -160,7 +160,7 @@ Use true - /Zm200 %(AdditionalOptions) + /Zm384 %(AdditionalOptions) pch.h $(EngineRoot)external\wp_8.1-specific\zlib\include;$(EngineRoot)external\freetype2\include\wp_8.1;$(EngineRoot)external\websockets\include\wp_8.1;$(EngineRoot)external\curl\include\wp_8.1;$(EngineRoot)external\tiff\include\wp_8.1;$(EngineRoot)external\jpeg\include\wp_8.1;$(EngineRoot)external\png\include\wp_8.1;$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) CC_NO_GL_POINTSIZE;_USRDLL;_LIB;COCOS2DXWIN32_EXPORTS;_USE3DDLL;_EXPORT_DLL_;_USRSTUDIODLL;_USREXDLL;_USEGUIDLL;CC_ENABLE_CHIPMUNK_INTEGRATION=1;NDEBUG;%(PreprocessorDefinitions) diff --git a/cocos/2d/libcocos2d_wp8.vcxproj b/cocos/2d/libcocos2d_wp8.vcxproj index d3ba865a77..c9b10d10d2 100644 --- a/cocos/2d/libcocos2d_wp8.vcxproj +++ b/cocos/2d/libcocos2d_wp8.vcxproj @@ -93,7 +93,7 @@ true $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) $(EngineRoot)external\jpeg\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\tiff\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\png\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) - /Zm256 /bigobj %(AdditionalOptions) + /Zm384 /bigobj %(AdditionalOptions) pch.h @@ -114,7 +114,7 @@ true $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) $(EngineRoot)external\jpeg\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\tiff\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\png\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) - /Zm256 /bigobj %(AdditionalOptions) + /Zm384 /bigobj %(AdditionalOptions) pch.h @@ -135,7 +135,7 @@ true $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) $(EngineRoot)external\jpeg\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\tiff\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\png\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) - /Zm256 /bigobj %(AdditionalOptions) + /Zm384 /bigobj %(AdditionalOptions) pch.h @@ -156,7 +156,7 @@ true $(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories) $(EngineRoot)external\jpeg\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\tiff\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\png\include\$(COCOS2D_PLATFORM);$(EngineRoot)external\protobuf-lite\src;$(EngineRoot)external\protobuf-lite\win32;%(AdditionalIncludeDirectories) - /Zm256 /bigobj %(AdditionalOptions) + /Zm384 /bigobj %(AdditionalOptions) pch.h diff --git a/cocos/3d/CCBillBoard.cpp b/cocos/3d/CCBillBoard.cpp index 67f2a6816a..8a26a8c93f 100644 --- a/cocos/3d/CCBillBoard.cpp +++ b/cocos/3d/CCBillBoard.cpp @@ -102,6 +102,9 @@ void BillBoard::visit(Renderer *renderer, const Mat4& parentTransform, uint32_t { return; } + bool visibleByCamera = isVisitableByVisitingCamera(); + if (!visibleByCamera && _children.empty()) + return; uint32_t flags = processParentFlags(parentTransform, parentFlags); @@ -119,7 +122,7 @@ void BillBoard::visit(Renderer *renderer, const Mat4& parentTransform, uint32_t director->pushMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW); director->loadMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW, _modelViewTransform); - bool visibleByCamera = isVisitableByVisitingCamera(); + int i = 0; @@ -158,7 +161,7 @@ bool BillBoard::calculateBillbaordTransform() const Mat4& camWorldMat = camera->getNodeToWorldTransform(); //TODO: use math lib to calculate math lib Make it easier to read and maintain - if (memcmp(_camWorldMat.m, camWorldMat.m, sizeof(float) * 16) != 0 || _transformDirty || _modeDirty) + if (memcmp(_camWorldMat.m, camWorldMat.m, sizeof(float) * 16) != 0 || memcmp(_mvTransform.m, _modelViewTransform.m, sizeof(float) * 16) != 0 || _modeDirty || true) { //Rotate based on anchor point Vec3 anchorPoint(_anchorPointInPoints.x , _anchorPointInPoints.y , 0.0f); @@ -190,13 +193,9 @@ bool BillBoard::calculateBillbaordTransform() Quaternion rotationQuaternion; this->getNodeToWorldTransform().getRotation(&rotationQuaternion); - // fetch the rotation angle of z - float rotationZ = atan2(2*(rotationQuaternion.w*rotationQuaternion.z + rotationQuaternion.x*rotationQuaternion.y), - (1 - 2* (rotationQuaternion.y*rotationQuaternion.y + rotationQuaternion.z *rotationQuaternion.z))); Mat4 rotationMatrix; rotationMatrix.setIdentity(); - rotationMatrix.rotateZ(rotationZ); - + Vec3 upAxis = Vec3(rotationMatrix.m[4],rotationMatrix.m[5],rotationMatrix.m[6]); Vec3 x, y; camWorldMat.transformVector(upAxis, &y); @@ -217,7 +216,7 @@ bool BillBoard::calculateBillbaordTransform() billboardTransform.m[12] = localToWorld.m[12]; billboardTransform.m[13] = localToWorld.m[13]; billboardTransform.m[14] = localToWorld.m[14]; billboardTransform.translate(-anchorPoint); - _modelViewTransform = billboardTransform; + _mvTransform = _modelViewTransform = billboardTransform; _camWorldMat = camWorldMat; diff --git a/cocos/3d/CCBillBoard.h b/cocos/3d/CCBillBoard.h index b2f5ac8937..13862a97ee 100644 --- a/cocos/3d/CCBillBoard.h +++ b/cocos/3d/CCBillBoard.h @@ -105,6 +105,7 @@ protected: bool calculateBillbaordTransform(); Mat4 _camWorldMat; + Mat4 _mvTransform; Mode _mode; bool _modeDirty; diff --git a/cocos/3d/CCObjLoader.cpp b/cocos/3d/CCObjLoader.cpp index 01da07a27c..eb77f2a7d5 100644 --- a/cocos/3d/CCObjLoader.cpp +++ b/cocos/3d/CCObjLoader.cpp @@ -289,7 +289,7 @@ std::string LoadMtl ( std::map& material_map filepath = std::string(filename); } - std::ifstream ifs(filepath.c_str()); + std::istringstream ifs(FileUtils::getInstance()->getStringFromFile(filepath)); if (!ifs) { err << "Cannot open file [" << filepath << "]" << std::endl; diff --git a/cocos/CMakeLists.txt b/cocos/CMakeLists.txt index aceedb2d8c..2f337551f1 100644 --- a/cocos/CMakeLists.txt +++ b/cocos/CMakeLists.txt @@ -79,9 +79,7 @@ set(COCOS_SRC cocos2d.cpp ) #todo: provide prebuild versions of the xx libs for all platforms - include_directories( - ../external/xxhash - ../external/xxtea) + include_directories(../external/xxtea) add_library(cocos2d ${COCOS_SRC}) @@ -127,11 +125,11 @@ else() message( FATAL_ERROR "Unsupported platform, CMake will exit" ) endif() -foreach(pkg ZLIB MINIZIP JPEG PNG TIFF TinyXML2 FREETYPE WEBSOCKETS CURL FLATBUFFERS) +foreach(pkg ZLIB MINIZIP JPEG PNG TIFF TinyXML2 FREETYPE WEBSOCKETS CURL FLATBUFFERS XXHASH) cocos_use_pkg(cocos2d ${pkg}) endforeach() -target_link_libraries(cocos2d xxhash ${PLATFORM_SPECIFIC_LIBS}) +target_link_libraries(cocos2d ${PLATFORM_SPECIFIC_LIBS}) if(USE_WEBP) add_definitions(-DCC_USE_WEBP=1) diff --git a/cocos/network/HttpClient-android.cpp b/cocos/network/HttpClient-android.cpp index a8d1932027..ea81d79279 100644 --- a/cocos/network/HttpClient-android.cpp +++ b/cocos/network/HttpClient-android.cpp @@ -687,6 +687,7 @@ static void processResponse(HttpResponse* response, std::string& responseMessage { response->setSucceed(false); response->setErrorBuffer("connect failed"); + response->setResponseCode(responseCode); return; } diff --git a/cocos/network/HttpClient-ios.mm b/cocos/network/HttpClient-ios.mm index 5be5271ffc..9a63e5e265 100644 --- a/cocos/network/HttpClient-ios.mm +++ b/cocos/network/HttpClient-ios.mm @@ -170,6 +170,10 @@ static int processTask(HttpRequest *request, NSString* requestType, void *stream //if request type is post or put,set header and data if([requestType isEqual: @"POST"] || [requestType isEqual: @"PUT"]) { + if ([requestType isEqual: @"PUT"]) + { + [nsrequest setValue: @"application/x-www-form-urlencoded" forHTTPHeaderField: @"Content-Type"]; + } /* get custom header data (if set) */ std::vector headers=request->getHeaders(); if(!headers.empty()) @@ -190,8 +194,7 @@ static int processTask(HttpRequest *request, NSString* requestType, void *stream char* requestDataBuffer = request->getRequestData(); if (nullptr != requestDataBuffer && 0 != strlen(requestDataBuffer)) { - NSString* requestData = [NSString stringWithUTF8String:requestDataBuffer]; - NSData *postData = [requestData dataUsingEncoding:NSUTF8StringEncoding]; + NSData *postData = [NSData dataWithBytes:requestDataBuffer length:request->getRequestDataSize()]; [nsrequest setHTTPBody:postData]; } } diff --git a/cocos/platform/win32/CCDevice-win32.cpp b/cocos/platform/win32/CCDevice-win32.cpp index 40272ec0de..a56a7320ac 100644 --- a/cocos/platform/win32/CCDevice-win32.cpp +++ b/cocos/platform/win32/CCDevice-win32.cpp @@ -246,6 +246,7 @@ public: { int nRet = 0; wchar_t * pwszBuffer = 0; + wchar_t* fixedText = nullptr; do { CC_BREAK_IF(! pszText); @@ -276,7 +277,37 @@ public: memset(pwszBuffer, 0, sizeof(wchar_t)*nBufLen); nLen = MultiByteToWideChar(CP_UTF8, 0, pszText, nLen, pwszBuffer, nBufLen); - SIZE newSize = sizeWithText(pwszBuffer, nLen, dwFmt, tSize.cx); + if (strchr(pszText, '&')) + { + fixedText = new wchar_t[nLen * 2 + 1]; + int fixedIndex = 0; + for (int index = 0; index < nLen; ++index) + { + if (pwszBuffer[index] == '&') + { + fixedText[fixedIndex] = '&'; + fixedText[fixedIndex + 1] = '&'; + fixedIndex += 2; + } + else + { + fixedText[fixedIndex] = pwszBuffer[index]; + fixedIndex += 1; + } + } + fixedText[fixedIndex] = '\0'; + nLen = fixedIndex; + } + + SIZE newSize; + if (fixedText) + { + newSize = sizeWithText(fixedText, nLen, dwFmt, tSize.cx); + } + else + { + newSize = sizeWithText(pwszBuffer, nLen, dwFmt, tSize.cx); + } RECT rcText = {0}; // if content width is 0, use text size as content size @@ -343,13 +374,23 @@ public: SetTextColor(_DC, RGB(255, 255, 255)); // white color // draw text - nRet = DrawTextW(_DC, pwszBuffer, nLen, &rcText, dwFmt); + if (fixedText) + { + nRet = DrawTextW(_DC, fixedText, nLen, &rcText, dwFmt); + } + else + { + nRet = DrawTextW(_DC, pwszBuffer, nLen, &rcText, dwFmt); + } + //DrawTextA(_DC, pszText, nLen, &rcText, dwFmt); SelectObject(_DC, hOldBmp); SelectObject(_DC, hOldFont); } while (0); CC_SAFE_DELETE_ARRAY(pwszBuffer); + delete[] fixedText; + return nRet; } diff --git a/cocos/renderer/CCGLProgram.cpp b/cocos/renderer/CCGLProgram.cpp index 9acf163444..be3856748f 100644 --- a/cocos/renderer/CCGLProgram.cpp +++ b/cocos/renderer/CCGLProgram.cpp @@ -163,7 +163,7 @@ GLProgram::~GLProgram() for (auto e : _hashForUniforms) { - free(e.second); + free(e.second.first); } _hashForUniforms.clear(); } @@ -666,17 +666,24 @@ bool GLProgram::updateUniformLocation(GLint location, const GLvoid* data, unsign { GLvoid* value = malloc(bytes); memcpy(value, data, bytes ); - _hashForUniforms.insert(std::make_pair(location, value)); + _hashForUniforms.insert(std::make_pair(location, std::make_pair(value, bytes))); } else { - if (memcmp(element->second, data, bytes) == 0) + if (memcmp(element->second.first, data, bytes) == 0) { updated = false; } else { - memcpy(element->second, data, bytes); + if (element->second.second < bytes) + { + GLvoid* value = realloc(element->second.first, bytes); + memcpy(value, data, bytes ); + _hashForUniforms[location] = std::make_pair(value, bytes); + } + else + memcpy(element->second.first, data, bytes); } } @@ -937,7 +944,7 @@ void GLProgram::reset() for (auto e: _hashForUniforms) { - free(e.second); + free(e.second.first); } _hashForUniforms.clear(); diff --git a/cocos/renderer/CCGLProgram.h b/cocos/renderer/CCGLProgram.h index 08bea2c021..9fc77e8b28 100644 --- a/cocos/renderer/CCGLProgram.h +++ b/cocos/renderer/CCGLProgram.h @@ -361,7 +361,7 @@ protected: std::unordered_map _userUniforms; std::unordered_map _vertexAttribs; - std::unordered_map _hashForUniforms; + std::unordered_map> _hashForUniforms; //cached director pointer for calling Director* _director; }; diff --git a/cocos/renderer/CCGroupCommand.cpp b/cocos/renderer/CCGroupCommand.cpp index 576dab111e..24874f4351 100644 --- a/cocos/renderer/CCGroupCommand.cpp +++ b/cocos/renderer/CCGroupCommand.cpp @@ -49,13 +49,12 @@ bool GroupCommandManager::init() int GroupCommandManager::getGroupID() { //Reuse old id - for(auto it = _groupMapping.begin(); it != _groupMapping.end(); ++it) + if (!_unusedIDs.empty()) { - if(!it->second) - { - _groupMapping[it->first] = true; - return it->first; - } + int groupID = *_unusedIDs.rbegin(); + _unusedIDs.pop_back(); + _groupMapping[groupID] = true; + return groupID; } //Create new ID @@ -69,6 +68,7 @@ int GroupCommandManager::getGroupID() void GroupCommandManager::releaseGroupID(int groupID) { _groupMapping[groupID] = false; + _unusedIDs.push_back(groupID); } GroupCommand::GroupCommand() diff --git a/cocos/renderer/CCGroupCommand.h b/cocos/renderer/CCGroupCommand.h index 96fa8f70da..c261234ed8 100644 --- a/cocos/renderer/CCGroupCommand.h +++ b/cocos/renderer/CCGroupCommand.h @@ -26,6 +26,7 @@ #ifndef _CC_GROUPCOMMAND_H_ #define _CC_GROUPCOMMAND_H_ +#include #include #include "base/CCRef.h" @@ -45,6 +46,7 @@ protected: ~GroupCommandManager(); bool init(); std::unordered_map _groupMapping; + std::vector _unusedIDs; }; class CC_DLL GroupCommand : public RenderCommand diff --git a/cocos/renderer/CCMeshCommand.cpp b/cocos/renderer/CCMeshCommand.cpp index 48685f2c64..dd80bb31c7 100644 --- a/cocos/renderer/CCMeshCommand.cpp +++ b/cocos/renderer/CCMeshCommand.cpp @@ -83,6 +83,10 @@ MeshCommand::MeshCommand() , _cullFace(GL_BACK) , _depthTestEnabled(false) , _depthWriteEnabled(false) +, _forceDepthWrite(false) +, _renderStateCullFaceEnabled(false) +, _renderStateDepthTest(false) +, _renderStateDepthWrite(GL_FALSE) , _lightMask(-1) { _type = RenderCommand::Type::MESH_COMMAND; @@ -168,7 +172,11 @@ void MeshCommand::setTransparent(bool value) //Skip batching for transparent mesh _skipBatching = value; - if (!_forceDepthWrite) + if (_isTransparent && !_forceDepthWrite) + { + _depthWriteEnabled = false; + } + else { _depthWriteEnabled = true; } @@ -184,48 +192,55 @@ MeshCommand::~MeshCommand() void MeshCommand::applyRenderState() { - _renderStateCullFace = glIsEnabled(GL_CULL_FACE); + _renderStateCullFaceEnabled = glIsEnabled(GL_CULL_FACE); _renderStateDepthTest = glIsEnabled(GL_DEPTH_TEST); glGetBooleanv(GL_DEPTH_WRITEMASK, &_renderStateDepthWrite); + GLint cullface; + glGetIntegerv(GL_CULL_FACE_MODE, &cullface); + _renderStateCullFace = (GLenum)cullface; - if (_cullFaceEnabled && !_renderStateCullFace) + if (_cullFaceEnabled != _renderStateCullFaceEnabled) { - glEnable(GL_CULL_FACE); + _cullFaceEnabled ? glEnable(GL_CULL_FACE) : glDisable(GL_CULL_FACE); } - glCullFace(_cullFace); - - if (_depthTestEnabled && !_renderStateDepthTest) + if (_cullFace != _renderStateCullFace) { - glEnable(GL_DEPTH_TEST); + glCullFace(_cullFace); } - if (_depthWriteEnabled && !_renderStateDepthWrite) + + if (_depthTestEnabled != _renderStateDepthTest) { - glDepthMask(GL_TRUE); + _depthTestEnabled ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST); + } + + if (_depthWriteEnabled != _renderStateDepthWrite) + { + glDepthMask(_depthWriteEnabled); } } void MeshCommand::restoreRenderState() { - if (_renderStateCullFace) + if (_cullFaceEnabled != _renderStateCullFaceEnabled) { - glEnable(GL_CULL_FACE); - } - else - { - glDisable(GL_CULL_FACE); + _renderStateCullFaceEnabled ? glEnable(GL_CULL_FACE) : glDisable(GL_CULL_FACE); } - if (_renderStateDepthTest) + if (_cullFace != _renderStateCullFace) { - glEnable(GL_DEPTH_TEST); - } - else - { - glDisable(GL_DEPTH_TEST); + glCullFace(_renderStateCullFace); } - glDepthMask(_renderStateDepthTest); + if (_depthTestEnabled != _renderStateDepthTest) + { + _renderStateDepthTest ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST); + } + + if (_depthWriteEnabled != _renderStateDepthWrite) + { + glDepthMask(_renderStateDepthWrite); + } } void MeshCommand::genMaterialID(GLuint texID, void* glProgramState, GLuint vertexBuffer, GLuint indexBuffer, const BlendFunc& blend) diff --git a/cocos/renderer/CCMeshCommand.h b/cocos/renderer/CCMeshCommand.h index 128c294913..35855b8992 100644 --- a/cocos/renderer/CCMeshCommand.h +++ b/cocos/renderer/CCMeshCommand.h @@ -129,9 +129,10 @@ protected: bool _depthWriteEnabled; bool _forceDepthWrite; - bool _renderStateCullFace; + bool _renderStateCullFaceEnabled; bool _renderStateDepthTest; GLboolean _renderStateDepthWrite; + GLenum _renderStateCullFace; // ModelView transform Mat4 _mv; diff --git a/cocos/renderer/CCRenderer.cpp b/cocos/renderer/CCRenderer.cpp index 9754bea3d5..f6e39d9cae 100644 --- a/cocos/renderer/CCRenderer.cpp +++ b/cocos/renderer/CCRenderer.cpp @@ -539,7 +539,6 @@ void Renderer::visitRenderQueue(RenderQueue& queue) { //Clear depth to achieve layered rendering glDepthMask(true); - glClear(GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); for (auto it = opaqueQueue.cbegin(); it != opaqueQueue.cend(); ++it) @@ -586,10 +585,6 @@ void Renderer::visitRenderQueue(RenderQueue& queue) processRenderCommand(*it); } flush(); - - glDepthMask(true); - glClear(GL_DEPTH_BUFFER_BIT); - glDepthMask(false); } // diff --git a/cocos/scripting/lua-bindings/CMakeLists.txt b/cocos/scripting/lua-bindings/CMakeLists.txt index 971f06b140..0322dd47a8 100644 --- a/cocos/scripting/lua-bindings/CMakeLists.txt +++ b/cocos/scripting/lua-bindings/CMakeLists.txt @@ -1,9 +1,5 @@ set(cocos_root ${Cocos2d-X_SOURCE_DIR}) -if(WINDOWS) - add_definitions(-DLUASOCKET_INET_ATON -DLUASOCKET_INET_PTON) -endif() - include_directories( ${cocos_root}/external/lua/tolua ${cocos_root}/external/lua/lua @@ -14,6 +10,7 @@ include_directories( ${cocos_root}/cocos/ui ${cocos_root}/cocos/2d ${cocos_root}/cocos/3d + ${cocos_root}/cocos/base ${cocos_root}/cocos/editor-support/spine ${cocos_root}/cocos/editor-support/cocostudio ${cocos_root}/cocos/editor-support/cocostudio/ActionTimeline @@ -52,6 +49,10 @@ list(APPEND lua_cocos2d_source_files ) if(WINDOWS) + if(MINGW) + add_definitions(-DLUASOCKET_INET_ATON -DLUASOCKET_INET_PTON) + endif() + add_definitions(-DWIN32 -D_WINDOWS) list(APPEND lua_cocos2d_source_files ${cocos_root}/external/lua/luasocket/wsocket.c ) diff --git a/cocos/scripting/lua-bindings/auto/api/AsyncTaskPool.lua b/cocos/scripting/lua-bindings/auto/api/AsyncTaskPool.lua new file mode 100644 index 0000000000..7f083e814f --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/AsyncTaskPool.lua @@ -0,0 +1,26 @@ + +-------------------------------- +-- @module AsyncTaskPool +-- @parent_module cc + +-------------------------------- +-- stop tasks
+-- param type task type you want to stop +-- @function [parent=#AsyncTaskPool] stopTasks +-- @param self +-- @param #int type +-- @return AsyncTaskPool#AsyncTaskPool self (return value: cc.AsyncTaskPool) + +-------------------------------- +-- destroy instance +-- @function [parent=#AsyncTaskPool] destoryInstance +-- @param self +-- @return AsyncTaskPool#AsyncTaskPool self (return value: cc.AsyncTaskPool) + +-------------------------------- +-- get instance +-- @function [parent=#AsyncTaskPool] getInstance +-- @param self +-- @return AsyncTaskPool#AsyncTaskPool ret (return value: cc.AsyncTaskPool) + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/Sprite3D.lua b/cocos/scripting/lua-bindings/auto/api/Sprite3D.lua index d7060da219..d0fa5ee964 100644 --- a/cocos/scripting/lua-bindings/auto/api/Sprite3D.lua +++ b/cocos/scripting/lua-bindings/auto/api/Sprite3D.lua @@ -127,17 +127,6 @@ -- @param #string texturePath -- @return Sprite3D#Sprite3D ret (return value: cc.Sprite3D) --------------------------------- --- @overload self, string, string, function, void --- @overload self, string, function, void --- @function [parent=#Sprite3D] createAsync --- @param self --- @param #string modelPath --- @param #string texturePath --- @param #function callback --- @param #void callbackparam --- @return Sprite3D#Sprite3D self (return value: cc.Sprite3D) - -------------------------------- -- Returns 2d bounding-box
-- Note: the bouding-box is just get from the AABB which as Z=0, so that is not very accurate. diff --git a/cocos/scripting/lua-bindings/auto/api/Sprite3DCache.lua b/cocos/scripting/lua-bindings/auto/api/Sprite3DCache.lua new file mode 100644 index 0000000000..677a5bd770 --- /dev/null +++ b/cocos/scripting/lua-bindings/auto/api/Sprite3DCache.lua @@ -0,0 +1,31 @@ + +-------------------------------- +-- @module Sprite3DCache +-- @parent_module cc + +-------------------------------- +-- +-- @function [parent=#Sprite3DCache] removeSprite3DData +-- @param self +-- @param #string key +-- @return Sprite3DCache#Sprite3DCache self (return value: cc.Sprite3DCache) + +-------------------------------- +-- +-- @function [parent=#Sprite3DCache] removeAllSprite3DData +-- @param self +-- @return Sprite3DCache#Sprite3DCache self (return value: cc.Sprite3DCache) + +-------------------------------- +-- +-- @function [parent=#Sprite3DCache] destroyInstance +-- @param self +-- @return Sprite3DCache#Sprite3DCache self (return value: cc.Sprite3DCache) + +-------------------------------- +-- get & destroy +-- @function [parent=#Sprite3DCache] getInstance +-- @param self +-- @return Sprite3DCache#Sprite3DCache ret (return value: cc.Sprite3DCache) + +return nil diff --git a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua index df2829323b..355592bcc8 100644 --- a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua +++ b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_3d_auto_api.lua @@ -11,6 +11,11 @@ -- @field [parent=#cc] Sprite3D#Sprite3D Sprite3D preloaded module +-------------------------------------------------------- +-- the cc Sprite3DCache +-- @field [parent=#cc] Sprite3DCache#Sprite3DCache Sprite3DCache preloaded module + + -------------------------------------------------------- -- the cc Mesh -- @field [parent=#cc] Mesh#Mesh Mesh preloaded module diff --git a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua index 7ae6c196fa..6b4966fb2f 100644 --- a/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua +++ b/cocos/scripting/lua-bindings/auto/api/lua_cocos2dx_auto_api.lua @@ -1246,4 +1246,9 @@ -- @field [parent=#cc] Component#Component Component preloaded module +-------------------------------------------------------- +-- the cc AsyncTaskPool +-- @field [parent=#cc] AsyncTaskPool#AsyncTaskPool AsyncTaskPool preloaded module + + return nil diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp index 9968e1800a..4523f0a4ae 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.cpp @@ -1267,79 +1267,6 @@ int lua_cocos2dx_3d_Sprite3D_create(lua_State* tolua_S) #endif return 0; } -int lua_cocos2dx_3d_Sprite3D_createAsync(lua_State* tolua_S) -{ - int argc = 0; - bool ok = true; -#if COCOS2D_DEBUG >= 1 - tolua_Error tolua_err; -#endif - -#if COCOS2D_DEBUG >= 1 - if (!tolua_isusertable(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; -#endif - - argc = lua_gettop(tolua_S)-1; - - do - { - if (argc == 4) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Sprite3D:createAsync"); - if (!ok) { break; } - std::string arg1; - ok &= luaval_to_std_string(tolua_S, 3,&arg1, "cc.Sprite3D:createAsync"); - if (!ok) { break; } - std::function arg2; - do { - // Lambda binding for lua is not supported. - assert(false); - } while(0) - ; - if (!ok) { break; } - void* arg3; - #pragma warning NO CONVERSION TO NATIVE FOR void* - ok = false; - if (!ok) { break; } - cocos2d::Sprite3D::createAsync(arg0, arg1, arg2, arg3); - lua_settop(tolua_S, 1); - return 1; - } - } while (0); - ok = true; - do - { - if (argc == 3) - { - std::string arg0; - ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Sprite3D:createAsync"); - if (!ok) { break; } - std::function arg1; - do { - // Lambda binding for lua is not supported. - assert(false); - } while(0) - ; - if (!ok) { break; } - void* arg2; - #pragma warning NO CONVERSION TO NATIVE FOR void* - ok = false; - if (!ok) { break; } - cocos2d::Sprite3D::createAsync(arg0, arg1, arg2); - lua_settop(tolua_S, 1); - return 1; - } - } while (0); - ok = true; - luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.Sprite3D:createAsync",argc, 3); - return 0; -#if COCOS2D_DEBUG >= 1 - tolua_lerror: - tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_createAsync'.",&tolua_err); -#endif - return 0; -} static int lua_cocos2dx_3d_Sprite3D_finalize(lua_State* tolua_S) { printf("luabindings: finalizing LUA object (Sprite3D)"); @@ -1370,7 +1297,6 @@ int lua_register_cocos2dx_3d_Sprite3D(lua_State* tolua_S) tolua_function(tolua_S,"getMeshByName",lua_cocos2dx_3d_Sprite3D_getMeshByName); tolua_function(tolua_S,"getAttachNode",lua_cocos2dx_3d_Sprite3D_getAttachNode); tolua_function(tolua_S,"create", lua_cocos2dx_3d_Sprite3D_create); - tolua_function(tolua_S,"createAsync", lua_cocos2dx_3d_Sprite3D_createAsync); tolua_endmodule(tolua_S); std::string typeName = typeid(cocos2d::Sprite3D).name(); g_luaType[typeName] = "cc.Sprite3D"; @@ -1378,6 +1304,194 @@ int lua_register_cocos2dx_3d_Sprite3D(lua_State* tolua_S) return 1; } +int lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Sprite3DCache* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Sprite3DCache",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Sprite3DCache*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + std::string arg0; + + ok &= luaval_to_std_string(tolua_S, 2,&arg0, "cc.Sprite3DCache:removeSprite3DData"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData'", nullptr); + return 0; + } + cobj->removeSprite3DData(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3DCache:removeSprite3DData",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::Sprite3DCache* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.Sprite3DCache",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::Sprite3DCache*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData'", nullptr); + return 0; + } + cobj->removeAllSprite3DData(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.Sprite3DCache:removeAllSprite3DData",argc, 0); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_3d_Sprite3DCache_destroyInstance(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.Sprite3DCache",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DCache_destroyInstance'", nullptr); + return 0; + } + cocos2d::Sprite3DCache::destroyInstance(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Sprite3DCache:destroyInstance",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DCache_destroyInstance'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_3d_Sprite3DCache_getInstance(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.Sprite3DCache",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_3d_Sprite3DCache_getInstance'", nullptr); + return 0; + } + cocos2d::Sprite3DCache* ret = cocos2d::Sprite3DCache::getInstance(); + object_to_luaval(tolua_S, "cc.Sprite3DCache",(cocos2d::Sprite3DCache*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.Sprite3DCache:getInstance",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3DCache_getInstance'.",&tolua_err); +#endif + return 0; +} +static int lua_cocos2dx_3d_Sprite3DCache_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (Sprite3DCache)"); + return 0; +} + +int lua_register_cocos2dx_3d_Sprite3DCache(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.Sprite3DCache"); + tolua_cclass(tolua_S,"Sprite3DCache","cc.Sprite3DCache","",nullptr); + + tolua_beginmodule(tolua_S,"Sprite3DCache"); + tolua_function(tolua_S,"removeSprite3DData",lua_cocos2dx_3d_Sprite3DCache_removeSprite3DData); + tolua_function(tolua_S,"removeAllSprite3DData",lua_cocos2dx_3d_Sprite3DCache_removeAllSprite3DData); + tolua_function(tolua_S,"destroyInstance", lua_cocos2dx_3d_Sprite3DCache_destroyInstance); + tolua_function(tolua_S,"getInstance", lua_cocos2dx_3d_Sprite3DCache_getInstance); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::Sprite3DCache).name(); + g_luaType[typeName] = "cc.Sprite3DCache"; + g_typeCast["Sprite3DCache"] = "cc.Sprite3DCache"; + return 1; +} + int lua_cocos2dx_3d_Mesh_getMeshVertexAttribCount(lua_State* tolua_S) { int argc = 0; @@ -2881,6 +2995,7 @@ TOLUA_API int register_all_cocos2dx_3d(lua_State* tolua_S) lua_register_cocos2dx_3d_Animate3D(tolua_S); lua_register_cocos2dx_3d_Sprite3D(tolua_S); lua_register_cocos2dx_3d_AttachNode(tolua_S); + lua_register_cocos2dx_3d_Sprite3DCache(tolua_S); lua_register_cocos2dx_3d_BillBoard(tolua_S); lua_register_cocos2dx_3d_Animation3D(tolua_S); lua_register_cocos2dx_3d_Skeleton3D(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp index fb02fc2e6b..3963c71800 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_3d_auto.hpp @@ -67,6 +67,10 @@ int register_all_cocos2dx_3d(lua_State* tolua_S); + + + + diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp index 69cd52ea2a..5349d35a96 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.cpp @@ -1,6 +1,7 @@ #include "lua_cocos2dx_auto.hpp" #include "cocos2d.h" #include "CCProtectedNode.h" +#include "CCAsyncTaskPool.h" #include "tolua_fix.h" #include "LuaBasicConversions.h" @@ -72824,6 +72825,146 @@ int lua_register_cocos2dx_Component(lua_State* tolua_S) g_typeCast["Component"] = "cc.Component"; return 1; } + +int lua_cocos2dx_AsyncTaskPool_stopTasks(lua_State* tolua_S) +{ + int argc = 0; + cocos2d::AsyncTaskPool* cobj = nullptr; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertype(tolua_S,1,"cc.AsyncTaskPool",0,&tolua_err)) goto tolua_lerror; +#endif + + cobj = (cocos2d::AsyncTaskPool*)tolua_tousertype(tolua_S,1,0); + +#if COCOS2D_DEBUG >= 1 + if (!cobj) + { + tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_AsyncTaskPool_stopTasks'", nullptr); + return 0; + } +#endif + + argc = lua_gettop(tolua_S)-1; + if (argc == 1) + { + cocos2d::AsyncTaskPool::TaskType arg0; + + ok &= luaval_to_int32(tolua_S, 2,(int *)&arg0, "cc.AsyncTaskPool:stopTasks"); + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AsyncTaskPool_stopTasks'", nullptr); + return 0; + } + cobj->stopTasks(arg0); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "cc.AsyncTaskPool:stopTasks",argc, 1); + return 0; + +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AsyncTaskPool_stopTasks'.",&tolua_err); +#endif + + return 0; +} +int lua_cocos2dx_AsyncTaskPool_destoryInstance(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.AsyncTaskPool",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AsyncTaskPool_destoryInstance'", nullptr); + return 0; + } + cocos2d::AsyncTaskPool::destoryInstance(); + lua_settop(tolua_S, 1); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AsyncTaskPool:destoryInstance",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AsyncTaskPool_destoryInstance'.",&tolua_err); +#endif + return 0; +} +int lua_cocos2dx_AsyncTaskPool_getInstance(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; + +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.AsyncTaskPool",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S) - 1; + + if (argc == 0) + { + if(!ok) + { + tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_AsyncTaskPool_getInstance'", nullptr); + return 0; + } + cocos2d::AsyncTaskPool* ret = cocos2d::AsyncTaskPool::getInstance(); + object_to_luaval(tolua_S, "cc.AsyncTaskPool",(cocos2d::AsyncTaskPool*)ret); + return 1; + } + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "cc.AsyncTaskPool:getInstance",argc, 0); + return 0; +#if COCOS2D_DEBUG >= 1 + tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_AsyncTaskPool_getInstance'.",&tolua_err); +#endif + return 0; +} +static int lua_cocos2dx_AsyncTaskPool_finalize(lua_State* tolua_S) +{ + printf("luabindings: finalizing LUA object (AsyncTaskPool)"); + return 0; +} + +int lua_register_cocos2dx_AsyncTaskPool(lua_State* tolua_S) +{ + tolua_usertype(tolua_S,"cc.AsyncTaskPool"); + tolua_cclass(tolua_S,"AsyncTaskPool","cc.AsyncTaskPool","",nullptr); + + tolua_beginmodule(tolua_S,"AsyncTaskPool"); + tolua_function(tolua_S,"stopTasks",lua_cocos2dx_AsyncTaskPool_stopTasks); + tolua_function(tolua_S,"destoryInstance", lua_cocos2dx_AsyncTaskPool_destoryInstance); + tolua_function(tolua_S,"getInstance", lua_cocos2dx_AsyncTaskPool_getInstance); + tolua_endmodule(tolua_S); + std::string typeName = typeid(cocos2d::AsyncTaskPool).name(); + g_luaType[typeName] = "cc.AsyncTaskPool"; + g_typeCast["AsyncTaskPool"] = "cc.AsyncTaskPool"; + return 1; +} TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) { tolua_open(tolua_S); @@ -72925,6 +73066,7 @@ TOLUA_API int register_all_cocos2dx(lua_State* tolua_S) lua_register_cocos2dx_Application(tolua_S); lua_register_cocos2dx_DelayTime(tolua_S); lua_register_cocos2dx_LabelAtlas(tolua_S); + lua_register_cocos2dx_AsyncTaskPool(tolua_S); lua_register_cocos2dx_ParticleSnow(tolua_S); lua_register_cocos2dx_EaseElasticIn(tolua_S); lua_register_cocos2dx_EaseCircleActionInOut(tolua_S); diff --git a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp index 60ff8cc44b..f8080968eb 100644 --- a/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp +++ b/cocos/scripting/lua-bindings/auto/lua_cocos2dx_auto.hpp @@ -1637,6 +1637,10 @@ int register_all_cocos2dx(lua_State* tolua_S); + + + + diff --git a/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp b/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp index c948c249f4..ee0717712a 100644 --- a/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp +++ b/cocos/scripting/lua-bindings/manual/3d/lua_cocos2dx_3d_manual.cpp @@ -116,6 +116,89 @@ tolua_lerror: return 0; } +int lua_cocos2dx_3d_Sprite3D_createAsync(lua_State* tolua_S) +{ + int argc = 0; + bool ok = true; +#if COCOS2D_DEBUG >= 1 + tolua_Error tolua_err; +#endif + +#if COCOS2D_DEBUG >= 1 + if (!tolua_isusertable(tolua_S,1,"cc.Sprite3D",0,&tolua_err)) goto tolua_lerror; +#endif + + argc = lua_gettop(tolua_S)-1; + + do + { + if (argc == 3) + { + std::string modelPath; + ok &= luaval_to_std_string(tolua_S, 2,&modelPath, "cc.Sprite3D:createAsync"); + if (!ok) + break; + std::string texturePath; + ok &= luaval_to_std_string(tolua_S, 3,&texturePath, "cc.Sprite3D:createAsync"); + if (!ok) + break; + +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(tolua_S,4,"LUA_FUNCTION",0,&tolua_err)) { + goto tolua_lerror; + } +#endif + LUA_FUNCTION handler = toluafix_ref_function(tolua_S,4,0); + + cocos2d::Sprite3D::createAsync(modelPath, texturePath, [=](cocos2d::Sprite3D* sprite, void* callbackparam){ + int id = (sprite) ? (int)sprite->_ID : -1; + int* luaID = (sprite) ? &sprite->_luaID : nullptr; + toluafix_pushusertype_ccobject(tolua_S, id, luaID, (void*)sprite,"cc.Sprite3D"); + LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 1); + }, nullptr); + + lua_settop(tolua_S, 1); + return 1; + } + } while (0); + ok = true; + do + { + if (argc == 2) + { + std::string modelPath; + ok &= luaval_to_std_string(tolua_S, 2,&modelPath, "cc.Sprite3D:createAsync"); + if (!ok) + break; + +#if COCOS2D_DEBUG >= 1 + if (!toluafix_isfunction(tolua_S, 3, "LUA_FUNCTION", 0, &tolua_err)) { + goto tolua_lerror; + } +#endif + LUA_FUNCTION handler = toluafix_ref_function(tolua_S, 3, 0); + + cocos2d::Sprite3D::createAsync(modelPath, [=](cocos2d::Sprite3D* sprite, void* callbackparam){ + int id = (sprite) ? (int)sprite->_ID : -1; + int* luaID = (sprite) ? &sprite->_luaID : nullptr; + toluafix_pushusertype_ccobject(tolua_S, id, luaID, (void*)sprite,"cc.Sprite3D"); + LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 1); + }, nullptr); + + lua_settop(tolua_S, 1); + return 1; + } + } while (0); + ok = true; + luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d", "cc.Sprite3D:createAsync",argc, 3); + return 0; +#if COCOS2D_DEBUG >= 1 +tolua_lerror: + tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_3d_Sprite3D_createAsync'.",&tolua_err); +#endif + return 0; +} + static void extendSprite3D(lua_State* L) { lua_pushstring(L, "cc.Sprite3D"); @@ -124,6 +207,7 @@ static void extendSprite3D(lua_State* L) { tolua_function(L, "setBlendFunc", lua_cocos2dx_3d_Sprite3D_setBlendFunc01); tolua_function(L, "getAABB", lua_cocos2dx_3d_Sprite3D_getAABB); + tolua_function(L, "createAsync", lua_cocos2dx_3d_Sprite3D_createAsync); } lua_pop(L, 1); } diff --git a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj index 2ece90e2c5..d916eba7d1 100644 --- a/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj +++ b/cocos/scripting/lua-bindings/proj.win32/libluacocos2d.vcxproj @@ -277,7 +277,7 @@ Disabled - $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\lua;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocostudio\ActionTimeline;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\scripting\lua-bindings\manual\extension;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocostudio;$(EngineRoot)cocos\scripting\lua-bindings\manual\ui;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocos2d;$(EngineRoot)extensions;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)cocos\ui;$(EngineRoot)cocos\editor-support;$(EngineRoot)external;%(AdditionalIncludeDirectories) + $(EngineRoot);$(EngineRoot)cocos\2d;$(EngineRoot)cocos\base;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\audio\include;$(EngineRoot)cocos\ui;$(EngineRoot)external;$(EngineRoot)external\lua;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)extensions;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocostudio\ActionTimeline;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual\extension;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocostudio;$(EngineRoot)cocos\scripting\lua-bindings\manual\ui;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocos2d;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) false EnableFastChecks @@ -309,7 +309,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\..\external\lua\luajit\prebuilt\win32\*.*" "$ MinSpace true - $(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\lua;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\scripting\lua-bindings\manual\extension;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocostudio;$(EngineRoot)cocos\scripting\lua-bindings\manual\ui;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocos2d;$(EngineRoot)extensions;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocostudio\ActionTimeline;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)cocos\ui;$(EngineRoot)external;%(AdditionalIncludeDirectories) + $(EngineRoot);$(EngineRoot)cocos\base;$(EngineRoot)cocos;$(EngineRoot)external\lua\tolua;$(EngineRoot)external\lua\luajit\include;$(EngineRoot)external\lua;$(EngineRoot)cocos\scripting\lua-bindings\auto;$(EngineRoot)cocos\scripting\lua-bindings\manual;$(EngineRoot)cocos\2d;$(EngineRoot)cocos\3d;$(EngineRoot)cocos\scripting\lua-bindings\manual\extension;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocostudio;$(EngineRoot)cocos\scripting\lua-bindings\manual\ui;$(EngineRoot)cocos\scripting\lua-bindings\manual\cocos2d;$(EngineRoot)extensions;$(EngineRoot)cocos\editor-support;$(EngineRoot)cocos\editor-support\cocostudio;$(EngineRoot)cocos\editor-support\cocostudio\ActionTimeline;$(EngineRoot)cocos\editor-support\spine;$(EngineRoot)cocos\editor-support\cocosbuilder;$(EngineRoot)cocos\audio\include;$(EngineRoot)external\libwebsockets\win32\include;$(EngineRoot)cocos\ui;$(EngineRoot)external;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;LIBLUA_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL true diff --git a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua index defb4a51b8..b54ba5c100 100644 --- a/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua +++ b/cocos/scripting/lua-bindings/script/cocos2d/Cocos2dConstants.lua @@ -610,3 +610,12 @@ cc.LightFlag = LIGHT14 = math.pow(2,14), LIGHT15 = math.pow(2,15), } + +cc.AsyncTaskPool.TaskType = +{ + TASK_IO = 0, + TASK_NETWORK = 1, + TASK_OTHER = 2, + TASK_MAX_TYPE = 3, +} + diff --git a/docs/RELEASE_NOTES.md b/docs/RELEASE_NOTES.md index 54838904b9..1b7e437e4d 100644 --- a/docs/RELEASE_NOTES.md +++ b/docs/RELEASE_NOTES.md @@ -13,6 +13,8 @@ - [Windows](#windows) - [Linux](#linux) - [How to start a new game](#how-to-start-a-new-game) +- [v3.4](#v34) + - [Bugs fixed in v3.4](#bugs-fixed-in-v34) - [v3.4rc1](#v34rc1) - [Highlights of v3.4rc1](#highlights-of-v34rc1) - [Features in detail](#features-in-detail) @@ -39,7 +41,7 @@ # Misc Information -* Full Changelog: https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.4rc0/CHANGELOG +* [Full Changelog](https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.4/CHANGELOG) * v3.0 Release Notes can be found here: [v3.0 Release Notes](https://github.com/cocos2d/cocos2d-x/blob/cocos2d-x-3.0/docs/RELEASE_NOTES.md) # Requirements @@ -124,6 +126,13 @@ Run ## How to start a new game Please refer to this document: [ReadMe](../README.md) +# v3.4 +##Bugs fixed in v3.4 +* C++: crash on armeabi-v7a arch device which do not support NEON instructions +* GLProgram: crash on low end device with no more than 8 attributes support +* New audio: game freeze if audio played two many times on android +* Node: anchor point has no effects on rotation +* More bugs fixed # v3.4rc1 diff --git a/extensions/assets-manager/AssetsManagerEx.cpp b/extensions/assets-manager/AssetsManagerEx.cpp index 1b6d7a660f..18798a1feb 100644 --- a/extensions/assets-manager/AssetsManagerEx.cpp +++ b/extensions/assets-manager/AssetsManagerEx.cpp @@ -264,9 +264,6 @@ const std::string& AssetsManagerEx::getStoragePath() const void AssetsManagerEx::setStoragePath(const std::string& storagePath) { - if (_storagePath.size() > 0) - _fileUtils->removeDirectory(_storagePath); - _storagePath = storagePath; adjustPath(_storagePath); _fileUtils->createDirectory(_storagePath); diff --git a/templates/cocos2dx_files.json b/templates/cocos2dx_files.json index c262b095c0..a05606ec79 100644 --- a/templates/cocos2dx_files.json +++ b/templates/cocos2dx_files.json @@ -4909,6 +4909,7 @@ "cocos/scripting/lua-bindings/auto/api/ArmatureDisplayData.lua", "cocos/scripting/lua-bindings/auto/api/AssetsManager.lua", "cocos/scripting/lua-bindings/auto/api/AssetsManagerEx.lua", + "cocos/scripting/lua-bindings/auto/api/AsyncTaskPool.lua", "cocos/scripting/lua-bindings/auto/api/AtlasNode.lua", "cocos/scripting/lua-bindings/auto/api/AttachNode.lua", "cocos/scripting/lua-bindings/auto/api/AudioEngine.lua", @@ -5189,6 +5190,7 @@ "cocos/scripting/lua-bindings/auto/api/SpotLight.lua", "cocos/scripting/lua-bindings/auto/api/Sprite.lua", "cocos/scripting/lua-bindings/auto/api/Sprite3D.lua", + "cocos/scripting/lua-bindings/auto/api/Sprite3DCache.lua", "cocos/scripting/lua-bindings/auto/api/SpriteBatchNode.lua", "cocos/scripting/lua-bindings/auto/api/SpriteDisplayData.lua", "cocos/scripting/lua-bindings/auto/api/SpriteFrame.lua", diff --git a/tests/cpp-tests/CMakeLists.txt b/tests/cpp-tests/CMakeLists.txt index 253ceac2bb..e9eef36942 100644 --- a/tests/cpp-tests/CMakeLists.txt +++ b/tests/cpp-tests/CMakeLists.txt @@ -1,5 +1,8 @@ set(APP_NAME cpp-tests) +# Use same method as in cocos library +cocos_find_package(CURL CURL REQUIRED) + if(WIN32) set(PLATFORM_SRC proj.win32/main.cpp) set(RES_PREFIX "") @@ -252,6 +255,8 @@ target_link_libraries(${APP_NAME} cocos2d ) +cocos_use_pkg(${APP_NAME} CURL) + if(MACOSX OR APPLE) set_target_properties(${APP_NAME} PROPERTIES MACOSX_BUNDLE 1 diff --git a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp index 0408ea92dd..42d20c27a5 100644 --- a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp +++ b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp @@ -245,6 +245,7 @@ Camera3DTestDemo::Camera3DTestDemo(void) , _bZoomIn(false) , _bRotateLeft(false) , _bRotateRight(false) +, _cameraType(CameraType::Free) { } Camera3DTestDemo::~Camera3DTestDemo(void) diff --git a/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp b/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp index 290f5f0875..5fd0dd878e 100644 --- a/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp +++ b/tests/cpp-tests/Classes/LabelTest/LabelTest.cpp @@ -1537,11 +1537,7 @@ TTFFontShadowAndStroke::TTFFontShadowAndStroke() strokeShaodwTextDef._fontFillColor = tintColorBlue; // shadow + stroke label -#if CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 - auto fontStrokeAndShadow = LabelTTF::createWithFontDefinition("Stroke && Shadow Blue Text", strokeShaodwTextDef); -#else - auto fontStrokeAndShadow = LabelTTF::createWithFontDefinition("Stroke &Shadow Blue Text", strokeShaodwTextDef); -#endif + auto fontStrokeAndShadow = LabelTTF::createWithFontDefinition("Stroke & Shadow Blue Text", strokeShaodwTextDef); // add label to the scene this->addChild(fontStrokeAndShadow); diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp index b633f9252d..79fc9241ac 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.cpp @@ -70,7 +70,8 @@ static std::function createFunctions[] = CL(Sprite3DMirrorTest), CL(QuaternionTest), CL(Sprite3DEmptyTest), - CL(UseCaseSprite3D) + CL(UseCaseSprite3D), + CL(Sprite3DForceDepthTest) }; #define MAX_LAYER (sizeof(createFunctions) / sizeof(createFunctions[0])) @@ -156,6 +157,42 @@ void Sprite3DTestDemo::backCallback(Ref* sender) s->release(); } +//------------------------------------------------------------------ +// +// Sprite3DForceDepthTest +// +//------------------------------------------------------------------ +Sprite3DForceDepthTest::Sprite3DForceDepthTest() +{ + auto orc = Sprite3D::create("Sprite3DTest/orc.c3b"); + orc->setScale(5); + orc->setNormalizedPosition(Vec2(.5,.3)); + orc->setPositionZ(40); + orc->setRotation3D(Vec3(0,180,0)); + orc->setGlobalZOrder(-1); + + addChild(orc); + + auto ship = Sprite3D::create("Sprite3DTest/boss1.obj"); + ship->setScale(5); + ship->setTexture("Sprite3DTest/boss.png"); + ship->setNormalizedPosition(Vec2(.5,.5)); + ship->setRotation3D(Vec3(90,0,0)); + ship->setForceDepthWrite(true); + + addChild(ship); +} + +std::string Sprite3DForceDepthTest::title() const +{ + return "Force Depth Write Error Test"; +} + +std::string Sprite3DForceDepthTest::subtitle() const +{ + return "Ship should always appear behind orc"; +} + //------------------------------------------------------------------ // // Sprite3DEmptyTest diff --git a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h index 812e84171c..c59cd4895d 100644 --- a/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h +++ b/tests/cpp-tests/Classes/Sprite3DTest/Sprite3DTest.h @@ -54,6 +54,15 @@ public: virtual void onEnter() override; }; +class Sprite3DForceDepthTest : public Sprite3DTestDemo +{ +public: + CREATE_FUNC(Sprite3DForceDepthTest); + Sprite3DForceDepthTest(); + virtual std::string title() const override; + virtual std::string subtitle() const override; +}; + class Sprite3DEmptyTest : public Sprite3DTestDemo { public: diff --git a/tests/lua-tests/src/BugsTest/BugsTest.lua b/tests/lua-tests/src/BugsTest/BugsTest.lua index 648697281c..e20eeddbe6 100644 --- a/tests/lua-tests/src/BugsTest/BugsTest.lua +++ b/tests/lua-tests/src/BugsTest/BugsTest.lua @@ -356,8 +356,6 @@ end --BugTest1159 local function BugTest1159() local pLayer = cc.Layer:create() - - cc.Director:getInstance():setDepthTest(true) local background = cc.LayerColor:create(cc.c4b(255, 0, 255, 255)) pLayer:addChild(background) @@ -398,7 +396,6 @@ local function BugTest1159() scheduler:unscheduleScriptEntry(schedulerEntry) end ]]-- - cc.Director:getInstance():setDepthTest(false) end end diff --git a/tests/lua-tests/src/ParallaxTest/ParallaxTest.lua b/tests/lua-tests/src/ParallaxTest/ParallaxTest.lua index af6d1c160f..c0b834755a 100644 --- a/tests/lua-tests/src/ParallaxTest/ParallaxTest.lua +++ b/tests/lua-tests/src/ParallaxTest/ParallaxTest.lua @@ -145,7 +145,6 @@ end function ParallaxTestMain() cclog("ParallaxMain") Helper.index = 1 - cc.Director:getInstance():setDepthTest(true) local scene = cc.Scene:create() Helper.createFunctionTable = { diff --git a/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua b/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua index bb95144f61..6807e64103 100644 --- a/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua +++ b/tests/lua-tests/src/Sprite3DTest/Sprite3DTest.lua @@ -919,6 +919,113 @@ function Sprite3DMirrorTest.create() return layer end + +---------------------------------------- +----AsyncLoadSprite3DTest +---------------------------------------- +local AsyncLoadSprite3DTest = class("AsyncLoadSprite3DTest", function () + local layer = cc.Layer:create() + Helper.initWithLayer(layer) + return layer +end) + +function AsyncLoadSprite3DTest:ctor() + -- body + self:init() +end + +function AsyncLoadSprite3DTest:init() + Helper.titleLabel:setString(self:title()) + Helper.subtitleLabel:setString(self:subtitle()) + + self:registerScriptHandler(function (event) + if event == "enter" then + self:onEnter() + elseif event == "exit" then + self:onExit() + end + end) +end + +function AsyncLoadSprite3DTest:title() + return "Testing Sprite3D:createAsync" +end + +function AsyncLoadSprite3DTest:subtitle() + return "" +end + +function AsyncLoadSprite3DTest:onEnter() + + local ttfConfig = {} + ttfConfig.fontFilePath = "fonts/arial.ttf" + ttfConfig.fontSize = 15 + + local paths = {"Sprite3DTest/boss.obj", "Sprite3DTest/girl.c3b", "Sprite3DTest/orc.c3b", "Sprite3DTest/ReskinGirl.c3b", "Sprite3DTest/axe.c3b"} + + local label1 = cc.Label:createWithTTF(ttfConfig,"AsyncLoad Sprite3D") + local item1 = cc.MenuItemLabel:create(label1) + + function menuCallback_asyncLoadSprite(tag, sender) + --Note that you must stop the tasks before leaving the scene. + cc.AsyncTaskPool:getInstance():stopTasks(cc.AsyncTaskPool.TaskType.TASK_IO) + + local node = self:getChildByTag(101) + --remove all loaded sprite + node:removeAllChildren() + + --remove cache data + cc.Sprite3DCache:getInstance():removeAllSprite3DData() + + local function callback(sprite, index) + local node = self:getChildByTag(101) + local s = cc.Director:getInstance():getWinSize() + local width = s.width / (#paths) + local point = cc.p(width * (0.5 + index), s.height / 2.0) + sprite:setPosition(point) + node:addChild(sprite) + end + + cc.Sprite3D:createAsync(paths[1], function(sprite) + callback(sprite, 0) + end) + + cc.Sprite3D:createAsync(paths[2], function(sprite) + callback(sprite, 1) + end) + + cc.Sprite3D:createAsync(paths[3], function(sprite) + callback(sprite, 2) + end) + + cc.Sprite3D:createAsync(paths[4], function(sprite) + callback(sprite, 3) + end) + + cc.Sprite3D:createAsync(paths[5], function(sprite) + callback(sprite, 4) + end) + end + item1:registerScriptTapHandler(menuCallback_asyncLoadSprite) + + local s = cc.Director:getInstance():getWinSize() + item1:setPosition( s.width * 0.5, s.height * 0.8) + + local menu = cc.Menu:create(item1) + menu:setPosition(cc.p(0,0)) + self:addChild(menu, 10) + + local node = cc.Node:create() + node:setTag(101) + self:addChild(node) + + menuCallback_asyncLoadSprite() +end + +function AsyncLoadSprite3DTest:onExit() + +end + function Sprite3DTest() local scene = cc.Scene:create() @@ -932,6 +1039,7 @@ function Sprite3DTest() Sprite3DReskinTest.create, Sprite3DWithOBBPerfromanceTest.create, Sprite3DMirrorTest.create, + AsyncLoadSprite3DTest.create } scene:addChild(Sprite3DBasicTest.create()) diff --git a/tools/tolua/cocos2dx.ini b/tools/tolua/cocos2dx.ini index c0019ef351..06a3865007 100644 --- a/tools/tolua/cocos2dx.ini +++ b/tools/tolua/cocos2dx.ini @@ -22,11 +22,11 @@ cxxgenerator_headers = extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s # what headers to parse -headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/2d/CCProtectedNode.h +headers = %(cocosdir)s/cocos/cocos2d.h %(cocosdir)s/cocos/2d/CCProtectedNode.h %(cocosdir)s/cocos/base/CCAsyncTaskPool.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console GLProgramCache GLProgramState Device ClippingRectangleNode .*Light$ +classes = New.* Sprite.* Scene Node.* Director Layer.* Menu.* Touch .*Action.* Move.* Rotate.* Blink.* Tint.* Sequence Repeat.* Fade.* Ease.* Scale.* Transition.* Spawn Animat.* Flip.* Delay.* Skew.* Jump.* Place.* Show.* Progress.* PointArray ToggleVisibility.* RemoveSelf Hide Particle.* Label.* Atlas.* TextureCache.* Texture2D Cardinal.* CatmullRom.* ParallaxNode TileMap.* .*TMX.* CallFunc RenderTexture GridAction Grid3DAction GridBase$ .+Grid Shaky3D Waves3D FlipX3D FlipY3D Speed ActionManager Set Scheduler Timer Orbit.* Follow.* Bezier.* CardinalSpline.* Camera.* DrawNode .*3D$ Liquid$ Waves$ ShuffleTiles$ TurnOffTiles$ Split.* Twirl$ FileUtils$ GLProgram ShaderCache Application ClippingNode MotionStreak ^Ref$ UserDefault GLViewImpl GLView Image Event(?!.*(Physics).*).* Component ProtectedNode Console GLProgramCache GLProgramState Device ClippingRectangleNode .*Light$ AsyncTaskPool # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also diff --git a/tools/tolua/cocos2dx_3d.ini b/tools/tolua/cocos2dx_3d.ini index d554da2066..6cdd569c0f 100644 --- a/tools/tolua/cocos2dx_3d.ini +++ b/tools/tolua/cocos2dx_3d.ini @@ -26,7 +26,7 @@ headers = %(cocosdir)s/cocos/cocos2d.h # what classes to produce code for. You can use regular expressions here. When testing the regular # expression, it will be enclosed in "^$", like this: "^Menu*$". -classes = Animate3D Sprite3D Animation3D Skeleton3D ^Mesh$ AttachNode BillBoard +classes = Animate3D Sprite3D Animation3D Skeleton3D ^Mesh$ AttachNode BillBoard Sprite3DCache # what should we skip? in the format ClassName::[function function] # ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also @@ -36,10 +36,11 @@ classes = Animate3D Sprite3D Animation3D Skeleton3D ^Mesh$ AttachNode BillBoard # functions from all classes. skip = Mesh::[create getAABB getVertexBuffer hasVertexAttrib getSkin getMeshIndexData getGLProgramState getPrimitiveType getIndexCount getIndexFormat getIndexBuffer], - Sprite3D::[getSkin getAABB getMeshArrayByName], + Sprite3D::[getSkin getAABB getMeshArrayByName createAsync], Skeleton3D::[create], Animation3D::[getBoneCurveByName], - BillBoard::[draw] + BillBoard::[draw], + Sprite3DCache::[addSprite3DData getSpriteData] rename_functions = From c6ab07ea02cab2a9c8624b2dad71946ef19a6123 Mon Sep 17 00:00:00 2001 From: kompjoefriek Date: Thu, 29 Jan 2015 01:40:19 +0100 Subject: [PATCH 3/6] fixed indentation of Python files - Changed tabs to spaces - Changed 2 spaces to 4 spaces --- .../proj.android/build_native.py | 54 +- tools/jenkins-scripts/autotest.py | 264 +++++----- tools/jenkins-scripts/cocos-console-test.py | 458 ++++++++-------- tools/jenkins-scripts/configs/autotest.py | 2 +- .../configs/cocos-2dx-develop-android.py | 12 +- .../configs/cocos-2dx-develop-base-repo.py | 22 +- .../configs/cocos-2dx-develop-ios.py | 12 +- .../configs/cocos-2dx-develop-win32.py | 14 +- .../configs/cocos-2dx-doxygen.py | 14 +- ...-2dx-pull-request-build-comment-trigger.py | 4 +- .../cocos-2dx-pull-request-build-trigger.py | 4 +- .../configs/cocos-2dx-pull-request-build.py | 30 +- .../configs/cocos2d-console-test.py | 2 +- .../configs/cocostudiox-base-repo.py | 4 +- .../configs/cocostudiox-daily-build.py | 24 +- tools/jenkins-scripts/emptytest.py | 490 +++++++++--------- tools/jenkins-scripts/github-pr-watchdog.py | 96 ++-- tools/jenkins-scripts/post-build.py | 8 +- tools/jenkins-scripts/reboot.py | 60 +-- 19 files changed, 787 insertions(+), 787 deletions(-) diff --git a/templates/cpp-template-default/proj.android/build_native.py b/templates/cpp-template-default/proj.android/build_native.py index fdcdf9b0ac..dd948d6d9b 100755 --- a/templates/cpp-template-default/proj.android/build_native.py +++ b/templates/cpp-template-default/proj.android/build_native.py @@ -9,14 +9,14 @@ import shutil from optparse import OptionParser def get_num_of_cpu(): - ''' The build process can be accelerated by running multiple concurrent job processes using the -j-option. - ''' - try: - import multiprocessing - return multiprocessing.cpu_count() - except Exception: - print "Can't know cpuinfo, use default 1 cpu" - return 1 + ''' The build process can be accelerated by running multiple concurrent job processes using the -j-option. + ''' + try: + import multiprocessing + return multiprocessing.cpu_count() + except Exception: + print "Can't know cpuinfo, use default 1 cpu" + return 1 def check_environment_variables_sdk(): ''' Checking the environment ANDROID_SDK_ROOT, which will be used for building @@ -69,17 +69,17 @@ def do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,and if os.system(command) != 0: raise Exception("Build dynamic library for project [ " + app_android_root + " ] fails!") elif android_platform is not None: - sdk_tool_path = os.path.join(sdk_root, "tools/android") - cocoslib_path = os.path.join(cocos_root, "cocos/platform/android/java") - command = '%s update lib-project -t %s -p %s' % (sdk_tool_path,android_platform,cocoslib_path) - if os.system(command) != 0: - raise Exception("update cocos lib-project [ " + cocoslib_path + " ] fails!") - command = '%s update project -t %s -p %s -s' % (sdk_tool_path,android_platform,app_android_root) - if os.system(command) != 0: - raise Exception("update project [ " + app_android_root + " ] fails!") - buildfile_path = os.path.join(app_android_root, "build.xml") - command = 'ant clean %s -f %s -Dsdk.dir=%s' % (build_mode,buildfile_path,sdk_root) - os.system(command) + sdk_tool_path = os.path.join(sdk_root, "tools/android") + cocoslib_path = os.path.join(cocos_root, "cocos/platform/android/java") + command = '%s update lib-project -t %s -p %s' % (sdk_tool_path,android_platform,cocoslib_path) + if os.system(command) != 0: + raise Exception("update cocos lib-project [ " + cocoslib_path + " ] fails!") + command = '%s update project -t %s -p %s -s' % (sdk_tool_path,android_platform,app_android_root) + if os.system(command) != 0: + raise Exception("update project [ " + app_android_root + " ] fails!") + buildfile_path = os.path.join(app_android_root, "build.xml") + command = 'ant clean %s -f %s -Dsdk.dir=%s' % (build_mode,buildfile_path,sdk_root) + os.system(command) def copy_files(src, dst): @@ -119,15 +119,15 @@ def build(ndk_build_param,android_platform,build_mode): copy_resources(app_android_root) if android_platform is not None: - sdk_root = check_environment_variables_sdk() - if android_platform.isdigit(): - android_platform = 'android-'+android_platform - else: - print 'please use vaild android platform' - exit(1) - + sdk_root = check_environment_variables_sdk() + if android_platform.isdigit(): + android_platform = 'android-'+android_platform + else: + print 'please use vaild android platform' + exit(1) + if build_mode is None: - build_mode = 'debug' + build_mode = 'debug' elif build_mode != 'release': build_mode = 'debug' diff --git a/tools/jenkins-scripts/autotest.py b/tools/jenkins-scripts/autotest.py index 74857a17cf..31ea709e1d 100755 --- a/tools/jenkins-scripts/autotest.py +++ b/tools/jenkins-scripts/autotest.py @@ -21,153 +21,153 @@ sleep_time = 1.5 # def getADBDeviceIP(): - output = os.popen("adb shell netcfg") - configs = output.read().split('\r\n') - for l in configs: - items = l.split() - if(items[1] == 'UP'): - if(items[2] != '127.0.0.1'): - return items[2] + output = os.popen("adb shell netcfg") + configs = output.read().split('\r\n') + for l in configs: + items = l.split() + if(items[1] == 'UP'): + if(items[2] != '127.0.0.1'): + return items[2] def autotest(type): - soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) - if type == TYPE_MAC: - soc.connect((HOST_MAC, PORT)) - if type == TYPE_ANDROID: - HOST_ANDROID = getADBDeviceIP() - soc.connect((HOST_ANDROID, PORT)) - if type == TYPE_IOS: - soc.connect((HOST_IOS, PORT)) - time.sleep(1) - print 'autotest run:' - soc.send('autotest run\r\n') + soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) + if type == TYPE_MAC: + soc.connect((HOST_MAC, PORT)) + if type == TYPE_ANDROID: + HOST_ANDROID = getADBDeviceIP() + soc.connect((HOST_ANDROID, PORT)) + if type == TYPE_IOS: + soc.connect((HOST_IOS, PORT)) + time.sleep(1) + print 'autotest run:' + soc.send('autotest run\r\n') - while True: - data = soc.recv(1024) - print data - if data == 'TestEnd': - lastTestInfo = True - break - global lastTestInfo - if len(data) > len('\n') : - lastTestInfo = data - if not data: break - - soc.send('director end\r\n') - print 'test end and close socket.' - soc.close() + while True: + data = soc.recv(1024) + print data + if data == 'TestEnd': + lastTestInfo = True + break + global lastTestInfo + if len(data) > len('\n') : + lastTestInfo = data + if not data: break + + soc.send('director end\r\n') + print 'test end and close socket.' + soc.close() #----------------autotest build and run----------------# def MAC_BUILD(): - def cleanProj(): - infoClean = os.system('xcodebuild -project ./build/cocos2d_tests.xcodeproj -target cpp-tests\ Mac clean') - print 'infoClean: ', infoClean - if infoClean != 0: - return False - time.sleep(sleep_time) - return True - def buildProj(): - infoBuild = os.system('xcodebuild -project ./build/cocos2d_tests.xcodeproj -target cpp-tests\ Mac') - print 'infoBuild: ', infoBuild - if infoBuild != 0: - return False - time.sleep(sleep_time) - return True - def openProj(): - cmd = 'open ./build/build/Debug/cpp-tests\ Mac.app' - print 'cmd: ', cmd - infoOpen = os.system(cmd) - print 'infoOpen: ', infoOpen - if infoOpen != 0: - return False - time.sleep(sleep_time) - return True - def buildAndRun(): - if not cleanProj(): - print '**CLEAN FAILED**' - if not buildProj(): - print '**BUILD FAILED**' - return False - if not openProj(): - return False - time.sleep(sleep_time) - return True - return buildAndRun() + def cleanProj(): + infoClean = os.system('xcodebuild -project ./build/cocos2d_tests.xcodeproj -target cpp-tests\ Mac clean') + print 'infoClean: ', infoClean + if infoClean != 0: + return False + time.sleep(sleep_time) + return True + def buildProj(): + infoBuild = os.system('xcodebuild -project ./build/cocos2d_tests.xcodeproj -target cpp-tests\ Mac') + print 'infoBuild: ', infoBuild + if infoBuild != 0: + return False + time.sleep(sleep_time) + return True + def openProj(): + cmd = 'open ./build/build/Debug/cpp-tests\ Mac.app' + print 'cmd: ', cmd + infoOpen = os.system(cmd) + print 'infoOpen: ', infoOpen + if infoOpen != 0: + return False + time.sleep(sleep_time) + return True + def buildAndRun(): + if not cleanProj(): + print '**CLEAN FAILED**' + if not buildProj(): + print '**BUILD FAILED**' + return False + if not openProj(): + return False + time.sleep(sleep_time) + return True + return buildAndRun() #----------------autotest build and run end----------------# PATH_ANDROID_SRC = 'tests/cpp-tests/proj.android/' FILE_ANDROID_DELETE = ['libs','gen','assets','bin','obj'] #----------------autotest-android build and run----------------# def ANDROID_BUILD(): - def checkDevice(): - cmd = 'adb devices' - infoDev = os.popen(cmd).readlines() - firstDev = infoDev[1] - if len(firstDev) < 5 or firstDev.find('device') < 0: - print 'no android device.' - return False - else: - print 'device info:', firstDev - return True - def cleanProj(): - for strFile in FILE_ANDROID_DELETE: - infoClean = os.system('rm -rf '+PATH_ANDROID_SRC+strFile) - infoClean = os.system('adb uninstall org.cocos2dx.cpp_tests'); - print 'infoClean: ', infoClean - if infoClean != 0: - print 'clean **CLEAN FAILED**' - time.sleep(sleep_time) - def updateProperty(): - infoUpdate = os.system('android update project -p ./cocos/platform/android/java/ -t 12') - print 'cocos update:', infoUpdate - infoUpdate = os.system('android update project -p '+PATH_ANDROID_SRC+' -t 12') - print 'test update:', infoUpdate - def buildProj(): - infoBuild = os.system('./build/android-build.py -p 13 cpp-tests') - print 'infoBuild cpp_tests: ', infoBuild - infoBuild = os.system('ant -buildfile '+PATH_ANDROID_SRC+' debug') - print 'infoBuild: ', infoBuild - if infoBuild != 0: - print 'build **BUILD FAILED**' - time.sleep(sleep_time) - return infoBuild - def installProj(): - cmd = 'adb install '+PATH_ANDROID_SRC+'bin/CppTests-debug.apk' - infoInstall = os.system(cmd) - print 'infoInstall:', infoInstall - if infoInstall != 0: - print 'install **INSTALL FAILED**' - return infoInstall - def openProj(): - cmd = 'adb shell am start -n org.cocos2dx.cpp_tests/org.cocos2dx.cpp_tests.Cocos2dxActivity' - print 'cmd: ', cmd - infoOpen = os.system(cmd) - print 'infoOpen: ', infoOpen - if infoOpen != 0: - return False - time.sleep(sleep_time) - return True - def buildAndRun(): - if not checkDevice(): - return False - cleanProj() - updateProperty() - buildProj() - installProj() - return openProj() - return buildAndRun() + def checkDevice(): + cmd = 'adb devices' + infoDev = os.popen(cmd).readlines() + firstDev = infoDev[1] + if len(firstDev) < 5 or firstDev.find('device') < 0: + print 'no android device.' + return False + else: + print 'device info:', firstDev + return True + def cleanProj(): + for strFile in FILE_ANDROID_DELETE: + infoClean = os.system('rm -rf '+PATH_ANDROID_SRC+strFile) + infoClean = os.system('adb uninstall org.cocos2dx.cpp_tests'); + print 'infoClean: ', infoClean + if infoClean != 0: + print 'clean **CLEAN FAILED**' + time.sleep(sleep_time) + def updateProperty(): + infoUpdate = os.system('android update project -p ./cocos/platform/android/java/ -t 12') + print 'cocos update:', infoUpdate + infoUpdate = os.system('android update project -p '+PATH_ANDROID_SRC+' -t 12') + print 'test update:', infoUpdate + def buildProj(): + infoBuild = os.system('./build/android-build.py -p 13 cpp-tests') + print 'infoBuild cpp_tests: ', infoBuild + infoBuild = os.system('ant -buildfile '+PATH_ANDROID_SRC+' debug') + print 'infoBuild: ', infoBuild + if infoBuild != 0: + print 'build **BUILD FAILED**' + time.sleep(sleep_time) + return infoBuild + def installProj(): + cmd = 'adb install '+PATH_ANDROID_SRC+'bin/CppTests-debug.apk' + infoInstall = os.system(cmd) + print 'infoInstall:', infoInstall + if infoInstall != 0: + print 'install **INSTALL FAILED**' + return infoInstall + def openProj(): + cmd = 'adb shell am start -n org.cocos2dx.cpp_tests/org.cocos2dx.cpp_tests.Cocos2dxActivity' + print 'cmd: ', cmd + infoOpen = os.system(cmd) + print 'infoOpen: ', infoOpen + if infoOpen != 0: + return False + time.sleep(sleep_time) + return True + def buildAndRun(): + if not checkDevice(): + return False + cleanProj() + updateProperty() + buildProj() + installProj() + return openProj() + return buildAndRun() #----------------autotest-android build and run end----------------# def main(): - print 'will build mac project.' - suc_build_mac = MAC_BUILD() - # print 'will build android project.' - # suc_build_android = ANDROID_BUILD() - if suc_build_mac: - autotest(TYPE_MAC) - if suc_build_android: - print 'will run android autotest.' - autotest(TYPE_ANDROID) + print 'will build mac project.' + suc_build_mac = MAC_BUILD() + # print 'will build android project.' + # suc_build_android = ANDROID_BUILD() + if suc_build_mac: + autotest(TYPE_MAC) + if suc_build_android: + print 'will run android autotest.' + autotest(TYPE_ANDROID) # -------------- main -------------- diff --git a/tools/jenkins-scripts/cocos-console-test.py b/tools/jenkins-scripts/cocos-console-test.py index 4623cdc83b..b76ec22444 100755 --- a/tools/jenkins-scripts/cocos-console-test.py +++ b/tools/jenkins-scripts/cocos-console-test.py @@ -20,10 +20,10 @@ from os.path import join, getsize console_param = '[console run]' # get param from commit. if os.environ.has_key('payload'): - payload_str = os.environ['payload'] - payload = json.loads(payload_str) - if payload.has_key('console'): - console_param = payload['console'] + payload_str = os.environ['payload'] + payload = json.loads(payload_str) + if payload.has_key('console'): + console_param = payload['console'] console_param = console_param[1:len(console_param)-1] print 'console_param:',console_param @@ -31,34 +31,34 @@ console_param_arr = console_param.split(' ') # enum command type class ENUM_PARAM: - new = 0 - compile = 1 - deploy = 2 - run = 3 + new = 0 + compile = 1 + deploy = 2 + run = 3 # partition different level LEVEL_COCOS = { - ENUM_PARAM.new : 1, - ENUM_PARAM.compile : 2, - ENUM_PARAM.deploy : 4, - ENUM_PARAM.run : 8 + ENUM_PARAM.new : 1, + ENUM_PARAM.compile : 2, + ENUM_PARAM.deploy : 4, + ENUM_PARAM.run : 8 } # level's cocos command COCOS_CMD = { - ENUM_PARAM.new:'new', - ENUM_PARAM.compile:'compile', - ENUM_PARAM.deploy:'deploy', - ENUM_PARAM.run:'run' + ENUM_PARAM.new:'new', + ENUM_PARAM.compile:'compile', + ENUM_PARAM.deploy:'deploy', + ENUM_PARAM.run:'run' } # set cocos_param for run different command cocos_param = 0 for level in LEVEL_COCOS: - if console_param_arr.count(COCOS_CMD[level]): - cocos_param = cocos_param + LEVEL_COCOS[level] + if console_param_arr.count(COCOS_CMD[level]): + cocos_param = cocos_param + LEVEL_COCOS[level] if cocos_param < LEVEL_COCOS[ENUM_PARAM.new]: - cocos_param = LEVEL_COCOS[ENUM_PARAM.new] + cocos_param = LEVEL_COCOS[ENUM_PARAM.new] print 'cocos_param:', cocos_param # project types @@ -73,109 +73,109 @@ cocos_console_dir = 'tools/cocos2d-console/bin/' # now cocos2d-console suport different run on Platforms, e.g: only run android on win runSupport = { - 'darwin' : {'mac':1,'ios':1,'android':1}, - 'win' : {'mac':0,'ios':0,'android':1}, - 'linux' : {'mac':0,'ios':0,'android':1} + 'darwin' : {'mac':1,'ios':1,'android':1}, + 'win' : {'mac':0,'ios':0,'android':1}, + 'linux' : {'mac':0,'ios':0,'android':1} } # get current running system curPlat = sys.platform if curPlat.find('linux') >= 0: - curPlat = 'linux' + curPlat = 'linux' elif curPlat.find('darwin') >= 0: - curPlat = 'darwin' + curPlat = 'darwin' else: - curPlat = 'win' + curPlat = 'win' print 'current platform is:', curPlat # delete project.(will use different system command to delete.just mac now.) def clean_project(): - print 'delete older project.' - for proj in project_types: - cmd = 'rm -rf '+proj+PROJ_SUFFIX - os.system(cmd) + print 'delete older project.' + for proj in project_types: + cmd = 'rm -rf '+proj+PROJ_SUFFIX + os.system(cmd) # file path.(for add console listen command.) FILE_PATH = '/Classes/AppDelegate.cpp' FILE_DIR = { - 'cpp':'', - 'lua':'/frameworks/runtime-src' + 'cpp':'', + 'lua':'/frameworks/runtime-src' } PARSE_WORD = 'director->setDisplayStats(true);' CONSOLE_COMMAND = 'director->getConsole()->listenOnTCP(5678);' # add console listenOnTCP to AppDelegate.cpp. def addConsoleListenOnTCP(name): - filePath = name+PROJ_SUFFIX+FILE_DIR[name]+FILE_PATH - print 'filePath:',filePath - strCont = '' - if os.path.isfile(filePath): - file_object = open(filePath, 'r') - strLine = file_object.readline() - while strLine: - strCont = strCont + strLine - if strLine.find(PARSE_WORD) > -1: - print 'add console listenOnTCP command.' - strCont = strCont+'\n\t' + CONSOLE_COMMAND + '\n' - strLine = file_object.readline() - - file_object.close() - file_object = open(filePath, 'w') - file_object.write(strCont) - file_object.close() - time.sleep(2) - else: - print 'file is not exist.' + filePath = name+PROJ_SUFFIX+FILE_DIR[name]+FILE_PATH + print 'filePath:',filePath + strCont = '' + if os.path.isfile(filePath): + file_object = open(filePath, 'r') + strLine = file_object.readline() + while strLine: + strCont = strCont + strLine + if strLine.find(PARSE_WORD) > -1: + print 'add console listenOnTCP command.' + strCont = strCont+'\n\t' + CONSOLE_COMMAND + '\n' + strLine = file_object.readline() + + file_object.close() + file_object = open(filePath, 'w') + file_object.write(strCont) + file_object.close() + time.sleep(2) + else: + print 'file is not exist.' # console result, for record result console_result = 'the result of cocos-console-test is:\n\r' # get current android devices count. def getAndroidDevices(): - cmd = 'adb devices' - info_devices = os.popen(cmd).read() - arrDevices = info_devices.split('\n') - del arrDevices[0] - count = 0 - for device in arrDevices: - # e.g: emulator-5554 device, contains 'device', so, min length is len('device') - if len(device) > len('device') and (device.find('device') >= 0): - count += 1 - return count + cmd = 'adb devices' + info_devices = os.popen(cmd).read() + arrDevices = info_devices.split('\n') + del arrDevices[0] + count = 0 + for device in arrDevices: + # e.g: emulator-5554 device, contains 'device', so, min length is len('device') + if len(device) > len('device') and (device.find('device') >= 0): + count += 1 + return count # close running app or exe by using console command. IP_PHONE = { - 'mac':'localhost', - 'ios':'localhost' + 'mac':'localhost', + 'ios':'localhost' } PORT = 5678 def close_proj(proj, phone): - print 'close running project' - # connect socket - strClose = 'close ' + proj + ' on ' + phone - if IP_PHONE.has_key(phone): - soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) - print proj, phone, IP_PHONE[phone] - try: - soc.connect((IP_PHONE[phone], PORT)) - cmd = 'director end\r\n' - print 'cmd close:', cmd - soc.send(cmd) - time.sleep(2) - strClose = strClose + ' success.' - except Exception, e: - print 'socket is not connect.' - strClose = strClose + ' failed.' + ' socket is not connect.' - else: - strClose = strClose + ' failed.' + ' no ' +phone+ ' type.' - time.sleep(2) - return strClose + print 'close running project' + # connect socket + strClose = 'close ' + proj + ' on ' + phone + if IP_PHONE.has_key(phone): + soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) + print proj, phone, IP_PHONE[phone] + try: + soc.connect((IP_PHONE[phone], PORT)) + cmd = 'director end\r\n' + print 'cmd close:', cmd + soc.send(cmd) + time.sleep(2) + strClose = strClose + ' success.' + except Exception, e: + print 'socket is not connect.' + strClose = strClose + ' failed.' + ' socket is not connect.' + else: + strClose = strClose + ' failed.' + ' no ' +phone+ ' type.' + time.sleep(2) + return strClose # appendToResult def appendToResult(content): - global console_result - console_result = console_result + content + global console_result + console_result = console_result + content info_of_close_app = {} cur_test_name = '' @@ -186,194 +186,194 @@ class myThread(threading.Thread): run_name = self.getName() print 'run_name:', run_name if run_name == 'close': - while True: - soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) - try: - soc.connect(('localhost', PORT)) - cmd_close = 'director end\r\n' - print 'cmd close:', cmd_close - soc.send(cmd_close) - time.sleep(2) - global cur_test_name - print 'cur_test_name:', cur_test_name - info_of_close_app[cur_test_name] = True - break - except Exception, e: - time.sleep(5) + while True: + soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) + try: + soc.connect(('localhost', PORT)) + cmd_close = 'director end\r\n' + print 'cmd close:', cmd_close + soc.send(cmd_close) + time.sleep(2) + global cur_test_name + print 'cur_test_name:', cur_test_name + info_of_close_app[cur_test_name] = True + break + except Exception, e: + time.sleep(5) # if any error ANY_ERROR_IN_RUN = 0 # excute cocos command def cocos_project(level): - global ANY_ERROR_IN_RUN - print 'will excute cocos_command: ', COCOS_CMD[level], level - appendToResult('will excute ' + COCOS_CMD[level] + ' command:'+"\n\r\t") - for proj in project_types: - print 'proj: ', proj - if level == ENUM_PARAM.new: - cmd = './'+cocos_console_dir+'cocos new -l '+proj+' '+proj+PROJ_SUFFIX - print proj,'cmd:',cmd - info_create = os.system(cmd) #call cmd on win is diff - if info_create == 0: - time.sleep(12) - addConsoleListenOnTCP(proj) - print 'create project',proj,' is:', not info_create - ANY_ERROR_IN_RUN = ANY_ERROR_IN_RUN + info_create - appendToResult(' '+cmd +': ' + str(not info_create) + ".\n\r\t") - else: - for phone in phonePlats: - print 'platform is: ', phone - cmd = './'+cocos_console_dir+'cocos '+COCOS_CMD[level]+' -s '+proj+PROJ_SUFFIX+' -p '+phone - print 'cmd:',cmd - info_cmd = '' - if level == ENUM_PARAM.compile: - if runSupport[curPlat][phone]: - info_cmd = os.system(cmd) - print 'info '+COCOS_CMD[level]+':', not info_cmd - appendToResult(' '+cmd +': ' + str(not info_cmd) + ".\n\r\t") - else: - if runSupport[curPlat][phone]: - print 'in desploy or run:', phone, getAndroidDevices() - if phone == 'android' and getAndroidDevices() == 0: - strInfo = 'no android device, please checkout the device is running ok.' - print strInfo - else: - if level == ENUM_PARAM.run: - global cur_test_name - cur_test_name = proj+','+phone - thread_close = myThread('close') - thread_close.start() - info_cmd = os.system(cmd) - time.sleep(5) - appendToResult(' '+cmd +': ' + str(not info_cmd) + ".\n\r\t") + global ANY_ERROR_IN_RUN + print 'will excute cocos_command: ', COCOS_CMD[level], level + appendToResult('will excute ' + COCOS_CMD[level] + ' command:'+"\n\r\t") + for proj in project_types: + print 'proj: ', proj + if level == ENUM_PARAM.new: + cmd = './'+cocos_console_dir+'cocos new -l '+proj+' '+proj+PROJ_SUFFIX + print proj,'cmd:',cmd + info_create = os.system(cmd) #call cmd on win is diff + if info_create == 0: + time.sleep(12) + addConsoleListenOnTCP(proj) + print 'create project',proj,' is:', not info_create + ANY_ERROR_IN_RUN = ANY_ERROR_IN_RUN + info_create + appendToResult(' '+cmd +': ' + str(not info_create) + ".\n\r\t") + else: + for phone in phonePlats: + print 'platform is: ', phone + cmd = './'+cocos_console_dir+'cocos '+COCOS_CMD[level]+' -s '+proj+PROJ_SUFFIX+' -p '+phone + print 'cmd:',cmd + info_cmd = '' + if level == ENUM_PARAM.compile: + if runSupport[curPlat][phone]: + info_cmd = os.system(cmd) + print 'info '+COCOS_CMD[level]+':', not info_cmd + appendToResult(' '+cmd +': ' + str(not info_cmd) + ".\n\r\t") + else: + if runSupport[curPlat][phone]: + print 'in desploy or run:', phone, getAndroidDevices() + if phone == 'android' and getAndroidDevices() == 0: + strInfo = 'no android device, please checkout the device is running ok.' + print strInfo + else: + if level == ENUM_PARAM.run: + global cur_test_name + cur_test_name = proj+','+phone + thread_close = myThread('close') + thread_close.start() + info_cmd = os.system(cmd) + time.sleep(5) + appendToResult(' '+cmd +': ' + str(not info_cmd) + ".\n\r\t") # build and run according to params of provided.(lv_ignore: e.g:ignore new) def build_run(lv_ignore): - print 'will build and run, in function build_run' - for level in LEVEL_COCOS: - print 'level:', level, cocos_param, LEVEL_COCOS[level] - if cocos_param >= LEVEL_COCOS[level] and level > lv_ignore: - if level == ENUM_PARAM.new: - clean_project() - cocos_project(level) + print 'will build and run, in function build_run' + for level in LEVEL_COCOS: + print 'level:', level, cocos_param, LEVEL_COCOS[level] + if cocos_param >= LEVEL_COCOS[level] and level > lv_ignore: + if level == ENUM_PARAM.new: + clean_project() + cocos_project(level) # android simulator name. ANDROID_SIMULATOR_NAME = 'console-test' # start android simulator if no android devices connected. def start_android_simulator(): - print 'in function start_android_simulator.' - if getAndroidDevices() > 0: - print 'already connected android device.' - return - if cocos_param >= LEVEL_COCOS[ENUM_PARAM.deploy]: - cmd_start = [ 'emulator -avd '+ANDROID_SIMULATOR_NAME ] - # print 'cmd_start:', cmd_start - # info_start = subprocess.Popen(cmd_start, stdin=subprocess.PIPE, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - # print 'start an android simulator:', not info_start + print 'in function start_android_simulator.' + if getAndroidDevices() > 0: + print 'already connected android device.' + return + if cocos_param >= LEVEL_COCOS[ENUM_PARAM.deploy]: + cmd_start = [ 'emulator -avd '+ANDROID_SIMULATOR_NAME ] + # print 'cmd_start:', cmd_start + # info_start = subprocess.Popen(cmd_start, stdin=subprocess.PIPE, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + # print 'start an android simulator:', not info_start # send email EMAIL_KEYS={ - 0:'EMAIL_HOST', - 1:'EMAIL_USER', - 2:'EMAIL_PWD', - 3:'EMAIL_POSTFIX', - 4:'EMAIL_LIST', - 5:'NEED_SEND_EMAIL' + 0:'EMAIL_HOST', + 1:'EMAIL_USER', + 2:'EMAIL_PWD', + 3:'EMAIL_POSTFIX', + 4:'EMAIL_LIST', + 5:'NEED_SEND_EMAIL' } OBJ_EMAIL_INFO = {} print 'will get env info.' for key in EMAIL_KEYS: - if os.environ.has_key(EMAIL_KEYS[key]): - OBJ_EMAIL_INFO[EMAIL_KEYS[key]] = os.environ[EMAIL_KEYS[key]] - if key == 4: - # string to list by ' ', for separate users. - OBJ_EMAIL_INFO[EMAIL_KEYS[4]] = OBJ_EMAIL_INFO[EMAIL_KEYS[4]].split(' ') + if os.environ.has_key(EMAIL_KEYS[key]): + OBJ_EMAIL_INFO[EMAIL_KEYS[key]] = os.environ[EMAIL_KEYS[key]] + if key == 4: + # string to list by ' ', for separate users. + OBJ_EMAIL_INFO[EMAIL_KEYS[4]] = OBJ_EMAIL_INFO[EMAIL_KEYS[4]].split(' ') print 'will send email.', OBJ_EMAIL_INFO def send_mail(to_list,sub,title,content): - mail_user = OBJ_EMAIL_INFO[ EMAIL_KEYS[1] ] - mail_postfix = OBJ_EMAIL_INFO[ EMAIL_KEYS[3] ] - mail_host = OBJ_EMAIL_INFO[ EMAIL_KEYS[0] ] - mail_pass = OBJ_EMAIL_INFO[ EMAIL_KEYS[2] ] - me = mail_user+"<"+mail_user+"@"+mail_postfix+">" - msg = MIMEText(content,_subtype='plain',_charset='gb2312') - msg['Subject'] = sub - msg['From'] = me - msg['To'] = " ".join(to_list) - print 'to users:', msg['To'] - msg['Content'] = 'test' - try: - s = smtplib.SMTP() - s.connect(mail_host) - s.login(mail_user,mail_pass) - s.sendmail(me, to_list, str(msg)) - print 'info:', me, to_list, str(msg) - s.close() - appendToResult( 'send email true:' + str(msg) ) - return True - except Exception, e: - appendToResult( 'send email false:' + str(e) ) + mail_user = OBJ_EMAIL_INFO[ EMAIL_KEYS[1] ] + mail_postfix = OBJ_EMAIL_INFO[ EMAIL_KEYS[3] ] + mail_host = OBJ_EMAIL_INFO[ EMAIL_KEYS[0] ] + mail_pass = OBJ_EMAIL_INFO[ EMAIL_KEYS[2] ] + me = mail_user+"<"+mail_user+"@"+mail_postfix+">" + msg = MIMEText(content,_subtype='plain',_charset='gb2312') + msg['Subject'] = sub + msg['From'] = me + msg['To'] = " ".join(to_list) + print 'to users:', msg['To'] + msg['Content'] = 'test' + try: + s = smtplib.SMTP() + s.connect(mail_host) + s.login(mail_user,mail_pass) + s.sendmail(me, to_list, str(msg)) + print 'info:', me, to_list, str(msg) + s.close() + appendToResult( 'send email true:' + str(msg) ) + return True + except Exception, e: + appendToResult( 'send email false:' + str(e) ) print str(e) return False def sendEmail(msg): - send_mail(OBJ_EMAIL_INFO[EMAIL_KEYS[4]], "cocos-console-test result", 'for error.', msg) + send_mail(OBJ_EMAIL_INFO[EMAIL_KEYS[4]], "cocos-console-test result", 'for error.', msg) # get package size def getdirsize(dir): - size = 0L - for root, dirs, files in os.walk(dir): - size += sum([getsize(join(root, name)) for name in files]) - return size + size = 0L + for root, dirs, files in os.walk(dir): + size += sum([getsize(join(root, name)) for name in files]) + return size APP_FILE_DIR = { - 'cpp':'bin/debug/', - 'lua':'runtime/' + 'cpp':'bin/debug/', + 'lua':'runtime/' } APP_FILE_SUFFIX = { - 'mac':'.app', - 'ios':'.app', - 'android':'-debug-unaligned.apk' + 'mac':'.app', + 'ios':'.app', + 'android':'-debug-unaligned.apk' } if os.environ.has_key('APP_FILE_SUFFIX'): - str_app_suffix = os.environ['APP_FILE_SUFFIX'] - APP_FILE_SUFFIX = eval(str_app_suffix) + str_app_suffix = os.environ['APP_FILE_SUFFIX'] + APP_FILE_SUFFIX = eval(str_app_suffix) def getPackageSize(): - for proj in project_types: - for phone in phonePlats: - # if runSupport[curPlat][phone]: - package_path = './'+proj+PROJ_SUFFIX+'/'+APP_FILE_DIR[proj]+phone+'/'+proj+PROJ_SUFFIX+APP_FILE_SUFFIX[phone] - print 'package_path', package_path - package_size = 0 - if os.path.isfile(package_path): - package_size = os.path.getsize(package_path); - else: - package_size = getdirsize(package_path); - strSize = 'size of '+proj+PROJ_SUFFIX+' '+phone+' is:'+str(package_size/(1024))+'KB'+'\n\t' - print 'strSize:', strSize - appendToResult(strSize) + for proj in project_types: + for phone in phonePlats: + # if runSupport[curPlat][phone]: + package_path = './'+proj+PROJ_SUFFIX+'/'+APP_FILE_DIR[proj]+phone+'/'+proj+PROJ_SUFFIX+APP_FILE_SUFFIX[phone] + print 'package_path', package_path + package_size = 0 + if os.path.isfile(package_path): + package_size = os.path.getsize(package_path); + else: + package_size = getdirsize(package_path); + strSize = 'size of '+proj+PROJ_SUFFIX+' '+phone+' is:'+str(package_size/(1024))+'KB'+'\n\t' + print 'strSize:', strSize + appendToResult(strSize) def main(): - print 'in main:' - # start_android_simulator() - print 'will build_run:' - build_run(-1) - print 'ANY_ERROR_IN_RUN:', ANY_ERROR_IN_RUN - print 'end build run. and get package size.' - getPackageSize() - print 'will send email:' - print 'console_result:', console_result - if OBJ_EMAIL_INFO[ EMAIL_KEYS[5] ] or ANY_ERROR_IN_RUN: - sendEmail(console_result) + print 'in main:' + # start_android_simulator() + print 'will build_run:' + build_run(-1) + print 'ANY_ERROR_IN_RUN:', ANY_ERROR_IN_RUN + print 'end build run. and get package size.' + getPackageSize() + print 'will send email:' + print 'console_result:', console_result + if OBJ_EMAIL_INFO[ EMAIL_KEYS[5] ] or ANY_ERROR_IN_RUN: + sendEmail(console_result) # -------------- main -------------- if __name__ == '__main__': sys_ret = 0 try: - sys_ret = main() + sys_ret = main() except: - traceback.print_exc() - sys_ret = 1 + traceback.print_exc() + sys_ret = 1 finally: - sys.exit(sys_ret) + sys.exit(sys_ret) diff --git a/tools/jenkins-scripts/configs/autotest.py b/tools/jenkins-scripts/configs/autotest.py index 5e6a6098a8..ea57782db7 100644 --- a/tools/jenkins-scripts/configs/autotest.py +++ b/tools/jenkins-scripts/configs/autotest.py @@ -6,5 +6,5 @@ ret = os.system('python -u tools/jenkins-scripts/autotest.py') os.system('git reset --hard') print ret if(ret > 0): - ret = 1 + ret = 1 exit(ret) diff --git a/tools/jenkins-scripts/configs/cocos-2dx-develop-android.py b/tools/jenkins-scripts/configs/cocos-2dx-develop-android.py index e632c330c5..60bdd4a173 100644 --- a/tools/jenkins-scripts/configs/cocos-2dx-develop-android.py +++ b/tools/jenkins-scripts/configs/cocos-2dx-develop-android.py @@ -5,10 +5,10 @@ print ' Branch:develop' print ' Target:Android' print ' build script:python build/android-build.py all' if(os.path.exists('build/android-build.py') == False): - node_name = os.environ['NODE_NAME'] - source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name + "/." - os.system("cp -r" + source_dir + " .") - os.system('git pull origin develop') + node_name = os.environ['NODE_NAME'] + source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name + "/." + os.system("cp -r" + source_dir + " .") + os.system('git pull origin develop') os.system('git submodule update --init --force') ret = os.system('python build/android-build.py -n -j8 all') @@ -16,6 +16,6 @@ os.system('git clean -xdf -f') print 'build exit' print ret if ret == 0: - exit(0) + exit(0) else: - exit(1) + exit(1) diff --git a/tools/jenkins-scripts/configs/cocos-2dx-develop-base-repo.py b/tools/jenkins-scripts/configs/cocos-2dx-develop-base-repo.py index f70b31d568..c7cd0f2fd3 100644 --- a/tools/jenkins-scripts/configs/cocos-2dx-develop-base-repo.py +++ b/tools/jenkins-scripts/configs/cocos-2dx-develop-base-repo.py @@ -2,20 +2,20 @@ import os import sys def check_ret(ret): - if(ret != 0): - os.system('git checkout -B develop remotes/origin/develop') - os.system('git clean -xdf -f') - sys.exit(1) + if(ret != 0): + os.system('git checkout -B develop remotes/origin/develop') + os.system('git clean -xdf -f') + sys.exit(1) branchs = ['develop', 'master'] for item in branchs: - os.system('git clean -xdf -f') - os.system('git checkout -B ' + item + ' remotes/origin/' + item) - os.system('git clean -xdf -f') - ret = os.system('git pull origin') - check_ret(ret) - ret = os.system('git submodule update --init --force') - check_ret(ret) + os.system('git clean -xdf -f') + os.system('git checkout -B ' + item + ' remotes/origin/' + item) + os.system('git clean -xdf -f') + ret = os.system('git pull origin') + check_ret(ret) + ret = os.system('git submodule update --init --force') + check_ret(ret) #back to develop os.system('git checkout -B develop remotes/origin/develop') diff --git a/tools/jenkins-scripts/configs/cocos-2dx-develop-ios.py b/tools/jenkins-scripts/configs/cocos-2dx-develop-ios.py index 7a0c672f47..0dedd56b3c 100644 --- a/tools/jenkins-scripts/configs/cocos-2dx-develop-ios.py +++ b/tools/jenkins-scripts/configs/cocos-2dx-develop-ios.py @@ -4,10 +4,10 @@ print ' Host:MAC' print ' Branch:develop' print ' Target:iOS' if(os.path.exists('tools/jenkins-scripts/ios-build.sh') == False): - node_name = os.environ['NODE_NAME'] - source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name + "/." - os.system("cp -r " + source_dir + " .") - os.system('git pull origin develop') + node_name = os.environ['NODE_NAME'] + source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name + "/." + os.system("cp -r " + source_dir + " .") + os.system('git pull origin develop') os.system('git submodule update --init --force') ret = os.system('tools/jenkins-scripts/ios-build.sh') @@ -15,6 +15,6 @@ os.system('git clean -xdf -f') print 'build exit' print ret if ret == 0: - exit(0) + exit(0) else: - exit(1) + exit(1) diff --git a/tools/jenkins-scripts/configs/cocos-2dx-develop-win32.py b/tools/jenkins-scripts/configs/cocos-2dx-develop-win32.py index 801874494e..1e55080898 100644 --- a/tools/jenkins-scripts/configs/cocos-2dx-develop-win32.py +++ b/tools/jenkins-scripts/configs/cocos-2dx-develop-win32.py @@ -7,11 +7,11 @@ print ' Branch:develop' print ' Target:win32' print ' "%VS110COMNTOOLS%..\IDE\devenv.com" "build\cocos2d-win32.vc2012.sln" /Build "Debug|Win32"' if(os.path.exists('build/cocos2d-win32.vc2012.sln') == False): - node_name = os.environ['NODE_NAME'] - source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name - source_dir = source_dir.replace("/", os.sep) - os.system("xcopy " + source_dir + " . /E /Y /H") - os.system('git pull origin develop') + node_name = os.environ['NODE_NAME'] + source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name + source_dir = source_dir.replace("/", os.sep) + os.system("xcopy " + source_dir + " . /E /Y /H") + os.system('git pull origin develop') os.system('git submodule update --init --force') ret = subprocess.call('"%VS110COMNTOOLS%..\IDE\devenv.com" "build\cocos2d-win32.vc2012.sln" /Build "Debug|Win32"', shell=True) @@ -19,6 +19,6 @@ os.system('git clean -xdf -f') print 'build exit' print ret if ret == 0: - exit(0) + exit(0) else: - exit(1) + exit(1) diff --git a/tools/jenkins-scripts/configs/cocos-2dx-doxygen.py b/tools/jenkins-scripts/configs/cocos-2dx-doxygen.py index 4367230caf..2dadb80233 100644 --- a/tools/jenkins-scripts/configs/cocos-2dx-doxygen.py +++ b/tools/jenkins-scripts/configs/cocos-2dx-doxygen.py @@ -5,11 +5,11 @@ print ' Branch:develop' print ' Target:Doxygen' print ' doxygen doxygen.config' if(os.path.exists('docs/doxygen.config') == False): - node_name = os.environ['NODE_NAME'] - source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name - source_dir = source_dir.replace("/", os.sep) - os.system("xcopy " + source_dir + " . /E /Y /H") - os.system('git pull origin develop') + node_name = os.environ['NODE_NAME'] + source_dir = '../cocos-2dx-develop-base-repo/node/' + node_name + source_dir = source_dir.replace("/", os.sep) + os.system("xcopy " + source_dir + " . /E /Y /H") + os.system('git pull origin develop') os.system('git submodule update --init --force') os.chdir('docs/') @@ -19,6 +19,6 @@ os.system('git clean -xdf -f') print 'build exit' print ret if ret == 0: - exit(0) + exit(0) else: - exit(1) + exit(1) diff --git a/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build-comment-trigger.py b/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build-comment-trigger.py index e7817809c5..3cc1053ce3 100644 --- a/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build-comment-trigger.py +++ b/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build-comment-trigger.py @@ -3,6 +3,6 @@ import os #os.system('git pull origin develop') ret = os.system('python -u tools/jenkins-scripts/job-comment-trigger.py') if ret == 0: - exit(0) + exit(0) else: - exit(1) + exit(1) diff --git a/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build-trigger.py b/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build-trigger.py index 60c79ddc94..fcdca42b38 100644 --- a/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build-trigger.py +++ b/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build-trigger.py @@ -3,6 +3,6 @@ import os #os.system('git pull origin develop') ret = os.system('python -u tools/jenkins-scripts/job-trigger.py') if ret == 0: - exit(0) + exit(0) else: - exit(1) + exit(1) diff --git a/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build.py b/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build.py index a09fdf2b79..6783e89cb9 100644 --- a/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build.py +++ b/tools/jenkins-scripts/configs/cocos-2dx-pull-request-build.py @@ -1,17 +1,17 @@ import os import platform if(os.path.exists('tools/jenkins-scripts/pull-request-builder.py') == False): - node_name = os.environ['NODE_NAME'] - source_dir = '../../../cocos-2dx-develop-base-repo/node/' + node_name - if(platform.system() == 'Windows'): - source_dir = source_dir.replace("/", os.sep) - os.system("xcopy " + source_dir + ' . /E /Y /H') - else: - os.system("cp -r " + source_dir + "/. .") + node_name = os.environ['NODE_NAME'] + source_dir = '../../../cocos-2dx-develop-base-repo/node/' + node_name + if(platform.system() == 'Windows'): + source_dir = source_dir.replace("/", os.sep) + os.system("xcopy " + source_dir + ' . /E /Y /H') + else: + os.system("cp -r " + source_dir + "/. .") def clean_workspace(): - os.system('git reset --hard') - os.system('git clean -xdf -f') + os.system('git reset --hard') + os.system('git clean -xdf -f') clean_workspace() os.system('git checkout develop') @@ -19,14 +19,14 @@ clean_workspace() os.system('git pull origin develop') for i in range(0, 3): - ret = os.system('python -u tools/jenkins-scripts/pull-request-builder.py') - if(ret > 255): - ret >>= 8 - if(ret == 0) or (ret == 1): - break + ret = os.system('python -u tools/jenkins-scripts/pull-request-builder.py') + if(ret > 255): + ret >>= 8 + if(ret == 0) or (ret == 1): + break clean_workspace() print ret if(ret > 0): - ret = 1 + ret = 1 exit(ret) diff --git a/tools/jenkins-scripts/configs/cocos2d-console-test.py b/tools/jenkins-scripts/configs/cocos2d-console-test.py index 26a2492a2f..9e58f9f1ec 100644 --- a/tools/jenkins-scripts/configs/cocos2d-console-test.py +++ b/tools/jenkins-scripts/configs/cocos2d-console-test.py @@ -8,5 +8,5 @@ ret = os.system('python -u tools/jenkins-scripts/cocos-console-test.py') os.system('git reset --hard') print ret if(ret > 0): - ret = 1 + ret = 1 exit(ret) diff --git a/tools/jenkins-scripts/configs/cocostudiox-base-repo.py b/tools/jenkins-scripts/configs/cocostudiox-base-repo.py index 91aeb02ee0..8c264bc7df 100644 --- a/tools/jenkins-scripts/configs/cocostudiox-base-repo.py +++ b/tools/jenkins-scripts/configs/cocostudiox-base-repo.py @@ -2,7 +2,7 @@ import os import sys ret = os.system('git pull origin master') if(ret != 0): - sys.exit(1) + sys.exit(1) ret = os.system('git submodule update --init --force') if(ret != 0): - sys.exit(1) + sys.exit(1) diff --git a/tools/jenkins-scripts/configs/cocostudiox-daily-build.py b/tools/jenkins-scripts/configs/cocostudiox-daily-build.py index 00cf754f82..b7f0e04a5c 100644 --- a/tools/jenkins-scripts/configs/cocostudiox-daily-build.py +++ b/tools/jenkins-scripts/configs/cocostudiox-daily-build.py @@ -1,13 +1,13 @@ import os import platform if(os.path.exists('CocoStudio/CSX/CSX/CSX.pro') == False): - node_name = os.environ['NODE_NAME'] - source_dir = '../../../cocostudiox-base-repo/node/' + node_name - if(platform.system() == 'Windows'): - source_dir = source_dir.replace("/", os.sep) - os.system("xcopy " + source_dir + ' . /E /Y /H') - else: - os.system("cp -r " + source_dir + "/. .") + node_name = os.environ['NODE_NAME'] + source_dir = '../../../cocostudiox-base-repo/node/' + node_name + if(platform.system() == 'Windows'): + source_dir = source_dir.replace("/", os.sep) + os.system("xcopy " + source_dir + ' . /E /Y /H') + else: + os.system("cp -r " + source_dir + "/. .") os.system('git pull origin') os.system('git submodule update --init --force') @@ -16,15 +16,15 @@ node_name = os.environ['NODE_NAME'] os.chdir('CocoStudio/CSX/CSX') ret = os.system('qmake -r') if(ret == 0): - if(node_name == 'android_mac'): - ret = os.system('make -j8') - elif(node_name == 'win32_win7'): - ret = os.system('mingw32-make -j8') + if(node_name == 'android_mac'): + ret = os.system('make -j8') + elif(node_name == 'win32_win7'): + ret = os.system('mingw32-make -j8') os.chdir('../../..') os.system('git clean -xdf') os.system('git reset --hard') print ret if(ret > 0): - ret = 1 + ret = 1 exit(ret) diff --git a/tools/jenkins-scripts/emptytest.py b/tools/jenkins-scripts/emptytest.py index d5cc7e3f9a..86d671981a 100644 --- a/tools/jenkins-scripts/emptytest.py +++ b/tools/jenkins-scripts/emptytest.py @@ -19,290 +19,290 @@ import paramiko payload = {} #get payload from os env if os.environ.has_key('payload'): - payload_str = os.environ['payload'] - #parse to json obj - payload = json.loads(payload_str) + payload_str = os.environ['payload'] + #parse to json obj + payload = json.loads(payload_str) print 'payload:',payload pr_num = 6326 #get pull number if payload.has_key('number'): - pr_num = payload['number'] + pr_num = payload['number'] print 'pr_num:' + str(pr_num) run_app_time = 5 if os.environ.has_key('RUN_APP_TIME'): - run_app_time = os.environ['RUN_APP_TIME'] + run_app_time = os.environ['RUN_APP_TIME'] print 'run_app_time:', run_app_time test_name = ['cpp_empty_test'] if os.environ.has_key('TESTS_NAME'): - temp_var = os.environ['TESTS_NAME'] - test_name = temp_var.split(', ') + temp_var = os.environ['TESTS_NAME'] + test_name = temp_var.split(', ') package_name = ['org.cocos2dx.cpp_empty_test'] if os.environ.has_key('PACKAGE_NAME'): - temp_var = os.environ['PACKAGE_NAME'] - package_name = temp_var.split(', ') + temp_var = os.environ['PACKAGE_NAME'] + package_name = temp_var.split(', ') activity_name = ['org.cocos2dx.cpp_empty_test.AppActivity'] if os.environ.has_key('ACTIVITY_NAME'): - temp_var = os.environ['ACTIVITY_NAME'] - activity_name = temp_var.split(', ') + temp_var = os.environ['ACTIVITY_NAME'] + activity_name = temp_var.split(', ') gIdx = 0 if os.environ.has_key('TEST_INDEX'): - gIdx = os.environ('TEST_INDEX') + gIdx = os.environ('TEST_INDEX') current_platform = platform.system() print 'current platform is:', current_platform arrDevices = [] def getDevices(): - cmd = 'adb devices' - info_devices = os.popen(cmd).read() - arr_info = info_devices.split('\n') - del arr_info[0] - count = 0 - for device in arr_info: - if len(device) > 0: - count += 1 - print 'device ', count,device - deviceInfo = device.split(' ') - global arrDevices - obj = {} - obj['name'] = deviceInfo[0] - arrDevices.append(obj) - return count + cmd = 'adb devices' + info_devices = os.popen(cmd).read() + arr_info = info_devices.split('\n') + del arr_info[0] + count = 0 + for device in arr_info: + if len(device) > 0: + count += 1 + print 'device ', count,device + deviceInfo = device.split(' ') + global arrDevices + obj = {} + obj['name'] = deviceInfo[0] + arrDevices.append(obj) + return count def getADBDeviceIP(device_name): - output = os.popen("adb -s "+device_name+" shell netcfg") - configs = output.read().split('\r\n') - output.close() - for l in configs: - items = l.split() - if len(items)>1 and items[1] == 'UP': - if items[2].find('127.0.0.1') < 0 and items[2].find('0.0.0.0') < 0: - return items[2] - return False + output = os.popen("adb -s "+device_name+" shell netcfg") + configs = output.read().split('\r\n') + output.close() + for l in configs: + items = l.split() + if len(items)>1 and items[1] == 'UP': + if items[2].find('127.0.0.1') < 0 and items[2].find('0.0.0.0') < 0: + return items[2] + return False def mapIP(): - for device in arrDevices: - ip_d = getADBDeviceIP(device['name']) - device['ip'] = ip_d + for device in arrDevices: + ip_d = getADBDeviceIP(device['name']) + device['ip'] = ip_d allThreadIsRunning = {} def setThreadStatus(): - for device in arrDevices: - allThreadIsRunning[device['name']] = 1 + for device in arrDevices: + allThreadIsRunning[device['name']] = 1 devices_info = {} info_list = '{"product":["model","brand","name","cpu.abi","cpu.abi2","manufacturer","locale.language","locale.region"],"build":["id","version.sdk","version.release"]}' if os.environ.has_key('DEVICE_INFO_LIST'): - info_list = os.environ['DEVICE_INFO_LIST'] + info_list = os.environ['DEVICE_INFO_LIST'] info_list = eval(info_list) def getDeviceInfoByName(name): - cmd = '' - dev_name = name - if len(name) > 0: - cmd = 'adb -s '+name+' shell cat /system/build.prop' - else: - cmd = 'adb shell cat /system/build.prop' - dev_name = 'device one' - pip_cat = os.popen(cmd) - read_info = pip_cat.read() - read_info_list = read_info.split('\r\n') - device_info_one = {} - def checkProperty(item_str, device_name): - for argv in info_list: - for item in info_list[argv]: - prop = argv+'.'+item - if item_str.find(prop) > -1: - arr_item = item_str.split('=') - device_info_one[prop] = arr_item[1] - break - for item in read_info_list: - checkProperty(item, dev_name) - devices_info[dev_name] = device_info_one + cmd = '' + dev_name = name + if len(name) > 0: + cmd = 'adb -s '+name+' shell cat /system/build.prop' + else: + cmd = 'adb shell cat /system/build.prop' + dev_name = 'device one' + pip_cat = os.popen(cmd) + read_info = pip_cat.read() + read_info_list = read_info.split('\r\n') + device_info_one = {} + def checkProperty(item_str, device_name): + for argv in info_list: + for item in info_list[argv]: + prop = argv+'.'+item + if item_str.find(prop) > -1: + arr_item = item_str.split('=') + device_info_one[prop] = arr_item[1] + break + for item in read_info_list: + checkProperty(item, dev_name) + devices_info[dev_name] = device_info_one #getDeviceInfoByName('') #print 'device_info:',device_info def getDeviceInfomation(): - for device in arrDevices: - getDeviceInfoByName(device['name']) + for device in arrDevices: + getDeviceInfoByName(device['name']) info_empty_test = {} info_empty_test_pro = ['install','open','socket','uninstall'] def init_info_empty_test(): - for item in info_empty_test_pro: - info_empty_test[item] = {} + for item in info_empty_test_pro: + info_empty_test[item] = {} init_info_empty_test() apk_name = 'apks/'+test_name[gIdx]+'/'+test_name[gIdx]+'_'+str(pr_num)+'.apk' def install_apk_on_device(device): - name = device['name'] - cmd = 'adb -s '+name+' install '+apk_name - print 'install on '+name - info_install = os.popen(cmd).read() - print 'infomation of install apk:', info_install - info_install_arr = info_install.split('\r\n') - info_install_result = False - for item in info_install_arr: - if item.find('Success') > -1: - info_install_result = True - info_empty_test['install'][name] = info_install_result - return True + name = device['name'] + cmd = 'adb -s '+name+' install '+apk_name + print 'install on '+name + info_install = os.popen(cmd).read() + print 'infomation of install apk:', info_install + info_install_arr = info_install.split('\r\n') + info_install_result = False + for item in info_install_arr: + if item.find('Success') > -1: + info_install_result = True + info_empty_test['install'][name] = info_install_result + return True def open_apk_on_device(device): - print 'will open activity:' - name = device['name'] - cmd = 'adb -s '+name+' shell am start -n '+package_name[gIdx]+'/'+activity_name[gIdx] - # print 'start activity:', cmd - info_start = os.popen(cmd).read() - info_start = info_start.split('\r\n') - # print 'info_start:', info_start - info_start_result = True - for info in info_start: - if info.find('Error:') > -1: - print 'infomation of open activity:',info - info_start_result = False - info_empty_test['open'][name] = info_start_result - return True + print 'will open activity:' + name = device['name'] + cmd = 'adb -s '+name+' shell am start -n '+package_name[gIdx]+'/'+activity_name[gIdx] + # print 'start activity:', cmd + info_start = os.popen(cmd).read() + info_start = info_start.split('\r\n') + # print 'info_start:', info_start + info_start_result = True + for info in info_start: + if info.find('Error:') > -1: + print 'infomation of open activity:',info + info_start_result = False + info_empty_test['open'][name] = info_start_result + return True PORT = 5678 def socket_status_on_device(device): - name = device['name'] - ip = device['ip'] - soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) - status_socket = False - info_of_socket_result = '' - try: - print 'telnet ', ip, PORT - soc.connect((ip, PORT)) - cmd = 'resolution\r\n' - print 'connected successfully.' - print 'send console command: resolution' - soc.send(cmd) - while True: - data = soc.recv(1024) - if len(data): - print data - if data.find('size:') > -1: - info_of_socket_result = 'OK' - print 'close', test_name[gIdx] - soc.send('director end') - status_socket = True - break - if not data: - info_of_socket_result = test_name[gIdx]+' is crashed!' - break - except Exception, e: - info_of_socket_result = test_name[gIdx]+' is crashed!' - time.sleep(2) - soc.close() - time.sleep(2) - info_empty_test['socket'][name] = info_of_socket_result - return status_socket + name = device['name'] + ip = device['ip'] + soc = socket.socket( socket.AF_INET, socket.SOCK_STREAM ) + status_socket = False + info_of_socket_result = '' + try: + print 'telnet ', ip, PORT + soc.connect((ip, PORT)) + cmd = 'resolution\r\n' + print 'connected successfully.' + print 'send console command: resolution' + soc.send(cmd) + while True: + data = soc.recv(1024) + if len(data): + print data + if data.find('size:') > -1: + info_of_socket_result = 'OK' + print 'close', test_name[gIdx] + soc.send('director end') + status_socket = True + break + if not data: + info_of_socket_result = test_name[gIdx]+' is crashed!' + break + except Exception, e: + info_of_socket_result = test_name[gIdx]+' is crashed!' + time.sleep(2) + soc.close() + time.sleep(2) + info_empty_test['socket'][name] = info_of_socket_result + return status_socket def uninstall_apk_on_device(device): - # adb shell pm uninstall -n org.cocos2dx.hellolua - print 'uninstall ', test_name[gIdx] - name = device['name'] - cmd = 'adb -s '+name+' shell pm uninstall -n '+package_name[gIdx] - info_uninstall = os.popen(cmd).read() - info_uninstall_result = '' - if info_uninstall.find('Success') > -1: - info_uninstall_result = 'OK' - else: - info_uninstall_result = 'uninstall Failed!' - info_empty_test['uninstall'][name] = info_uninstall_result - return True + # adb shell pm uninstall -n org.cocos2dx.hellolua + print 'uninstall ', test_name[gIdx] + name = device['name'] + cmd = 'adb -s '+name+' shell pm uninstall -n '+package_name[gIdx] + info_uninstall = os.popen(cmd).read() + info_uninstall_result = '' + if info_uninstall.find('Success') > -1: + info_uninstall_result = 'OK' + else: + info_uninstall_result = 'uninstall Failed!' + info_empty_test['uninstall'][name] = info_uninstall_result + return True def excute_test_on_device(device): - uninstall_apk_on_device(device) - print device - info_install = install_apk_on_device(device) - print 'install:', info_install - info_open = open_apk_on_device(device) - print 'open:', info_open - time.sleep(3) - info_socket = socket_status_on_device(device) - print 'socket:', info_socket - info_uninstall = uninstall_apk_on_device(device) - print 'uninstall:', info_uninstall - allThreadIsRunning[device['name']] = 0 + uninstall_apk_on_device(device) + print device + info_install = install_apk_on_device(device) + print 'install:', info_install + info_open = open_apk_on_device(device) + print 'open:', info_open + time.sleep(3) + info_socket = socket_status_on_device(device) + print 'socket:', info_socket + info_uninstall = uninstall_apk_on_device(device) + print 'uninstall:', info_uninstall + allThreadIsRunning[device['name']] = 0 address_of_result_html = '' def send_result_to_master(): - if not os.environ.has_key('REMOTE_IP'): - return false - remote_ip = os.environ['REMOTE_IP'] - remote_port = os.environ['REMOTE_PORT'] - remote_user = os.environ['REMOTE_USER'] - remote_pwd = os.environ['REMOTE_PWD'] - remote_dir = os.environ['REMOTE_DIR'] - remote_dir = remote_dir + str(pr_num)+'/' - print remote_dir - ssh = paramiko.SSHClient() - print 'ssh:',ssh - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - ssh.connect(remote_ip, int(remote_port), remote_user, remote_pwd) - # create dir - stdin, stdout, stderr = ssh.exec_command("mkdir "+remote_dir) - ssh.close() - trans = paramiko.Transport((remote_ip,int(remote_port))) - trans.connect(username = remote_user, password = remote_pwd) - sftp = paramiko.SFTPClient.from_transport(trans) - remotepath = remote_dir+test_name[gIdx]+'_'+str(pr_num)+'.html' - localpath = 'html/cpp_empty_test/cpp_empty_test_'+str(pr_num)+'.html' - sftp.put(localpath, remotepath) - sftp.close() - result_dir = remote_dir.replace('/data',':9000') - global address_of_result_html - address_of_result_html = 'http://'+remote_ip+result_dir+test_name[gIdx]+'_'+str(pr_num)+'.html' - + if not os.environ.has_key('REMOTE_IP'): + return false + remote_ip = os.environ['REMOTE_IP'] + remote_port = os.environ['REMOTE_PORT'] + remote_user = os.environ['REMOTE_USER'] + remote_pwd = os.environ['REMOTE_PWD'] + remote_dir = os.environ['REMOTE_DIR'] + remote_dir = remote_dir + str(pr_num)+'/' + print remote_dir + ssh = paramiko.SSHClient() + print 'ssh:',ssh + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + ssh.connect(remote_ip, int(remote_port), remote_user, remote_pwd) + # create dir + stdin, stdout, stderr = ssh.exec_command("mkdir "+remote_dir) + ssh.close() + trans = paramiko.Transport((remote_ip,int(remote_port))) + trans.connect(username = remote_user, password = remote_pwd) + sftp = paramiko.SFTPClient.from_transport(trans) + remotepath = remote_dir+test_name[gIdx]+'_'+str(pr_num)+'.html' + localpath = 'html/cpp_empty_test/cpp_empty_test_'+str(pr_num)+'.html' + sftp.put(localpath, remotepath) + sftp.close() + result_dir = remote_dir.replace('/data',':9000') + global address_of_result_html + address_of_result_html = 'http://'+remote_ip+result_dir+test_name[gIdx]+'_'+str(pr_num)+'.html' + def check_thread_is_running(): - while 1: - in_running = 0 - for key in allThreadIsRunning: - in_running = in_running + allThreadIsRunning[key] - # print 'in_running:', in_running - time.sleep(3) - if not in_running: - break - print 'all cpp emptytest is finished.' - log_emptytest_result() - print 'will send result:' - send_result_to_master() - print 'end of check thread is running.' - print 'address of result is:',address_of_result_html + while 1: + in_running = 0 + for key in allThreadIsRunning: + in_running = in_running + allThreadIsRunning[key] + # print 'in_running:', in_running + time.sleep(3) + if not in_running: + break + print 'all cpp emptytest is finished.' + log_emptytest_result() + print 'will send result:' + send_result_to_master() + print 'end of check thread is running.' + print 'address of result is:',address_of_result_html def generate_html_with_result(result): - target_path = 'html/cpp_empty_test/cpp_empty_test_'+str(pr_num)+'.html' - data = codecs.open('hello.html', encoding='UTF-8').read() - data = re.sub("content", result, data) - codecs.open(target_path, 'wb', encoding='UTF-8').write(data) + target_path = 'html/cpp_empty_test/cpp_empty_test_'+str(pr_num)+'.html' + data = codecs.open('hello.html', encoding='UTF-8').read() + data = re.sub("content", result, data) + codecs.open(target_path, 'wb', encoding='UTF-8').write(data) empty_test_result = True str_result = '' def log_emptytest_result(): - def appendToResult(one_str): - global str_result - str_result = str_result + one_str + '\r\n' - appendToResult('
')
-	appendToResult('empty test start:')
-	for device in arrDevices:
-		name = device['name']
-		appendToResult('device infomation of : '+name)
-		for key in devices_info[name]:
-			appendToResult('\t'+key+':'+devices_info[name][key])
-		appendToResult('install: ' + str(info_empty_test['install'][name]))
-		appendToResult('open: ' + str(info_empty_test['open'][name]))
-		appendToResult('telnet ' + str(device['ip'])+' : ' + str(info_empty_test['socket'][name]))
-		appendToResult('close: ' + str(info_empty_test['socket'][name]))
-		appendToResult('uninstall: ' + str(info_empty_test['uninstall'][name]))
-		if not info_empty_test['install'][name] or not info_empty_test['open'][name] or not info_empty_test['socket'][name] or not info_empty_test['uninstall'][name]:
-			empty_test_result = False
-			appendToResult('run failed!')
-		else: appendToResult('run successfully!')
-		appendToResult('')
-	appendToResult('empty test end.
') - generate_html_with_result(str_result) - print 'log empty test end' + def appendToResult(one_str): + global str_result + str_result = str_result + one_str + '\r\n' + appendToResult('
')
+    appendToResult('empty test start:')
+    for device in arrDevices:
+        name = device['name']
+        appendToResult('device infomation of : '+name)
+        for key in devices_info[name]:
+            appendToResult('\t'+key+':'+devices_info[name][key])
+        appendToResult('install: ' + str(info_empty_test['install'][name]))
+        appendToResult('open: ' + str(info_empty_test['open'][name]))
+        appendToResult('telnet ' + str(device['ip'])+' : ' + str(info_empty_test['socket'][name]))
+        appendToResult('close: ' + str(info_empty_test['socket'][name]))
+        appendToResult('uninstall: ' + str(info_empty_test['uninstall'][name]))
+        if not info_empty_test['install'][name] or not info_empty_test['open'][name] or not info_empty_test['socket'][name] or not info_empty_test['uninstall'][name]:
+            empty_test_result = False
+            appendToResult('run failed!')
+        else: appendToResult('run successfully!')
+        appendToResult('')
+    appendToResult('empty test end.
') + generate_html_with_result(str_result) + print 'log empty test end' class myThread(threading.Thread): def __init__(self,threadname): @@ -316,39 +316,39 @@ class myThread(threading.Thread): excute_test_on_device(device) def run_emptytest(): - for device in arrDevices: - th = myThread(device) - th.start() + for device in arrDevices: + th = myThread(device) + th.start() def main(): - print 'in main:' - getDevices() - if len(arrDevices): - mapIP() - setThreadStatus() - print 'arrDevices:',arrDevices - time.sleep(1) - else: - print 'there is no device for emptytest, please check devices!' - return 1 - if len(arrDevices): - getDeviceInfomation() - run_emptytest() - check_thread_is_running() - print 'info_empty_test:', info_empty_test - print 'empty test end', empty_test_result - if empty_test_result: - return 0 - else: - return 1 + print 'in main:' + getDevices() + if len(arrDevices): + mapIP() + setThreadStatus() + print 'arrDevices:',arrDevices + time.sleep(1) + else: + print 'there is no device for emptytest, please check devices!' + return 1 + if len(arrDevices): + getDeviceInfomation() + run_emptytest() + check_thread_is_running() + print 'info_empty_test:', info_empty_test + print 'empty test end', empty_test_result + if empty_test_result: + return 0 + else: + return 1 # -------------- main -------------- if __name__ == '__main__': sys_ret = 0 try: - sys_ret = main() + sys_ret = main() except: - traceback.print_exc() - sys_ret = 1 + traceback.print_exc() + sys_ret = 1 finally: - sys.exit(sys_ret) + sys.exit(sys_ret) diff --git a/tools/jenkins-scripts/github-pr-watchdog.py b/tools/jenkins-scripts/github-pr-watchdog.py index d5c417730e..0f38b46117 100644 --- a/tools/jenkins-scripts/github-pr-watchdog.py +++ b/tools/jenkins-scripts/github-pr-watchdog.py @@ -12,61 +12,61 @@ job_trigger_url=os.environ['JOB_PULL_REQUEST_BUILD_TRIGGER_URL'] access_token = os.environ['GITHUB_ACCESS_TOKEN'] Headers = {"Authorization":"token " + access_token} def main(): - r = requests.get(url,headers=Headers) - payload = r.json() - #print payload - for pr in payload: - pr_num = pr['number'] - r = requests.get(pr['url']+"/commits",headers=Headers) - commits = r.json() - #print commits - last_commit = commits[len(commits)-1] - message = last_commit['commit']['message'] - - #print message - pattern = re.compile("\[ci(\s+)skip\]", re.I) - result_commit_title = pattern.search(message) + r = requests.get(url,headers=Headers) + payload = r.json() + #print payload + for pr in payload: + pr_num = pr['number'] + r = requests.get(pr['url']+"/commits",headers=Headers) + commits = r.json() + #print commits + last_commit = commits[len(commits)-1] + message = last_commit['commit']['message'] + + #print message + pattern = re.compile("\[ci(\s+)skip\]", re.I) + result_commit_title = pattern.search(message) - title = pr['title'] - result_pr_title = pattern.search(title) - if result_commit_title is not None or result_pr_title is not None: - print 'skip build for pull request #' + str(pr_num) - break - #return(0) - s = pr['statuses_url'] - update_time = pr['updated_at'] - #print pr_num - #print s - #print update_time - t = datetime.datetime.strptime(update_time, "%Y-%m-%dT%H:%M:%SZ") - now = datetime.datetime.utcnow() - three_minutes = datetime.timedelta(seconds=3*60) - if (t + three_minutes < now): - #print pr_num - statuses = requests.get(s, headers=Headers) - #print statuses.json() - if(len(statuses.json()) < 1): - print pr_num - payload_forward = {} - payload_forward['number']=pr_num - payload_forward['action']=pr['state'] - payload_forward['html_url']=pr['html_url'] - payload_forward['statuses_url']=pr['statuses_url'] - payload_forward['branch']=pr['base']['ref'] - print payload_forward - post_data = {'payload':""} - post_data['payload']= json.dumps(payload_forward) + title = pr['title'] + result_pr_title = pattern.search(title) + if result_commit_title is not None or result_pr_title is not None: + print 'skip build for pull request #' + str(pr_num) + break + #return(0) + s = pr['statuses_url'] + update_time = pr['updated_at'] + #print pr_num + #print s + #print update_time + t = datetime.datetime.strptime(update_time, "%Y-%m-%dT%H:%M:%SZ") + now = datetime.datetime.utcnow() + three_minutes = datetime.timedelta(seconds=3*60) + if (t + three_minutes < now): + #print pr_num + statuses = requests.get(s, headers=Headers) + #print statuses.json() + if(len(statuses.json()) < 1): + print pr_num + payload_forward = {} + payload_forward['number']=pr_num + payload_forward['action']=pr['state'] + payload_forward['html_url']=pr['html_url'] + payload_forward['statuses_url']=pr['statuses_url'] + payload_forward['branch']=pr['base']['ref'] + print payload_forward + post_data = {'payload':""} + post_data['payload']= json.dumps(payload_forward) - requests.post(job_trigger_url, data=post_data) + requests.post(job_trigger_url, data=post_data) # -------------- main -------------- if __name__ == '__main__': sys_ret = 0 try: - main() + main() except: - traceback.print_exc() - sys_ret = 1 + traceback.print_exc() + sys_ret = 1 finally: - sys.exit(sys_ret) + sys.exit(sys_ret) diff --git a/tools/jenkins-scripts/post-build.py b/tools/jenkins-scripts/post-build.py index 2efc346ded..68d9055111 100644 --- a/tools/jenkins-scripts/post-build.py +++ b/tools/jenkins-scripts/post-build.py @@ -33,10 +33,10 @@ def send_mail(sub,title,content): return False def sendEmail(pr, html_url, target_url): - sub = "Pull request #" + str(pr) + " build is failed!" - title = "build failed!" - content = 'to view build result, check:\r\n'+target_url + '\r\nYou can view the failed pr at:\r\n'+html_url - send_mail(sub, title, content) + sub = "Pull request #" + str(pr) + " build is failed!" + title = "build failed!" + content = 'to view build result, check:\r\n'+target_url + '\r\nYou can view the failed pr at:\r\n'+html_url + send_mail(sub, title, content) payload_str = os.environ['payload'] payload_str = payload_str.decode('utf-8','ignore') diff --git a/tools/jenkins-scripts/reboot.py b/tools/jenkins-scripts/reboot.py index 8d21c6d175..22f6a1b05c 100755 --- a/tools/jenkins-scripts/reboot.py +++ b/tools/jenkins-scripts/reboot.py @@ -25,40 +25,40 @@ print 'remote_port',int(remote_port[0]) all_machines = {} def set_default_value_to_all_machines(): - for idx, item in enumerate(remote_machines): - all_machines[item]={} - all_machines[item]['ip']=remote_ip[idx] - all_machines[item]['dir']=remote_dir[idx] - all_machines[item]['port']=remote_port[idx] - all_machines[item]['user']=remote_user[idx] - all_machines[item]['pwd']=os.environ[item+'_PWD'] + for idx, item in enumerate(remote_machines): + all_machines[item]={} + all_machines[item]['ip']=remote_ip[idx] + all_machines[item]['dir']=remote_dir[idx] + all_machines[item]['port']=remote_port[idx] + all_machines[item]['user']=remote_user[idx] + all_machines[item]['pwd']=os.environ[item+'_PWD'] def reboot_machine(machine, item): - print 'machine:',machine, 'item:', item - remote_ip = machine['ip'] - remote_port = machine['port'] - remote_user = machine['user'] - remote_pwd = machine['pwd'] - remote_dir = os.path.join(machine['dir'],'workspace','reboot', 'reboot.py') - print remote_dir - ssh = paramiko.SSHClient() - print 'ssh:',ssh - ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) - ssh.connect(remote_ip, int(remote_port), remote_user, remote_pwd) - # excute reboot.py on machine - cmd = 'python '+remote_dir - if item == 'win32_win7': - cmd = 'cmd.exe /c "python '+remote_dir+'"' - stdin, stdout, stderr = ssh.exec_command(cmd) - print stdout.readlines() - ssh.close() - print 'OK' + print 'machine:',machine, 'item:', item + remote_ip = machine['ip'] + remote_port = machine['port'] + remote_user = machine['user'] + remote_pwd = machine['pwd'] + remote_dir = os.path.join(machine['dir'],'workspace','reboot', 'reboot.py') + print remote_dir + ssh = paramiko.SSHClient() + print 'ssh:',ssh + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + ssh.connect(remote_ip, int(remote_port), remote_user, remote_pwd) + # excute reboot.py on machine + cmd = 'python '+remote_dir + if item == 'win32_win7': + cmd = 'cmd.exe /c "python '+remote_dir+'"' + stdin, stdout, stderr = ssh.exec_command(cmd) + print stdout.readlines() + ssh.close() + print 'OK' def main(): - print 'in main' - set_default_value_to_all_machines() - for item in all_machines: - reboot_machine( all_machines[item], item ) + print 'in main' + set_default_value_to_all_machines() + for item in all_machines: + reboot_machine( all_machines[item], item ) # -------------- main -------------- if __name__ == '__main__': From 0eafeba16b0483309ca06b73572a22d04c3f590e Mon Sep 17 00:00:00 2001 From: kompjoefriek Date: Thu, 12 Feb 2015 21:40:11 +0100 Subject: [PATCH 4/6] Manually undo unwanted changed made by previous merge --- cocos/2d/libcocos2d.vcxproj | 5 +++-- cocos/2d/libcocos2d.vcxproj.filters | 15 +++++++++------ .../Classes/Camera3DTest/Camera3DTest.cpp | 1 - 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cocos/2d/libcocos2d.vcxproj b/cocos/2d/libcocos2d.vcxproj index 4df8209fb3..fb0b1f4062 100644 --- a/cocos/2d/libcocos2d.vcxproj +++ b/cocos/2d/libcocos2d.vcxproj @@ -587,6 +587,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + @@ -657,6 +658,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* + + @@ -822,8 +825,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\chipmunk\prebuilt\win32\release-lib\*.* - - diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index 98fedbaec1..3220ca46b1 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -1639,6 +1639,12 @@ base + + platform + + + platform + base @@ -1870,6 +1876,9 @@ base + + 3d + 3d @@ -2539,12 +2548,6 @@ physics - - platform - - - platform -
diff --git a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp index 42d20c27a5..0408ea92dd 100644 --- a/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp +++ b/tests/cpp-tests/Classes/Camera3DTest/Camera3DTest.cpp @@ -245,7 +245,6 @@ Camera3DTestDemo::Camera3DTestDemo(void) , _bZoomIn(false) , _bRotateLeft(false) , _bRotateRight(false) -, _cameraType(CameraType::Free) { } Camera3DTestDemo::~Camera3DTestDemo(void) From c7303c70031077747f816d793608b31cbcd47593 Mon Sep 17 00:00:00 2001 From: kompjoefriek Date: Thu, 12 Feb 2015 21:45:27 +0100 Subject: [PATCH 5/6] Manually undo unwanted changes made by previous merge --- cocos/2d/libcocos2d.vcxproj.filters | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/2d/libcocos2d.vcxproj.filters b/cocos/2d/libcocos2d.vcxproj.filters index 3220ca46b1..7862cbe2c6 100644 --- a/cocos/2d/libcocos2d.vcxproj.filters +++ b/cocos/2d/libcocos2d.vcxproj.filters @@ -1640,10 +1640,10 @@ base
- platform + base - platform + base base From c0c55f885e21e165b3fdb5923f87574cbaa71479 Mon Sep 17 00:00:00 2001 From: kompjoefriek Date: Thu, 12 Feb 2015 22:38:07 +0100 Subject: [PATCH 6/6] Removed trailing spaces --- templates/cpp-template-default/proj.android/build_native.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/cpp-template-default/proj.android/build_native.py b/templates/cpp-template-default/proj.android/build_native.py index dd948d6d9b..e10a41d1fc 100755 --- a/templates/cpp-template-default/proj.android/build_native.py +++ b/templates/cpp-template-default/proj.android/build_native.py @@ -71,12 +71,12 @@ def do_build(cocos_root, ndk_root, app_android_root,ndk_build_param,sdk_root,and elif android_platform is not None: sdk_tool_path = os.path.join(sdk_root, "tools/android") cocoslib_path = os.path.join(cocos_root, "cocos/platform/android/java") - command = '%s update lib-project -t %s -p %s' % (sdk_tool_path,android_platform,cocoslib_path) + command = '%s update lib-project -t %s -p %s' % (sdk_tool_path,android_platform,cocoslib_path) if os.system(command) != 0: - raise Exception("update cocos lib-project [ " + cocoslib_path + " ] fails!") + raise Exception("update cocos lib-project [ " + cocoslib_path + " ] fails!") command = '%s update project -t %s -p %s -s' % (sdk_tool_path,android_platform,app_android_root) if os.system(command) != 0: - raise Exception("update project [ " + app_android_root + " ] fails!") + raise Exception("update project [ " + app_android_root + " ] fails!") buildfile_path = os.path.join(app_android_root, "build.xml") command = 'ant clean %s -f %s -Dsdk.dir=%s' % (build_mode,buildfile_path,sdk_root) os.system(command)