1# vi: syntax=python:et:ts=4 2# 3# SCons build description for the Wesnoth UMC Development IDE 4# 5# Prerequisites are: 6# 1. Sun/Oracle Java JDK 7# 2. Eclipse 3.7 environment with all required plugins 8# (Can be found at: http://sourceforge.net/projects/wesnoth/files/wesnoth-umcplugin/build_utils/ ) 9 10import os, shutil, re, subprocess 11 12# Warn user of current set of build options. 13if os.path.exists('.scons-option-cache'): 14 optfile = file('.scons-option-cache') 15 print("Saved options: {}".format(optfile.read().replace("\n", ", ")[:-2])) 16 optfile.close() 17 18# variables 19opts = Variables( ".scons-option-cache" ) 20opts.AddVariables( 21 PathVariable( "eclipsedir", "The directory that contains the eclipse binary and all the needed plugins", 22 "", PathVariable.PathIsDir ), 23 PathVariable( "updatesdir", "The directory that should contain the updates for the plugin", 24 "updates", PathVariable.PathIsDirCreate ), 25 PathVariable( "binariesdir", "The directory that should contain the binaries for the plugin", 26 "binaries", PathVariable.PathIsDirCreate ), 27 PathVariable( "storepass", "The store pass for signing the jars", "", PathVariable.PathAccept ), 28 PathVariable( "keypass", "The key pass for signing the jars", "", PathVariable.PathAccept ), 29 PathVariable( "keystorepath", "The path to the keystore used for signing the jars", "", PathVariable.PathIsFile) 30) 31env = Environment( options = opts ) 32opts.Save( '.scons-option-cache', env ) 33 34eclipse_dir = env[ "eclipsedir" ] 35updates_dir = env[ "updatesdir" ] 36binaries_dir = env[ "binariesdir" ] 37 38store_pass = env["storepass"] 39if len(store_pass) == 0: 40 print("Please specify the 'storepass' variable") 41 Return() 42 43key_pass = env["keypass"] 44if len(key_pass) == 0: 45 print("Please specify the 'keypass' variable") 46 Return() 47 48temp_build_dir = os.environ[ "TMP" ] + "/umcdev_build" 49 50print("Clearing temporary build dir ( " + temp_build_dir + " ) ...") 51if os.path.exists( temp_build_dir ): 52 shutil.rmtree( temp_build_dir ) 53 54os.makedirs( temp_build_dir ) 55 56# now, we need to find 2 things: 57# 1) file: org.eclipse.equinox.launcher_*.jar 58# 2) dir: org.eclipse.pde.build_* 59 60equinox_launcher_path = "" 61pde_build_dir = "" 62 63for file in os.listdir( eclipse_dir + "/plugins" ): 64 if re.match( "org.eclipse.equinox.launcher_.*.jar", file ): 65 equinox_launcher_path = eclipse_dir + "/plugins/" + file 66 elif re.match( "org.eclipse.pde.build_.*", file ): 67 pde_build_dir = eclipse_dir + "/plugins/" + file 68 69if equinox_launcher_path: 70 print("Found equinox launcher: " + equinox_launcher_path) 71else: 72 print("Couldn't find equinox launcher. Aborting...") 73 Return( ) 74 75if pde_build_dir: 76 print("Found PDE Build dir: " + pde_build_dir) 77else: 78 print("Couldn't find PDE Build dir. Aborting...") 79 Return( ) 80 81print("Building...") 82subprocess.call( [ 83 "java", 84 "-cp", equinox_launcher_path, "org.eclipse.core.launcher.Main", 85 "-data", "workspace", 86 "-application", "org.eclipse.ant.core.antRunner", 87 "-DbuildDirectory=" + temp_build_dir, 88 "-Dbase=" + eclipse_dir, 89 "-DbaseLocation=" + eclipse_dir, 90 "-DupdatesDir=" + updates_dir, 91 "-DbinariesDir=" + binaries_dir, 92 "-Ddeltapack=" + eclipse_dir, 93 "-Declipse.pdebuild.scripts=" + pde_build_dir + "/scripts", 94 "-Declipse.pdebuild.templates=" + pde_build_dir + "/templates", 95 "-DstorePass=" + store_pass, 96 "-DkeyPass=" + key_pass, 97 "-DkeystorePath=" + env["keystorepath"], 98 "-buildfile", "build.xml" ] ) 99 100# Some cleanup 101print("Cleaning up...") 102# Some cleanup 103to_cleanup = [ 104 "../org.wesnoth.feature/build.xml", 105 "../org.wesnoth.dependencies.feature/build.xml", 106 "../org.wesnoth/build.xml", 107 "../org.wesnoth.ui/build.xml", 108 "../org.wesnoth/javaCompiler...args", 109 "../org.wesnoth.ui/javaCompiler...args" ] 110 111for cleanup_file in to_cleanup: 112 try: os.remove( cleanup_file ) 113 except: pass 114 115try: shutil.rmtree( "../org.wesnoth.feature/feature.temp.folder" ) 116except: pass 117 118try: shutil.rmtree( "../org.wesnoth.dependencies.feature/feature.temp.folder" ) 119except: pass 120 121# Local variables: 122# mode: python 123# end: 124