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 sys
|
||||
import traceback
|
||||
import platform
|
||||
|
||||
#set Jenkins build description using submitDescription to mock browser behavior
|
||||
#TODO: need to set parent build description
|
||||
def set_description(desc):
|
||||
def set_description(desc, url):
|
||||
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'])
|
||||
req.add_header('Content-Type', 'application/x-www-form-urlencoded')
|
||||
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'
|
||||
action = payload['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']
|
||||
url = pr['html_url']
|
||||
print "url:" + url
|
||||
pr_desc = '<h3><a href='+ url + '> pr#' + str(pr_num) + '</a></h3>'
|
||||
set_description(pr_desc)
|
||||
pr_desc = '<h3><a href='+ url + '> pr#' + str(pr_num) + ' is '+ action +'</a></h3>'
|
||||
|
||||
|
||||
|
||||
#get statuses url
|
||||
statuses_url = pr['statuses_url']
|
||||
|
@ -55,6 +55,13 @@ def main():
|
|||
|
||||
#set commit status to pending
|
||||
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}
|
||||
access_token = os.environ['GITHUB_ACCESS_TOKEN']
|
||||
Headers = {"Authorization":"token " + access_token}
|
||||
|
@ -78,7 +85,18 @@ def main():
|
|||
#update submodule
|
||||
git_update_submodule = "git submodule update --init --force"
|
||||
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
|
||||
#TODO: support android-mac build currently
|
||||
#TODO: add android-windows7 build
|
||||
|
@ -87,7 +105,7 @@ def main():
|
|||
#TODO: add mac build
|
||||
#TODO: add win32 build
|
||||
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'):
|
||||
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 branch -D pull" + str(pr_num))
|
||||
|
||||
exit(exit_code)
|
||||
return(exit_code)
|
||||
|
||||
# -------------- main --------------
|
||||
if __name__ == '__main__':
|
||||
sys_ret = 0
|
||||
try:
|
||||
main()
|
||||
sys_ret = main()
|
||||
except:
|
||||
traceback.print_exc()
|
||||
exit(1)
|
||||
sys_ret = 1
|
||||
finally:
|
||||
sys.exit(sys_ret)
|
||||
|
|
Loading…
Reference in New Issue