Skip to content

Commit 454955e

Browse files
author
Zachary Turner
committed
Add better logging to the new Python-based SWIG generation scripts.
llvm-svn: 212759
1 parent d092f0e commit 454955e

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

lldb/scripts/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ if ( LLDB_ENABLE_PYTHON_SCRIPTS_SWIG_API_GENERATION )
66
add_custom_command(
77
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
88
DEPENDS ${LLDB_SOURCE_DIR}/scripts/lldb.swig
9+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/buildSwigWrapperClasses.py
910
DEPENDS ${SWIG_INPUTS}
1011
COMMAND python ${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
1112
COMMENT "Python script building LLDB Python wrapper")

lldb/scripts/Python/finishSwigPythonLLDB.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,20 @@
5757
# User facing text:
5858
strMsgOsVersion = "The current OS is %s";
5959
strMsgPyVersion = "The Python version is %d.%d";
60-
strErrMsgProgFail = "Program failure: ";
60+
strErrMsgProgFail = "Program failure: ";
61+
strErrMsgLLDBPyFileNotNotFound = "Unable to locate lldb.py at path '%s'";
62+
strMsgCopyLLDBPy = "Copying lldb.py from '%s' to '%s'";
6163
strErrMsgFrameWkPyDirNotExist = "Unable to find the LLDB.framework directory '%s'";
64+
strMsgCreatePyPkgCopyPkgFile = "create_py_pkg: Copied file '%s' to folder '%s'";
65+
strMsgCreatePyPkgInitFile = "create_py_pkg: Creating pakage init file '%s'";
66+
strMsgCreatePyPkgMkDir = "create_py_pkg: Created folder '%s'";
67+
strMsgConfigBuildDir = "Configuration build directory located at '%s'";
6268
strMsgFoundLldbFrameWkDir = "Found '%s'";
6369
strMsgPyFileLocatedHere = "Python file will be put in '%s'";
64-
strMsgFrameWkPyExists = "'%s' already exists";
65-
strMsgFrameWkPyMkDir = "Making directory '%s'";
70+
strMsgFrameWkPyExists = "Python output folder '%s' already exists";
71+
strMsgFrameWkPyMkDir = "Python output folder '%s' will be created";
6672
strErrMsgCreateFrmWkPyDirFailed = "Unable to create directory '%s' error: %s";
67-
strMsglldbsoExists = "'%s' already exists";
73+
strMsglldbsoExists = "Symlink '%s' already exists";
6874
strMsglldbsoMk = "Creating symlink for _lldb.so";
6975
strErrMsgCpLldbpy = "copying lldb to lldb package directory";
7076
strErrMsgCreatePyPkgMissingSlash = "Parameter 3 fn create_py_pkg() missing slash";
@@ -117,7 +123,8 @@ def macosx_copy_file_for_heap( vDictArgs, vstrFrameworkPythonDir ):
117123
def create_py_pkg( vDictArgs, vstrFrameworkPythonDir, vstrPkgDir, vListPkgFiles ):
118124
dbg = utilsDebug.CDebugFnVerbose( "Python script create_py_pkg()" );
119125
dbg.dump_object( "Package file(s):", vListPkgFiles );
120-
126+
bDbg = vDictArgs.has_key( "-d" );
127+
121128
bOk = True;
122129
strMsg = "";
123130

@@ -135,11 +142,15 @@ def create_py_pkg( vDictArgs, vstrFrameworkPythonDir, vstrPkgDir, vListPkgFiles
135142
strPkgDir = os.path.normcase( strPkgDir );
136143

137144
if not(os.path.exists( strPkgDir ) and os.path.isdir( strPkgDir )):
145+
if bDbg:
146+
print(strMsgCreatePyPkgMkDir % strPkgDir);
138147
os.makedirs( strPkgDir );
139148

140149
for strPkgFile in vListPkgFiles:
141150
if os.path.exists( strPkgFile ) and os.path.isfile( strPkgFile ):
142151
strPyFile = os.path.normcase( strPkgFile );
152+
if bDbg:
153+
print(strMsgCreatePyPkgCopyPkgFile % (strPkgFile, strPkgDir));
143154
shutil.copy( strPyFile, strPkgDir );
144155

145156
# Create a packet init files if there wasn't one
@@ -163,6 +174,8 @@ def create_py_pkg( vDictArgs, vstrFrameworkPythonDir, vstrPkgDir, vListPkgFiles
163174
strPyScript += "for x in __all__:\n";
164175
strPyScript += "\t__import__('%s.' + x)" % strPkgName;
165176

177+
if bDbg:
178+
print(strMsgCreatePyPkgInitFile % strPkgIniFile);
166179
file = open( strPkgIniFile, "w" );
167180
file.write( strPyScript );
168181
file.close();
@@ -172,15 +185,17 @@ def create_py_pkg( vDictArgs, vstrFrameworkPythonDir, vstrPkgDir, vListPkgFiles
172185
#++---------------------------------------------------------------------------
173186
# Details: Copy the lldb.py file into the lldb package directory and rename
174187
# to __init_.py.
175-
# Args: vstrFrameworkPythonDir - (R) Python framework directory.
188+
# Args: vDictArgs - (R) Program input parameters.
189+
# vstrFrameworkPythonDir - (R) Python framework directory.
176190
# vstrCfgBldDir - (R) Config directory path.
177191
# Returns: Bool - True = function success, False = failure.
178192
# Str - Error description on task failure.
179193
# Throws: None.
180194
#--
181-
def copy_lldbpy_file_to_lldb_pkg_dir( vstrFrameworkPythonDir, vstrCfgBldDir ):
195+
def copy_lldbpy_file_to_lldb_pkg_dir( vDictArgs, vstrFrameworkPythonDir, vstrCfgBldDir ):
182196
dbg = utilsDebug.CDebugFnVerbose( "Python script copy_lldbpy_file_to_lldb_pkg_dir()" );
183197
bOk = True;
198+
bDbg = vDictArgs.has_key( "-d" );
184199
strMsg = "";
185200

186201
strSrc = vstrCfgBldDir + "/lldb.py";
@@ -189,9 +204,12 @@ def copy_lldbpy_file_to_lldb_pkg_dir( vstrFrameworkPythonDir, vstrCfgBldDir ):
189204
strDst = os.path.normcase( strDst );
190205

191206
if not os.path.exists( strSrc ):
207+
strMsg = strErrMsgLLDBPyFileNotNotFound % strSrc;
192208
return (bOk, strMsg);
193209

194210
try:
211+
if bDbg:
212+
print(strMsgCopyLLDBPy % (strSrc, strDst));
195213
shutil.copyfile( strSrc, strDst );
196214
except IOError as e:
197215
bOk = False;
@@ -538,15 +556,16 @@ def main( vDictArgs ):
538556
eOSType = utilsOsType.determine_os_type();
539557
if bDbg:
540558
pyVersion = sys.version_info;
541-
print strMsgOsVersion % utilsOsType.EnumOsType.name_of( eOSType );
542-
print strMsgPyVersion % (pyVersion[ 0 ], pyVersion[ 1 ]);
559+
print(strMsgOsVersion % utilsOsType.EnumOsType.name_of( eOSType ));
560+
print(strMsgPyVersion % (pyVersion[ 0 ], pyVersion[ 1 ]));
543561

544562
bOk, strFrameworkPythonDir, strMsg = get_framework_python_dir( vDictArgs );
545563

546564
if bOk:
547565
bOk, strCfgBldDir, strMsg = get_config_build_dir( vDictArgs, strFrameworkPythonDir );
548566
if bOk and bDbg:
549567
print strMsgPyFileLocatedHere % strFrameworkPythonDir;
568+
print strMsgConfigBuildDir % strCfgBldDir;
550569

551570
if bOk:
552571
bOk, strMsg = find_or_create_python_dir( vDictArgs, strFrameworkPythonDir );
@@ -555,7 +574,8 @@ def main( vDictArgs ):
555574
bOk, strMsg = make_symlink( vDictArgs, strFrameworkPythonDir );
556575

557576
if bOk:
558-
bOk, strMsg = copy_lldbpy_file_to_lldb_pkg_dir( strFrameworkPythonDir,
577+
bOk, strMsg = copy_lldbpy_file_to_lldb_pkg_dir( vDictArgs,
578+
strFrameworkPythonDir,
559579
strCfgBldDir );
560580
strRoot = vDictArgs[ "--srcRoot" ];
561581
if bOk:

0 commit comments

Comments
 (0)