mirror of https://github.com/axmolengine/axmol.git
build all android targets
This commit is contained in:
parent
559e5b771f
commit
bc5303f6f2
|
@ -0,0 +1,30 @@
|
||||||
|
#create ghprb job by pr number
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
import requests
|
||||||
|
|
||||||
|
#get pr number from cmd
|
||||||
|
pr_num = sys.argv[1]
|
||||||
|
|
||||||
|
#get github access token
|
||||||
|
access_token = os.environ['GITHUB_ACCESS_TOKEN']
|
||||||
|
|
||||||
|
#get pr data via github api
|
||||||
|
|
||||||
|
api_get_pr = "https://api.github.com/repos/cocos2d/cocos2d-x/pulls/"+str(pr_num)+"?access_token="+access_token
|
||||||
|
|
||||||
|
r = requests.get(api_get_pr)
|
||||||
|
pr = r.json()
|
||||||
|
|
||||||
|
#forge a payload
|
||||||
|
payload = {"action":"open","number":"","pull_request":""}
|
||||||
|
payload['number']=pr_num
|
||||||
|
payload['pull_request']=pr
|
||||||
|
|
||||||
|
jenkins_trigger_url="http://ci.cocos2d-x.org:8000/job/cocos-2dx-pull-request-build/buildWithParameters?token="+access_token
|
||||||
|
|
||||||
|
#send trigger and payload
|
||||||
|
post_data = "payload:"+json.dumps(payload
|
||||||
|
requests.post(jenkins_trigger_url, data=post_data)
|
|
@ -9,12 +9,13 @@ import base64
|
||||||
import requests
|
import requests
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
import platform
|
||||||
|
|
||||||
#set Jenkins build description using submitDescription to mock browser behavior
|
#set Jenkins build description using submitDescription to mock browser behavior
|
||||||
#TODO: need to set parent build description
|
#TODO: need to set parent build description
|
||||||
def set_description(desc):
|
def set_description(desc, url):
|
||||||
req_data = urllib.urlencode({'description': desc})
|
req_data = urllib.urlencode({'description': desc})
|
||||||
req = urllib2.Request(os.environ['BUILD_URL'] + 'submitDescription', req_data)
|
req = urllib2.Request(url + 'submitDescription', req_data)
|
||||||
#print(os.environ['BUILD_URL'])
|
#print(os.environ['BUILD_URL'])
|
||||||
req.add_header('Content-Type', 'application/x-www-form-urlencoded')
|
req.add_header('Content-Type', 'application/x-www-form-urlencoded')
|
||||||
base64string = base64.encodestring(os.environ['JENKINS_ADMIN']+ ":" + os.environ['JENKINS_ADMIN_PW']).replace('\n', '')
|
base64string = base64.encodestring(os.environ['JENKINS_ADMIN']+ ":" + os.environ['JENKINS_ADMIN_PW']).replace('\n', '')
|
||||||
|
@ -36,16 +37,15 @@ def main():
|
||||||
#build for pull request action 'open' and 'synchronize', skip 'close'
|
#build for pull request action 'open' and 'synchronize', skip 'close'
|
||||||
action = payload['action']
|
action = payload['action']
|
||||||
print 'action: ' + action
|
print 'action: ' + action
|
||||||
if((action != 'opened') and (action != 'synchronize')):
|
|
||||||
print 'pull request #' + str(pr_num) + ' is closed, no build triggered'
|
|
||||||
exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
pr = payload['pull_request']
|
pr = payload['pull_request']
|
||||||
url = pr['html_url']
|
url = pr['html_url']
|
||||||
print "url:" + url
|
print "url:" + url
|
||||||
pr_desc = '<h3><a href='+ url + '> pr#' + str(pr_num) + '</a></h3>'
|
pr_desc = '<h3><a href='+ url + '> pr#' + str(pr_num) + ' is '+ action +'</a></h3>'
|
||||||
set_description(pr_desc)
|
|
||||||
|
|
||||||
|
|
||||||
#get statuses url
|
#get statuses url
|
||||||
statuses_url = pr['statuses_url']
|
statuses_url = pr['statuses_url']
|
||||||
|
@ -55,6 +55,13 @@ def main():
|
||||||
|
|
||||||
#set commit status to pending
|
#set commit status to pending
|
||||||
target_url = os.environ['BUILD_URL']
|
target_url = os.environ['BUILD_URL']
|
||||||
|
|
||||||
|
set_description(pr_desc, target_url)
|
||||||
|
|
||||||
|
if((action != 'opened') and (action != 'synchronize')):
|
||||||
|
print 'pull request #' + str(pr_num) + ' is '+action+', no build triggered'
|
||||||
|
return(0)
|
||||||
|
|
||||||
data = {"state":"pending", "target_url":target_url}
|
data = {"state":"pending", "target_url":target_url}
|
||||||
access_token = os.environ['GITHUB_ACCESS_TOKEN']
|
access_token = os.environ['GITHUB_ACCESS_TOKEN']
|
||||||
Headers = {"Authorization":"token " + access_token}
|
Headers = {"Authorization":"token " + access_token}
|
||||||
|
@ -79,6 +86,17 @@ def main():
|
||||||
git_update_submodule = "git submodule update --init --force"
|
git_update_submodule = "git submodule update --init --force"
|
||||||
os.system(git_update_submodule)
|
os.system(git_update_submodule)
|
||||||
|
|
||||||
|
#add symbol link
|
||||||
|
PROJECTS=["Cpp/HelloCpp","Cpp/TestCpp","Cpp/SimpleGame","Cpp/AssetsManagerTest",
|
||||||
|
"Javascript/TestJavascript","Javascript/CocosDragonJS","Javascript/CrystalCraze",
|
||||||
|
"Javascript/MoonWarriors","Javascript/WatermelonWithMe","Lua/HelloLua","Lua/TestLua"]
|
||||||
|
if(platform.system == 'Darwin'):
|
||||||
|
for item in PROJECTS:
|
||||||
|
os.System("ln -s "+os.environ['WORKSPACE']+"/android_build_objs " + os.environ['WORKSPACE']+"/samples/"+item+"/proj.android/obj")
|
||||||
|
elif(platform.system == 'Windows'):
|
||||||
|
for item in PROJECTS:
|
||||||
|
os.System("mklink /J "+os.environ['WORKSPACE']+os.sep+"samples"+os.sep +item+os.sep+"proj.android/obj " + os.environ['WORKSPACE']+os.sep+"android_build_objs")
|
||||||
|
|
||||||
#build
|
#build
|
||||||
#TODO: support android-mac build currently
|
#TODO: support android-mac build currently
|
||||||
#TODO: add android-windows7 build
|
#TODO: add android-windows7 build
|
||||||
|
@ -87,7 +105,7 @@ def main():
|
||||||
#TODO: add mac build
|
#TODO: add mac build
|
||||||
#TODO: add win32 build
|
#TODO: add win32 build
|
||||||
if(branch == 'develop'):
|
if(branch == 'develop'):
|
||||||
ret = os.system("python build/android-build.py -n -j5 testcpp")
|
ret = os.system("python build/android-build.py -n -j10 all")
|
||||||
elif(branch == 'master'):
|
elif(branch == 'master'):
|
||||||
ret = os.system("samples/Cpp/TestCpp/proj.android/build_native.sh")
|
ret = os.system("samples/Cpp/TestCpp/proj.android/build_native.sh")
|
||||||
|
|
||||||
|
@ -113,12 +131,15 @@ def main():
|
||||||
os.system("git checkout develop")
|
os.system("git checkout develop")
|
||||||
os.system("git branch -D pull" + str(pr_num))
|
os.system("git branch -D pull" + str(pr_num))
|
||||||
|
|
||||||
exit(exit_code)
|
return(exit_code)
|
||||||
|
|
||||||
# -------------- main --------------
|
# -------------- main --------------
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
sys_ret = 0
|
||||||
try:
|
try:
|
||||||
main()
|
sys_ret = main()
|
||||||
except:
|
except:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
exit(1)
|
sys_ret = 1
|
||||||
|
finally:
|
||||||
|
sys.exit(sys_ret)
|
||||||
|
|
Loading…
Reference in New Issue