当前位置: 首页>>代码示例>>Python>>正文


Python module.ModuleDetector类代码示例

本文整理汇总了Python中module.ModuleDetector的典型用法代码示例。如果您正苦于以下问题:Python ModuleDetector类的具体用法?Python ModuleDetector怎么用?Python ModuleDetector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ModuleDetector类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: build_modules_info

	def build_modules_info(self, resources_dir, app_bin_dir, include_all_ti_modules=False):
		self.app_modules = []
		(modules, external_child_modules) = bindings.get_all_module_bindings()
		
		compiler = Compiler(self.tiapp, resources_dir, self.java, app_bin_dir, os.path.dirname(app_bin_dir),
				include_all_modules=include_all_ti_modules)
		compiler.compile(compile_bytecode=False, info_message=None)
		for module in compiler.modules:
			module_bindings = []
			# TODO: we should also detect module properties
			for method in compiler.module_methods:
				if method.lower().startswith(module+'.') and '.' not in method:
					module_bindings.append(method[len(module)+1:])
			
			module_class = None
			module_apiName = None
			for m in modules.keys():
				if modules[m]['fullAPIName'].lower() == module:
					module_class = m
					module_apiName = modules[m]['fullAPIName']
					break
			
			if module_apiName == None: continue # module wasn't found
			if '.' not in module:
				ext_modules = []
				if module_class in external_child_modules:
					for child_module in external_child_modules[module_class]:
						if child_module['fullAPIName'].lower() in compiler.modules:
							ext_modules.append(child_module)
				self.app_modules.append({
					'api_name': module_apiName,
					'class_name': module_class,
					'bindings': module_bindings,
					'external_child_modules': ext_modules
				})
		
		# discover app modules
		detector = ModuleDetector(self.project_dir)
		missing, detected_modules = detector.find_app_modules(self.tiapp, 'android')
		for missing_module in missing: print '[WARN] Couldn\'t find app module: %s' % missing_module['id']
		
		self.custom_modules = []
		for module in detected_modules:
			if module.jar == None: continue
			module_jar = zipfile.ZipFile(module.jar)
			module_bindings = bindings.get_module_bindings(module_jar)
			if module_bindings is None: continue
			
			for module_class in module_bindings['modules'].keys():
				module_id = module_bindings['proxies'][module_class]['proxyAttrs']['id']
				print '[DEBUG] module_id = %s' % module_id
				if module_id == module.manifest.moduleid:
					print '[DEBUG] appending module: %s' % module_class
					self.custom_modules.append({
						'class_name': module_class,
						'manifest': module.manifest
					})
开发者ID:AndrewWestberg,项目名称:titanium_mobile,代码行数:57,代码来源:android.py

