Hi granata.enrico,

SWIG is searched under certain paths within python script. CMake can
detect SWIG with `find_package(SWIG)`. This is used iff user checks
`LLDB_ENABLE_PYTHON_SCRIPTS_SWIG_API_GENERATION`. If
buildSwigWrapperClasses.py does not receive swigExecutable argument,
then script will use its current search implementation.

This patch also fixes a typo in OS detection, where there is one too
many equals in the assignment for Darwin.

http://reviews.llvm.org/D6290

Files:
  scripts/CMakeLists.txt
  scripts/buildSwigWrapperClasses.py
  scripts/utilsArgsParse.py
  scripts/utilsOsType.py
Index: scripts/CMakeLists.txt
===================================================================
--- scripts/CMakeLists.txt
+++ scripts/CMakeLists.txt
@@ -3,12 +3,13 @@
 file(GLOB SWIG_INPUTS Python/interface/*.i)
 
 if ( LLDB_ENABLE_PYTHON_SCRIPTS_SWIG_API_GENERATION )
+  find_package(SWIG REQUIRED)
 	add_custom_command(
 	  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
 	  DEPENDS ${LLDB_SOURCE_DIR}/scripts/lldb.swig
 	  DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/buildSwigWrapperClasses.py
-	  DEPENDS ${SWIG_INPUTS}  
-	  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/buildSwigWrapperClasses.py "--srcRoot=${LLDB_SOURCE_DIR}" "--targetDir=${CMAKE_CURRENT_BINARY_DIR}" "--cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}" "--prefix=${CMAKE_BINARY_DIR}" -m    
+	  DEPENDS ${SWIG_INPUTS}
+	  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/buildSwigWrapperClasses.py "--srcRoot=${LLDB_SOURCE_DIR}" "--targetDir=${CMAKE_CURRENT_BINARY_DIR}" "--cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}" "--prefix=${CMAKE_BINARY_DIR}" "--swigDir=${SWIG_DIR}" "--swigExecutable=${SWIG_EXECUTABLE}" -m
 	  COMMENT "Python script building LLDB Python wrapper")  
 	set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp PROPERTIES GENERATED 1)
 
Index: scripts/buildSwigWrapperClasses.py
===================================================================
--- scripts/buildSwigWrapperClasses.py
+++ scripts/buildSwigWrapperClasses.py
@@ -85,10 +85,11 @@
 			automatically. Python install directory.\n\
 	--argsFile=	The args are read from a file instead of the\n\
 			command line. Other command line args are ignored.\n\
+	--swigExecutable=	(optional) Full path of swig executable.\n\
 \n\
 Usage:\n\
 	buildSwigWrapperClasses.py --srcRoot=ADirPath --targetDir=ADirPath\n\
-	--cfgBldDir=ADirPath --prefix=ADirPath -m -d\n\
+	--cfgBldDir=ADirPath --prefix=ADirPath --swigExecutable=ADirPath -m -d\n\
 \n\
 "; #TAG_PROGRAM_HELP_INFO
 strHelpInfoExtraWindows = "\
@@ -404,17 +405,21 @@
 #--
 def check_lldb_swig_executable_file_exists( vDictArgs, veOSType ):
 	dbg = utilsDebug.CDebugFnVerbose( "check_lldb_swig_executable_file_exists()" );
-	bExeFileFound = False;
-	strStatusMsg = "";
-	
-	switch = { 0 : check_lldb_swig_executable_file_exists_Unknown,
+	bExeFileFound = False
+	strStatusMsg = None
+
+	if "--swigExecutable" in vDictArgs:
+		vDictArgs["--swigExeName"] = os.path.basename(vDictArgs["--swigExecutable"])
+		vDictArgs["--swigExePath"] = os.path.dirname(vDictArgs["--swigExecutable"])
+		bExeFileFound = True
+	else:
+		switch = { 0 : check_lldb_swig_executable_file_exists_Unknown,
 			   1 : check_lldb_swig_executable_file_exists_windows,
 			   2 : check_lldb_swig_executable_file_exists_Linux,
 			   3 : check_lldb_swig_executable_file_exists_Darwin }
-	bExeFileFound, strStatusMsg = switch[ veOSType ]( vDictArgs );
-	
-	return (bExeFileFound, strStatusMsg);
+		bExeFileFound, strStatusMsg = switch[ veOSType ]( vDictArgs );
 
+	return (bExeFileFound, strStatusMsg);
 #++---------------------------------------------------------------------------
 # Details:	Validate the arguments passed to the program. This function exits
 #			the program should error with the arguments be found.
@@ -429,14 +434,16 @@
 	dictArgs = {};
 	nResult = 0;
 	strListArgs = "hdmM"; # Format "hiox:" = -h -i -o -x <arg>
-	listLongArgs = ["srcRoot=", "targetDir=", "cfgBldDir=", "prefix=", 
-					"argsFile"];
+	listLongArgs = ["srcRoot=", "targetDir=", "cfgBldDir=", "prefix=",
+					"swigDir=", "swigExecutable=", "argsFile"];
 	dictArgReq = {	"-h": "o",			# o = optional, m = mandatory
 					"-d": "o",
 					"-m": "o",
 					"-M": "o",
 					"--srcRoot": "m",
 					"--targetDir": "m",
+					"--swigExecutable" : "o",
+					"--swigDir" : "o",
 					"--cfgBldDir": "o",
 					"--prefix": "o",
 					"--argsFile": "o" };
@@ -532,8 +539,8 @@
 			--argsFile=		The args are read from a file instead of the
 							command line. Other command line args are ignored.
 	Usage:
-			buildSwigWrapperClasses.py --srcRoot=ADirPath --targetDir=ADirPath 
-			--cfgBldDir=ADirPath --prefix=ADirPath -m -d
+			buildSwigWrapperClasses.py --srcRoot=ADirPath --targetDir=ADirPath
+			--cfgBldDir=ADirPath --prefix=ADirPath --swigDir=ADirPath -m -d
 
 	Results:	0 Success
 				-1 Error - invalid parameters passed.
@@ -558,4 +565,3 @@
 	main( sys.argv[ 1: ] );
 else:
 	program_exit( -5, strMsgErrorNoMain );
-	
\ No newline at end of file
Index: scripts/utilsArgsParse.py
===================================================================
--- scripts/utilsArgsParse.py
+++ scripts/utilsArgsParse.py
@@ -67,7 +67,7 @@
 			
 	# Validate parameters above and error on not recognised
 	try:
-		dictOptsNeeded, dictArgsLeftOver = getopt.getopt( vArgv, 
+		dictOptsNeeded, dictArgsLeftOver = getopt.getopt( vArgv,
 														  vstrListArgs, 
 														  vListLongArgs );
 	except getopt.GetoptError:
@@ -143,4 +143,3 @@
 		return (-2, dictDummy, strMsg);
 
 	return (0, dictArgs, strDummy);
-	
Index: scripts/utilsOsType.py
===================================================================
--- scripts/utilsOsType.py
+++ scripts/utilsOsType.py
@@ -73,10 +73,9 @@
 	
 	strOS = sys.platform
 	if strOS == "win32":
-		eOSType = EnumOsType.Windows;
+		eOSType = EnumOsType.Windows
 	elif (strOS == "linux") or (strOS == "linux2"):
-		eOSType = EnumOsType.Linux;
+		eOSType = EnumOsType.Linux
 	elif strOS == "darwin":
-		eOSType == EnumOsType.Darwin;
-		
-	return eOSType;
+		eOSType = EnumOsType.Darwin
+	return eOSType
_______________________________________________
lldb-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to