Пример #1
0
def zip_android(zf, basepath, version):
    android_dist_dir = os.path.join(top_dir, 'dist', 'android')

    for jar in [
            'titanium.jar', 'kroll-apt.jar', 'kroll-common.jar',
            'kroll-v8.jar', 'kroll-rhino.jar'
    ]:
        jar_path = os.path.join(android_dist_dir, jar)
        zf.write(jar_path, '%s/android/%s' % (basepath, jar))

    zip_dir(zf, os.path.join(top_dir, 'android', 'cli'),
            basepath + '/android/cli')
    zip_dir(zf, os.path.join(top_dir, 'android', 'templates'),
            basepath + '/android/templates')

    # include headers for v8 3rd party module building
    def add_headers(dir):
        for header in os.listdir(dir):
            if not header.endswith('.h'):
                continue
            header_path = os.path.join(dir, header)
            zf.write(header_path,
                     '%s/android/native/include/%s' % (basepath, header))

    android_runtime_dir = os.path.join(top_dir, 'android', 'runtime')
    android_runtime_v8_dir = os.path.join(android_runtime_dir, 'v8')
    android_runtime_rhino_dir = os.path.join(android_runtime_dir, 'rhino')

    v8_src_native_dir = os.path.join(android_runtime_v8_dir, 'src', 'native')
    add_headers(v8_src_native_dir)

    v8_gen_dir = os.path.join(android_runtime_v8_dir, 'generated')
    add_headers(v8_gen_dir)

    import ant
    libv8_properties = ant.read_properties(
        open(os.path.join(top_dir, 'android', 'build', 'libv8.properties')))
    libv8_version = libv8_properties['libv8.version']
    libv8_mode = libv8_properties['libv8.mode']

    v8_include_dir = os.path.join(android_dist_dir, 'libv8', libv8_version,
                                  libv8_mode, 'include')
    add_headers(v8_include_dir)

    # add js2c.py for js -> C embedding
    js2c_py = os.path.join(android_runtime_v8_dir, 'tools', 'js2c.py')
    jsmin_py = os.path.join(android_runtime_v8_dir, 'tools', 'jsmin.py')
    zf.write(js2c_py, '%s/module/android/js2c.py' % basepath)
    zf.write(jsmin_py, '%s/module/android/jsmin.py' % basepath)

    js_jar = os.path.join(android_runtime_rhino_dir, 'lib', 'js.jar')
    zf.write(js_jar, '%s/android/%s' % (basepath, 'js.jar'))

    # include all native shared libraries
    libs_dir = os.path.join(android_dist_dir, 'libs')
    for lib_dir in os.listdir(libs_dir):
        arch_dir = os.path.join(libs_dir, lib_dir)
        for so_file in os.listdir(arch_dir):
            if so_file.endswith('.so'):
                so_path = os.path.join(arch_dir, so_file)
                zf.write(
                    so_path, '%s/android/native/libs/%s/%s' %
                    (basepath, lib_dir, so_file))

    ant_tasks_jar = os.path.join(android_dist_dir, 'ant-tasks.jar')
    zf.write(ant_tasks_jar, '%s/module/android/ant-tasks.jar' % basepath)

    ant_contrib_jar = os.path.join(top_dir, 'android', 'build', 'lib',
                                   'ant-contrib-1.0b3.jar')
    zf.write(ant_contrib_jar,
             '%s/module/android/ant-contrib-1.0b3.jar' % basepath)

    kroll_apt_lib_dir = os.path.join(top_dir, 'android', 'kroll-apt', 'lib')
    for jar in os.listdir(kroll_apt_lib_dir):
        if jar.endswith('.jar'):
            jar_path = os.path.join(kroll_apt_lib_dir, jar)
            zf.write(jar_path, '%s/android/%s' % (basepath, jar))

    android_depends = os.path.join(top_dir, 'android', 'dependency.json')
    zf.write(android_depends, '%s/android/dependency.json' % basepath)

    android_modules = os.path.join(android_dist_dir, 'modules.json')
    zf.write(android_modules, '%s/android/modules.json' % basepath)

    zf.writestr(
        '%s/android/package.json' % basepath,
        codecs.open(os.path.join(top_dir, 'android', 'package.json'), 'r',
                    'utf-8').read().replace('__VERSION__', version))

    titanium_lib_dir = os.path.join(top_dir, 'android', 'titanium', 'lib')
    for thirdparty_jar in os.listdir(titanium_lib_dir):
        if thirdparty_jar == "commons-logging-1.1.1.jar": continue
        jar_path = os.path.join(top_dir, 'android', 'titanium', 'lib',
                                thirdparty_jar)
        zf.write(jar_path, '%s/android/%s' % (basepath, thirdparty_jar))

    # include all module lib dependencies
    modules_dir = os.path.join(top_dir, 'android', 'modules')
    for module_dir in os.listdir(modules_dir):
        module_lib_dir = os.path.join(modules_dir, module_dir, 'lib')
        if os.path.exists(module_lib_dir):
            for thirdparty_jar in os.listdir(module_lib_dir):
                if thirdparty_jar.endswith('.jar'):
                    jar_path = os.path.join(module_lib_dir, thirdparty_jar)
                    zf.write(jar_path,
                             '%s/android/%s' % (basepath, thirdparty_jar))

    android_module_jars = glob.glob(
        os.path.join(android_dist_dir, 'titanium-*.jar'))
    for android_module_jar in android_module_jars:
        jarname = os.path.split(android_module_jar)[1]
        zf.write(android_module_jar,
                 '%s/android/modules/%s' % (basepath, jarname))

    android_module_res_zips = glob.glob(
        os.path.join(android_dist_dir, 'titanium-*.res.zip'))
    for android_module_res_zip in android_module_res_zips:
        zipname = os.path.split(android_module_res_zip)[1]
        zf.write(android_module_res_zip,
                 '%s/android/modules/%s' % (basepath, zipname))
