2015-04-13 15:56:28 +08:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import traceback
|
2015-05-08 14:44:43 +08:00
|
|
|
import json
|
2015-04-13 15:56:28 +08:00
|
|
|
|
|
|
|
branch = "v3"
|
|
|
|
node_name = "ios"
|
|
|
|
|
2015-05-08 14:44:43 +08:00
|
|
|
payload_str = os.environ['payload']
|
|
|
|
payload_str = payload_str.decode('utf-8', 'ignore')
|
|
|
|
#parse to json obj
|
|
|
|
payload = json.loads(payload_str)
|
|
|
|
pr_num = payload['number']
|
|
|
|
|
|
|
|
#get pr target branch
|
|
|
|
branch = payload['branch']
|
|
|
|
workspace = os.environ['WORKSPACE']
|
|
|
|
node_name = os.environ['NODE_NAME']
|
2015-04-13 15:56:28 +08:00
|
|
|
|
2015-05-08 14:44:43 +08:00
|
|
|
def download_3rd_libs(branch):
|
2015-04-13 15:56:28 +08:00
|
|
|
#run download-deps.py
|
|
|
|
print("prepare to downloading ...")
|
|
|
|
os.system('python download-deps.py -r no')
|
|
|
|
|
|
|
|
|
|
|
|
def gen_scripting_bindings():
|
|
|
|
global branch
|
|
|
|
# Generate binding glue codes
|
|
|
|
if(branch != 'v1' and branch != 'v2'):
|
2015-04-13 16:17:17 +08:00
|
|
|
ret = os.system("python tools/jenkins-scripts/slave-scripts/gen_jsb.py")
|
2015-04-13 15:56:28 +08:00
|
|
|
if(ret != 0):
|
2015-04-29 09:53:40 +08:00
|
|
|
sys.exit(1)
|
2015-04-13 15:56:28 +08:00
|
|
|
|
|
|
|
|
|
|
|
def do_build_slaves():
|
|
|
|
global branch
|
|
|
|
global node_name
|
|
|
|
|
2015-07-09 11:26:55 +08:00
|
|
|
jenkins_script_path = "tools" + os.sep + "jenkins-scripts" + os.sep + "slave-scripts" + os.sep + "tests" + os.sep
|
2015-04-13 15:56:28 +08:00
|
|
|
|
|
|
|
if(branch != 'v1' and branch != 'v2'):
|
|
|
|
slave_build_scripts = ""
|
|
|
|
if(node_name == 'android') or (node_name == 'android_bak'):
|
|
|
|
slave_build_scripts = jenkins_script_path + "android-build.sh"
|
|
|
|
elif(node_name == 'win32' or node_name == 'win32_win7' or node_name == 'win32_bak'):
|
2015-05-20 13:55:23 +08:00
|
|
|
slave_build_scripts = jenkins_script_path + "win32-build.bat"
|
2015-04-13 15:56:28 +08:00
|
|
|
elif(node_name == 'windows-universal' or node_name == 'windows-universal_bak'):
|
2015-05-05 16:11:26 +08:00
|
|
|
slave_build_scripts = jenkins_script_path + "windows-universal.bat"
|
2015-04-13 15:56:28 +08:00
|
|
|
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"
|
|
|
|
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
|
|
|
|
|
2015-05-08 14:44:43 +08:00
|
|
|
def cleanup_workspace():
|
2015-04-13 15:56:28 +08:00
|
|
|
global workspace
|
|
|
|
global branch
|
2015-05-08 14:44:43 +08:00
|
|
|
global pr_num
|
|
|
|
#clean workspace
|
|
|
|
os.system("cd " + workspace)
|
|
|
|
os.system("git reset --hard")
|
|
|
|
os.system("git clean -xdf -f")
|
|
|
|
os.system("git checkout " + branch)
|
|
|
|
os.system("git branch -D pull" + str(pr_num))
|
2015-04-13 15:56:28 +08:00
|
|
|
|
2015-05-08 14:44:43 +08:00
|
|
|
def main():
|
|
|
|
download_3rd_libs(branch)
|
2015-04-13 16:17:17 +08:00
|
|
|
#generate jsb and luabindings
|
|
|
|
gen_scripting_bindings()
|
2015-04-13 15:56:28 +08:00
|
|
|
#start build jobs on each slave
|
|
|
|
ret = do_build_slaves()
|
|
|
|
|
2015-05-08 14:44:43 +08:00
|
|
|
cleanup_workspace()
|
|
|
|
|
2015-04-13 15:56:28 +08:00
|
|
|
exit_code = 1
|
|
|
|
if ret == 0:
|
|
|
|
exit_code = 0
|
|
|
|
else:
|
|
|
|
exit_code = 1
|
|
|
|
|
|
|
|
return(exit_code)
|
|
|
|
|
2015-05-08 14:44:43 +08:00
|
|
|
|
2015-04-13 15:56:28 +08:00
|
|
|
# -------------- main --------------
|
|
|
|
if __name__ == '__main__':
|
|
|
|
sys_ret = 0
|
|
|
|
try:
|
|
|
|
sys_ret = main()
|
|
|
|
except:
|
|
|
|
traceback.print_exc()
|
|
|
|
sys_ret = 1
|
|
|
|
finally:
|
2015-04-28 11:08:47 +08:00
|
|
|
print "return value is " + str(sys_ret)
|
2015-04-29 09:53:40 +08:00
|
|
|
if sys_ret != 0:
|
2015-04-28 11:08:47 +08:00
|
|
|
sys.exit(1)
|
|
|
|
else:
|
|
|
|
sys.exit(0)
|