improve template daily build scripts

This commit is contained in:
andyque 2015-07-07 11:02:21 +08:00
parent 1b9b741068
commit d8bf9c8a2a
7 changed files with 131 additions and 78 deletions

View File

@ -0,0 +1,13 @@
#put xctool.sh into your PATH
tools/cocos2d-console/bin/cocos new -l $1
# DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# COCOS2DX_ROOT="$DIR"/../../..
# cd ${COCOS2DX_ROOT}
# python build/android-build.py -p 10 cpp-tests lua-tests js-tests
if [ $1 == "cpp" ];then
cocos compile -p android -s MyCppGame --android-studio -j4 --ndk-mode release --compile-script 0
elif [ $1 == "lua" ];then
cocos compile -p android -s MyLuaGame --android-studio -j4 --ndk-mode release --compile-script 0
elif [ $1 == "js" ];then
cocos compile -p android -s MyJsGame --android-studio -j4 --ndk-mode release --compile-script 0
fi

View File

@ -0,0 +1,7 @@
#put xctool.sh into your PATH
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
COCOS2DX_ROOT="$DIR"/../../..
xcodebuild -project "$COCOS2DX_ROOT"/build/cocos2d_tests.xcodeproj -scheme "build all tests iOS" -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" clean | xcpretty
xcodebuild -project "$COCOS2DX_ROOT"/build/cocos2d_tests.xcodeproj -scheme "build all tests iOS" -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" build | xcpretty
#the following commands must not be removed
xcodebuild -project "$COCOS2DX_ROOT"/build/cocos2d_tests.xcodeproj -scheme "build all tests iOS" -destination "platform=iOS Simulator,name=iPhone Retina (4-inch)" build

View File

@ -0,0 +1,13 @@
#put xctool.sh into your PATH
tools/cocos2d-console/bin/cocos new -l $1
# DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# COCOS2DX_ROOT="$DIR"/../../..
# cd ${COCOS2DX_ROOT}
# python build/android-build.py -p 10 cpp-tests lua-tests js-tests
if [ $1 == "cpp" ];then
cocos compile -p linux -s MyCppGame -m release -j4 --compile-script 0
elif [ $1 == "lua" ];then
cocos compile -p linux -s MyLuaGame -m release -j4 --compile-script 0
elif [ $1 == "js" ];then
cocos compile -p linux -s MyJsGame -m release -j4 --compile-script 0
fi

View File

@ -0,0 +1,22 @@
#put xctool.sh into your PATH
#######
# Cmake build
#######
# DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# COCOS2DX_ROOT="$DIR"/../../..
# cd ${COCOS2DX_ROOT}
# mkdir mac-build
# cd mac-build
# cmake ..
# make -j4
#######
# xcode build
#######
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
COCOS2DX_ROOT="$DIR"/../../..
xcodebuild -project "$COCOS2DX_ROOT"/build/cocos2d_tests.xcodeproj -scheme "build all tests Mac" clean | xcpretty
xcodebuild -project "$COCOS2DX_ROOT"/build/cocos2d_tests.xcodeproj -scheme "build all tests Mac" build | xcpretty
#xcpretty has a bug, some xcodebuid fails return value would be treated as 0.
xcodebuild -project "$COCOS2DX_ROOT"/build/cocos2d_tests.xcodeproj -scheme "build all tests Mac" build

View File

@ -0,0 +1,2 @@
call "%VS120COMNTOOLS%vsvars32.bat"
msbuild build\cocos2d-win32.sln /t:Build /p:Platform="Win32" /p:Configuration="Release" /m

View File

@ -0,0 +1,2 @@
call "%VS120COMNTOOLS%vsvars32.bat"
msbuild build\cocos2d-win8.1-universal.sln /t:Build /p:Platform="Win32" /p:Configuration="Release" /m

View File

