Don't use literal slashes when concatenating paths in Python.

This patch fixes the swig generation scripts to use os.path.join
instead, which produces correctly normalized paths for platforms
that don't use the standard forward slash separator.

llvm-svn: 234030
diff --git a/lldb/scripts/Python/finishSwigPythonLLDB.py b/lldb/scripts/Python/finishSwigPythonLLDB.py
index 0ddbf93..c9b5e81 100644
--- a/lldb/scripts/Python/finishSwigPythonLLDB.py
+++ b/lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -90,17 +90,17 @@
     if eOSType != utilsOsType.EnumOsType.Darwin:
         return (bOk, strMsg);
 
-    strHeapDir = vstrFrameworkPythonDir + "/macosx/heap";
+    strHeapDir = os.path.join(vstrFrameworkPythonDir, "macosx", "heap");
     strHeapDir = os.path.normcase( strHeapDir );
     if (os.path.exists( strHeapDir ) and os.path.isdir( strHeapDir )):
         return (bOk, strMsg);
 
     os.makedirs( strHeapDir );
 
-    strRoot = vDictArgs[ "--srcRoot" ];
-    strSrc = strRoot + "/examples/darwin/heap_find/heap/heap_find.cpp";
+    strRoot = os.path.normpath(vDictArgs[ "--srcRoot" ]);
+    strSrc = os.path.join(strRoot, "examples", "darwin", "heap_find", "heap", "heap_find.cpp");
     shutil.copy( strSrc, strHeapDir );
-    strSrc = strRoot + "/examples/darwin/heap_find/heap/Makefile";
+    strSrc = os.path.join(strRoot, "examples", "darwin", "heap_find", "heap", "Makefile");
     shutil.copy( strSrc, strHeapDir );
 
     return (bOk, strMsg);
@@ -147,8 +147,7 @@
             shutil.copy( strPkgFile, strPkgDir );
 
     # Create a packet init files if there wasn't one
-    strPkgIniFile = strPkgDir + "/__init__.py";
-    strPkgIniFile = os.path.normcase( strPkgIniFile );
+    strPkgIniFile = os.path.normpath(os.path.join(strPkgDir, "__init__.py"));
     if os.path.exists( strPkgIniFile ) and os.path.isfile( strPkgIniFile ):
         return (bOk, strMsg);
 
@@ -190,9 +189,9 @@
     bDbg = vDictArgs.has_key( "-d" );
     strMsg = "";
 
-    strSrc = vstrCfgBldDir + "/lldb.py";
+    strSrc = os.path.join(vstrCfgBldDir, "lldb.py");
     strSrc = os.path.normcase( strSrc );
-    strDst = vstrFrameworkPythonDir + "/__init__.py";
+    strDst = os.path.join(vstrFrameworkPythonDir, "__init__.py");
     strDst = os.path.normcase( strDst );
 
     if not os.path.exists( strSrc ):
@@ -282,7 +281,7 @@
     bOk = True;
     strErrMsg = "";
     bDbg = vDictArgs.has_key( "-d" );
-    strTarget = "%s/%s" % (vstrFrameworkPythonDir, vstrTargetFile);
+    strTarget = os.path.join(vstrFrameworkPythonDir, vstrTargetFile);
     strTarget = os.path.normcase( strTarget );
     strSrc = "";
 
@@ -293,16 +292,15 @@
         return (bOk, strErrMsg);
     else:
         # Resolve vstrSrcFile path relatively the build directory
-        strBuildDir = "";
         if eOSType == utilsOsType.EnumOsType.Windows:
             # On a Windows platform the vstrFrameworkPythonDir looks like:
             # llvm\\build\\Lib\\site-packages\\lldb
-            strBuildDir = "../../..";
+            strBuildDir = os.path.join("..", "..", "..");
         else:
             # On a UNIX style platform the vstrFrameworkPythonDir looks like:
             # llvm/build/lib/python2.7/site-packages/lldb
-            strBuildDir = "../../../..";
-        strSrc = os.path.normcase( "%s/%s" % (strBuildDir, vstrSrcFile) );
+            strBuildDir = os.path.join("..", "..", "..", "..");
+        strSrc = os.path.normcase(os.path.join(strBuildDir, vstrSrcFile));
 
     if eOSType == utilsOsType.EnumOsType.Unknown:
         bOk = False;
@@ -358,18 +356,17 @@
 
     bMakeFileCalled = vDictArgs.has_key( "-m" );
     if not bMakeFileCalled:
