4343import stat
4444import json
4545from urllib .request import urlopen
46+ import operator
4647
4748###############################################################################
4849# Platform independent functions (formerly indep.py) #
@@ -1808,6 +1809,11 @@ def make_dmg(CPT_SRC_DIR):
18081809###############################################################################
18091810
18101811parser = argparse .ArgumentParser (description = 'Cling Packaging Tool' )
1812+ parser .add_argument ('--last-stable-build' , help = 'Build the last stable snapshot in one of these formats: tar | deb | nsis | rpm | dmg | pkg' )
1813+ parser .add_argument ('--current-dev-build' ,
1814+ help = ('--current-dev:<tar | deb | nsis | rpm | dmg | pkg> will build the latest development snapshot in the given format'
1815+ + '\n --current-dev:branch:<branch> will build <branch> on llvm, clang, and cling'
1816+ + '\n --current-dev:branches:<a,b,c> will build branch <a> on llvm, <b> on clang, and <c> on cling' ))
18111817parser .add_argument ('-c' , '--check-requirements' , help = 'Check if packages required by the script are installed' ,
18121818 action = 'store_true' )
18131819parser .add_argument ('--current-dev' ,
@@ -2195,8 +2201,10 @@ def custom_input(prompt, always_yes=False):
21952201if args ["with_llvm_tar" ] or args ["with_llvm_binary" ]:
21962202 download_llvm_binary ()
21972203
2198- if args ['current_dev' ]:
2204+
2205+ if bool (args ['current_dev' ]) or bool (args ['current_dev_build' ]):
21992206 travis_fold_start ("git-clone" )
2207+ current_cond = args ['current_dev' ] if args ['current_dev' ] else args ['current_dev_build' ]
22002208 llvm_revision = urlopen (
22012209 "https://raw.githubusercontent.com/root-project/" +
22022210 "cling/master/LastKnownGoodLLVMSVNRevision.txt" ).readline ().strip ().decode (
@@ -2257,66 +2265,72 @@ def custom_input(prompt, always_yes=False):
22572265 if args ['with_llvm_binary' ]:
22582266 setup_tests ()
22592267 test_cling ()
2260- tarball ()
2268+ if args ['current_dev' ]:
2269+ tarball ()
22612270 cleanup ()
22622271
2263- elif args [ 'current_dev' ] == 'deb' or (args [ 'current_dev' ] == 'pkg' and DIST == 'Ubuntu' ):
2272+ elif current_cond == 'deb' or (current_cond == 'pkg' and DIST == 'Ubuntu' ):
22642273 compile (os .path .join (workdir , 'cling-' + VERSION ))
22652274 install_prefix ()
22662275 if not args ['no_test' ]:
22672276 if args ['with_llvm_binary' ]:
22682277 setup_tests ()
22692278 test_cling ()
2270- tarball_deb ()
2271- debianize ()
2279+ if args ['current_dev' ]:
2280+ tarball_deb ()
2281+ debianize ()
22722282 cleanup ()
22732283
2274- elif args [ 'current_dev' ] == 'rpm' or (args [ 'current_dev' ] == 'pkg' and platform .dist ()[0 ] == 'redhat' ):
2284+ elif current_cond == 'rpm' or (current_cond == 'pkg' and platform .dist ()[0 ] == 'redhat' ):
22752285 compile (os .path .join (workdir , 'cling-' +
22762286 VERSION .replace ('-' + revision [:7 ], '' )))
22772287 install_prefix ()
22782288 if not args ['no_test' ]:
22792289 test_cling ()
2280- tarball ()
2281- rpm_build (revision )
2290+ if args ['current_dev' ]:
2291+ tarball ()
2292+ rpm_build ()
22822293 cleanup ()
22832294
2284- elif args [ 'current_dev' ] == 'nsis' or (args [ 'current_dev' ] == 'pkg' and OS == 'Windows' ):
2295+ elif current_cond == 'nsis' or (current_cond == 'pkg' and OS == 'Windows' ):
22852296 get_win_dep ()
22862297 compile (os .path .join (workdir , 'cling-' + RELEASE + '-'
22872298 + platform .machine ().lower () + '-' + VERSION ))
22882299 CPT_SRC_DIR = install_prefix ()
22892300 if not args ['no_test' ]:
22902301 test_cling ()
2291- make_nsi (CPT_SRC_DIR )
2292- build_nsis ()
2302+ if args ['current_dev' ]:
2303+ make_nsi (CPT_SRC_DIR )
2304+ build_nsis ()
22932305 cleanup ()
22942306
2295- elif args [ 'current_dev' ] == 'dmg' or (args [ 'current_dev' ] == 'pkg' and OS == 'Darwin' ):
2307+ elif current_cond == 'dmg' or (current_cond == 'pkg' and OS == 'Darwin' ):
22962308 compile (os .path .join (workdir , 'cling-' + DIST + '-' + REV + '-'
22972309 + platform .machine ().lower () + '-' + VERSION ))
22982310 CPT_SRC_DIR = install_prefix ()
22992311 if not args ['no_test' ]:
23002312 if args ['with_llvm_binary' ]:
23012313 setup_tests ()
23022314 test_cling ()
2303- make_dmg (CPT_SRC_DIR )
2315+ if args ['current_dev' ]:
2316+ make_dmg (CPT_SRC_DIR )
23042317 cleanup ()
23052318
2306- elif args [ 'current_dev' ] == 'pkg' :
2319+ elif current_cond == 'pkg' :
23072320 compile (os .path .join (workdir , 'cling-' + DIST + '-' + REV + '-'
23082321 + platform .machine ().lower () + '-' + VERSION ))
23092322 install_prefix ()
23102323 if not args ['no_test' ]:
23112324 if args ['with_llvm_binary' ]:
23122325 setup_tests ()
23132326 test_cling ()
2314- tarball ()
2327+ if args ['current_dev' ]:
2328+ tarball ()
23152329 cleanup ()
23162330
2317- if args ['last_stable' ]:
2318- tag = json . loads ( urlopen
2319- ("https://api.github.com/repos/vgvassilev/cling/tags" )
2331+ if bool ( args ['last_stable' ]) ^ bool ( args [ 'last_stable_build' ]) :
2332+ stable_cond = args [ 'last_stable' ] if args [ 'last_stable' ] else args [ 'last_stable_build' ]
2333+ tag = json . loads ( urlopen ("https://api.github.com/repos/vgvassilev/cling/tags" )
23202334 .read ().decode ('utf-8' ))[0 ]['name' ].encode ('ascii' , 'ignore' ).decode ("utf-8" )
23212335
23222336 tag = str (tag )
@@ -2344,7 +2358,7 @@ def custom_input(prompt, always_yes=False):
23442358 print ("Last stable Cling release detected: " , tag )
23452359 fetch_cling (tag )
23462360
2347- if args [ 'last_stable' ] == 'tar' :
2361+ if stable_cond == 'tar' :
23482362 set_version ()
23492363 if OS == 'Windows' :
23502364 get_win_dep ()
@@ -2365,44 +2379,48 @@ def custom_input(prompt, always_yes=False):
23652379 if args ['with_llvm_binary' ]:
23662380 setup_tests ()
23672381 test_cling ()
2368- tarball ()
2382+ if args ['last_stable' ]:
2383+ tarball ()
23692384 cleanup ()
23702385
2371- elif args [ 'last_stable' ] == 'deb' or (args [ 'last_stable' ] == 'pkg' and DIST == 'Ubuntu' ):
2386+ elif stable_cond == 'deb' or (stable_cond == 'pkg' and DIST == 'Ubuntu' ):
23722387 set_version ()
23732388 compile (os .path .join (workdir , 'cling-' + VERSION ))
23742389 install_prefix ()
23752390 if not args ['no_test' ]:
23762391 if args ['with_llvm_binary' ]:
23772392 setup_tests ()
23782393 test_cling ()
2379- tarball_deb ()
2380- debianize ()
2394+ if args ['last_stable' ]:
2395+ tarball_deb ()
2396+ debianize ()
23812397 cleanup ()
23822398
2383- elif args [ 'last_stable' ] == 'rpm' or (args [ 'last_stable' ] == 'pkg' and platform .dist ()[0 ] == 'redhat' ):
2399+ elif stable_cond == 'rpm' or (stable_cond == 'pkg' and platform .dist ()[0 ] == 'redhat' ):
23842400 set_version ()
23852401 compile (os .path .join (workdir , 'cling-' + VERSION ))
23862402 install_prefix ()
23872403 if not args ['no_test' ]:
23882404 test_cling ()
2389- tarball ()
2390- rpm_build ()
2405+ if args ['last_stable' ]:
2406+ tarball ()
2407+ rpm_build ()
23912408 cleanup ()
23922409
2393- elif args [ 'last_stable' ] == 'nsis' or (args [ 'last_stable' ] == 'pkg' and OS == 'Windows' ):
2410+ elif stable_cond == 'nsis' or (stable_cond == 'pkg' and OS == 'Windows' ):
23942411 set_version ()
23952412 get_win_dep ()
23962413 compile (os .path .join (workdir , 'cling-' + DIST + '-' + REV + '-'
23972414 + platform .machine () + '-' + VERSION ))
23982415 CPT_SRC_DIR = install_prefix ()
23992416 if not args ['no_test' ]:
24002417 test_cling ()
2401- make_nsi (CPT_SRC_DIR )
2402- build_nsis ()
2418+ if args ['last_stable' ]:
2419+ make_nsi (CPT_SRC_DIR )
2420+ build_nsis ()
24032421 cleanup ()
24042422
2405- elif args [ 'last_stable' ] == 'dmg' or (args [ 'last_stable' ] == 'pkg' and OS == 'Darwin' ):
2423+ elif stable_cond == 'dmg' or (stable_cond == 'pkg' and OS == 'Darwin' ):
24062424 set_version ()
24072425 compile (os .path .join (workdir , 'cling-' + DIST + '-' + REV + '-'
24082426 + platform .machine ().lower () + '-' + VERSION ))
@@ -2411,10 +2429,11 @@ def custom_input(prompt, always_yes=False):
24112429 if args ['with_llvm_binary' ]:
24122430 setup_tests ()
24132431 test_cling ()
2414- make_dmg (CPT_SRC_DIR )
2432+ if args ['last_stable' ]:
2433+ make_dmg (CPT_SRC_DIR )
24152434 cleanup ()
24162435
2417- elif args [ 'last_stable' ] == 'pkg' :
2436+ elif stable_cond == 'pkg' :
24182437 set_version ()
24192438 compile (os .path .join (workdir , 'cling-' + DIST + '-' + REV + '-'
24202439 + platform .machine ().lower () + '-' + VERSION ))
@@ -2423,7 +2442,8 @@ def custom_input(prompt, always_yes=False):
24232442 if args ['with_llvm_binary' ]:
24242443 setup_tests ()
24252444 test_cling ()
2426- tarball ()
2445+ if args ['last_stable' ]:
2446+ tarball ()
24272447 cleanup ()
24282448
24292449if args ['tarball_tag' ] or args ['tarball_tag_build' ]:
0 commit comments