From 0ca645f7444bc0c10331ddecdace163f4130d03c Mon Sep 17 00:00:00 2001 From: andyque Date: Tue, 7 Jul 2015 16:54:03 +0800 Subject: [PATCH] add runtime daily build script --- tools/jenkins-scripts/runtime-daily-build.py | 129 ++++++++++++++++++ .../slave-scripts/runtime/android-build.sh | 12 ++ .../slave-scripts/runtime/ios-build.sh | 20 +++ .../slave-scripts/runtime/linux-build.sh | 13 ++ .../slave-scripts/runtime/mac-build.sh | 19 +++ .../slave-scripts/runtime/win32-build.bat | 14 ++ .../runtime/windows-universal.bat | 14 ++ 7 files changed, 221 insertions(+) create mode 100644 tools/jenkins-scripts/runtime-daily-build.py create mode 100755 tools/jenkins-scripts/slave-scripts/runtime/android-build.sh create mode 100755 tools/jenkins-scripts/slave-scripts/runtime/ios-build.sh create mode 100755 tools/jenkins-scripts/slave-scripts/runtime/linux-build.sh create mode 100755 tools/jenkins-scripts/slave-scripts/runtime/mac-build.sh create mode 100644 tools/jenkins-scripts/slave-scripts/runtime/win32-build.bat create mode 100755 tools/jenkins-scripts/slave-scripts/runtime/windows-universal.bat diff --git a/tools/jenkins-scripts/runtime-daily-build.py b/tools/jenkins-scripts/runtime-daily-build.py new file mode 100644 index 0000000000..40b674711c --- /dev/null +++ b/tools/jenkins-scripts/runtime-daily-build.py @@ -0,0 +1,129 @@ +#Cocos2D-X runtime project daily build + +import os +import sys +import traceback + +if('branch' in os.environ): + branch = os.environ['branch'] +else: + branch = 'v4-develop' + +if('WORKSPACE' in os.environ): + workspace = os.environ['WORKSPACE'] +else: + workspace = "." + +if('NODE_NAME' in os.environ): + node_name = os.environ['NODE_NAME'] +else: + node_name = 'win32' + +if('language' in os.environ): + language = os.environ['language'] +else: + language = 'lua' + +# for local debugging purpose, you could change the value to 0 and run +# this scripts in your local machine +remote_build = 0 + +def download_3rd_library(): + #run download-deps.py + print("prepare to downloading ...") + os.system('python download-deps.py -r no') + + +def sync_remote_repo(): + #reset path to workspace root + os.system("cd " + workspace) + + #pull latest code + os.system("git fetch origin " + branch) + os.system("git checkout " + branch) + os.system("git merge origin/" + branch) + #clean workspace + print "Before checkout: git clean -xdf -f" + os.system("git clean -xdf -f") + + #update submodule + git_update_submodule = "git submodule update --init --force" + ret = os.system(git_update_submodule) + if(ret != 0): + sys.exit(ret) + + +def gen_scripting_bindings(): + # Generate binding glue codes + if(branch == 'v3' or branch == 'v4-develop'): + ret = os.system("python tools/jenkins-scripts/slave-scripts/gen_jsb.py") + if(ret != 0): + sys.exit(ret) + + +def do_build_slaves(): + jenkins_script_path = "tools" + os.sep + "jenkins-scripts" + os.sep + "slave-scripts" + os.sep + "runtime" + os.sep + + if(branch == 'v3' or branch == 'v4-develop'): + slave_build_scripts = "" + if(node_name == 'android') or (node_name == 'android_bak'): + slave_build_scripts = jenkins_script_path + "android-build.sh " + language + elif(node_name == 'win32' or node_name == 'win32_win7' or node_name == 'win32_bak'): + slave_build_scripts = jenkins_script_path + "win32-build.bat " + language + elif(node_name == 'windows-universal' or node_name == 'windows-universal_bak'): + slave_build_scripts = jenkins_script_path + "windows-universal.bat " + language + elif(node_name == 'ios_mac' or node_name == 'ios' or node_name == 'ios_bak'): + slave_build_scripts = jenkins_script_path + "ios-build.sh " + language + elif(node_name == 'mac' or node_name == 'mac_bak'): + slave_build_scripts = jenkins_script_path + "mac-build.sh " + language + elif(node_name == 'linux_centos' or node_name == 'linux' or node_name == 'linux_bak'): + slave_build_scripts = jenkins_script_path + "linux-build.sh " + language + elif(node_name == 'wp8'): + if(branch != 'v4'): + slave_build_scripts = jenkins_script_path + "wp8-v3.bat" + + ret = os.system(slave_build_scripts) + + #get build result + print "build finished and return " + str(ret) + return ret + + +def main(): + if remote_build == 1: + #syntronize local git repository with remote and merge the PR + sync_remote_repo() + #copy check_current_3rd_libs + download_3rd_library() + #generate jsb and luabindings + gen_scripting_bindings() + + #start build jobs on each slave + ret = do_build_slaves() + + exit_code = 1 + if ret == 0: + exit_code = 0 + else: + exit_code = 1 + + #clean workspace, we don't won't clean the repository + if remote_build == 1: + os.system("cd " + workspace) + os.system("git reset --hard") + os.system("git clean -xdf -f") + else: + print "local build, no need to cleanup" + + return(exit_code) + +# -------------- main -------------- +if __name__ == '__main__': + sys_ret = 0 + try: + sys_ret = main() + except: + traceback.print_exc() + sys_ret = 1 + finally: + sys.exit(sys_ret) diff --git a/tools/jenkins-scripts/slave-scripts/runtime/android-build.sh b/tools/jenkins-scripts/slave-scripts/runtime/android-build.sh new file mode 100755 index 0000000000..d9b019a866 --- /dev/null +++ b/tools/jenkins-scripts/slave-scripts/runtime/android-build.sh @@ -0,0 +1,12 @@ +#!/bin/bash +mycocos=tools/cocos2d-console/bin/cocos +$mycocos new -l $1 -t runtime +if [ $1 = "cpp" ];then + projectname="MyCppGame" +elif [ $1 = "lua" ];then + projectname="MyLuaGame" +elif [ $1 = "js" ];then + projectname="MyJSGame" +fi + +$mycocos compile -p android -s $projectname --android-studio -j4 --ndk-mode release --compile-script 0 diff --git a/tools/jenkins-scripts/slave-scripts/runtime/ios-build.sh b/tools/jenkins-scripts/slave-scripts/runtime/ios-build.sh new file mode 100755 index 0000000000..98c78458ef --- /dev/null +++ b/tools/jenkins-scripts/slave-scripts/runtime/ios-build.sh @@ -0,0 +1,20 @@ +#!/bin/bash +mycocos=tools/cocos2d-console/bin/cocos +$mycocos new -l $1 -t runtime + +if [ $1 = "cpp" ];then + schemename="MyCppGame-mobile" + projectpath="MyCppGame/proj.ios_mac/MyCppGame.xcodeproj" +elif [ $1 = "lua" ];then + schemename="MyLuaGame-mobile" + projectpath="MyLuaGame/frameworks/runtime-src/proj.ios_mac/MyLuaGame.xcodeproj" +elif [ $1 = "js" ];then + schemename="MyJSGame-mobile" + projectpath="MyJSGame/frameworks/runtime-src/proj.ios_mac/MyJSGame.xcodeproj" +fi + +echo "start building..." +xcodebuild -project $projectpath -target "${schemename}" -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" clean | xcpretty +xcodebuild -project $projectpath -target "${schemename}" -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" build | xcpretty +#the following commands must not be removed +xcodebuild -project $projectpath -target "${schemename}" -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" build diff --git a/tools/jenkins-scripts/slave-scripts/runtime/linux-build.sh b/tools/jenkins-scripts/slave-scripts/runtime/linux-build.sh new file mode 100755 index 0000000000..7c051bfc22 --- /dev/null +++ b/tools/jenkins-scripts/slave-scripts/runtime/linux-build.sh @@ -0,0 +1,13 @@ +#!/bin/bash +mycocos=tools/cocos2d-console/bin/cocos +$mycocos new -l $1 + +if [ $1 = "cpp" ]; then + projectname="MyCppGame" +elif [ $1 = "lua" ]; then + projectname="MyLuaGame" +elif [ $1 = "js" ]; then + projectname="MyJSGame" +fi + +$mycocos compile -p linux -s $projectname -m release -j4 --compile-script 0 diff --git a/tools/jenkins-scripts/slave-scripts/runtime/mac-build.sh b/tools/jenkins-scripts/slave-scripts/runtime/mac-build.sh new file mode 100755 index 0000000000..8d18c0af81 --- /dev/null +++ b/tools/jenkins-scripts/slave-scripts/runtime/mac-build.sh @@ -0,0 +1,19 @@ +#!/bin/bash +mycocos=tools/cocos2d-console/bin/cocos +$mycocos new -l $1 -t runtime + +if [ $1 = "cpp" ];then + schemename="MyCppGame-desktop" + projectpath="MyCppGame/proj.ios_mac/MyCppGame.xcodeproj" +elif [ $1 = "lua" ];then + schemename="MyLuaGame-desktop" + projectpath="MyLuaGame/frameworks/runtime-src/proj.ios_mac/MyLuaGame.xcodeproj" +elif [ $1 = "js" ];then + schemename="MyJSGame-desktop" + projectpath="MyJSGame/frameworks/runtime-src/proj.ios_mac/MyJSGame.xcodeproj" +fi + +xcodebuild -project $projectpath -target "${schemename}" -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" clean | xcpretty +xcodebuild -project $projectpath -target "${schemename}" -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" build | xcpretty +#the following commands must not be removed +xcodebuild -project $projectpath -target "${schemename}" -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" build diff --git a/tools/jenkins-scripts/slave-scripts/runtime/win32-build.bat b/tools/jenkins-scripts/slave-scripts/runtime/win32-build.bat new file mode 100644 index 0000000000..43dc1ba890 --- /dev/null +++ b/tools/jenkins-scripts/slave-scripts/runtime/win32-build.bat @@ -0,0 +1,14 @@ +@echo on + +set mycocos=tools/cocos2d-console/bin/cocos.bat +set language=%1 +call %mycocos% new -l %language% -t runtime + +set projectname= +if "%language%"=="cpp" set projectname=MyCppGame/proj.win32/MyCppGame.sln +if "%language%"=="lua" set projectname=MyLuaGame/frameworks/runtime-src/proj.win32/MyLuaGame.sln +if "%language%"=="js" set projectname=MyJSGame/frameworks/runtime-src/proj.win32/MyJSGame.sln + +echo %projectname% +call "%VS120COMNTOOLS%vsvars32.bat" +msbuild %projectname% /t:Build /p:Platform="Win32" /p:Configuration="Release" /m diff --git a/tools/jenkins-scripts/slave-scripts/runtime/windows-universal.bat b/tools/jenkins-scripts/slave-scripts/runtime/windows-universal.bat new file mode 100755 index 0000000000..4def9c437e --- /dev/null +++ b/tools/jenkins-scripts/slave-scripts/runtime/windows-universal.bat @@ -0,0 +1,14 @@ +@echo on + +set mycocos=tools/cocos2d-console/bin/cocos.bat +set language=%1 +call %mycocos% new -l %language% + +set projectname= +if "%language%"=="cpp" set projectname=MyCppGame/proj.win8.1-universal/MyCppGame.sln +if "%language%"=="lua" set projectname=MyLuaGame/frameworks/runtime-src/proj.win8.1-universal/MyLuaGame.sln +if "%language%"=="js" set projectname=MyJSGame/frameworks/runtime-src/proj.win8.1-universal/MyJSGame.sln + +echo %projectname% +call "%VS120COMNTOOLS%vsvars32.bat" +msbuild %projectname% /t:Build /p:Platform="Win32" /p:Configuration="Release" /m