-        strSrc = "lib/LLDB";
+        strSrc = os.path.join("lib", "LLDB");
     else:
         strLibFileExtn = "";
         if eOSType == utilsOsType.EnumOsType.Windows:
-            strLibFileExtn = ".dll";
-            strSrc = "bin/liblldb%s" % strLibFileExtn;
+            strSrc = os.path.join("bin", "liblldb.dll");
         else:
             if eOSType == utilsOsType.EnumOsType.Darwin:
                 strLibFileExtn = ".dylib";
             else:
                 strLibFileExtn = ".so";
-            strSrc = "lib/liblldb%s" % strLibFileExtn;
+            strSrc = os.path.join("lib", "liblldb" + strLibFileExtn);
 
     bOk, strErrMsg = make_symlink( vDictArgs, vstrFrameworkPythonDir, strSrc, strTarget );
 
@@ -395,7 +392,7 @@
     if not bMakeFileCalled:
         return (bOk, strErrMsg);
     else:
-        strSrc = "bin/lldb-launcher";
+        strSrc = os.path.join("bin", "lldb-launcher");
 
     bOk, strErrMsg = make_symlink( vDictArgs, vstrFrameworkPythonDir, strSrc, strTarget );
 
@@ -428,7 +425,7 @@
         strExeFileExtn = "";
         if eOSType == utilsOsType.EnumOsType.Windows:
             strExeFileExtn = ".exe";
-        strSrc = "bin/argdumper%s" % strExeFileExtn;
+        strSrc = os.path.join("bin", "argdumper" + strExeFileExtn);
 
     bOk, strErrMsg = make_symlink( vDictArgs, vstrFrameworkPythonDir, strSrc, strTarget );
 
@@ -550,18 +547,17 @@
     strPythonInstallDir = "";
     bHaveArgPrefix = vDictArgs.has_key( "--prefix" );
     if bHaveArgPrefix:
-        strPythonInstallDir = vDictArgs[ "--prefix" ];
+        strPythonInstallDir = os.path.normpath(vDictArgs[ "--prefix" ]);
 
     bHaveArgCmakeBuildConfiguration = vDictArgs.has_key( "--cmakeBuildConfiguration" );
     if bHaveArgCmakeBuildConfiguration:
-        strPythonInstallDir += '/' + vDictArgs[ "--cmakeBuildConfiguration" ];
+        strPythonInstallDir = os.path.join(strPythonInstallDir, vDictArgs["--cmakeBuildConfiguration"]);
 
     if strPythonInstallDir.__len__() != 0:
         strWkDir = get_python_lib( True, False, strPythonInstallDir );
     else:
         strWkDir = get_python_lib( True, False );
-    strWkDir += "/lldb";
-    strWkDir = os.path.normcase( strWkDir );
+    strWkDir = os.path.normcase(os.path.join(strWkDir, "lldb"));
 
     return (bOk, strWkDir, strErrMsg);
 
@@ -590,11 +586,11 @@
         # We are being built by XCode, so all the lldb Python files can go
         # into the LLDB.framework/Resources/Python subdirectory.
         strWkDir = vDictArgs[ "--targetDir" ];
-        strWkDir += "/LLDB.framework";
+        strWkDir += os.path.join(strWkDir, "LLDB.framework");
         if os.path.exists( strWkDir ):
             if bDbg:
                 print strMsgFoundLldbFrameWkDir % strWkDir;
-            strWkDir += "/Resources/Python/lldb";
+            strWkDir = os.path.join(strWkDir, "Resources", "Python", "lldb");
             strWkDir = os.path.normcase( strWkDir );
         else:
             bOk = False;
@@ -694,16 +690,16 @@
         bOk, strMsg = copy_lldbpy_file_to_lldb_pkg_dir( vDictArgs,
                                                         strFrameworkPythonDir,
                                                         strCfgBldDir );
-    strRoot = vDictArgs[ "--srcRoot" ];
+    strRoot = os.path.normpath(vDictArgs[ "--srcRoot" ]);
     if bOk:
         # lldb
-        listPkgFiles = [ strRoot + "/source/Interpreter/embedded_interpreter.py" ];
+        listPkgFiles = [ os.path.join(strRoot, "source", "Interpreter", "embedded_interpreter.py") ];
         bOk, strMsg = create_py_pkg( vDictArgs, strFrameworkPythonDir, "", listPkgFiles );
 
     if bOk:
         # lldb/formatters/cpp
-        listPkgFiles = [ strRoot + "/examples/synthetic/gnu_libstdcpp.py",
-                         strRoot + "/examples/synthetic/libcxx.py" ];
+        listPkgFiles = [ os.path.join(strRoot, "examples", "synthetic", "gnu_libstdcpp.py"),
+                         os.path.join(strRoot, "examples", "synthetic", "libcxx.py") ];
         bOk, strMsg = create_py_pkg( vDictArgs, strFrameworkPythonDir, "/formatters/cpp", listPkgFiles );
 
     if bOk:
@@ -717,27 +713,27 @@
         # lldb/formatters
         # Having these files copied here ensure that lldb/formatters is a
         # valid package itself
-        listPkgFiles = [ strRoot + "/examples/summaries/cocoa/cache.py",
-                         strRoot + "/examples/summaries/cocoa/metrics.py",
-                         strRoot + "/examples/summaries/cocoa/attrib_fromdict.py",
-                         strRoot + "/examples/summaries/cocoa/Logger.py" ];
+        listPkgFiles = [ os.path.join(strRoot, "examples", "summaries", "cocoa", "cache.py"),
+                         os.path.join(strRoot, "examples", "summaries", "cocoa", "metrics.py"),
+                         os.path.join(strRoot, "examples", "summaries", "cocoa", "attrib_fromdict.py"),
+                         os.path.join(strRoot, "examples", "summaries", "cocoa", "Logger.py") ];
         bOk, strMsg = create_py_pkg( vDictArgs, strFrameworkPythonDir, "/formatters", listPkgFiles );
 
     if bOk:
         # lldb/utils
-        listPkgFiles = [ strRoot + "/examples/python/symbolication.py" ];
+        listPkgFiles = [ os.path.join(strRoot, "examples", "python", "symbolication.py") ];
         bOk, strMsg = create_py_pkg( vDictArgs, strFrameworkPythonDir, "/utils", listPkgFiles );
 
     if bOk and (eOSType == utilsOsType.EnumOsType.Darwin):
         # lldb/macosx
-        listPkgFiles = [ strRoot + "/examples/python/crashlog.py",
-                         strRoot + "/examples/darwin/heap_find/heap.py" ];
+        listPkgFiles = [ os.path.join(strRoot, "examples", "python", "crashlog.py"),
+                         os.path.join(strRoot, "examples", "darwin", "heap_find", "heap.py") ];
         bOk, strMsg = create_py_pkg( vDictArgs, strFrameworkPythonDir, "/macosx", listPkgFiles );
 
     if bOk and (eOSType == utilsOsType.EnumOsType.Darwin):
         # lldb/diagnose
-        listPkgFiles = [ strRoot + "/examples/python/diagnose_unwind.py",
-                         strRoot + "/examples/python/diagnose_nsstring.py" ];
+        listPkgFiles = [ os.path.join(strRoot, "examples", "python", "diagnose_unwind.py"),
+                         os.path.join(strRoot, "examples", "python", "diagnose_nsstring.py") ];
         bOk, strMsg = create_py_pkg( vDictArgs, strFrameworkPythonDir, "/diagnose", listPkgFiles );
 
     if bOk:
diff --git a/lldb/scripts/finishSwigWrapperClasses.py b/lldb/scripts/finishSwigWrapperClasses.py
index 75f7d46..ca2cbc3 100644
--- a/lldb/scripts/finishSwigWrapperClasses.py
+++ b/lldb/scripts/finishSwigWrapperClasses.py
@@ -199,9 +199,8 @@
     nResult = 0;
     strStatusMsg = "";
     strScriptFile = vstrFinishFileName % vStrScriptLang;
-    strScriptFileDir = "%s%s/%s" % (vDictArgs[ "--srcRoot" ], "/scripts",
-                                    vStrScriptLang);
-    strScriptFilePath = "%s/%s" % (strScriptFileDir, strScriptFile);
+    strScriptFileDir = os.path.normpath(os.path.join(vDictArgs["--srcRoot"], "scripts", vStrScriptLang));
+    strScriptFilePath = os.path.join(strScriptFileDir, strScriptFile);
 
     # Check for the existence of the script file
     strPath = os.path.normcase( strScriptFilePath );
@@ -245,7 +244,7 @@
     dbg = utilsDebug.CDebugFnVerbose( "run_post_process_for_each_script_supported()" );
     nResult = 0;
     strStatusMsg = "";
-    strScriptDir = vDictArgs[ "--srcRoot" ] + "/scripts";
+    strScriptDir = os.path.normpath(os.path.join(vDictArgs["--srcRoot"], "scripts"));
     strFinishFileName = "finishSwig%sLLDB.py";
 
     # Check for the existence of the scripts folder