Пример #2
0
def zip_android(zf, basepath, version):
	print "Zipping Android platform..."
	android_dist_dir = os.path.join(top_dir, 'dist', 'android')

	for jar in ['titanium.jar', 'kroll-apt.jar', 'kroll-common.jar', 'kroll-v8.jar']:
		jar_path = os.path.join(android_dist_dir, jar)
		zf.write(jar_path, '%s/android/%s' % (basepath, jar))

	zip_dir(zf, os.path.join(top_dir, 'android', 'cli'), basepath+'/android/cli')
	zip_dir(zf, os.path.join(top_dir, 'android', 'templates'), basepath+'/android/templates')

	# include headers for v8 3rd party module building
	def add_headers(dir):
		for header in os.listdir(dir):
			if not header.endswith('.h'):
				continue
			header_path = os.path.join(dir, header)
			zf.write(header_path, '%s/android/native/include/%s' % (basepath, header))

	android_runtime_dir = os.path.join(top_dir, 'android', 'runtime')
	android_runtime_v8_dir = os.path.join(android_runtime_dir, 'v8')

	v8_src_native_dir = os.path.join(android_runtime_v8_dir, 'src', 'native')
	add_headers(v8_src_native_dir)

	v8_gen_dir = os.path.join(android_runtime_v8_dir, 'generated')
	add_headers(v8_gen_dir)

	import ant
	libv8_properties = ant.read_properties(open(os.path.join(top_dir, 'android', 'build', 'libv8.properties')))
	libv8_version = libv8_properties['libv8.version']
	libv8_mode = libv8_properties['libv8.mode']

	v8_include_dir = os.path.join(android_dist_dir, 'libv8', libv8_version, libv8_mode, 'include')
	add_headers(v8_include_dir)

	# add js2c.py for js -> C embedding
	js2c_py = os.path.join(android_runtime_v8_dir, 'tools', 'js2c.py')
	jsmin_py = os.path.join(android_runtime_v8_dir, 'tools', 'jsmin.py')
	zf.write(js2c_py, '%s/module/android/js2c.py' % basepath)
	zf.write(jsmin_py, '%s/module/android/jsmin.py' % basepath)

	# include all native shared libraries
	libs_dir = os.path.join(android_dist_dir, 'libs')
	for lib_dir in os.listdir(libs_dir):
		arch_dir = os.path.join(libs_dir, lib_dir)
		for so_file in os.listdir(arch_dir):
			if so_file.endswith('.so'):
				so_path = os.path.join(arch_dir, so_file)
				zf.write(so_path, '%s/android/native/libs/%s/%s' % (basepath, lib_dir, so_file))

	ant_tasks_jar = os.path.join(android_dist_dir, 'ant-tasks.jar')
	zf.write(ant_tasks_jar, '%s/module/android/ant-tasks.jar' % basepath)

	ant_contrib_jar = os.path.join(top_dir, 'android', 'build', 'lib', 'ant-contrib-1.0b3.jar')
	zf.write(ant_contrib_jar, '%s/module/android/ant-contrib-1.0b3.jar' % basepath)

	kroll_apt_lib_dir = os.path.join(top_dir, 'android', 'kroll-apt', 'lib')
	for jar in os.listdir(kroll_apt_lib_dir):
		if jar.endswith('.jar'):
			jar_path = os.path.join(kroll_apt_lib_dir, jar)
			zf.write(jar_path, '%s/android/%s' % (basepath, jar))

	android_depends = os.path.join(top_dir, 'android', 'dependency.json')
	zf.write(android_depends, '%s/android/dependency.json' % basepath)

	android_modules = os.path.join(android_dist_dir, 'modules.json')
	zf.write(android_modules, '%s/android/modules.json' % basepath)

	zf.writestr('%s/android/package.json' % basepath, codecs.open(os.path.join(top_dir, 'android', 'package.json'), 'r', 'utf-8').read().replace('__VERSION__', version))

	titanium_lib_dir = os.path.join(top_dir, 'android', 'titanium', 'lib')
	for thirdparty_jar in os.listdir(titanium_lib_dir):
		if thirdparty_jar == "commons-logging-1.1.1.jar": continue
		jar_path = os.path.join(top_dir, 'android', 'titanium', 'lib', thirdparty_jar)
		zf.write(jar_path, '%s/android/%s' % (basepath, thirdparty_jar))

	# include all module lib dependencies
	modules_dir = os.path.join(top_dir, 'android', 'modules')
	for module_dir in os.listdir(modules_dir):
		module_lib_dir = os.path.join(modules_dir, module_dir, 'lib')
		if os.path.exists(module_lib_dir):
			for thirdparty_jar in os.listdir(module_lib_dir):
				if thirdparty_jar.endswith('.jar'):
					jar_path = os.path.join(module_lib_dir, thirdparty_jar)
					zf.write(jar_path, '%s/android/%s' % (basepath, thirdparty_jar))

	android_module_jars = glob.glob(os.path.join(android_dist_dir, 'titanium-*.jar'))
	for android_module_jar in android_module_jars:
		 jarname = os.path.split(android_module_jar)[1]
		 zf.write(android_module_jar, '%s/android/modules/%s' % (basepath, jarname))

	android_module_res_zips = glob.glob(os.path.join(android_dist_dir, 'titanium-*.res.zip'))
	for android_module_res_zip in android_module_res_zips:
		zipname = os.path.split(android_module_res_zip)[1]
		zf.write(android_module_res_zip, '%s/android/modules/%s' % (basepath, zipname))

	android_module_res_packages = glob.glob(os.path.join(android_dist_dir, 'titanium-*.respackage'))
	for android_module_res_package in android_module_res_packages:
		packagename = os.path.split(android_module_res_package)[1]
		zf.write(android_module_res_package, '%s/android/modules/%s' % (basepath, packagename))
