Exemple #1
0
def build_and_run(args=None):
    if len(args) == 1 and args[0] in ["--help", "-h"]:
        usage()

    if len(sdk_dirs) == 0:
        error_no_desktop_sdk()

    version_dirs = []
    for sdk_dir in sdk_dirs:
        for dir in os.listdir(sdk_dir):
            if dir.startswith("."): continue
            version_dirs.append(os.path.join(sdk_dir, dir))

    if len(version_dirs) == 0:
        error_no_desktop_sdk()

    version_map = {}
    for version_dir in version_dirs:
        version_map[os.path.basename(version_dir)] = version_dir

    # use the latest version in the system
    versions = version_map.keys()
    versions.sort()
    use_version = versions[-1]

    print 'Using Desktop version %s in %s' % (use_version,
                                              version_map[use_version])

    desktop_sdk = version_map[use_version]
    tibuild = os.path.join(desktop_sdk, 'tibuild.py')
    drillbit_build_dir = os.path.join(mobile_dir, 'build', 'drillbit')

    extract = 'NO_EXTRACT' not in os.environ
    mobilesdk_dir = extract_mobilesdk(extract)

    if not os.path.exists(drillbit_build_dir):
        os.makedirs(drillbit_build_dir)

    sys.path.append(desktop_sdk)
    import env

    # use the desktop SDK API to stage and run drillbit (along w/ its custom modules)
    appstore = False
    bundle = False

    # if we're in OSX Lion, package against the system webkit (using --appstore)
    if platform.system() == "Darwin" and platform.release() == "11.0.0":
        appstore = True
        bundle = True

    # the win32 env.py doesn't have the appstore flag for some reason
    if platform.system() == "Windows":
        environment = env.PackagingEnvironment(platform_name, False)
    else:
        environment = env.PackagingEnvironment(platform_name, False, appstore)
    app = environment.create_app(drillbit_app_dir)
    stage_dir = os.path.join(drillbit_build_dir, app.name)

    # This isn't set internally until stage() is set, but by then it's too
    # late for module resolving
    app.stage_dir = stage_dir
    if platform.system() == 'Darwin':
        app.stage_dir += '.app'

    # We need this to resolve our custom modules
    app.env.components_dir = app.get_contents_dir()

    app_modules_dir = os.path.join(app.get_contents_dir(), 'modules')
    if os.path.exists(app_modules_dir):
        shutil.rmtree(app_modules_dir)
    elif not os.path.exists(app.get_contents_dir()):
        os.makedirs(app.get_contents_dir())

    print 'Copying modules to %s' % app_modules_dir
    shutil.copytree(os.path.join(drillbit_dir, 'modules'), app_modules_dir)

    # Desktop 1.2 doesn't pass on named-args for app subclasses
    # stage(stage_dir, bundle=False, no_install=True, js_obfuscate=False
    app.stage(stage_dir, bundle, True, False)

    app_tests_dir = os.path.join(app.get_contents_dir(), 'Resources', 'tests')
    if os.path.exists(app_tests_dir):
        shutil.rmtree(app_tests_dir)

    print 'Copying tests to %s' % app_tests_dir
    shutil.copytree(os.path.join(drillbit_dir, 'tests'), app_tests_dir)

    installed_file = os.path.join(app.get_contents_dir(), '.installed')
    if not os.path.exists(installed_file):
        open(installed_file, "w").write('installed')

    drillbit_args = [
        app.executable_path, '--debug',
        '--mobile-sdk=%s' % mobilesdk_dir,
        '--mobile-repository=%s' % mobile_dir
    ]
    if args != None:
        drillbit_args.extend(args)

    app.env.run(drillbit_args)
Exemple #2
0
		sys.exit(1)
	if not path.exists(appdir):
		print "Couldn't find application directory at: %s" % appdir
		sys.exit(1)
	if not path.exists(options.destination):
		print('Invalid destination directory: %s' % options.destination)
		sys.exit(1)
	if not options.platform in ALLOWED_PLATFORMS:
		print "Error: unsupported/unknown platform: %s" % options.platform
		print "Must be one of: %s" % str(ALLOWED_PLATFORMS)
		sys.exit(1)
	bundle = options.type == 'bundle'

	# Eventually we should detect if we are a packager
	# and not use any installed components.
	script_dir = os.path.abspath(os.path.dirname(sys._getframe(0).f_code.co_filename))
	packager = os.path.exists(path.join(script_dir, '.packager'))

	environment = env.PackagingEnvironment(options.platform, packager)
	app = environment.create_app(appdir)
	app.stage(path.join(options.destination, app.name), bundle=bundle)
	if options.no_install:
		app.install()

	# Always create the package on the packaging server.
	if options.package or packager:
		app.package(options.destination, bundle=bundle)

	if options.run:
		run(app.executable_path)