示例2: __init__

	def __init__(self,project_dir,appid,name,deploytype,xcode,devicefamily,iphone_version,silent=False):
		self.project_dir = project_dir
		self.project_name = name
		self.appid = appid
		self.iphone_dir = os.path.join(project_dir,'build','iphone')
		self.classes_dir = os.path.join(self.iphone_dir,'Classes')
		self.modules = []
		self.modules_metadata = []
		
		# for now, these are required
		self.defines = ['USE_TI_ANALYTICS','USE_TI_NETWORK','USE_TI_PLATFORM','USE_TI_UI']

		tiapp_xml = os.path.join(project_dir,'tiapp.xml')
		ti = TiAppXML(tiapp_xml)
		sdk_version = os.path.basename(os.path.abspath(os.path.join(template_dir,'../')))
		detector = ModuleDetector(project_dir)
		missing_modules, modules = detector.find_app_modules(ti, 'iphone')

		if xcode:
			app_name = os.environ['FULL_PRODUCT_NAME']
			app_dir = os.path.join(os.environ['TARGET_BUILD_DIR'],os.environ['CONTENTS_FOLDER_PATH'])
		else:
			target = 'Debug'
			if deploytype == 'install':
				target = 'Release'
			app_name = name+'.app'
			app_folder_name = '%s-iphoneos' % target
			app_dir = os.path.abspath(os.path.join(self.iphone_dir,'build',app_folder_name,app_name))
		
		main_template_file = os.path.join(template_dir,'main.m')
		main_template = codecs.open(main_template_file, encoding='utf-8').read()
		main_template = main_template.replace('__PROJECT_NAME__',name)
		main_template = main_template.replace('__PROJECT_ID__',appid)
		main_template = main_template.replace('__DEPLOYTYPE__',deploytype)
		main_template = main_template.replace('__APP_ID__',appid)
		main_template = main_template.replace('__APP_ANALYTICS__',ti.properties['analytics'])
		main_template = main_template.replace('__APP_PUBLISHER__',ti.properties['publisher'])
		main_template = main_template.replace('__APP_URL__',ti.properties['url'])
		main_template = main_template.replace('__APP_NAME__',ti.properties['name'])
		main_template = main_template.replace('__APP_VERSION__',ti.properties['version'])
		main_template = main_template.replace('__APP_DESCRIPTION__',ti.properties['description'])
		main_template = main_template.replace('__APP_COPYRIGHT__',ti.properties['copyright'])
		main_template = main_template.replace('__APP_GUID__',ti.properties['guid'])
		if deploytype=='development':
			main_template = main_template.replace('__APP_RESOURCE_DIR__',os.path.abspath(os.path.join(project_dir,'Resources')))
		else:
			main_template = main_template.replace('__APP_RESOURCE_DIR__','')

		if not silent:
			print "[INFO] Titanium SDK version: %s" % sdk_version
			print "[INFO] iPhone Device family: %s" % devicefamily
			print "[INFO] iPhone SDK version: %s" % iphone_version
		
		main_template_out = os.path.join(self.iphone_dir,'main.m')	
		main_file = codecs.open(main_template_out,'w+',encoding='utf-8')
		main_file_contents = main_file.read()
		if main_file_contents!=main_template:
			main_file.write(main_template)
			main_file.close()
		
		if deploytype == 'production':
			version = ti.properties['version']
			# we want to make sure in debug mode the version always changes
			version = "%s.%d" % (version,time.time())
			ti.properties['version']=version

		resources_dir = os.path.join(project_dir,'Resources')
		iphone_resources_dir = os.path.join(resources_dir,'iphone')

		# copy in any resources in our module like icons
		project_module_dir = os.path.join(project_dir,'modules','iphone')
		if os.path.exists(project_module_dir):
			self.copy_resources([project_module_dir],app_dir,False)
		
		# we have to copy these even in simulator given the path difference
		if os.path.exists(app_dir):
			self.copy_resources([iphone_resources_dir],app_dir,False)

		# generate the includes for all compiled modules
		xcconfig_c = "// this is a generated file - DO NOT EDIT\n\n"
		has_modules = False

		if len(modules) > 0:
			mods = open(os.path.join(self.classes_dir,'ApplicationMods.m'),'w+')
			mods.write(MODULE_IMPL_HEADER)
			for module in modules:
				module_id = module.manifest.moduleid.lower()
				module_name = module.manifest.name.lower()
				module_version = module.manifest.version
				module_guid = ''
				module_licensekey = ''
				if module.manifest.has_property('guid'):
					module_guid = module.manifest.guid
				if module.manifest.has_property('licensekey'):
					module_licensekey = module.manifest.licensekey
				self.modules_metadata.append({'guid':module_guid,'name':module_name,'id':module_id,'dir':module.path,'version':module_version,'licensekey':module_licensekey})
				xcfile = module.get_resource('module.xcconfig')
				if os.path.exists(xcfile):
					xcconfig_c+="#include \"%s\"\n" % xcfile
				xcfile = os.path.join(self.project_dir,'modules','iphone',"%s.xcconfig" % module_name)
#.........这里部分代码省略.........
开发者ID:JMjones,项目名称:titanium_mobile,代码行数:101,代码来源:compiler.py

示例3: main