Пример #3
0
def zip_android(zf, basepath, version):
    android_dist_dir = os.path.join(top_dir, "dist", "android")

    for jar in ["titanium.jar", "kroll-apt.jar", "kroll-common.jar", "kroll-v8.jar"]:
        jar_path = os.path.join(android_dist_dir, jar)
        zf.write(jar_path, "%s/android/%s" % (basepath, jar))

    zip_dir(zf, os.path.join(top_dir, "android", "cli"), basepath + "/android/cli")
    zip_dir(zf, os.path.join(top_dir, "android", "templates"), basepath + "/android/templates")

    # include headers for v8 3rd party module building
    def add_headers(dir):
        for header in os.listdir(dir):
            if not header.endswith(".h"):
                continue
            header_path = os.path.join(dir, header)
            zf.write(header_path, "%s/android/native/include/%s" % (basepath, header))

    android_runtime_dir = os.path.join(top_dir, "android", "runtime")
    android_runtime_v8_dir = os.path.join(android_runtime_dir, "v8")

    v8_src_native_dir = os.path.join(android_runtime_v8_dir, "src", "native")
    add_headers(v8_src_native_dir)

    v8_gen_dir = os.path.join(android_runtime_v8_dir, "generated")
    add_headers(v8_gen_dir)

    import ant

    libv8_properties = ant.read_properties(open(os.path.join(top_dir, "android", "build", "libv8.properties")))
    libv8_version = libv8_properties["libv8.version"]
    libv8_mode = libv8_properties["libv8.mode"]

    v8_include_dir = os.path.join(android_dist_dir, "libv8", libv8_version, libv8_mode, "include")
    add_headers(v8_include_dir)

    # add js2c.py for js -> C embedding
    js2c_py = os.path.join(android_runtime_v8_dir, "tools", "js2c.py")
    jsmin_py = os.path.join(android_runtime_v8_dir, "tools", "jsmin.py")
    zf.write(js2c_py, "%s/module/android/js2c.py" % basepath)
    zf.write(jsmin_py, "%s/module/android/jsmin.py" % basepath)

    # include all native shared libraries
    libs_dir = os.path.join(android_dist_dir, "libs")
    for lib_dir in os.listdir(libs_dir):
        arch_dir = os.path.join(libs_dir, lib_dir)
        for so_file in os.listdir(arch_dir):
            if so_file.endswith(".so"):
                so_path = os.path.join(arch_dir, so_file)
                zf.write(so_path, "%s/android/native/libs/%s/%s" % (basepath, lib_dir, so_file))

    ant_tasks_jar = os.path.join(android_dist_dir, "ant-tasks.jar")
    zf.write(ant_tasks_jar, "%s/module/android/ant-tasks.jar" % basepath)

    ant_contrib_jar = os.path.join(top_dir, "android", "build", "lib", "ant-contrib-1.0b3.jar")
    zf.write(ant_contrib_jar, "%s/module/android/ant-contrib-1.0b3.jar" % basepath)

    kroll_apt_lib_dir = os.path.join(top_dir, "android", "kroll-apt", "lib")
    for jar in os.listdir(kroll_apt_lib_dir):
        if jar.endswith(".jar"):
            jar_path = os.path.join(kroll_apt_lib_dir, jar)
            zf.write(jar_path, "%s/android/%s" % (basepath, jar))

    android_depends = os.path.join(top_dir, "android", "dependency.json")
    zf.write(android_depends, "%s/android/dependency.json" % basepath)

    android_modules = os.path.join(android_dist_dir, "modules.json")
    zf.write(android_modules, "%s/android/modules.json" % basepath)

    zf.writestr(
        "%s/android/package.json" % basepath,
        codecs.open(os.path.join(top_dir, "android", "package.json"), "r", "utf-8")
        .read()
        .replace("__VERSION__", version),
    )

    titanium_lib_dir = os.path.join(top_dir, "android", "titanium", "lib")
    for thirdparty_jar in os.listdir(titanium_lib_dir):
        if thirdparty_jar == "commons-logging-1.1.1.jar":
            continue
        jar_path = os.path.join(top_dir, "android", "titanium", "lib", thirdparty_jar)
        zf.write(jar_path, "%s/android/%s" % (basepath, thirdparty_jar))

        # include all module lib dependencies
    modules_dir = os.path.join(top_dir, "android", "modules")
    for module_dir in os.listdir(modules_dir):
        module_lib_dir = os.path.join(modules_dir, module_dir, "lib")
        if os.path.exists(module_lib_dir):
            for thirdparty_jar in os.listdir(module_lib_dir):
                if thirdparty_jar.endswith(".jar"):
                    jar_path = os.path.join(module_lib_dir, thirdparty_jar)
                    zf.write(jar_path, "%s/android/%s" % (basepath, thirdparty_jar))

    android_module_jars = glob.glob(os.path.join(android_dist_dir, "titanium-*.jar"))
    for android_module_jar in android_module_jars:
        jarname = os.path.split(android_module_jar)[1]
        zf.write(android_module_jar, "%s/android/modules/%s" % (basepath, jarname))

    android_module_res_zips = glob.glob(os.path.join(android_dist_dir, "titanium-*.res.zip"))
    for android_module_res_zip in android_module_res_zips:
        zipname = os.path.split(android_module_res_zip)[1]
        zf.write(android_module_res_zip, "%s/android/modules/%s" % (basepath, zipname))

    android_module_res_packages = glob.glob(os.path.join(android_dist_dir, "titanium-*.respackage"))
    for android_module_res_package in android_module_res_packages:
        packagename = os.path.split(android_module_res_package)[1]
        zf.write(android_module_res_package, "%s/android/modules/%s" % (basepath, packagename))