@ -1,13 +1,9 @@
#Cocos2D-X templates daily build scripts #Cocos2D-X template project daily build
import os import os
import sys import sys
import traceback import traceback
# for local debugging purpose, you could change the value to 0 and run
# this scripts in your local machine
remote_build = 1
if('branch' in os.environ): if('branch' in os.environ):
branch = os.environ['branch'] branch = os.environ['branch']
else: else:
@ -21,93 +17,83 @@ else:
if('NODE_NAME' in os.environ): if('NODE_NAME' in os.environ):
node_name = os.environ['NODE_NAME'] node_name = os.environ['NODE_NAME']
else: else:
node_name = 'mac' node_name = 'linux'
# for local debugging purpose, you could change the value to 0 and run
# this scripts in your local machine
remote_build = 0
if('build_mode' in os.environ): def download_3rd_library():
build_mode = os.environ['build_mode'] #run download-deps.py
else: print("prepare to downloading ...")
build_mode = "debug" os.system('python download-deps.py -r no')
#valide build_type are 'template' and 'runtime'
if('build_type' in os.environ):
build_type = os.environ['build_type']
else:
build_type = 'template'
default_templates_types = ["cpp", "lua", "js"]
runtime_templates_types = ["lua", "js"]
default_templates_names = ["test_cpp", "test_lua", "test_js"]
runtime_template_names = ["test_rt_lua", "test_rt_js"]
def do_clean_up():
for name in default_templates_names:
commands = 'rm -rf ' + name
os.system(commands)
for name in runtime_template_names:
commands = 'rm -rf ' + name
os.system(commands)
def build_templates(mode, templates, is_runtime): def sync_remote_repo():
ret = 0 #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'): if(branch == 'v3' or branch == 'v4-develop'):
do_clean_up() ret = os.system("python tools/jenkins-scripts/slave-scripts/gen_jsb.py")
test_project_prefix = " test_" if(ret != 0):
if is_runtime: sys.exit(ret)
test_project_prefix = " test_rt_"
#build for default templates
for type in templates:
#create project
create_project_commands = "cocos new -l " + type
if is_runtime:
create_project_commands += " -t runtime " + test_project_prefix + type
else:
create_project_commands += test_project_prefix + type
create_ret = os.system(create_project_commands)
#create project failed def do_build_slaves():
if create_ret != 0: jenkins_script_path = "tools" + os.sep + "jenkins-scripts" + os.sep + "slave-scripts" + os.sep + "templates" + os.sep
return 1
ret += create_ret if(branch == 'v3' or branch == 'v4-develop'):
#compile slave_build_scripts = ""
compile_project_commands = "cocos compile -p " + node_name + " -s " + test_project_prefix + type + " --compile-script 0" if(node_name == 'android') or (node_name == 'android_bak'):
build_mode_args = " -m " slave_build_scripts = jenkins_script_path + "android-build.sh js"
if node_name == "android": elif(node_name == 'win32' or node_name == 'win32_win7' or node_name == 'win32_bak'):
build_mode_args = " --ndk-mode " slave_build_scripts = jenkins_script_path + "win32-build.bat"
build_mode_args += mode elif(node_name == 'windows-universal' or node_name == 'windows-universal_bak'):
slave_build_scripts = jenkins_script_path + "windows-universal.bat"
elif(node_name == 'ios_mac' or node_name == 'ios' or node_name == 'ios_bak'):
slave_build_scripts = jenkins_script_path + "ios-build.sh"
elif(node_name == 'mac' or node_name == 'mac_bak'):
slave_build_scripts = jenkins_script_path + "mac-build.sh"
elif(node_name == 'linux_centos' or node_name == 'linux' or node_name == 'linux_bak'):
slave_build_scripts = jenkins_script_path + "linux-build.sh cpp"
elif(node_name == 'wp8'):
if(branch != 'v4'):
slave_build_scripts = jenkins_script_path + "wp8-v3.bat"
if node_name == "windows-universal": ret = os.system(slave_build_scripts)
#run wp8.1 and windows 8.1
# lua & js don't have runtime template
if is_runtime:
continue
wp_ret = os.system("cocos compile -p wp8_1 " + build_mode_args + " -s " + test_project_prefix + type + " --compile-script 0")
winrt_ret = os.system("cocos compile -p metro " + build_mode_args + " -s " + test_project_prefix + type + " --compile-script 0")
ret += wp_ret
ret += winrt_ret
else:
if node_name == "android":
compile_project_commands += " --app-abi armeabi:armeabi-v7a:x86 "
if node_name == "linux" and is_runtime:
continue
compile_ret = os.system(compile_project_commands + build_mode_args)
ret += compile_ret
#get build result
print "build finished and return " + str(ret)
return ret return ret
def main(): def main():
#start build jobs on each slave if remote_build == 1:
default_build_type = default_templates_types #syntronize local git repository with remote and merge the PR
default_flag = False sync_remote_repo()
if build_type == "runtime": #copy check_current_3rd_libs
default_build_type = runtime_templates_types download_3rd_library()
default_flag = True #generate jsb and luabindings
ret = build_templates(build_mode, default_build_type, default_flag) gen_scripting_bindings()
print "build finished and return " + str(ret) #start build jobs on each slave
ret = do_build_slaves()
exit_code = 1 exit_code = 1
if ret == 0: if ret == 0:
@ -115,6 +101,14 @@ def main():
else: else:
exit_code = 1 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) return(exit_code)
# -------------- main -------------- # -------------- main --------------