70
70
strMsgFrameWkPyExists = "Python output folder '%s' already exists" ;
71
71
strMsgFrameWkPyMkDir = "Python output folder '%s' will be created" ;
72
72
strErrMsgCreateFrmWkPyDirFailed = "Unable to create directory '%s' error: %s" ;
73
- strMsglldbsoExists = "Symlink '%s' already exists" ;
74
- strMsglldbsoMk = "Creating symlink for _lldb.so (%s -> %s)" ;
73
+ strMsgSymlinkExists = "Symlink for '%s' already exists" ;
74
+ strMsgSymlinkMk = "Creating symlink for %s (%s -> %s)" ;
75
75
strErrMsgCpLldbpy = "copying lldb to lldb package directory" ;
76
76
strErrMsgCreatePyPkgMissingSlash = "Parameter 3 fn create_py_pkg() missing slash" ;
77
77
strErrMsgMkLinkExecute = "Command mklink failed: %s" ;
@@ -218,120 +218,169 @@ def copy_lldbpy_file_to_lldb_pkg_dir( vDictArgs, vstrFrameworkPythonDir, vstrCfg
218
218
strMsg = strErrMsgUnexpected % sys .exec_info ()[ 0 ];
219
219
220
220
return (bOk , strMsg );
221
+
222
+ #++---------------------------------------------------------------------------
223
+ # Details: Make the symbolic link on a Windows platform.
224
+ # Args: vstrSrcFile - (R) Source file name.
225
+ # vstrTargetFile - (R) Destination file name.
226
+ # Returns: Bool - True = function success, False = failure.
227
+ # Str - Error description on task failure.
228
+ # Throws: None.
229
+ #--
230
+ def make_symlink_windows ( vstrSrcPath , vstrTargetPath ):
231
+ print "Making symlink from %s to %s" % (vstrSrcPath , vstrTargetPath );
232
+ dbg = utilsDebug .CDebugFnVerbose ( "Python script make_symlink_windows()" );
233
+ bOk = True ;
234
+ strErrMsg = "" ;
235
+
236
+ try :
237
+ csl = ctypes .windll .kernel32 .CreateHardLinkW
238
+ csl .argtypes = (ctypes .c_wchar_p , ctypes .c_wchar_p , ctypes .c_uint32 )
239
+ csl .restype = ctypes .c_ubyte
240
+ if csl (vstrTargetPath , vstrSrcPath , 0 ) == 0 :
241
+ raise ctypes .WinError ()
242
+ except Exception as e :
243
+ if e .errno != 17 :
244
+ bOk = False ;
245
+ strErrMsg = "WinError( %d ): %s %s" % (e .errno , e .strerror , strErrMsgMakeSymlink );
246
+ strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath , vstrTargetPath );
247
+
248
+ return (bOk , strErrMsg );
221
249
222
250
#++---------------------------------------------------------------------------
223
- # Details: Make the symbolic that the script bridge for Python will need in
224
- # the Python framework directory. Code for specific to Windows.
251
+ # Details: Make the symbolic link on a UNIX style platform.
252
+ # Args: vstrSrcFile - (R) Source file name.
253
+ # vstrTargetFile - (R) Destination file name.
254
+ # Returns: Bool - True = function success, False = failure.
255
+ # Str - Error description on task failure.
256
+ # Throws: None.
257
+ #--
258
+ def make_symlink_other_platforms ( vstrSrcPath , vstrTargetPath ):
259
+ dbg = utilsDebug .CDebugFnVerbose ( "Python script make_symlink_other_platforms()" );
260
+ bOk = True ;
261
+ strErrMsg = "" ;
262
+
263
+ try :
264
+ os .symlink ( vstrSrcPath , vstrTargetPath );
265
+ except OSError as e :
266
+ bOk = False ;
267
+ strErrMsg = "OSError( %d ): %s %s" % (e .errno , e .strerror , strErrMsgMakeSymlink );
268
+ strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath , vstrTargetPath );
269
+ except :
270
+ bOk = False ;
271
+ strErrMsg = strErrMsgUnexpected % sys .exec_info ()[ 0 ];
272
+
273
+ return (bOk , strErrMsg );
274
+
275
+ #++---------------------------------------------------------------------------
276
+ # Details: Make the symbolic link.
225
277
# Args: vDictArgs - (R) Program input parameters.
226
278
# vstrFrameworkPythonDir - (R) Python framework directory.
227
- # vstrDllName - (R) File name for _lldb.dll.
279
+ # vstrSrcFile - (R) Source file name.
280
+ # vstrTargetFile - (R) Destination file name.
228
281
# Returns: Bool - True = function success, False = failure.
229
282
# Str - Error description on task failure.
230
283
# Throws: None.
231
284
#--
232
- def make_symlink_windows ( vDictArgs , vstrFrameworkPythonDir , vstrDllName ):
233
- dbg = utilsDebug .CDebugFnVerbose ( "Python script make_symlink_windows ()" );
285
+ def make_symlink ( vDictArgs , vstrFrameworkPythonDir , vstrSrcFile , vstrTargetFile ):
286
+ dbg = utilsDebug .CDebugFnVerbose ( "Python script make_symlink ()" );
234
287
bOk = True ;
235
- strMsg = "" ;
236
-
288
+ strErrMsg = "" ;
237
289
bDbg = vDictArgs .has_key ( "-d" );
238
- strTarget = vstrDllName ;
239
- # When importing an extension module using a debug version of python, you
240
- # write, for example, "import foo", but the interpreter searches for
241
- # "foo_d.pyd"
242
- if vDictArgs ["--buildConfig" ].lower () == "debug" :
243
- strTarget += "_d" ;
244
- strTarget += ".pyd" ;
245
- strDLLPath = "%s\\ %s" % (vstrFrameworkPythonDir , strTarget );
246
- strTarget = os .path .normcase ( strDLLPath );
290
+ strTarget = "%s/%s" % (vstrFrameworkPythonDir , vstrTargetFile );
291
+ strTarget = os .path .normcase ( strTarget );
247
292
strSrc = "" ;
248
293
249
294
os .chdir ( vstrFrameworkPythonDir );
250
295
bMakeFileCalled = vDictArgs .has_key ( "-m" );
296
+ eOSType = utilsOsType .determine_os_type ();
251
297
if not bMakeFileCalled :
252
- strSrc = os . path . normcase ( "../../../LLDB" );
298
+ return ( bOk , strErrMsg );
253
299
else :
254
- strLibFileExtn = ".dll" ;
255
- strSrc = os .path .normcase ( "../../../bin/liblldb%s" % strLibFileExtn );
300
+ # Resolve vstrSrcFile path relatively the build directory
301
+ stdBuildDir = "" ;
302
+ if eOSType == utilsOsType .EnumOsType .Windows :
303
+ # On a Windows platform the vstrFrameworkPythonDir looks like:
304
+ # llvm\\build\\Lib\\site-packages\\lldb
305
+ strBuildDir = "../../.." ;
306
+ else :
307
+ # On a UNIX style platform the vstrFrameworkPythonDir looks like:
308
+ # llvm/build/lib/python2.7/site-packages/lldb
309
+ strBuildDir = "../../../.." ;
310
+ strSrc = os .path .normcase ( "%s/%s" % (strBuildDir , vstrSrcFile ) );
256
311
257
- if os .path .isfile ( strTarget ):
312
+ if eOSType == utilsOsType .EnumOsType .Unknown :
313
+ bOk = False ;
314
+ strErrMsg = strErrMsgOsTypeUnknown ;
315
+ elif eOSType == utilsOsType .EnumOsType .Windows :
316
+ if os .path .isfile ( strTarget ):
317
+ if bDbg :
318
+ print strMsgSymlinkExists % vstrTargetFile ;
258
319
if bDbg :
259
- print strMsglldbsoExists % strTarget ;
260
- return (bOk , strMsg );
320
+ print strMsgSymlinkMk % (vstrTargetFile , strSrc , strTarget );
321
+ bOk , strErrMsg = make_symlink_windows ( strSrc ,
322
+ strTarget );
323
+ else :
324
+ if os .path .islink ( strTarget ):
325
+ if bDbg :
326
+ print strMsgSymlinkExists % vstrTargetFile ;
327
+ if bDbg :
328
+ print strMsgSymlinkMk % (vstrTargetFile , strSrc , strTarget );
329
+ return (bOk , strErrMsg );
330
+ bOk , strErrMsg = make_symlink_other_platforms ( strSrc ,
331
+ strTarget );
261
332
262
- if bDbg :
263
- print strMsglldbsoMk % (os .path .abspath (strSrc ), os .path .abspath (strTarget ));
264
-
265
- try :
266
- csl = ctypes .windll .kernel32 .CreateHardLinkW
267
- csl .argtypes = (ctypes .c_wchar_p , ctypes .c_wchar_p , ctypes .c_uint32 )
268
- csl .restype = ctypes .c_ubyte
269
- if csl (strTarget , strSrc , 0 ) == 0 :
270
- raise ctypes .WinError ()
271
- except Exception as e :
272
- bOk = False ;
273
- strMsg = "WinError( %d ): %s %s" % (e .errno , e .strerror , strErrMsgMakeSymlink );
274
- strMsg += " Src:'%s' Target:'%s'" % (strSrc , strTarget );
333
+ return (bOk , strErrMsg );
275
334
276
- return (bOk , strMsg );
277
-
278
335
#++---------------------------------------------------------------------------
279
- # Details: Make the symbolic link that the script bridge for Python will need in
280
- # the Python framework directory. Code for all platforms apart from
281
- # Windows.
336
+ # Details: Make the symbolic that the script bridge for Python will need in
337
+ # the Python framework directory.
282
338
# Args: vDictArgs - (R) Program input parameters.
283
339
# vstrFrameworkPythonDir - (R) Python framework directory.
284
- # vstrSoName - (R) File name for _lldb.so .
340
+ # vstrLiblldbName - (R) File name for _lldb library .
285
341
# Returns: Bool - True = function success, False = failure.
286
342
# Str - Error description on task failure.
287
343
# Throws: None.
288
344
#--
289
- def make_symlink_other_platforms ( vDictArgs , vstrFrameworkPythonDir , vstrSoPath ):
290
- dbg = utilsDebug .CDebugFnVerbose ( "Python script make_symlink_other_platforms ()" );
345
+ def make_symlink_liblldb ( vDictArgs , vstrFrameworkPythonDir , vstrLiblldbFileName ):
346
+ dbg = utilsDebug .CDebugFnVerbose ( "Python script make_symlink_liblldb ()" );
291
347
bOk = True ;
292
- strMsg = "" ;
293
- bDbg = vDictArgs .has_key ( "-d" );
294
- strTarget = vstrSoPath + ".so" ;
295
- strSoPath = "%s/%s" % (vstrFrameworkPythonDir , strTarget );
296
- strTarget = os .path .normcase ( strSoPath );
348
+ strErrMsg = "" ;
349
+ strTarget = vstrLiblldbFileName ;
297
350
strSrc = "" ;
298
-
299
- os .chdir ( vstrFrameworkPythonDir );
351
+
352
+ eOSType = utilsOsType .determine_os_type ();
353
+ if eOSType == utilsOsType .EnumOsType .Windows :
354
+ # When importing an extension module using a debug version of python, you
355
+ # write, for example, "import foo", but the interpreter searches for
356
+ # "foo_d.pyd"
357
+ if vDictArgs ["--buildConfig" ].lower () == "debug" :
358
+ strTarget += "_d" ;
359
+ strTarget += ".pyd" ;
360
+ else :
361
+ strTarget += ".so" ;
362
+
300
363
bMakeFileCalled = vDictArgs .has_key ( "-m" );
301
364
if not bMakeFileCalled :
302
- strSrc = os . path . normcase ( "../../../ LLDB" ) ;
365
+ strSrc = "lib/ LLDB" ;
303
366
else :
304
367
strLibFileExtn = "" ;
305
- eOSType = utilsOsType .determine_os_type ();
306
- if eOSType == utilsOsType .EnumOsType .Linux :
307
- strLibFileExtn = ".so" ;
308
- elif eOSType == utilsOsType .EnumOsType .Darwin :
309
- strLibFileExtn = ".dylib" ;
310
- strSrc = os .path .normcase ( "../../../liblldb%s" % strLibFileExtn );
311
-
312
- if os .path .islink ( strTarget ):
313
- if bDbg :
314
- print strMsglldbsoExists % strTarget ;
315
- return (bOk , strMsg );
316
-
317
- if bDbg :
318
- print strMsglldbsoMk ;
319
-
320
- try :
321
- os .symlink ( strSrc , strTarget );
322
- except OSError as e :
323
- bOk = False ;
324
- strMsg = "OSError( %d ): %s %s" % (e .errno , e .strerror , strErrMsgMakeSymlink );
325
- strMsg += " Src:'%s' Target:'%s'" % (strSrc , strTarget );
326
- except :
327
- bOk = False ;
328
- strMsg = strErrMsgUnexpected % sys .exec_info ()[ 0 ];
329
-
330
- return (bOk , strMsg );
331
-
368
+ if eOSType == utilsOsType .EnumOsType .Windows :
369
+ strLibFileExtn = ".dll" ;
370
+ strSrc = "bin/liblldb%s" % strLibFileExtn ;
371
+ else :
372
+ if eOSType == utilsOsType .EnumOsType .Linux :
373
+ strLibFileExtn = ".so" ;
374
+ elif eOSType == utilsOsType .EnumOsType .Darwin :
375
+ strLibFileExtn = ".dylib" ;
376
+ strSrc = "lib/liblldb%s" % strLibFileExtn ;
377
+
378
+ bOk , strErrMsg = make_symlink ( vDictArgs , vstrFrameworkPythonDir , strSrc , strTarget );
379
+
380
+ return (bOk , strErrMsg );
381
+
332
382
#++---------------------------------------------------------------------------
333
- # Details: Make the symbolic link to the darwin-debug. Code for all platforms
334
- # apart from Windows.
383
+ # Details: Make the symbolic link to the darwin-debug.
335
384
# Args: vDictArgs - (R) Program input parameters.
336
385
# vstrFrameworkPythonDir - (R) Python framework directory.
337
386
# vstrDarwinDebugFileName - (R) File name for darwin-debug.
@@ -340,41 +389,54 @@ def make_symlink_other_platforms( vDictArgs, vstrFrameworkPythonDir, vstrSoPath
340
389
# Throws: None.
341
390
#--
342
391
def make_symlink_darwin_debug ( vDictArgs , vstrFrameworkPythonDir , vstrDarwinDebugFileName ):
343
- dbg = utilsDebug .CDebugFnVerbose ( "Python script make_symlink_other_platforms ()" );
392
+ dbg = utilsDebug .CDebugFnVerbose ( "Python script make_symlink_darwin_debug ()" );
344
393
bOk = True ;
345
- strMsg = "" ;
346
- bDbg = vDictArgs .has_key ( "-d" );
347
- strTarget = vstrDarwinDebugFileName
348
- strDarwinDebugPath = "%s/%s" % (vstrFrameworkPythonDir , strTarget );
349
- strTarget = os .path .normcase ( strDarwinDebugPath );
394
+ strErrMsg = "" ;
395
+ strTarget = vstrDarwinDebugFileName ;
350
396
strSrc = "" ;
351
397
352
- os .chdir ( vstrFrameworkPythonDir );
353
398
bMakeFileCalled = vDictArgs .has_key ( "-m" );
354
399
if not bMakeFileCalled :
355
- return (bOk , strMsg );
400
+ return (bOk , strErrMsg );
356
401
else :
357
- strSrc = os . path . normcase ( "../../../../ bin/lldb-launcher" ) ;
402
+ strSrc = " bin/lldb-launcher" ;
358
403
359
- if os .path .islink ( strTarget ):
360
- if bDbg :
361
- print strMsglldbsoExists % strTarget ;
362
- return (bOk , strMsg );
363
-
364
- if bDbg :
365
- print strMsglldbsoMk ;
366
-
367
- try :
368
- os .symlink ( strSrc , strTarget );
369
- except OSError as e :
370
- bOk = False ;
371
- strMsg = "OSError( %d ): %s %s" % (e .errno , e .strerror , strErrMsgMakeSymlink );
372
- strMsg += " Src:'%s' Target:'%s'" % (strSrc , strTarget );
373
- except :
374
- bOk = False ;
375
- strMsg = strErrMsgUnexpected % sys .exec_info ()[ 0 ];
376
-
377
- return (bOk , strMsg );
404
+ bOk , strErrMsg = make_symlink ( vDictArgs , vstrFrameworkPythonDir , strSrc , strTarget );
405
+
406
+ return (bOk , strErrMsg );
407
+
408
+ #++---------------------------------------------------------------------------
409
+ # Details: Make the symbolic link to the argdumper.
410
+ # Args: vDictArgs - (R) Program input parameters.
411
+ # vstrFrameworkPythonDir - (R) Python framework directory.
412
+ # vstrArgdumperFileName - (R) File name for argdumper.
413
+ # Returns: Bool - True = function success, False = failure.
414
+ # Str - Error description on task failure.
415
+ # Throws: None.
416
+ #--
417
+ def make_symlink_argdumper ( vDictArgs , vstrFrameworkPythonDir , vstrArgdumperFileName ):
418
+ dbg = utilsDebug .CDebugFnVerbose ( "Python script make_symlink_argdumper()" );
419
+ bOk = True ;
420
+ strErrMsg = "" ;
421
+ strTarget = vstrArgdumperFileName ;
422
+ strSrc = "" ;
423
+
424
+ eOSType = utilsOsType .determine_os_type ();
425
+ if eOSType == utilsOsType .EnumOsType .Windows :
426
+ strTarget += ".exe" ;
427
+
428
+ bMakeFileCalled = vDictArgs .has_key ( "-m" );
429
+ if not bMakeFileCalled :
430
+ return (bOk , strErrMsg );
431
+ else :
432
+ strExeFileExtn = "" ;
433
+ if eOSType == utilsOsType .EnumOsType .Windows :
434
+ strExeFileExtn = ".exe" ;
435
+ strSrc = "bin/argdumper%s" % strExeFileExtn ;
436
+
437
+ bOk , strErrMsg = make_symlink ( vDictArgs , vstrFrameworkPythonDir , strSrc , strTarget );
438
+
439
+ return (bOk , strErrMsg );
378
440
379
441
#++---------------------------------------------------------------------------
380
442
# Details: Make the symlink that the script bridge for Python will need in
@@ -385,34 +447,33 @@ def make_symlink_darwin_debug( vDictArgs, vstrFrameworkPythonDir, vstrDarwinDebu
385
447
# strErrMsg - Error description on task failure.
386
448
# Throws: None.
387
449
#--
388
- def make_symlink ( vDictArgs , vstrFrameworkPythonDir ):
389
- dbg = utilsDebug .CDebugFnVerbose ( "Python script make_symlink ()" );
450
+ def create_symlinks ( vDictArgs , vstrFrameworkPythonDir ):
451
+ dbg = utilsDebug .CDebugFnVerbose ( "Python script create_symlinks ()" );
390
452
bOk = True ;
391
- strWkDir = "" ;
392
453
strErrMsg = "" ;
393
454
eOSType = utilsOsType .determine_os_type ();
394
455
395
- # Make symlink for _lldb
396
- strSoFileName = "_lldb" ;
397
- if eOSType == utilsOsType .EnumOsType .Unknown :
398
- bOk = False ;
399
- strErrMsg = strErrMsgOsTypeUnknown ;
400
- elif eOSType == utilsOsType .EnumOsType .Windows :
401
- bOk , strErrMsg = make_symlink_windows ( vDictArgs ,
456
+ # Make symlink for _lldb
457
+ strLibLldbFileName = "_lldb" ;
458
+ if bOk :
459
+ bOk , strErrMsg = make_symlink_liblldb ( vDictArgs ,
402
460
vstrFrameworkPythonDir ,
403
- strSoFileName );
404
- else :
405
- bOk , strErrMsg = make_symlink_other_platforms ( vDictArgs ,
406
- vstrFrameworkPythonDir ,
407
- strSoFileName );
461
+ strLibLldbFileName );
408
462
409
- # Make symlink for darwin-debug
463
+ # Make symlink for darwin-debug on Darwin
410
464
strDarwinDebugFileName = "darwin-debug"
411
465
if bOk and eOSType == utilsOsType .EnumOsType .Darwin :
412
466
bOk , strErrMsg = make_symlink_darwin_debug ( vDictArgs ,
413
467
vstrFrameworkPythonDir ,
414
468
strDarwinDebugFileName );
415
469
470
+ # Make symlink for argdumper
471
+ strArgdumperFileName = "argdumper"
472
+ if bOk :
473
+ bOk , strErrMsg = make_symlink_argdumper ( vDictArgs ,
474
+ vstrFrameworkPythonDir ,
475
+ strArgdumperFileName );
476
+
416
477
return (bOk , strErrMsg );
417
478
418
479
#++---------------------------------------------------------------------------
@@ -631,7 +692,7 @@ def main( vDictArgs ):
631
692
bOk , strMsg = find_or_create_python_dir ( vDictArgs , strFrameworkPythonDir );
632
693
633
694
if bOk :
634
- bOk , strMsg = make_symlink ( vDictArgs , strFrameworkPythonDir );
695
+ bOk , strMsg = create_symlinks ( vDictArgs , strFrameworkPythonDir );
635
696
636
697
if bOk :
637
698
bOk , strMsg = copy_lldbpy_file_to_lldb_pkg_dir ( vDictArgs ,
0 commit comments