Пример #4
0
def zip_android(zf, basepath):
    android_dist_dir = os.path.join(top_dir, "dist", "android")
    zip_dir(zf, os.path.join(cur_dir, "simplejson"), os.path.join(basepath, "android", "simplejson"))

    for jar in ["titanium.jar", "kroll-apt.jar", "kroll-common.jar", "kroll-v8.jar", "kroll-rhino.jar"]:
        jar_path = os.path.join(android_dist_dir, jar)
        zf.write(jar_path, "%s/android/%s" % (basepath, jar))

    def add_headers(dir):
        for header in os.listdir(dir):
            if not header.endswith(".h"):
                continue
            header_path = os.path.join(dir, header)
            zf.write(header_path, "%s/android/native/include/%s" % (basepath, header))

    v8_src_native_dir = os.path.join(top_dir, "android", "runtime", "v8", "src", "native")
    add_headers(v8_src_native_dir)

    v8_gen_dir = os.path.join(top_dir, "android", "runtime", "v8", "generated")
    add_headers(v8_gen_dir)

    import ant

    libv8_properties = ant.read_properties(open(os.path.join(top_dir, "android", "build", "libv8.properties")))
    libv8_version = libv8_properties["libv8.version"]
    libv8_mode = libv8_properties["libv8.mode"]

    v8_include_dir = os.path.join(android_dist_dir, "libv8", libv8_version, libv8_mode, "include")
    add_headers(v8_include_dir)

    js_jar = os.path.join(top_dir, "android", "runtime", "rhino", "lib", "js.jar")
    zf.write(js_jar, "%s/android/%s" % (basepath, "js.jar"))

    libs_dir = os.path.join(android_dist_dir, "libs")
    for lib_dir in os.listdir(libs_dir):
        arch_dir = os.path.join(libs_dir, lib_dir)
        for so_file in os.listdir(arch_dir):
            if so_file.endswith(".so"):
                so_path = os.path.join(arch_dir, so_file)
                zf.write(so_path, "%s/android/native/libs/%s/%s" % (basepath, lib_dir, so_file))

    ant_tasks_jar = os.path.join(android_dist_dir, "ant-tasks.jar")
    zf.write(ant_tasks_jar, "%s/module/android/ant-tasks.jar" % basepath)

    ant_contrib_jar = os.path.join(top_dir, "android", "build", "lib", "ant-contrib-1.0b3.jar")
    zf.write(ant_contrib_jar, "%s/module/android/ant-contrib-1.0b3.jar" % basepath)

    kroll_apt_lib_dir = os.path.join(top_dir, "android", "kroll-apt", "lib")
    for jar in os.listdir(kroll_apt_lib_dir):
        if jar.endswith(".jar"):
            jar_path = os.path.join(kroll_apt_lib_dir, jar)
            zf.write(jar_path, "%s/android/%s" % (basepath, jar))

    android_depends = os.path.join(top_dir, "android", "dependency.json")
    zf.write(android_depends, "%s/android/dependency.json" % basepath)

    android_modules = os.path.join(android_dist_dir, "modules.json")
    zf.write(android_modules, "%s/android/modules.json" % basepath)

    titanium_lib_dir = os.path.join(top_dir, "android", "titanium", "lib")
    for thirdparty_jar in os.listdir(titanium_lib_dir):
        if thirdparty_jar == "commons-logging-1.1.1.jar":
            continue
        jar_path = os.path.join(top_dir, "android", "titanium", "lib", thirdparty_jar)
        zf.write(jar_path, "%s/android/%s" % (basepath, thirdparty_jar))

        # include all module lib dependencies
    modules_dir = os.path.join(top_dir, "android", "modules")
    for module_dir in os.listdir(modules_dir):
        module_lib_dir = os.path.join(modules_dir, module_dir, "lib")
        if os.path.exists(module_lib_dir):
            for thirdparty_jar in os.listdir(module_lib_dir):
                if thirdparty_jar.endswith(".jar"):
                    jar_path = os.path.join(module_lib_dir, thirdparty_jar)
                    zf.write(jar_path, "%s/android/%s" % (basepath, thirdparty_jar))

    android_module_jars = glob.glob(os.path.join(android_dist_dir, "titanium-*.jar"))
    for android_module_jar in android_module_jars:
        jarname = os.path.split(android_module_jar)[1]
        zf.write(android_module_jar, "%s/android/modules/%s" % (basepath, jarname))

    android_module_res_zips = glob.glob(os.path.join(android_dist_dir, "titanium-*.res.zip"))
    for android_module_res_zip in android_module_res_zips:
        zipname = os.path.split(android_module_res_zip)[1]
        zf.write(android_module_res_zip, "%s/android/modules/%s" % (basepath, zipname))