#.........这里部分代码省略.........
		info("Generating project from Titanium template...")
		project = Projector(app_name,version,template_dir,project_dir,app_id)
		project.create(template_dir,build_dir)			
		
		# Because the debugger.plist is built as part of the required
		# resources, we need to autogen an empty one
		debug_plist = os.path.join(resources_dir,'debugger.plist')
		force_xcode = write_debugger_plist(None, None, template_dir, debug_plist)
		
		# Populate Info.plist
		applogo = None
		info("Populating Info.plist...")
		plist_out = os.path.join(build_dir, 'Info.plist')
		create_info_plist(tiapp, template_dir, project_dir, plist_out)
		applogo = tiapp.generate_infoplist(plist_out, app_id, 'iphone', project_dir, None)
		
		# Run the compiler to autogenerate .m files
		info("Copying classes, creating generated .m files...")
		compiler = Compiler(project_dir,app_id,app_name,'export')
		compiler.compileProject(silent=True)
		
		#... But we still have to nuke the stuff that gets built that we don't want
		# to bundle.
		ios_build = os.path.join(build_dir,'build')
		if os.path.isdir(ios_build):
			shutil.rmtree(os.path.join(build_dir,'build'))
		
		# Install applogo/splash/etc.
		info("Copying icons and splash...")
		install_logo(tiapp, applogo, project_dir, template_dir, resources_dir)
		install_defaults(project_dir, template_dir, resources_dir)
		
		# Get Modules
		detector = ModuleDetector(project_dir)
		missing_modules, modules = detector.find_app_modules(tiapp, 'iphone')
		
		if len(missing_modules) != 0:
			for module in missing_modules:
				info("MISSING MODULE: %s ... Project will not build correctly" % module['id'])
			info("Terminating export: Please fix your modules.")
			sys.exit(1)
		
		module_search_path, module_asset_dirs = locate_modules(modules, project_dir, resources_dir, info)
		
		lib_dir = os.path.join(build_dir, 'lib')
		if not os.path.exists(lib_dir): 
			os.makedirs(lib_dir)
		
		if len(module_search_path) > 0:
			info("Copying modules...")
			for module in module_search_path:
				module_name, module_path = module
				info("\t%s..." % module_name)
				shutil.copy(os.path.join(module_path, module_name), lib_dir)
				module[1] = os.path.join(lib_dir, module_name)
				
			info("Copying module metadata...")
			metadata_dir = os.path.join(build_dir, 'metadata')
			for module in modules:
				module_metadata = os.path.join(module.path,'metadata.json')
				if os.path.exists(module_metadata):
					if not os.path.exists(metadata_dir):
						os.makedirs(metadata_dir)
					target = os.path.join(metadata_dir, "%s.json" % module.manifest.moduleid)
					shutil.copyfile(module_metadata, target)
			
开发者ID:AppceleratorCasts,项目名称:titanium_mobile,代码行数:66,代码来源:transport.py

示例4: compileProject

	def compileProject(self,xcode=False,devicefamily='ios',iphone_version='iphoneos',silent=False,sdk=None):
		tiapp_xml = os.path.join(self.project_dir,'tiapp.xml')
		ti = TiAppXML(tiapp_xml)
		if sdk is None:
			sdk_version = os.path.basename(os.path.abspath(os.path.join(template_dir,'../')))
		else:
			sdk_version = sdk

		if xcode:
			app_name = os.environ['FULL_PRODUCT_NAME']
			app_dir = os.path.join(os.environ['TARGET_BUILD_DIR'],os.environ['CONTENTS_FOLDER_PATH'])
		else:
			target = 'Debug'
			if self.deploytype == 'production':
				target = 'Release'
			app_name = self.project_name+'.app'
			app_folder_name = '%s-iphoneos' % target
			app_dir = os.path.abspath(os.path.join(self.iphone_dir,'build',app_folder_name,app_name))

		if not silent:
			print "[INFO] Titanium SDK version: %s" % sdk_version
			print "[INFO] iPhone Device family: %s" % devicefamily
			print "[INFO] iPhone SDK version: %s" % iphone_version

		if self.deploytype != 'export-build':
			main_template_file = os.path.join(template_dir,'main.m')
			main_template = codecs.open(main_template_file, encoding='utf-8').read()
			main_template = main_template.replace('__PROJECT_NAME__',self.project_name)
			main_template = main_template.replace('__PROJECT_ID__',self.appid)
			main_template = main_template.replace('__DEPLOYTYPE__',self.deploytype)
			main_template = main_template.replace('__APP_ID__',self.appid)
			main_template = main_template.replace('__APP_ANALYTICS__',ti.properties['analytics'])
			main_template = main_template.replace('__APP_PUBLISHER__',ti.properties['publisher'])
			main_template = main_template.replace('__APP_URL__',ti.properties['url'])
			main_template = main_template.replace('__APP_NAME__',ti.properties['name'])
			main_template = main_template.replace('__APP_VERSION__',ti.properties['version'])
			main_template = main_template.replace('__APP_DESCRIPTION__',ti.properties['description'])
			main_template = main_template.replace('__APP_COPYRIGHT__',ti.properties['copyright'])
			main_template = main_template.replace('__APP_GUID__',ti.properties['guid'])
			main_template = main_template.replace('__APP_RESOURCE_DIR__','')

			main_template_out = os.path.join(self.iphone_dir,'main.m')
			main_file = codecs.open(main_template_out,'w+',encoding='utf-8')
			main_file_contents = main_file.read()
			if main_file_contents!=main_template:
				main_file.write(main_template)
				main_file.close()

		resources_dir = os.path.join(self.project_dir,'Resources')
		iphone_resources_dir = os.path.join(resources_dir,'iphone')
		iphone_platform_dir = os.path.join(self.project_dir,'platform','iphone')

		# copy in any resources in our module like icons
		# NOTE: This means that any JS-only modules in the local project
		# are hashed up and dumped into the export.
		has_modules = False
		missing_modules, modules, module_js = ([], [], [])
		module_js_dir = os.path.join(self.project_dir,'modules')
		if os.path.exists(module_js_dir):
			for file in os.listdir(module_js_dir):
				if file.endswith('.js'):
					module_js.append({'from':os.path.join(module_js_dir,file),'to':os.path.join(app_dir,file),'path':'modules/'+file})

		if self.deploytype != 'export-build':
			# Have to load the module detection here, in order to
			# prevent distributing even MORE stuff in export/transport
			sys.path.append(os.path.join(template_dir,'../module'))
			from module import ModuleDetector

			detector = ModuleDetector(self.project_dir)
			missing_modules, modules = detector.find_app_modules(ti, 'iphone', self.deploytype)

			# we have to copy these even in simulator given the path difference
			if os.path.exists(app_dir):
				self.copy_resources([iphone_resources_dir],app_dir,False)

			if os.path.exists(app_dir):
				self.copy_resources([iphone_platform_dir],app_dir,False)

			# generate the includes for all compiled modules
			xcconfig_c = "// this is a generated file - DO NOT EDIT\n\n"

			if len(modules) > 0:
				mods = open(os.path.join(self.classes_dir,'ApplicationMods.m'),'w+')
				variables = {}
				mods.write(MODULE_IMPL_HEADER)
				for module in modules:
					if module.js:
						# CommonJS module
						module_js.append({'from': module.js, 'path': 'modules/' + os.path.basename(module.js)})
					module_id = module.manifest.moduleid.lower()
					module_name = module.manifest.name.lower()
					module_version = module.manifest.version
					module_guid = ''
					module_licensekey = ''
					if module.manifest.has_property('guid'):
						module_guid = module.manifest.guid
					if module.manifest.has_property('licensekey'):
						module_licensekey = module.manifest.licensekey
					self.modules_metadata.append({'guid':module_guid,'name':module_name,'id':module_id,'dir':module.path,'version':module_version,'licensekey':module_licensekey})
#.........这里部分代码省略.........
开发者ID:0x00evil,项目名称:titanium_mobile,代码行数:101,代码来源:compiler.py

示例5: build_modules_info

	def build_modules_info(self, resources_dir, app_bin_dir, include_all_ti_modules=False):
		self.app_modules = []
		(modules, external_child_modules) = bindings.get_all_module_bindings()

		compiler = Compiler(self.tiapp, resources_dir, self.java, app_bin_dir,
				None, os.path.dirname(app_bin_dir),
				include_all_modules=include_all_ti_modules)
		compiler.compile(compile_bytecode=False, info_message=None)
		for module in compiler.modules:
			module_bindings = []
			# TODO: we should also detect module properties
			for method in compiler.module_methods:
				if method.lower().startswith(module+'.') and '.' not in method:
					module_bindings.append(method[len(module)+1:])

			module_onAppCreate = None
			module_class = None
			module_apiName = None
			for m in modules.keys():
				if modules[m]['fullAPIName'].lower() == module:
					module_class = m
					module_apiName = modules[m]['fullAPIName']
					if 'onAppCreate' in modules[m]:
						module_onAppCreate = modules[m]['onAppCreate']
					break

			if module_apiName == None: continue # module wasn't found
			ext_modules = []
			if module_class in external_child_modules:
				for child_module in external_child_modules[module_class]:
					if child_module['fullAPIName'].lower() in compiler.modules:
						ext_modules.append(child_module)
			self.app_modules.append({
				'api_name': module_apiName,
				'class_name': module_class,
				'bindings': module_bindings,
				'external_child_modules': ext_modules,
				'on_app_create': module_onAppCreate
			})

		# discover app modules
		detector = ModuleDetector(self.project_dir)
		missing, detected_modules = detector.find_app_modules(self.tiapp, 'android', self.deploy_type)
		for missing_module in missing: print '[WARN] Couldn\'t find app module: %s' % missing_module['id']

		self.custom_modules = []
		for module in detected_modules:
			if module.jar == None: continue
			module_jar = zipfile.ZipFile(module.jar)
			module_bindings = bindings.get_module_bindings(module_jar)
			if module_bindings is None: continue

			for module_class in module_bindings['modules'].keys():
				module_apiName = module_bindings['modules'][module_class]['apiName']
				module_proxy = module_bindings['proxies'][module_class]
				module_id = module_proxy['proxyAttrs']['id']
				module_proxy_class_name = module_proxy['proxyClassName']
				module_onAppCreate = None
				if 'onAppCreate' in module_proxy:
					module_onAppCreate = module_proxy['onAppCreate']

				print '[DEBUG] module_id = %s' % module_id
				if module_id == module.manifest.moduleid:
					# make sure that the module was not built before 1.8.0.1
					try:
						module_api_version = int(module.manifest.apiversion)
						if module_api_version < 2:
							print "[ERROR] The 'apiversion' for '%s' in the module manifest is less than version 2.  The module was likely built against a Titanium SDK pre 1.8.0.1.  Please use a version of the module that has 'apiversion' 2 or greater" % module_id
							touch_tiapp_xml(os.path.join(self.project_dir, 'tiapp.xml'))
							sys.exit(1)

					except(TypeError, ValueError):
						print "[ERROR] The 'apiversion' for '%s' in the module manifest is not a valid value.  Please use a version of the module that has an 'apiversion' value of 2 or greater set in it's manifest file" % module_id
						touch_tiapp_xml(os.path.join(self.project_dir, 'tiapp.xml'))
						sys.exit(1)


					is_native_js_module = (hasattr(module.manifest, 'commonjs') and module.manifest.commonjs)
					print '[DEBUG] appending module: %s' % module_class
					self.custom_modules.append({
						'module_id': module_id,
						'module_apiName': module_apiName,
						'proxy_name': module_proxy_class_name,
						'class_name': module_class,
						'manifest': module.manifest,
						'on_app_create': module_onAppCreate,
						'is_native_js_module': is_native_js_module
					})
					if is_native_js_module:
						# Need to look at the app modules used in this external js module
						metadata_file = os.path.join(module.path, "metadata.json")
						metadata = None
						try:
							f = open(metadata_file, "r")
							metadata = f.read()
						finally:
							f.close()

						if metadata:
							metadata = simplejson.loads(metadata)
#.........这里部分代码省略.........
开发者ID:Amir-LooLoo,项目名称:titanium_mobile,代码行数:101,代码来源:android.py

示例6: main


#.........这里部分代码省略.........
			o.write("and aid in debugging. Please attach this log to any issue that you report.\n")
			o.write("%s\n\n" % ("="*80))
			o.write("Starting build at %s\n\n" % buildtime.strftime("%m/%d/%y %H:%M"))
			
			# write out the build versions info
			versions_txt = read_config(os.path.join(template_dir,'..','version.txt'))
			o.write("Build details:\n\n")
			for key in versions_txt:
				o.write("   %s=%s\n" % (key,versions_txt[key]))
			o.write("\n\n")
			
			if versions_txt.has_key('githash'): 
				githash = versions_txt['githash']
				
			o.write("Script arguments:\n")
			for arg in args:
				o.write(unicode("   %s\n" % arg, 'utf-8'))
			o.write("\n")
			o.write("Building from: %s\n" % template_dir)
			o.write("Platform: %s\n\n" % platform.version())

			# print out path to debug
			xcode_path=run.run(["/usr/bin/xcode-select","-print-path"],True,False)
			if xcode_path:
				o.write("Xcode path is: %s\n" % xcode_path)
			else:
				o.write("Xcode path undetermined\n")

			# find the module directory relative to the root of the SDK	
			titanium_dir = os.path.abspath(os.path.join(template_dir,'..','..','..','..'))
			tp_module_dir = os.path.abspath(os.path.join(titanium_dir,'modules','iphone'))
			force_destroy_build = command!='simulator'

			detector = ModuleDetector(project_dir)
			missing_modules, modules = detector.find_app_modules(ti, 'iphone')
			module_lib_search_path = []
			module_asset_dirs = []
			
			# search for modules that the project is using
			# and make sure we add them to the compile
			for module in modules:
				module_id = module.manifest.moduleid.lower()
				module_version = module.manifest.version
				module_lib_name = 'lib%s.a' % module_id
				# check first in the local project
				local_module_lib = os.path.join(project_dir, 'modules', 'iphone', module_lib_name)
				local = False
				if os.path.exists(local_module_lib):
					module_lib_search_path.append([module_lib_name, local_module_lib])
					local = True
					log("[INFO] Detected third-party module: %s" % (local_module_lib))
				else:
					if module.lib is None:
						module_lib_path = module.get_resource(module_lib_name)
						log("[ERROR] Third-party module: %s/%s missing library at %s" % (module_id, module_version, module_lib_path))
						sys.exit(1)
					module_lib_search_path.append([module_lib_name, os.path.abspath(module.lib)])
					log("[INFO] Detected third-party module: %s/%s" % (module_id, module_version))
				force_xcode = True

				if not local:
					# copy module resources
					img_dir = module.get_resource('assets', 'images')
					if os.path.exists(img_dir):
						dest_img_dir = os.path.join(app_dir, 'modules', module_id, 'images')
						if not os.path.exists(dest_img_dir):
开发者ID:JMjones,项目名称:titanium_mobile,代码行数:67,代码来源:builder.py

示例7: main


#.........这里部分代码省略.........
		o.write("and aid in debugging. Please attach this log to any issue that you report.\n")
		o.write("%s\n\n" % ("="*80))
		o.write("Starting build at %s\n\n" % buildtime.strftime("%m/%d/%y %H:%M"))
		
		# write out the build versions info
		versions_txt = read_config(os.path.join(template_dir,'..','version.txt'))
		o.write("Build details:\n\n")
		for key in versions_txt:
			o.write("   %s=%s\n" % (key,versions_txt[key]))
		o.write("\n\n")
		
		if versions_txt.has_key('githash'): 
			githash = versions_txt['githash']
			
		o.write("Script arguments:\n")
		for arg in args:
			o.write(unicode("   %s\n" % arg, 'utf-8'))
		o.write("\n")
		o.write("Building from: %s\n" % template_dir)
		o.write("Platform: %s\n\n" % platform.version())

		# print out path to debug
		xcode_path=run.run(["/usr/bin/xcode-select","-print-path"],True,False)
		if xcode_path:
			o.write("Xcode path is: %s\n" % xcode_path)
		else:
			o.write("Xcode path undetermined\n")

		# find the module directory relative to the root of the SDK	
		titanium_dir = os.path.abspath(os.path.join(template_dir,'..','..','..','..'))
		tp_module_dir = os.path.abspath(os.path.join(titanium_dir,'modules','iphone'))
		force_destroy_build = command!='simulator'

		detector = ModuleDetector(project_dir)
		missing_modules, modules = detector.find_app_modules(ti, 'iphone')
		module_lib_search_path, module_asset_dirs = locate_modules(modules, project_dir, app_dir, log)
		common_js_modules = []
		
		if len(missing_modules) != 0:
			print '[ERROR] Could not find the following required iOS modules:'
			for module in missing_modules:
				print "[ERROR]\tid: %s\tversion: %s" % (module['id'], module['version'])
			exit(1)

		# search for modules that the project is using
		# and make sure we add them to the compile
		for module in modules:
			if module.js:
				common_js_modules.append(module)
				continue
			module_id = module.manifest.moduleid.lower()
			module_version = module.manifest.version
			module_lib_name = ('lib%s.a' % module_id).lower()
			# check first in the local project
			local_module_lib = os.path.join(project_dir, 'modules', 'iphone', module_lib_name)
			local = False
			if os.path.exists(local_module_lib):
				module_lib_search_path.append([module_lib_name, local_module_lib])
				local = True
				log("[INFO] Detected third-party module: %s" % (local_module_lib))
			else:
				if module.lib is None:
					module_lib_path = module.get_resource(module_lib_name)
					log("[ERROR] Third-party module: %s/%s missing library at %s" % (module_id, module_version, module_lib_path))
					sys.exit(1)
				module_lib_search_path.append([module_lib_name, os.path.abspath(module.lib).rsplit('/',1)[0]])
开发者ID:iamyellow,项目名称:clti,代码行数:67,代码来源:builder.py

示例8: build_modules_info

	def build_modules_info(self, resources_dir, app_bin_dir):
		compiler = Compiler(self.tiapp, resources_dir, self.java, app_bin_dir, os.path.dirname(app_bin_dir))
		compiler.compile(compile_bytecode=False)
		self.app_modules = []
		template_dir = os.path.dirname(sys._getframe(0).f_code.co_filename)
		android_modules_dir = os.path.abspath(os.path.join(template_dir, 'modules'))
		
		modules = {}
		for jar in os.listdir(android_modules_dir):
			if not jar.endswith('.jar'): continue
			
			module_path = os.path.join(android_modules_dir, jar)
			module_jar = zipfile.ZipFile(module_path)
			module_bindings = self.get_module_bindings(module_jar)
			if module_bindings is None: continue
			
			for module_class in module_bindings['modules'].keys():
				full_api_name = module_bindings['proxies'][module_class]['proxyAttrs']['fullAPIName']
				modules[module_class] = module_bindings['modules'][module_class]
				modules[module_class]['fullAPIName'] = full_api_name

		for module in compiler.modules:
			bindings = []
			# TODO: we should also detect module properties
			for method in compiler.module_methods:
				if method.lower().startswith(module+'.') and '.' not in method:
					bindings.append(method[len(module)+1:])
			
			module_class = None
			module_apiName = None
			for m in modules.keys():
				if modules[m]['fullAPIName'].lower() == module:
					module_class = m
					module_apiName = modules[m]['fullAPIName']
					break
			
			if module_apiName == None: continue # module wasn't found
			self.app_modules.append({
				'api_name': module_apiName,
				'class_name': module_class,
				'bindings': bindings
			})
		
		# discover app modules
		detector = ModuleDetector(self.project_dir)
		missing, detected_modules = detector.find_app_modules(self.tiapp)
		for missing_module in missing: print '[WARN] Couldn\'t find app module: %s' % missing_module['name']
		
		self.custom_modules = []
		for module in detected_modules:
			module_jar = zipfile.ZipFile(module.path)
			module_bindings = self.get_module_bindings(module_jar)
			if module_bindings is None: continue
			
			for module_class in module_bindings['modules'].keys():
				module_id = module_bindings['proxies'][module_class]['proxyAttrs']['id']
				print '[DEBUG] module_id = %s' % module_id
				if module_id == module.manifest.moduleid:
					print '[DEBUG] appending module: %s' % module_class
					self.custom_modules.append({
						'class_name': module_class,
						'manifest': module.manifest
					})
开发者ID:IRONkyle,项目名称:IRONtimo,代码行数:63,代码来源:android.py

示例9: build_modules_info

	def build_modules_info(self, resources_dir, app_bin_dir, include_all_ti_modules=False):
		self.app_modules = []
		(modules, external_child_modules) = bindings.get_all_module_bindings()
		
		compiler = Compiler(self.tiapp, resources_dir, self.java, app_bin_dir,
				None, os.path.dirname(app_bin_dir),
				include_all_modules=include_all_ti_modules,
				ti_sdk_dir=self.ti_sdk_dir)
		compiler.compile(compile_bytecode=False, info_message=None)
		for module in compiler.modules:
			module_bindings = []
			# TODO: we should also detect module properties
			for method in compiler.module_methods:
				if method.lower().startswith(module+'.') and '.' not in method:
					module_bindings.append(method[len(module)+1:])

			module_onAppCreate = None
			module_class = None
			module_apiName = None
			for m in modules.keys():
				if modules[m]['fullAPIName'].lower() == module:
					module_class = m
					module_apiName = modules[m]['fullAPIName']
					if 'onAppCreate' in modules[m]:
						module_onAppCreate = modules[m]['onAppCreate']
					break
			
			if module_apiName == None: continue # module wasn't found
			ext_modules = []
			if module_class in external_child_modules:
				for child_module in external_child_modules[module_class]:
					if child_module['fullAPIName'].lower() in compiler.modules:
						ext_modules.append(child_module)
			self.app_modules.append({
				'api_name': module_apiName,
				'class_name': module_class,
				'bindings': module_bindings,
				'external_child_modules': ext_modules,
				'on_app_create': module_onAppCreate
			})
		
		# discover app modules
		detector = ModuleDetector(self.project_dir, self.ti_sdk_dir)
		missing, detected_modules = detector.find_app_modules(self.tiapp, 'android')
		for missing_module in missing: print '[WARN] Couldn\'t find app module: %s' % missing_module['id']
		
		self.custom_modules = []
		for module in detected_modules:
			if module.jar == None: continue
			module_jar = zipfile.ZipFile(module.jar)
			module_bindings = bindings.get_module_bindings(module_jar)
			if module_bindings is None: continue
			
			for module_class in module_bindings['modules'].keys():
				module_apiName = module_bindings['modules'][module_class]['apiName']
				module_proxy = module_bindings['proxies'][module_class]
				module_id = module_proxy['proxyAttrs']['id']
				module_proxy_class_name = module_proxy['proxyClassName']
				module_onAppCreate = None
				if 'onAppCreate' in module_proxy:
					module_onAppCreate = module_proxy['onAppCreate']

				print '[DEBUG] module_id = %s' % module_id
				if module_id == module.manifest.moduleid:
					# make sure that the module was not built before 1.8.0.1
					try:
						module_api_version = int(module.manifest.apiversion)
						if module_api_version < 2:
							print "[ERROR] The 'apiversion' for '%s' in the module manifest is less than version 2.  The module was likely built against a Titanium SDK pre 1.8.0.1.  Please use a version of the module that has 'apiversion' 2 or greater" % module_id
							touch_tiapp_xml(os.path.join(self.project_dir, 'tiapp.xml'))
							sys.exit(1)

					except(TypeError, ValueError):
						print "[ERROR] The 'apiversion' for '%s' in the module manifest is not a valid value.  Please use a version of the module that has an 'apiversion' value of 2 or greater set in it's manifest file" % module_id
						touch_tiapp_xml(os.path.join(self.project_dir, 'tiapp.xml'))
						sys.exit(1)
 

					print '[DEBUG] appending module: %s' % module_class
					self.custom_modules.append({
						'module_id': module_id,
						'module_apiName': module_apiName,
						'proxy_name': module_proxy_class_name,
						'class_name': module_class,
						'manifest': module.manifest,
						'on_app_create': module_onAppCreate
					})
开发者ID:appcelerator,项目名称:titanium_mobile_tooling,代码行数:87,代码来源:android.py


注:本文中的module.ModuleDetector类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。