incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject ios commit: [CB-1122] Diagnostic tool for Cordova iOS Xcode projects
Date Sat, 08 Sep 2012 07:38:23 GMT
Updated Branches:
  refs/heads/master 1acd9cb84 -> 21d285d7a


[CB-1122] Diagnostic tool for Cordova iOS Xcode projects


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/21d285d7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/21d285d7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/21d285d7

Branch: refs/heads/master
Commit: 21d285d7a2625057726fefde68b678a0e2144907
Parents: 1acd9cb
Author: Shazron Abdullah <shazron@apache.org>
Authored: Sat Sep 8 00:38:16 2012 -0700
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Sat Sep 8 00:38:16 2012 -0700

----------------------------------------------------------------------
 bin/diagnose_project |  176 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 176 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/21d285d7/bin/diagnose_project
----------------------------------------------------------------------
diff --git a/bin/diagnose_project b/bin/diagnose_project
new file mode 100755
index 0000000..9f9558a
--- /dev/null
+++ b/bin/diagnose_project
@@ -0,0 +1,176 @@
+#!/usr/bin/python
+"""
+Prints out information regarding a Cordova project for diagnostic purposes.
+Currently this only reports information but does not give any recommendations yet.
+
+Usage: CordovaVersion/bin/diagnose_project path/to/your/app.xcodeproj
+"""
+
+import os
+import sys
+import plistlib
+import shutil
+import tempfile
+import pprint
+
+def Usage():
+  print __doc__
+  sys.exit(1)
+
+def AbsParentPath(path):
+  return os.path.abspath(os.path.join(path, os.path.pardir))
+
+def AbsFrameworkPath(argv0):
+  script_path = argv0
+  # This can happen if the script's dir is in the user's PATH
+  if not os.path.exists(script_path):
+    raise Exception('Could not locale framework directory.')
+  return AbsParentPath(AbsParentPath(script_path))
+
+def AbsProjectPath(relative_path):
+  # Do an extra abspath here to strip off trailing / if present.
+  project_path = os.path.abspath(relative_path)
+  if project_path.endswith('.pbxproj'):
+    project_path = AbsParentPath(project_path)
+  elif project_path.endswith('.xcodeproj'):
+    pass
+  else:
+    raise Exception('The following is not a valid path to an XCode project: %s' % project_path)
+  return project_path
+
+def getXcodePlist(pbxPath):
+	tmpfile = tempfile.mktemp (".xml")
+	os.system("plutil -convert xml1 -o %s %s" % (tmpfile, pbxPath))
+
+	return plistlib.readPlist( tmpfile )
+	
+def getXcodeBuildSettings(diagKeys, xcodePlist):
+	allObjects = xcodePlist['objects']
+	rootObj = allObjects[ xcodePlist['rootObject'] ]
+	
+	buildSettings = {};
+
+	bclist = allObjects[ rootObj['buildConfigurationList'] ]['buildConfigurations']
+	for conflist in bclist:
+		cl = allObjects[conflist];
+		clname = cl.get("name", 'no name')
+		buildSettings[clname] = {}
+		for key in diagKeys:
+			val = cl['buildSettings'].get(key, '(not found)')
+			buildSettings[clname][key] = val
+	
+	return buildSettings
+  
+def main(argv):
+	if len(argv) != 2:
+		Usage()
+
+	framework_path = AbsFrameworkPath(argv[0])
+	project_path = AbsProjectPath(argv[1])
+
+	parent_project_path = AbsParentPath(project_path)
+	cordova_lib_xcode_path = os.path.join(framework_path, 'CordovaLib', 'CordovaLib.xcodeproj')
+	subproject_path = os.path.relpath(cordova_lib_xcode_path, parent_project_path)
+
+	projPbx = os.path.join(project_path, 'project.pbxproj')
+
+	buildSettingsKeys = ['HEADER_SEARCH_PATHS', 'ARCHS', 'USER_HEADER_SEARCH_PATHS', 'IPHONEOS_DEPLOYMENT_TARGET',
'OTHER_LDFLAGS', 'GCC_VERSION']
+
+	projPlist = getXcodePlist(projPbx)
+	allObjects = projPlist['objects']
+	rootObj = allObjects[ projPlist['rootObject'] ]
+
+	print "\n\n-------------------------------------BEGIN--------------------------------------"
+	print "Inspecting project: %s" % (projPbx) 
+
+	print "\n\n--------------------------------------------------------------------------------"
+	print "Finding your project's sub-projects...\n"
+
+	subprojKeys = ['name', 'path', 'sourceTree']
+	subprojValues = []
+
+	subprojRef = rootObj['projectReferences']
+	for subproj in subprojRef:
+	  sp = {}
+	  subprojGroup = allObjects[ subproj['ProjectRef'] ]
+	  for key in subprojKeys:
+	  	val = subprojGroup.get(key, "(not found)")
+	  	sp[key] = val;
+	  print "Sub-project:", sp
+	  subprojValues.append(sp)
+  	
+  
+	print "\n\n--------------------------------------------------------------------------------"
+	print "Inspecting your project's Build Settings...\n"
+
+	buildSettings = getXcodeBuildSettings(buildSettingsKeys, projPlist)
+	pp = pprint.PrettyPrinter(indent=4)
+
+	for key in buildSettings:
+	  print key, ":" 
+	  pp.pprint(buildSettings[key])
+	
+	print "\n\n--------------------------------------------------------------------------------"
+	print "Inspecting Xcode Preferences...\n"
+
+	xcodeBinaryPrefsPath = os.path.join( os.path.expanduser("~"), "Library", "Preferences",
"com.apple.dt.Xcode.plist" );
+	xcodePrefsPlist = getXcodePlist(xcodeBinaryPrefsPath)
+
+	xcodeCordovaLib = xcodePrefsPlist['IDEApplicationwideBuildSettings'].get("CORDOVALIB", "(not
found)")
+	print "CORDOVALIB:", xcodeCordovaLib
+	print "Build Location Style:", xcodePrefsPlist.get('IDEBuildLocationStyle', "(unknown)")
+
+	print "\n\n--------------------------------------------------------------------------------"
+	print "Inspecting your CordovaLib's Build Settings...\n"
+
+	usesXcodeVariable = False
+	cdvlibPath = None
+	cdvlibProjName = 'CordovaLib.xcodeproj'
+	
+	for sp in subprojValues:
+	  if cdvlibProjName in sp['path']:
+	  	if 'CORDOVALIB' in sp['sourceTree']:
+			print "Your project is using the CORDOVALIB Xcode variable (source tree)."
+	  		cdvlibPath = os.path.join( xcodeCordovaLib, cdvlibProjName)
+	  	else:
+	  		cdvlibPath = sp['path']
+  	
+	print "Path is:", cdvlibPath, "\n"
+
+	cdvlibNormalizedPath = os.path.normpath( os.path.join(parent_project_path, cdvlibPath) )
+	cdvlibPbx = os.path.join( cdvlibNormalizedPath , 'project.pbxproj' )
+
+	cdvPlist = getXcodePlist(cdvlibPbx)
+	cdvBuildSettingsKeys = ['PUBLIC_HEADERS_FOLDER_PATH', 'ARCHS', 'USER_HEADER_SEARCH_PATHS',
'IPHONEOS_DEPLOYMENT_TARGET', 'OTHER_LDFLAGS', 'GCC_VERSION']
+
+	cdvBuildSettings = getXcodeBuildSettings(cdvBuildSettingsKeys, cdvPlist)
+	pp.pprint( cdvBuildSettings )
+
+	print "\n\n--------------------------------------------------------------------------------"
+	print "Inspecting CordovaLib Version...\n"
+  
+	cdvlibFolder = AbsParentPath(cdvlibNormalizedPath)
+	cdvlibVersionFile = os.path.join( cdvlibFolder, "VERSION")
+
+	try:
+		vf = open(cdvlibVersionFile, 'r')
+	  	print "VERSION file:", vf.readline()
+	  	vf.close()
+	except:
+		print "VERSION file not found at:", cdvlibVersionFile
+
+	cdvlibAvailabilityFile = os.path.join( cdvlibFolder, "Classes", "CDVAvailability.h" )
+	try:
+	    af = open(cdvlibAvailabilityFile, 'r')
+	    match = "#define CORDOVA_VERSION_MIN_REQUIRED"
+	    for line in af:
+	  		if match in line:
+	  			print "CDVAvailability.h version:", line.strip().replace(match, ""),
+	    af.close()
+	except:
+		print "CDVAvailability.h file not found at:", cdvlibAvailabilityFile, 
+
+	print "\n\n--------------------------------------END---------------------------------------"
+
+if __name__ == '__main__':
+  main(sys.argv)


Mime
View raw message