Exemple #3
0
def build_and_run(args=None):
	# first we need to find the desktop SDK for tibuild.py
	if platform.system() == 'Darwin':
		base_sdk = '/Library/Application Support/Titanium/sdk/osx'
		platform_name = 'osx'
	elif platform.system() == 'Windows':
		if platform.release() == 'XP':
			base_sdk = 'C:\\Documents and Settings\\All Users\\Application Data\\Titanium\\sdk\\win32'
		else:
			base_sdk = 'C:\\ProgramData\\Titanium\\sdk\\win32'
		platform_name = 'win32'
	elif platform.system() == 'Linux':
		base_sdk = os.path.expanduser("~/.titanium/sdk/linux")
		platform_name = 'linux'
	
	if not os.path.exists(base_sdk):
		error_no_desktop_sdk()
	
	versions = [dir for dir in os.listdir(base_sdk) if not dir.startswith(".")]
	if len(versions) == 0:
		error_no_desktop_sdk()
	
	# use the latest version in the system
	versions.sort()
	use_version = versions[len(versions) - 1]
	print 'Using Desktop version %s' % use_version
	
	desktop_sdk = os.path.join(base_sdk, use_version)
	tibuild = os.path.join(desktop_sdk, 'tibuild.py')
	drillbit_build_dir = os.path.join(mobile_dir, 'build', 'drillbit')
	mobile_dist_dir = os.path.join(mobile_dir, 'dist')
	
	sys.path.append(mobile_dist_dir)
	sys.path.append(os.path.join(mobile_dir, 'build'))
	import titanium_version
	
	mobilesdk_dir = os.path.join(mobile_dist_dir, 'mobilesdk', platform_name, titanium_version.version)
	mobilesdk_zipfile = os.path.join(mobile_dist_dir, 'mobilesdk-%s-%s.zip' % (titanium_version.version, platform_name))
	if platform.system() == 'Darwin':
		subprocess.Popen(['/usr/bin/unzip', '-q', '-o', '-d', mobile_dist_dir, os.path.join(mobile_dist_dir, 'mobilesdk-%s-%s.zip' % (titanium_version.version, platform_name))])
	else:
		# extract the mobilesdk zip so we can use it for testing
		mobilesdk_zip = zipfile.ZipFile(mobilesdk_zipfile)
		mobilesdk_zip.extractall(mobile_dist_dir)
		mobilesdk_zip.close()
	
	if not os.path.exists(drillbit_build_dir):
		os.makedirs(drillbit_build_dir)
	
	sys.path.append(desktop_sdk)
	import env
	
	# use the desktop SDK API to stage and run drillbit (along w/ it's custom modules)
	environment = env.PackagingEnvironment(platform_name, False)
	app = environment.create_app(drillbit_app_dir)
	stage_dir = os.path.join(drillbit_build_dir, app.name)
	app.stage(stage_dir, bundle=False)
	app.install()
	
	app_modules_dir = os.path.join(app.get_contents_dir(), 'modules')
	app_tests_dir = os.path.join(app.get_contents_dir(), 'Resources', 'tests')
	
	if os.path.exists(app_modules_dir):
		shutil.rmtree(app_modules_dir)
	
	if os.path.exists(app_tests_dir):
		shutil.rmtree(app_tests_dir)
	
	shutil.copytree(os.path.join(drillbit_dir, 'modules'), app_modules_dir)
	shutil.copytree(os.path.join(drillbit_dir, 'tests'), app_tests_dir)
	
	drillbit_args = [app.executable_path, '--debug', '--mobile-sdk=%s' % mobilesdk_dir, '--mobile-repository=%s' % mobile_dir]
	if args != None:
		drillbit_args.extend(args)
	
	app.env.run(drillbit_args)
Exemple #4
0
    if not path.exists(options.destination):
        print('Invalid destination directory: %s' % options.destination)
        sys.exit(1)
    if not options.platform in ALLOWED_PLATFORMS:
        print "Error: unsupported/unknown platform: %s" % options.platform
        print "Must be one of: %s" % str(ALLOWED_PLATFORMS)
        sys.exit(1)

    if options.appstore:
        bundle = True
        no_install = True
    else:
        bundle = options.type == 'bundle'
        no_install = options.no_install

    # Eventually we should detect if we are a packager
    # and not use any installed components.
    script_dir = os.path.abspath(os.path.dirname(sys._getframe(0).f_code.co_filename))
    packager = os.path.exists(path.join(script_dir, '.packager'))

    environment = env.PackagingEnvironment(options.platform, packager, options.appstore)
    app = environment.create_app(appdir)
    app.stage(path.join(options.destination, app.name), bundle=bundle, no_install=no_install, js_obfuscate=options.js_obfuscate, ignore_patterns=options.ignore_patterns)

    # Always create the package on the packaging server.
    if options.package or packager:
        app.package(options.destination, bundle=bundle)

    if options.run:
        run(app.executable_path)