Created
February 1, 2010 23:48
-
-
Save pifantastic/292189 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
AIR builder v%(VERSION)s | |
Synopsis: build.py [options] | |
-b Build the final .air file (will prompt for password) | |
-d Launch the application in the debugger | |
-s Create a new Self-Signed security certificate | |
-h This help message | |
""" | |
import os, sys, getopt, shutil | |
VERSION = '0.1' | |
# Things you may want to customize | |
BUILD_PATH = "build" | |
APP_DESCRIPTOR = "application.xml" | |
APP_FILE = "MyAirApplication.air" | |
CERTIFICATE_FILE = "certificate.pfx" | |
BUILD_AIR_FILE = False | |
LAUNCH_DEBUGGER = False | |
CREATE_CERTIFICATE = False | |
def usage(): | |
print __doc__ % globals() | |
def copy(src, dest): | |
os.system("copy %s %s" % (src, dest)) | |
def xcopy(src, dest): | |
os.system("robocopy %s %s /E /XD .svn" % (src, dest)) | |
def transfer(): | |
DEST = os.path.join(BUILD_PATH, "tmp\\") | |
os.mkdir(DEST) | |
# files | |
copy("index.html", os.path.join(DEST, "index.html")) | |
copy("application.xml", os.path.join(DEST, "application.xml")) | |
copy("certificate.pfx", os.path.join(DEST, "certificate.pfx")) | |
# folders | |
xcopy("locale", os.path.join(DEST, "locale")) | |
xcopy("css", os.path.join(DEST, "css")) | |
xcopy("js", os.path.join(DEST, "js")) | |
xcopy("icons", os.path.join(DEST, "icons")) | |
if __name__ == "__main__": | |
try: | |
opts, args = getopt.getopt(sys.argv[1:], "bdhs") | |
if len(sys.argv) < 2: | |
usage() | |
except getopt.GetoptError, err: | |
print str(err) | |
usage() | |
sys.exit(2) | |
for o, a in opts: | |
if o == "-h": | |
usage() | |
sys.exit(2) | |
elif o == "-b": | |
BUILD_AIR_FILE = True | |
elif o == "-d": | |
LAUNCH_DEBUGGER = True | |
elif o == "-s": | |
CREATE_CERTIFICATE = True | |
else: | |
assert False, "unhandled option" | |
# Create a new security certificate | |
if CREATE_CERTIFICATE: | |
print("Creating certificate") | |
password = raw_input("Please enter the password for the new certificate: ") | |
result = os.system("adt -certificate -cn SelfSigned 1024-RSA %s %s" % (CERTIFICATE_FILE, password)) | |
if result > 0: sys.exit("Error!") | |
# Build AIR application file | |
if BUILD_AIR_FILE: | |
print("Building AIR application file") | |
transfer() | |
curdir = os.getcwd() | |
os.chdir(os.path.join(BUILD_PATH, "tmp")) | |
result = os.system("adt -package -storetype pkcs12 -keystore %s ..\%s %s ." % (CERTIFICATE_FILE, APP_FILE, APP_DESCRIPTOR)) | |
os.chdir(curdir) | |
shutil.rmtree(os.path.join(BUILD_PATH, "tmp")) | |
if result > 0: sys.exit("Error!") | |
# Launch application in AIR debugger | |
if LAUNCH_DEBUGGER: | |
print("Launching app in debugger") | |
result = os.system("adl %s" % APP_DESCRIPTOR) | |
if result > 0: sys.exit("Error!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment