[Lldb-commits] [PATCH] D74727: Allow customized relative PYTHONHOME

2020-02-17 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.
hhb edited the summary of this revision.
hhb added a reviewer: labath.

This change allows a hard coded relative PYTHONHOME setting. So that python can 
easily be packaged together with lldb.

The change includes:

1. Extend LLDB_RELOCATABLE_PYTHON to all platforms. It defaults to ON for 
platforms other than Windows, to keep the behavior compatible.
2. Allows to customize LLDB_PYTHON_HOME. But still defaults to PYTHON_HOME.
3. LLDB_PYTHON_HOME can be a path relative to liblldb. If it is relative, we 
will resolve it before send it to Py_DecodeLocale.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74727

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -279,12 +279,35 @@
   void InitializePythonHome() {
 #if defined(LLDB_PYTHON_HOME)
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef const wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-Py_SetPythonHome(g_python_home);
+static str_type g_python_home = []() -> str_type {
+  const char *lldb_python_home = LLDB_PYTHON_HOME;
+  const char *absolute_python_home = nullptr;
+  llvm::SmallString<64> path;
+  if (llvm::sys::path::is_absolute(lldb_python_home)) {
+absolute_python_home = lldb_python_home;
+  } else {
+FileSpec spec = HostInfo::GetShlibDir();
+if (!spec)
+  return nullptr;
+spec.GetPath(path);
+llvm::sys::path::append(path, lldb_python_home);
+llvm::sys::path::remove_dots(path, /* remove_dot_dots = */ true);
+absolute_python_home = path.c_str();
+  }
+#if PY_MAJOR_VERSION >= 3
+  size_t size = 0;
+  return Py_DecodeLocale(absolute_python_home, &size);
+#else
+  return strdup(absolute_python_home);
+#endif
+}();
+if (g_python_home != nullptr) {
+  Py_SetPythonHome(g_python_home);
+}
 #else
 #if defined(__APPLE__) && PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 7
 // For Darwin, the only Python version supported is the one shipped in the
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -59,7 +59,13 @@
 add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in 
LLDB" PythonInterpAndLibs PYTHONINTERPANDLIBS_FOUND)
 add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" 
LibXml2 LIBXML2_FOUND VERSION 2.8)
 
-option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." OFF)
+if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+  set(default_relocatable_python OFF)
+else()
+  set(default_relocatable_python ON)
+endif()
+
+option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." {default_relocatable_python})
 option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install 
a copy of it" OFF)
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" 
ON)
 option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
@@ -141,9 +147,11 @@
 
 if (LLDB_ENABLE_PYTHON)
   include_directories(${PYTHON_INCLUDE_DIRS})
-  if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND NOT 
LLDB_RELOCATABLE_PYTHON)
+  if (NOT LLDB_RELOCATABLE_PYTHON)
 get_filename_component(PYTHON_HOME "${PYTHON_EXECUTABLE}" DIRECTORY)
-file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME)
+set(LLDB_PYTHON_HOME "${PYTHON_HOME}" CACHE STRING
+  "Path to use as PYTHONHONE in lldb. If a relative path is specified, \
+  it will be resolved at runtime relative to liblldb directory.")
   endif()
 endif()
 


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -279,12 +279,35 @@
   void InitializePythonHome() {
 #if defined(LLDB_PYTHON_HOME)
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef const wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-Py_SetPythonHome(g_python_home);
+static str_type g_python_home = []() -> str

[Lldb-commits] [PATCH] D74727: Allow customized relative PYTHONHOME

2020-02-18 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 245206.
hhb marked 5 inline comments as done.
hhb added a comment.

Fix comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74727/new/

https://reviews.llvm.org/D74727

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -279,12 +279,34 @@
   void InitializePythonHome() {
 #if defined(LLDB_PYTHON_HOME)
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef const wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-Py_SetPythonHome(g_python_home);
+static str_type g_python_home = []() -> str_type {
+  const char *lldb_python_home = LLDB_PYTHON_HOME;
+  const char *absolute_python_home = nullptr;
+  llvm::SmallString<64> path;
+  if (llvm::sys::path::is_absolute(lldb_python_home)) {
+absolute_python_home = lldb_python_home;
+  } else {
+FileSpec spec = HostInfo::GetShlibDir();
+if (!spec)
+  return nullptr;
+spec.GetPath(path);
+llvm::sys::path::append(path, lldb_python_home);
+absolute_python_home = path.c_str();
+  }
+#if PY_MAJOR_VERSION >= 3
+  size_t size = 0;
+  return Py_DecodeLocale(absolute_python_home, &size);
+#else
+  return strdup(absolute_python_home);
+#endif
+}();
+if (g_python_home != nullptr) {
+  Py_SetPythonHome(g_python_home);
+}
 #else
 #if defined(__APPLE__) && PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 7
 // For Darwin, the only Python version supported is the one shipped in the
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -59,7 +59,13 @@
 add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in 
LLDB" PythonInterpAndLibs PYTHONINTERPANDLIBS_FOUND)
 add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" 
LibXml2 LIBXML2_FOUND VERSION 2.8)
 
-option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." OFF)
+if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+  set(default_relocatable_python OFF)
+else()
+  set(default_relocatable_python ON)
+endif()
+
+option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." ${default_relocatable_python})
 option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install 
a copy of it" OFF)
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" 
ON)
 option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
@@ -141,9 +147,11 @@
 
 if (LLDB_ENABLE_PYTHON)
   include_directories(${PYTHON_INCLUDE_DIRS})
-  if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND NOT 
LLDB_RELOCATABLE_PYTHON)
+  if (NOT LLDB_RELOCATABLE_PYTHON)
 get_filename_component(PYTHON_HOME "${PYTHON_EXECUTABLE}" DIRECTORY)
-file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME)
+set(LLDB_PYTHON_HOME "${PYTHON_HOME}" CACHE STRING
+  "Path to use as PYTHONHOME in lldb. If a relative path is specified, \
+  it will be resolved at runtime relative to liblldb directory.")
   endif()
 endif()
 


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -279,12 +279,34 @@
   void InitializePythonHome() {
 #if defined(LLDB_PYTHON_HOME)
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef const wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-Py_SetPythonHome(g_python_home);
+static str_type g_python_home = []() -> str_type {
+  const char *lldb_python_home = LLDB_PYTHON_HOME;
+  const char *absolute_python_home = nullptr;
+  llvm::SmallString<64> path;
+  if (llvm::sys::path::is_absolute(lldb_python_home)) {
+absolute_python_home = lldb_python_home;
+  } else {
+FileSpec spec = HostInfo::GetShlibDir();
+if (!spec)
+  return nullptr;
+spec.GetPath(path);
+llvm::sys::path::append(path, lldb_python_home);
+absolute_python_home = path.c_str();
+  }
+#if PY_MAJOR_VERSION >= 3
+  size_t

[Lldb-commits] [PATCH] D74727: Allow customized relative PYTHONHOME

2020-02-18 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 245211.
hhb added a comment.

Fix comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74727/new/

https://reviews.llvm.org/D74727

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -279,12 +279,34 @@
   void InitializePythonHome() {
 #if defined(LLDB_PYTHON_HOME)
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef const wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-Py_SetPythonHome(g_python_home);
+static str_type g_python_home = []() -> str_type {
+  const char *lldb_python_home = LLDB_PYTHON_HOME;
+  const char *absolute_python_home = nullptr;
+  llvm::SmallString<64> path;
+  if (llvm::sys::path::is_absolute(lldb_python_home)) {
+absolute_python_home = lldb_python_home;
+  } else {
+FileSpec spec = HostInfo::GetShlibDir();
+if (!spec)
+  return nullptr;
+spec.GetPath(path);
+llvm::sys::path::append(path, lldb_python_home);
+absolute_python_home = path.c_str();
+  }
+#if PY_MAJOR_VERSION >= 3
+  size_t size = 0;
+  return Py_DecodeLocale(absolute_python_home, &size);
+#else
+  return strdup(absolute_python_home);
+#endif
+}();
+if (g_python_home != nullptr) {
+  Py_SetPythonHome(g_python_home);
+}
 #else
 #if defined(__APPLE__) && PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 7
 // For Darwin, the only Python version supported is the one shipped in the
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -59,7 +59,13 @@
 add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in 
LLDB" PythonInterpAndLibs PYTHONINTERPANDLIBS_FOUND)
 add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" 
LibXml2 LIBXML2_FOUND VERSION 2.8)
 
-option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." OFF)
+if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+  set(default_relocatable_python OFF)
+else()
+  set(default_relocatable_python ON)
+endif()
+
+option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." ${default_relocatable_python})
 option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install 
a copy of it" OFF)
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" 
ON)
 option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
@@ -141,9 +147,11 @@
 
 if (LLDB_ENABLE_PYTHON)
   include_directories(${PYTHON_INCLUDE_DIRS})
-  if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND NOT 
LLDB_RELOCATABLE_PYTHON)
+  if (NOT LLDB_RELOCATABLE_PYTHON)
 get_filename_component(PYTHON_HOME "${PYTHON_EXECUTABLE}" DIRECTORY)
-file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME)
+set(LLDB_PYTHON_HOME "${PYTHON_HOME}" CACHE STRING
+  "Path to use as PYTHONHOME in lldb. If a relative path is specified, \
+  it will be resolved at runtime relative to liblldb directory.")
   endif()
 endif()
 


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -279,12 +279,34 @@
   void InitializePythonHome() {
 #if defined(LLDB_PYTHON_HOME)
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef const wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-Py_SetPythonHome(g_python_home);
+static str_type g_python_home = []() -> str_type {
+  const char *lldb_python_home = LLDB_PYTHON_HOME;
+  const char *absolute_python_home = nullptr;
+  llvm::SmallString<64> path;
+  if (llvm::sys::path::is_absolute(lldb_python_home)) {
+absolute_python_home = lldb_python_home;
+  } else {
+FileSpec spec = HostInfo::GetShlibDir();
+if (!spec)
+  return nullptr;
+spec.GetPath(path);
+llvm::sys::path::append(path, lldb_python_home);
+absolute_python_home = path.c_str();
+  }
+#if PY_MAJOR_VERSION >= 3
+  size_t size = 0;
+  return Py_DecodeLoc

[Lldb-commits] [PATCH] D74727: Allow customized relative PYTHONHOME

2020-02-18 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

> Can we maybe rename it to something like that?

LLDB_RELOCATABLE_PYTHON is misleading. I'd be happy to rename it. But that may 
break people who already set this flag.

Is there a standard procedure to do this? Maybe add the new one and remove the 
old one a year later? Or maybe fail when the old is set. So that at least 
people know how to fix?

> Or maybe even just a single LLDB_PYTHON_HOME variable, with the empty value 
> meaning we use the default python mechanism (PYTHONHOME env var, or the 
> baked-in python default)?

To do that, we have to make LLDB_PYTHON_HOME default to PYTHON_HOME for 
Windows. And if windows users want to make it "relocatable", they should set 
LLDB_PYTHON_HOME back to empty. That's also somehow weird...

> The other thing which bugs me is that the relative python path chosen here 
> will likely only be correct once lldb is installed. Will it be possible to 
> run lldb (and its test suite) configured in this way directly from the build 
> tree? I don't know if there's anything we can or should do about that, but 
> this situation seems less than ideal...

If someone uses relative python, that mean they should be responsible to put 
Python at the right place. No matter it is build tree or install tree. Or in 
other words, the install tree won't work by default either. People still need 
to put a symlink to python at the right place.




Comment at: lldb/cmake/modules/LLDBConfig.cmake:68
+
+option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." {default_relocatable_python})
 option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install 
a copy of it" OFF)

labath wrote:
> missing `$` in {default_relocatable_python}
Good catch. Thanks!



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp:298
+llvm::sys::path::append(path, lldb_python_home);
+llvm::sys::path::remove_dots(path, /* remove_dot_dots = */ true);
+absolute_python_home = path.c_str();

labath wrote:
> Is the `remove_dot_dots` really necessary? It can produce unexpected results 
> when `..`s back up over symlinks...
I was just trying to make the string shorter. It is not necessary. Removed.

But just curious what is the unexpected result? Say if I have a symlink 
"/src/python" -> "/usr/local/lib/python3.7", a "/src/python/../" should be 
resolved to /src, with or without remove_dot_dots?

Well I guess things get more interesting when liblldb is a symlink... That 
doesn't affect my use case though.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74727/new/

https://reviews.llvm.org/D74727



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74727: Allow customized relative PYTHONHOME

2020-02-18 Thread Haibo Huang via Phabricator via lldb-commits
hhb marked an inline comment as done.
hhb added inline comments.



Comment at: 
lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp:298
+llvm::sys::path::append(path, lldb_python_home);
+llvm::sys::path::remove_dots(path, /* remove_dot_dots = */ true);
+absolute_python_home = path.c_str();

hhb wrote:
> labath wrote:
> > Is the `remove_dot_dots` really necessary? It can produce unexpected 
> > results when `..`s back up over symlinks...
> I was just trying to make the string shorter. It is not necessary. Removed.
> 
> But just curious what is the unexpected result? Say if I have a symlink 
> "/src/python" -> "/usr/local/lib/python3.7", a "/src/python/../" should be 
> resolved to /src, with or without remove_dot_dots?
> 
> Well I guess things get more interesting when liblldb is a symlink... That 
> doesn't affect my use case though.
Kind of understood after searching around. For me remove_dot_dots is the 
expected behavior. But yea let's remove it to reduce some confusion...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74727/new/

https://reviews.llvm.org/D74727



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D74727: Allow customized relative PYTHONHOME

2020-02-19 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 245499.
hhb added a comment.

Rename LLDB_RELOCATABLE_PYTHON to LLDB_EMBED_PYTHON_HOME.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74727/new/

https://reviews.llvm.org/D74727

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -279,12 +279,34 @@
   void InitializePythonHome() {
 #if defined(LLDB_PYTHON_HOME)
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef const wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-Py_SetPythonHome(g_python_home);
+static str_type g_python_home = []() -> str_type {
+  const char *lldb_python_home = LLDB_PYTHON_HOME;
+  const char *absolute_python_home = nullptr;
+  llvm::SmallString<64> path;
+  if (llvm::sys::path::is_absolute(lldb_python_home)) {
+absolute_python_home = lldb_python_home;
+  } else {
+FileSpec spec = HostInfo::GetShlibDir();
+if (!spec)
+  return nullptr;
+spec.GetPath(path);
+llvm::sys::path::append(path, lldb_python_home);
+absolute_python_home = path.c_str();
+  }
+#if PY_MAJOR_VERSION >= 3
+  size_t size = 0;
+  return Py_DecodeLocale(absolute_python_home, &size);
+#else
+  return strdup(absolute_python_home);
+#endif
+}();
+if (g_python_home != nullptr) {
+  Py_SetPythonHome(g_python_home);
+}
 #else
 #if defined(__APPLE__) && PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 7
 // For Darwin, the only Python version supported is the one shipped in the
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -59,7 +59,15 @@
 add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in 
LLDB" PythonInterpAndLibs PYTHONINTERPANDLIBS_FOUND)
 add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" 
LibXml2 LIBXML2_FOUND VERSION 2.8)
 
-option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." OFF)
+if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+  set(default_embed_python_home ON)
+else()
+  set(default_embed_python_home OFF)
+endif()
+
+option(LLDB_EMBED_PYTHON_HOME
+   "Embed PYTHONHOME in the binary. If set to OFF, PYTHONHOME environment 
variable will \
+   be used to to locate Python." ${default_embed_python_home})
 option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install 
a copy of it" OFF)
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" 
ON)
 option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
@@ -141,9 +149,11 @@
 
 if (LLDB_ENABLE_PYTHON)
   include_directories(${PYTHON_INCLUDE_DIRS})
-  if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND NOT 
LLDB_RELOCATABLE_PYTHON)
+  if (LLDB_EMBED_PYTHON_HOME)
 get_filename_component(PYTHON_HOME "${PYTHON_EXECUTABLE}" DIRECTORY)
-file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME)
+set(LLDB_PYTHON_HOME "${PYTHON_HOME}" CACHE STRING
+  "Path to use as PYTHONHOME in lldb. If a relative path is specified, \
+  it will be resolved at runtime relative to liblldb directory.")
   endif()
 endif()
 


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -279,12 +279,34 @@
   void InitializePythonHome() {
 #if defined(LLDB_PYTHON_HOME)
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef const wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-Py_SetPythonHome(g_python_home);
+static str_type g_python_home = []() -> str_type {
+  const char *lldb_python_home = LLDB_PYTHON_HOME;
+  const char *absolute_python_home = nullptr;
+  llvm::SmallString<64> path;
+  if (llvm::sys::path::is_absolute(lldb_python_home)) {
+absolute_python_home = lldb_python_home;
+  } else {
+FileSpec spec = HostInfo::GetShlibDir();
+if (!spec)
+  return nullptr;
+spec.GetPath(path);
+llvm::sys::path::append(path, lldb_python_home);
+absolute_python

[Lldb-commits] [PATCH] D74727: Allow customized relative PYTHONHOME

2020-02-20 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 245750.
hhb added a comment.

Move option() into if


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74727/new/

https://reviews.llvm.org/D74727

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -279,12 +279,34 @@
   void InitializePythonHome() {
 #if defined(LLDB_PYTHON_HOME)
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef const wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-Py_SetPythonHome(g_python_home);
+static str_type g_python_home = []() -> str_type {
+  const char *lldb_python_home = LLDB_PYTHON_HOME;
+  const char *absolute_python_home = nullptr;
+  llvm::SmallString<64> path;
+  if (llvm::sys::path::is_absolute(lldb_python_home)) {
+absolute_python_home = lldb_python_home;
+  } else {
+FileSpec spec = HostInfo::GetShlibDir();
+if (!spec)
+  return nullptr;
+spec.GetPath(path);
+llvm::sys::path::append(path, lldb_python_home);
+absolute_python_home = path.c_str();
+  }
+#if PY_MAJOR_VERSION >= 3
+  size_t size = 0;
+  return Py_DecodeLocale(absolute_python_home, &size);
+#else
+  return strdup(absolute_python_home);
+#endif
+}();
+if (g_python_home != nullptr) {
+  Py_SetPythonHome(g_python_home);
+}
 #else
 #if defined(__APPLE__) && PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 7
 // For Darwin, the only Python version supported is the one shipped in the
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -59,7 +59,6 @@
 add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in 
LLDB" PythonInterpAndLibs PYTHONINTERPANDLIBS_FOUND)
 add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" 
LibXml2 LIBXML2_FOUND VERSION 2.8)
 
-option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." OFF)
 option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install 
a copy of it" OFF)
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" 
ON)
 option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
@@ -140,10 +139,21 @@
 endif()
 
 if (LLDB_ENABLE_PYTHON)
+  if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+set(default_embed_python_home ON)
+  else()
+set(default_embed_python_home OFF)
+  endif()
+  option(LLDB_EMBED_PYTHON_HOME
+ "Embed PYTHONHOME in the binary. If set to OFF, PYTHONHOME 
environment variable will \
+ be used to to locate Python." ${default_embed_python_home})
+
   include_directories(${PYTHON_INCLUDE_DIRS})
-  if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND NOT 
LLDB_RELOCATABLE_PYTHON)
+  if (LLDB_EMBED_PYTHON_HOME)
 get_filename_component(PYTHON_HOME "${PYTHON_EXECUTABLE}" DIRECTORY)
-file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME)
+set(LLDB_PYTHON_HOME "${PYTHON_HOME}" CACHE STRING
+  "Path to use as PYTHONHOME in lldb. If a relative path is specified, \
+  it will be resolved at runtime relative to liblldb directory.")
   endif()
 endif()
 


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -279,12 +279,34 @@
   void InitializePythonHome() {
 #if defined(LLDB_PYTHON_HOME)
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef const wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-Py_SetPythonHome(g_python_home);
+static str_type g_python_home = []() -> str_type {
+  const char *lldb_python_home = LLDB_PYTHON_HOME;
+  const char *absolute_python_home = nullptr;
+  llvm::SmallString<64> path;
+  if (llvm::sys::path::is_absolute(lldb_python_home)) {
+absolute_python_home = lldb_python_home;
+  } else {
+FileSpec spec = HostInfo::GetShlibDir();
+if (!spec)
+  return nullptr;
+spec.GetPath(path);
+llvm::sys::path::append(path, lldb_python_home);
+absolute_python_home = pat

[Lldb-commits] [PATCH] D74727: Allow customized relative PYTHONHOME

2020-02-20 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 245770.
hhb added a comment.

The code should check on LLDB_EMBED_PYTHON_HOME


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74727/new/

https://reviews.llvm.org/D74727

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -277,14 +277,36 @@
 
 private:
   void InitializePythonHome() {
-#if defined(LLDB_PYTHON_HOME)
+#if LLDB_EMBED_PYTHON_HOME
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef const wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-Py_SetPythonHome(g_python_home);
+static str_type g_python_home = []() -> str_type {
+  const char *lldb_python_home = LLDB_PYTHON_HOME;
+  const char *absolute_python_home = nullptr;
+  llvm::SmallString<64> path;
+  if (llvm::sys::path::is_absolute(lldb_python_home)) {
+absolute_python_home = lldb_python_home;
+  } else {
+FileSpec spec = HostInfo::GetShlibDir();
+if (!spec)
+  return nullptr;
+spec.GetPath(path);
+llvm::sys::path::append(path, lldb_python_home);
+absolute_python_home = path.c_str();
+  }
+#if PY_MAJOR_VERSION >= 3
+  size_t size = 0;
+  return Py_DecodeLocale(absolute_python_home, &size);
+#else
+  return strdup(absolute_python_home);
+#endif
+}();
+if (g_python_home != nullptr) {
+  Py_SetPythonHome(g_python_home);
+}
 #else
 #if defined(__APPLE__) && PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 7
 // For Darwin, the only Python version supported is the one shipped in the
Index: lldb/include/lldb/Host/Config.h.cmake
===
--- lldb/include/lldb/Host/Config.h.cmake
+++ lldb/include/lldb/Host/Config.h.cmake
@@ -46,6 +46,8 @@
 
 #cmakedefine01 LLDB_ENABLE_PYTHON
 
+#cmakedefine01 LLDB_EMBED_PYTHON_HOME
+
 #cmakedefine LLDB_PYTHON_HOME "${LLDB_PYTHON_HOME}"
 
 #define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}"
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -59,7 +59,6 @@
 add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in 
LLDB" PythonInterpAndLibs PYTHONINTERPANDLIBS_FOUND)
 add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" 
LibXml2 LIBXML2_FOUND VERSION 2.8)
 
-option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." OFF)
 option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install 
a copy of it" OFF)
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" 
ON)
 option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
@@ -140,10 +139,20 @@
 endif()
 
 if (LLDB_ENABLE_PYTHON)
+  if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+set(default_embed_python_home ON)
+  else()
+set(default_embed_python_home OFF)
+  endif()
+  option(LLDB_EMBED_PYTHON_HOME
+"Embed PYTHONHOME in the binary. If set to OFF, PYTHONHOME environment 
variable will be used to to locate Python."
+${default_embed_python_home})
+
   include_directories(${PYTHON_INCLUDE_DIRS})
-  if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND NOT 
LLDB_RELOCATABLE_PYTHON)
+  if (LLDB_EMBED_PYTHON_HOME)
 get_filename_component(PYTHON_HOME "${PYTHON_EXECUTABLE}" DIRECTORY)
-file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME)
+set(LLDB_PYTHON_HOME "${PYTHON_HOME}" CACHE STRING
+  "Path to use as PYTHONHOME in lldb. If a relative path is specified, it 
will be resolved at runtime relative to liblldb directory.")
   endif()
 endif()
 


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -277,14 +277,36 @@
 
 private:
   void InitializePythonHome() {
-#if defined(LLDB_PYTHON_HOME)
+#if LLDB_EMBED_PYTHON_HOME
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef const wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-Py_SetPythonHome(g_python_home);
+static str_

[Lldb-commits] [PATCH] D74727: Allow customized relative PYTHONHOME

2020-02-21 Thread Haibo Huang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0bb90628b5f7: Allow customized relative PYTHONHOME (authored 
by hhb).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74727/new/

https://reviews.llvm.org/D74727

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -277,14 +277,36 @@
 
 private:
   void InitializePythonHome() {
-#if defined(LLDB_PYTHON_HOME)
+#if LLDB_EMBED_PYTHON_HOME
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef const wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-Py_SetPythonHome(g_python_home);
+static str_type g_python_home = []() -> str_type {
+  const char *lldb_python_home = LLDB_PYTHON_HOME;
+  const char *absolute_python_home = nullptr;
+  llvm::SmallString<64> path;
+  if (llvm::sys::path::is_absolute(lldb_python_home)) {
+absolute_python_home = lldb_python_home;
+  } else {
+FileSpec spec = HostInfo::GetShlibDir();
+if (!spec)
+  return nullptr;
+spec.GetPath(path);
+llvm::sys::path::append(path, lldb_python_home);
+absolute_python_home = path.c_str();
+  }
+#if PY_MAJOR_VERSION >= 3
+  size_t size = 0;
+  return Py_DecodeLocale(absolute_python_home, &size);
+#else
+  return strdup(absolute_python_home);
+#endif
+}();
+if (g_python_home != nullptr) {
+  Py_SetPythonHome(g_python_home);
+}
 #else
 #if defined(__APPLE__) && PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 7
 // For Darwin, the only Python version supported is the one shipped in the
Index: lldb/include/lldb/Host/Config.h.cmake
===
--- lldb/include/lldb/Host/Config.h.cmake
+++ lldb/include/lldb/Host/Config.h.cmake
@@ -46,6 +46,8 @@
 
 #cmakedefine01 LLDB_ENABLE_PYTHON
 
+#cmakedefine01 LLDB_EMBED_PYTHON_HOME
+
 #cmakedefine LLDB_PYTHON_HOME "${LLDB_PYTHON_HOME}"
 
 #define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}"
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -59,7 +59,6 @@
 add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in 
LLDB" PythonInterpAndLibs PYTHONINTERPANDLIBS_FOUND)
 add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" 
LibXml2 LIBXML2_FOUND VERSION 2.8)
 
-option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." OFF)
 option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install 
a copy of it" OFF)
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" 
ON)
 option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
@@ -140,10 +139,20 @@
 endif()
 
 if (LLDB_ENABLE_PYTHON)
+  if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+set(default_embed_python_home ON)
+  else()
+set(default_embed_python_home OFF)
+  endif()
+  option(LLDB_EMBED_PYTHON_HOME
+"Embed PYTHONHOME in the binary. If set to OFF, PYTHONHOME environment 
variable will be used to to locate Python."
+${default_embed_python_home})
+
   include_directories(${PYTHON_INCLUDE_DIRS})
-  if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND NOT 
LLDB_RELOCATABLE_PYTHON)
+  if (LLDB_EMBED_PYTHON_HOME)
 get_filename_component(PYTHON_HOME "${PYTHON_EXECUTABLE}" DIRECTORY)
-file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME)
+set(LLDB_PYTHON_HOME "${PYTHON_HOME}" CACHE STRING
+  "Path to use as PYTHONHOME in lldb. If a relative path is specified, it 
will be resolved at runtime relative to liblldb directory.")
   endif()
 endif()
 


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -277,14 +277,36 @@
 
 private:
   void InitializePythonHome() {
-#if defined(LLDB_PYTHON_HOME)
+#if LLDB_EMBED_PYTHON_HOME
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef const wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-  

[Lldb-commits] [PATCH] D74998: Allow customized relative PYTHONHOME (Attemp 1)

2020-02-21 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.

This is another attempt of 0bb90628b5f7c170689d2d3f019af773772fc649 
.

The difference is that g_python_home is not declared as const. Since
some versions of python do not expect that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D74998

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -277,14 +277,36 @@
 
 private:
   void InitializePythonHome() {
-#if defined(LLDB_PYTHON_HOME)
+#if LLDB_EMBED_PYTHON_HOME
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-Py_SetPythonHome(g_python_home);
+static str_type g_python_home = []() -> str_type {
+  const char *lldb_python_home = LLDB_PYTHON_HOME;
+  const char *absolute_python_home = nullptr;
+  llvm::SmallString<64> path;
+  if (llvm::sys::path::is_absolute(lldb_python_home)) {
+absolute_python_home = lldb_python_home;
+  } else {
+FileSpec spec = HostInfo::GetShlibDir();
+if (!spec)
+  return nullptr;
+spec.GetPath(path);
+llvm::sys::path::append(path, lldb_python_home);
+absolute_python_home = path.c_str();
+  }
+#if PY_MAJOR_VERSION >= 3
+  size_t size = 0;
+  return Py_DecodeLocale(absolute_python_home, &size);
+#else
+  return strdup(absolute_python_home);
+#endif
+}();
+if (g_python_home != nullptr) {
+  Py_SetPythonHome(g_python_home);
+}
 #else
 #if defined(__APPLE__) && PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 7
 // For Darwin, the only Python version supported is the one shipped in the
Index: lldb/include/lldb/Host/Config.h.cmake
===
--- lldb/include/lldb/Host/Config.h.cmake
+++ lldb/include/lldb/Host/Config.h.cmake
@@ -46,6 +46,8 @@
 
 #cmakedefine01 LLDB_ENABLE_PYTHON
 
+#cmakedefine01 LLDB_EMBED_PYTHON_HOME
+
 #cmakedefine LLDB_PYTHON_HOME "${LLDB_PYTHON_HOME}"
 
 #define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}"
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -59,7 +59,6 @@
 add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in 
LLDB" PythonInterpAndLibs PYTHONINTERPANDLIBS_FOUND)
 add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" 
LibXml2 LIBXML2_FOUND VERSION 2.8)
 
-option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." OFF)
 option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install 
a copy of it" OFF)
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" 
ON)
 option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
@@ -140,10 +139,20 @@
 endif()
 
 if (LLDB_ENABLE_PYTHON)
+  if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+set(default_embed_python_home ON)
+  else()
+set(default_embed_python_home OFF)
+  endif()
+  option(LLDB_EMBED_PYTHON_HOME
+"Embed PYTHONHOME in the binary. If set to OFF, PYTHONHOME environment 
variable will be used to to locate Python."
+${default_embed_python_home})
+
   include_directories(${PYTHON_INCLUDE_DIRS})
-  if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND NOT 
LLDB_RELOCATABLE_PYTHON)
+  if (LLDB_EMBED_PYTHON_HOME)
 get_filename_component(PYTHON_HOME "${PYTHON_EXECUTABLE}" DIRECTORY)
-file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME)
+set(LLDB_PYTHON_HOME "${PYTHON_HOME}" CACHE STRING
+  "Path to use as PYTHONHOME in lldb. If a relative path is specified, it 
will be resolved at runtime relative to liblldb directory.")
   endif()
 endif()
 


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -277,14 +277,36 @@
 
 private:
   void InitializePythonHome() {
-#if defined(LLDB_PYTHON_HOME)
+#if LLDB_EMBED_PYTHON_HOME
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef 

[Lldb-commits] [PATCH] D74998: Allow customized relative PYTHONHOME (Attemp 1)

2020-02-21 Thread Haibo Huang via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3ec3f62f0a0b: Allow customized relative PYTHONHOME (Attemp 
1) (authored by hhb).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74998/new/

https://reviews.llvm.org/D74998

Files:
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -277,14 +277,36 @@
 
 private:
   void InitializePythonHome() {
-#if defined(LLDB_PYTHON_HOME)
+#if LLDB_EMBED_PYTHON_HOME
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef wchar_t* str_type;
 #else
-static char g_python_home[] = LLDB_PYTHON_HOME;
+typedef char* str_type;
 #endif
-Py_SetPythonHome(g_python_home);
+static str_type g_python_home = []() -> str_type {
+  const char *lldb_python_home = LLDB_PYTHON_HOME;
+  const char *absolute_python_home = nullptr;
+  llvm::SmallString<64> path;
+  if (llvm::sys::path::is_absolute(lldb_python_home)) {
+absolute_python_home = lldb_python_home;
+  } else {
+FileSpec spec = HostInfo::GetShlibDir();
+if (!spec)
+  return nullptr;
+spec.GetPath(path);
+llvm::sys::path::append(path, lldb_python_home);
+absolute_python_home = path.c_str();
+  }
+#if PY_MAJOR_VERSION >= 3
+  size_t size = 0;
+  return Py_DecodeLocale(absolute_python_home, &size);
+#else
+  return strdup(absolute_python_home);
+#endif
+}();
+if (g_python_home != nullptr) {
+  Py_SetPythonHome(g_python_home);
+}
 #else
 #if defined(__APPLE__) && PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 7
 // For Darwin, the only Python version supported is the one shipped in the
Index: lldb/include/lldb/Host/Config.h.cmake
===
--- lldb/include/lldb/Host/Config.h.cmake
+++ lldb/include/lldb/Host/Config.h.cmake
@@ -46,6 +46,8 @@
 
 #cmakedefine01 LLDB_ENABLE_PYTHON
 
+#cmakedefine01 LLDB_EMBED_PYTHON_HOME
+
 #cmakedefine LLDB_PYTHON_HOME "${LLDB_PYTHON_HOME}"
 
 #define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}"
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -59,7 +59,6 @@
 add_optional_dependency(LLDB_ENABLE_PYTHON "Enable Python scripting support in 
LLDB" PythonInterpAndLibs PYTHONINTERPANDLIBS_FOUND)
 add_optional_dependency(LLDB_ENABLE_LIBXML2 "Enable Libxml 2 support in LLDB" 
LibXml2 LIBXML2_FOUND VERSION 2.8)
 
-option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to 
locate Python." OFF)
 option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install 
a copy of it" OFF)
 option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" 
ON)
 option(LLDB_BUILD_FRAMEWORK "Build LLDB.framework (Darwin only)" OFF)
@@ -140,10 +139,20 @@
 endif()
 
 if (LLDB_ENABLE_PYTHON)
+  if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+set(default_embed_python_home ON)
+  else()
+set(default_embed_python_home OFF)
+  endif()
+  option(LLDB_EMBED_PYTHON_HOME
+"Embed PYTHONHOME in the binary. If set to OFF, PYTHONHOME environment 
variable will be used to to locate Python."
+${default_embed_python_home})
+
   include_directories(${PYTHON_INCLUDE_DIRS})
-  if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND NOT 
LLDB_RELOCATABLE_PYTHON)
+  if (LLDB_EMBED_PYTHON_HOME)
 get_filename_component(PYTHON_HOME "${PYTHON_EXECUTABLE}" DIRECTORY)
-file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME)
+set(LLDB_PYTHON_HOME "${PYTHON_HOME}" CACHE STRING
+  "Path to use as PYTHONHOME in lldb. If a relative path is specified, it 
will be resolved at runtime relative to liblldb directory.")
   endif()
 endif()
 


Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -277,14 +277,36 @@
 
 private:
   void InitializePythonHome() {
-#if defined(LLDB_PYTHON_HOME)
+#if LLDB_EMBED_PYTHON_HOME
 #if PY_MAJOR_VERSION >= 3
-size_t size = 0;
-static wchar_t *g_python_home = Py_DecodeLocale(LLDB_PYTHON_HOME, &size);
+typedef wchar_t* str_type;
 #else
-static

[Lldb-commits] [PATCH] D67993: [lldb] Calculate relative path for symbol links

2019-10-03 Thread Haibo Huang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL373668: [lldb] Calculate relative path for symbol links 
(authored by hhb, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67993?vs=221612&id=223102#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67993/new/

https://reviews.llvm.org/D67993

Files:
  lldb/trunk/scripts/Python/finishSwigPythonLLDB.py


Index: lldb/trunk/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/trunk/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/trunk/scripts/Python/finishSwigPythonLLDB.py
@@ -365,7 +365,6 @@
 # Throws:   None.
 #--
 
-
 def make_symlink(
 vDictArgs,
 vstrFrameworkPythonDir,
@@ -377,27 +376,15 @@
 bDbg = "-d" in vDictArgs
 strTarget = os.path.join(vstrFrameworkPythonDir, vstrTargetFile)
 strTarget = os.path.normcase(strTarget)
-strSrc = ""
+strPrefix = vDictArgs['--prefix']
 
 os.chdir(vstrFrameworkPythonDir)
 bMakeFileCalled = "-m" in vDictArgs
 eOSType = utilsOsType.determine_os_type()
-if not bMakeFileCalled:
-strBuildDir = os.path.join("..", "..", "..")
-else:
-# Resolve vstrSrcFile path relatively the build directory
-if eOSType == utilsOsType.EnumOsType.Windows:
-# On a Windows platform the vstrFrameworkPythonDir looks like:
-# llvm\\build\\Lib\\site-packages\\lldb
-strBuildDir = os.path.join("..", "..", "..")
-else:
-# On a UNIX style platform the vstrFrameworkPythonDir looks like:
-# llvm/build/lib/python2.7/site-packages/lldb
-strBuildDir = os.path.join("..", "..", "..", "..")
-strSrc = os.path.normcase(os.path.join(strBuildDir, vstrSrcFile))
-
-return make_symlink_native(vDictArgs, strSrc, strTarget)
 
+strSrc = os.path.normcase(os.path.join(strPrefix, vstrSrcFile))
+strRelSrc = os.path.relpath(strSrc, os.path.dirname(strTarget))
+return make_symlink_native(vDictArgs, strRelSrc, strTarget)
 
 #++---
 # Details:  Make the symbolic that the script bridge for Python will need in


Index: lldb/trunk/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/trunk/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/trunk/scripts/Python/finishSwigPythonLLDB.py
@@ -365,7 +365,6 @@
 # Throws:   None.
 #--
 
-
 def make_symlink(
 vDictArgs,
 vstrFrameworkPythonDir,
@@ -377,27 +376,15 @@
 bDbg = "-d" in vDictArgs
 strTarget = os.path.join(vstrFrameworkPythonDir, vstrTargetFile)
 strTarget = os.path.normcase(strTarget)
-strSrc = ""
+strPrefix = vDictArgs['--prefix']
 
 os.chdir(vstrFrameworkPythonDir)
 bMakeFileCalled = "-m" in vDictArgs
 eOSType = utilsOsType.determine_os_type()
-if not bMakeFileCalled:
-strBuildDir = os.path.join("..", "..", "..")
-else:
-# Resolve vstrSrcFile path relatively the build directory
-if eOSType == utilsOsType.EnumOsType.Windows:
-# On a Windows platform the vstrFrameworkPythonDir looks like:
-# llvm\\build\\Lib\\site-packages\\lldb
-strBuildDir = os.path.join("..", "..", "..")
-else:
-# On a UNIX style platform the vstrFrameworkPythonDir looks like:
-# llvm/build/lib/python2.7/site-packages/lldb
-strBuildDir = os.path.join("..", "..", "..", "..")
-strSrc = os.path.normcase(os.path.join(strBuildDir, vstrSrcFile))
-
-return make_symlink_native(vDictArgs, strSrc, strTarget)
 
+strSrc = os.path.normcase(os.path.join(strPrefix, vstrSrcFile))
+strRelSrc = os.path.relpath(strSrc, os.path.dirname(strTarget))
+return make_symlink_native(vDictArgs, strRelSrc, strTarget)
 
 #++---
 # Details:  Make the symbolic that the script bridge for Python will need in
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D67988: [lldb] clean up lldb/scripts a little bit

2019-10-03 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 223117.
hhb added a comment.

Fix comment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67988/new/

https://reviews.llvm.org/D67988

Files:
  lldb/scripts/Python/finishSwigPythonLLDB.py
  lldb/scripts/finishSwigWrapperClasses.py

Index: lldb/scripts/finishSwigWrapperClasses.py
===
--- lldb/scripts/finishSwigWrapperClasses.py
+++ lldb/scripts/finishSwigWrapperClasses.py
@@ -5,8 +5,6 @@
 
 Overview:   Python script(s) to finish off the SWIG Python C++ Script
 Bridge wrapper code on the Windows/LINUX/OSX platform.
-The Python scripts are equivalent to the shell script (.sh)
-files.
 We use SWIG to create a C++ file containing the appropriate
 wrapper classes and functions for each scripting language,
 before liblldb is built (thus the C++ file can be compiled
@@ -293,11 +291,9 @@
 
 # Iterate script directory find any script language directories
 for scriptLang in listDirs:
-# __pycache__ is a magic directory in Python 3 that holds .pyc files
-if scriptLang != "__pycache__" and scriptLang != "swig_bot_lib":
-dbg.dump_text("Executing language script for \'%s\'" % scriptLang)
-nResult, strStatusMsg = run_post_process(
-scriptLang, strFinishFileName, vDictArgs)
+dbg.dump_text("Executing language script for \'%s\'" % scriptLang)
+nResult, strStatusMsg = run_post_process(
+scriptLang, strFinishFileName, vDictArgs)
 if nResult < 0:
 break
 
Index: lldb/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -5,8 +5,6 @@
 
 Overview:   Python script(s) to post process SWIG Python C++ Script
 Bridge wrapper code on the Windows/LINUX/OSX platform.
-The Python scripts are equivalent to the shell script (.sh)
-files.
 For the Python script interpreter (external to liblldb) to
 be able to import and use the lldb module, there must be
 two files, lldb.py and _lldb.so, that it can find. lldb.py
@@ -599,7 +597,8 @@
 
 #++---
 # Details:  Determine where to put the files. Retrieve the directory path for
-#   Python's dist_packages/ site_package folder on a Windows platform.
+#   Python's dist_packages / site_package folder when build for traditional
+#   unix layout.
 # Args: vDictArgs   - (R) Program input parameters.
 # Returns:  Bool - True = function success, False = failure.
 #   Str - Python Framework directory path.
@@ -608,13 +607,14 @@
 #--
 
 
-def get_framework_python_dir_windows(vDictArgs):
+def get_framework_python_dir_traditional(vDictArgs):
 dbg = utilsDebug.CDebugFnVerbose(
-"Python script get_framework_python_dir_windows()")
+"Python script get_framework_python_dir_traditional()")
 bOk = True
 strWkDir = ""
 strErrMsg = ""
 
+dbg.dump_text("Built by LLVM")
 # We are being built by LLVM, so use the PYTHON_INSTALL_DIR argument,
 # and append the python version directory to the end of it.  Depending
 # on the system other stuff may need to be put here as well.
@@ -640,7 +640,7 @@
 
 #++---
 # Details:  Retrieve the directory path for Python's dist_packages/
-#   site_package folder on a UNIX style platform.
+#   site_package folder for macos framework.
 # Args: vDictArgs   - (R) Program input parameters.
 # Returns:  Bool - True = function success, False = failure.
 #   Str - Python Framework directory path.
@@ -649,32 +649,27 @@
 #--
 
 
-def get_framework_python_dir_other_platforms(vDictArgs):
+def get_framework_python_dir_macos_framework(vDictArgs):
 dbg = utilsDebug.CDebugFnVerbose(
-"Python script get_framework_python_dir_other_platform()")
+"Python script get_framework_python_dir_macos_framework()")
 bOk = True
 strWkDir = ""
 strErrMsg = ""
 bDbg = "-d" in vDictArgs
 
-bMakeFileCalled = "-m" in vDictArgs
-if bMakeFileCalled:
-dbg.dump_text("Built by LLVM")
-return get_framework_python_dir_windows(vDictArgs)
+dbg.dump_text("Built by XCode")
+# 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 = os.path.join(strWkDir, "LLDB.framework")
+if os.path.exists(strWkDir):
+if bDbg:
+print((

[Lldb-commits] [PATCH] D68442: [lldb] Remove unused variables.

2019-10-03 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.

Fixes the comment in https://reviews.llvm.org/D67993

[lldb] Unifying lldb python path

There are 3 places where python site-package path is calculated
independently:

1. finishSwigPythonLLDB.py where files are written to site-packages.

2. lldb/scripts/CMakeLists.txt where site-packages are installed.

3. ScriptInterpreterPython.cpp where site-packages are added to

PYTHONPATH.

This change creates the path once and use it everywhere. So that they
will not go out of sync.

Also it provides a chance for cross compile users to specify the right
path for site-packages.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68442

Files:
  lldb/CMakeLists.txt
  lldb/scripts/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py
  lldb/scripts/finishSwigWrapperClasses.py
  lldb/scripts/get_relative_lib_dir.py
  lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h

Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
@@ -48,8 +48,7 @@
 
 protected:
   static void ComputePythonDirForApple(llvm::SmallVectorImpl &path);
-  static void ComputePythonDirForPosix(llvm::SmallVectorImpl &path);
-  static void ComputePythonDirForWindows(llvm::SmallVectorImpl &path);
+  static void ComputePythonDir(llvm::SmallVectorImpl &path);
 };
 } // namespace lldb_private
 
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -304,39 +304,20 @@
   auto rend = llvm::sys::path::rend(path_ref);
   auto framework = std::find(rbegin, rend, "LLDB.framework");
   if (framework == rend) {
-ComputePythonDirForPosix(path);
+ComputePythonDir(path);
 return;
   }
   path.resize(framework - rend);
   llvm::sys::path::append(path, style, "LLDB.framework", "Resources", "Python");
 }
 
-void ScriptInterpreterPython::ComputePythonDirForPosix(
+void ScriptInterpreterPython::ComputePythonDir(
 llvm::SmallVectorImpl &path) {
-  auto style = llvm::sys::path::Style::posix;
-#if defined(LLDB_PYTHON_RELATIVE_LIBDIR)
   // Build the path by backing out of the lib dir, then building with whatever
   // the real python interpreter uses.  (e.g. lib for most, lib64 on RHEL
-  // x86_64).
-  llvm::sys::path::remove_filename(path, style);
-  llvm::sys::path::append(path, style, LLDB_PYTHON_RELATIVE_LIBDIR);
-#else
-  llvm::sys::path::append(path, style,
-  "python" + llvm::Twine(PY_MAJOR_VERSION) + "." +
-  llvm::Twine(PY_MINOR_VERSION),
-  "site-packages");
-#endif
-}
-
-void ScriptInterpreterPython::ComputePythonDirForWindows(
-llvm::SmallVectorImpl &path) {
-  auto style = llvm::sys::path::Style::windows;
-  llvm::sys::path::remove_filename(path, style);
-  llvm::sys::path::append(path, style, "lib", "site-packages");
-
-  // This will be injected directly through FileSpec.GetDirectory().SetString(),
-  // so we need to normalize manually.
-  std::replace(path.begin(), path.end(), '\\', '/');
+  // x86_64, or bin on Windows).
+  llvm::sys::path::remove_filename(path);
+  llvm::sys::path::append(path, LLDB_PYTHON_RELATIVE_LIBDIR);
 }
 
 FileSpec ScriptInterpreterPython::GetPythonDir() {
@@ -349,11 +330,10 @@
 
 #if defined(__APPLE__)
 ComputePythonDirForApple(path);
-#elif defined(_WIN32)
-ComputePythonDirForWindows(path);
 #else
-ComputePythonDirForPosix(path);
+ComputePythonDir(path);
 #endif
+llvm::sys::path::native(path);
 spec.GetDirectory().SetString(path);
 return spec;
   }();
Index: lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
===
--- lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
+++ lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
@@ -1,15 +1,7 @@
-if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
-  # Call a python script to gather the arch-specific libdir for
-  # modules like the lldb module.
-  execute_process(
-COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../scripts/get_relative_lib_dir.py
-RESULT_VARIABLE get_libdir_status
-OUTPUT_VARIABLE relative_libdir
-)
-  if (get_libdir_status EQUAL 0)
-add_definitions(-DLLDB_PYTHON_RELATIVE_LIBDIR="${relative_libdir}")
-  endif()
+if(NOT LLDB_PYTHON_RELATIVE_PATH)
+  message(FATAL_ERROR "

[Lldb-commits] [PATCH] D68442: [lldb] Unifying lldb python path

2019-10-03 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 223135.
hhb added a comment.

Fix description..


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68442/new/

https://reviews.llvm.org/D68442

Files:
  lldb/CMakeLists.txt
  lldb/scripts/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py
  lldb/scripts/finishSwigWrapperClasses.py
  lldb/scripts/get_relative_lib_dir.py
  lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h

Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
@@ -48,8 +48,7 @@
 
 protected:
   static void ComputePythonDirForApple(llvm::SmallVectorImpl &path);
-  static void ComputePythonDirForPosix(llvm::SmallVectorImpl &path);
-  static void ComputePythonDirForWindows(llvm::SmallVectorImpl &path);
+  static void ComputePythonDir(llvm::SmallVectorImpl &path);
 };
 } // namespace lldb_private
 
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -305,39 +305,20 @@
   auto rend = llvm::sys::path::rend(path_ref);
   auto framework = std::find(rbegin, rend, "LLDB.framework");
   if (framework == rend) {
-ComputePythonDirForPosix(path);
+ComputePythonDir(path);
 return;
   }
   path.resize(framework - rend);
   llvm::sys::path::append(path, style, "LLDB.framework", "Resources", "Python");
 }
 
-void ScriptInterpreterPython::ComputePythonDirForPosix(
+void ScriptInterpreterPython::ComputePythonDir(
 llvm::SmallVectorImpl &path) {
-  auto style = llvm::sys::path::Style::posix;
-#if defined(LLDB_PYTHON_RELATIVE_LIBDIR)
   // Build the path by backing out of the lib dir, then building with whatever
   // the real python interpreter uses.  (e.g. lib for most, lib64 on RHEL
-  // x86_64).
-  llvm::sys::path::remove_filename(path, style);
-  llvm::sys::path::append(path, style, LLDB_PYTHON_RELATIVE_LIBDIR);
-#else
-  llvm::sys::path::append(path, style,
-  "python" + llvm::Twine(PY_MAJOR_VERSION) + "." +
-  llvm::Twine(PY_MINOR_VERSION),
-  "site-packages");
-#endif
-}
-
-void ScriptInterpreterPython::ComputePythonDirForWindows(
-llvm::SmallVectorImpl &path) {
-  auto style = llvm::sys::path::Style::windows;
-  llvm::sys::path::remove_filename(path, style);
-  llvm::sys::path::append(path, style, "lib", "site-packages");
-
-  // This will be injected directly through FileSpec.GetDirectory().SetString(),
-  // so we need to normalize manually.
-  std::replace(path.begin(), path.end(), '\\', '/');
+  // x86_64, or bin on Windows).
+  llvm::sys::path::remove_filename(path);
+  llvm::sys::path::append(path, LLDB_PYTHON_RELATIVE_LIBDIR);
 }
 
 FileSpec ScriptInterpreterPython::GetPythonDir() {
@@ -350,11 +331,10 @@
 
 #if defined(__APPLE__)
 ComputePythonDirForApple(path);
-#elif defined(_WIN32)
-ComputePythonDirForWindows(path);
 #else
-ComputePythonDirForPosix(path);
+ComputePythonDir(path);
 #endif
+llvm::sys::path::native(path);
 spec.GetDirectory().SetString(path);
 return spec;
   }();
Index: lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
===
--- lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
+++ lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
@@ -1,15 +1,7 @@
-if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
-  # Call a python script to gather the arch-specific libdir for
-  # modules like the lldb module.
-  execute_process(
-COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../scripts/get_relative_lib_dir.py
-RESULT_VARIABLE get_libdir_status
-OUTPUT_VARIABLE relative_libdir
-)
-  if (get_libdir_status EQUAL 0)
-add_definitions(-DLLDB_PYTHON_RELATIVE_LIBDIR="${relative_libdir}")
-  endif()
+if(NOT LLDB_PYTHON_RELATIVE_PATH)
+  message(FATAL_ERROR "LLDB_PYTHON_RELATIVE_PATH is not set yet.")
 endif()
+add_definitions(-DLLDB_PYTHON_RELATIVE_LIBDIR="${LLDB_PYTHON_RELATIVE_PATH}")
 
 add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN
   PythonDataObjects.cpp
Index: lldb/scripts/get_relative_lib_dir.py
===
--- lldb/scripts/get_relative_lib_dir.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import distutils.sysconfig
-import os
-import platform
-import re
-import sys
-
-
-def get_python_relative_libdir():
-"""Retu

[Lldb-commits] [PATCH] D68442: [lldb] Unifying lldb python path

2019-10-04 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 223346.
hhb added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68442/new/

https://reviews.llvm.org/D68442

Files:
  lldb/CMakeLists.txt
  lldb/scripts/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py
  lldb/scripts/finishSwigWrapperClasses.py
  lldb/scripts/get_relative_lib_dir.py
  lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h

Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
@@ -48,8 +48,7 @@
 
 protected:
   static void ComputePythonDirForApple(llvm::SmallVectorImpl &path);
-  static void ComputePythonDirForPosix(llvm::SmallVectorImpl &path);
-  static void ComputePythonDirForWindows(llvm::SmallVectorImpl &path);
+  static void ComputePythonDir(llvm::SmallVectorImpl &path);
 };
 } // namespace lldb_private
 
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -305,39 +305,20 @@
   auto rend = llvm::sys::path::rend(path_ref);
   auto framework = std::find(rbegin, rend, "LLDB.framework");
   if (framework == rend) {
-ComputePythonDirForPosix(path);
+ComputePythonDir(path);
 return;
   }
   path.resize(framework - rend);
   llvm::sys::path::append(path, style, "LLDB.framework", "Resources", "Python");
 }
 
-void ScriptInterpreterPython::ComputePythonDirForPosix(
+void ScriptInterpreterPython::ComputePythonDir(
 llvm::SmallVectorImpl &path) {
-  auto style = llvm::sys::path::Style::posix;
-#if defined(LLDB_PYTHON_RELATIVE_LIBDIR)
   // Build the path by backing out of the lib dir, then building with whatever
   // the real python interpreter uses.  (e.g. lib for most, lib64 on RHEL
-  // x86_64).
-  llvm::sys::path::remove_filename(path, style);
-  llvm::sys::path::append(path, style, LLDB_PYTHON_RELATIVE_LIBDIR);
-#else
-  llvm::sys::path::append(path, style,
-  "python" + llvm::Twine(PY_MAJOR_VERSION) + "." +
-  llvm::Twine(PY_MINOR_VERSION),
-  "site-packages");
-#endif
-}
-
-void ScriptInterpreterPython::ComputePythonDirForWindows(
-llvm::SmallVectorImpl &path) {
-  auto style = llvm::sys::path::Style::windows;
-  llvm::sys::path::remove_filename(path, style);
-  llvm::sys::path::append(path, style, "lib", "site-packages");
-
-  // This will be injected directly through FileSpec.GetDirectory().SetString(),
-  // so we need to normalize manually.
-  std::replace(path.begin(), path.end(), '\\', '/');
+  // x86_64, or bin on Windows).
+  llvm::sys::path::remove_filename(path);
+  llvm::sys::path::append(path, LLDB_PYTHON_RELATIVE_LIBDIR);
 }
 
 FileSpec ScriptInterpreterPython::GetPythonDir() {
@@ -350,11 +331,10 @@
 
 #if defined(__APPLE__)
 ComputePythonDirForApple(path);
-#elif defined(_WIN32)
-ComputePythonDirForWindows(path);
 #else
-ComputePythonDirForPosix(path);
+ComputePythonDir(path);
 #endif
+llvm::sys::path::native(path);
 spec.GetDirectory().SetString(path);
 return spec;
   }();
Index: lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
===
--- lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
+++ lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
@@ -1,15 +1,7 @@
-if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
-  # Call a python script to gather the arch-specific libdir for
-  # modules like the lldb module.
-  execute_process(
-COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../scripts/get_relative_lib_dir.py
-RESULT_VARIABLE get_libdir_status
-OUTPUT_VARIABLE relative_libdir
-)
-  if (get_libdir_status EQUAL 0)
-add_definitions(-DLLDB_PYTHON_RELATIVE_LIBDIR="${relative_libdir}")
-  endif()
+if(NOT LLDB_PYTHON_RELATIVE_PATH)
+  message(FATAL_ERROR "LLDB_PYTHON_RELATIVE_PATH is not set.")
 endif()
+add_definitions(-DLLDB_PYTHON_RELATIVE_LIBDIR="${LLDB_PYTHON_RELATIVE_PATH}")
 
 add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN
   PythonDataObjects.cpp
Index: lldb/scripts/get_relative_lib_dir.py
===
--- lldb/scripts/get_relative_lib_dir.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import distutils.sysconfig
-import os
-import platform
-import re
-import sys
-
-
-def get_python_relative_libdir():
-"""Returns the appropr

[Lldb-commits] [PATCH] D68442: [lldb] Unifying lldb python path

2019-10-05 Thread Haibo Huang via Phabricator via lldb-commits
hhb marked an inline comment as done.
hhb added inline comments.



Comment at: lldb/CMakeLists.txt:42
+COMMAND ${PYTHON_EXECUTABLE}
+-c "import distutils.sysconfig, sys; 
print(distutils.sysconfig.get_python_lib(True, False, sys.argv[1]))"
+${CMAKE_INSTALL_PREFIX}

mgorny wrote:
> I still like my `(False, False, '')` version better than having to 
> recalculate path afterwards.
I don't have a strong opinion here. Let's see what labath@ think.

That been said, I did this because some distribution modified get_python_lib() 
to return differently based on prefix. One example is Debian/Ubuntu, where 
'dist-packages' will be used if prefix is '', '/usr' or '/usr/local'.

In reality, that only makes difference when CMAKE_INSTALL_PREFIX is set. But I 
guess it doesn't really matter whether we use 'dist-packages' or 
'site-packages' that time, as long as it is consistent everywhere.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68442/new/

https://reviews.llvm.org/D68442



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68442: [lldb] Unifying lldb python path

2019-10-05 Thread Haibo Huang via Phabricator via lldb-commits
hhb marked an inline comment as not done.
hhb added inline comments.



Comment at: lldb/CMakeLists.txt:42
+COMMAND ${PYTHON_EXECUTABLE}
+-c "import distutils.sysconfig, sys; 
print(distutils.sysconfig.get_python_lib(True, False, sys.argv[1]))"
+${CMAKE_INSTALL_PREFIX}

hhb wrote:
> mgorny wrote:
> > I still like my `(False, False, '')` version better than having to 
> > recalculate path afterwards.
> I don't have a strong opinion here. Let's see what labath@ think.
> 
> That been said, I did this because some distribution modified 
> get_python_lib() to return differently based on prefix. One example is 
> Debian/Ubuntu, where 'dist-packages' will be used if prefix is '', '/usr' or 
> '/usr/local'.
> 
> In reality, that only makes difference when CMAKE_INSTALL_PREFIX is set. But 
> I guess it doesn't really matter whether we use 'dist-packages' or 
> 'site-packages' that time, as long as it is consistent everywhere.
Considering DESTINT, maybe empty string is better...

By the way, what's the first parameter plat_specific? In all platforms I have, 
it doesn't make any difference...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68442/new/

https://reviews.llvm.org/D68442



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68442: [lldb] Unifying lldb python path

2019-10-07 Thread Haibo Huang via Phabricator via lldb-commits
hhb marked 3 inline comments as done and an inline comment as not done.
hhb added inline comments.



Comment at: lldb/CMakeLists.txt:42
+COMMAND ${PYTHON_EXECUTABLE}
+-c "import distutils.sysconfig, sys; 
print(distutils.sysconfig.get_python_lib(True, False, sys.argv[1]))"
+${CMAKE_INSTALL_PREFIX}

labath wrote:
> mgorny wrote:
> > hhb wrote:
> > > hhb wrote:
> > > > mgorny wrote:
> > > > > I still like my `(False, False, '')` version better than having to 
> > > > > recalculate path afterwards.
> > > > I don't have a strong opinion here. Let's see what labath@ think.
> > > > 
> > > > That been said, I did this because some distribution modified 
> > > > get_python_lib() to return differently based on prefix. One example is 
> > > > Debian/Ubuntu, where 'dist-packages' will be used if prefix is '', 
> > > > '/usr' or '/usr/local'.
> > > > 
> > > > In reality, that only makes difference when CMAKE_INSTALL_PREFIX is 
> > > > set. But I guess it doesn't really matter whether we use 
> > > > 'dist-packages' or 'site-packages' that time, as long as it is 
> > > > consistent everywhere.
> > > Considering DESTINT, maybe empty string is better...
> > > 
> > > By the way, what's the first parameter plat_specific? In all platforms I 
> > > have, it doesn't make any difference...
> > Technically, it's for arch-dependent vs arch-independent modules, i.e. 
> > should be True for .so extensions and False for .py modules.
> > 
> > Judging by the documentation, it's only used to switch between 
> > `sys.base_prefix` (i.e. `--prefix` given to build Python) and 
> > `sys.base_exec_prefix` (`--exec-prefix`). However, I'm not aware of any 
> > platform where two different prefixes are used for Python.
> > 
> > When a prefix is given as third argument, its value is ignored. So True vs 
> > False shouldn't really matter here, hence I've left it at the default 
> > (False).
> All else being equal, I would prefer the version which does not recompute the 
> relative path. However, if there is a meaningful functional difference 
> between the two versions, then we can stick to this one, if it is more 
> correct. As for whether the difference is "meaningful" and which version is 
> more "correct", you guys are probably more qualified to answer that than I 
> am...
I'll switch to the no recompute version in this patch. While they have some 
difference, I'm not aware of any platform where that matters. So I'll go with 
the easier way.

Also it is weird to build differently based on install prefix. Specially the 
prefix can be overwritten by DESTDIR afterwards..



Comment at: lldb/scripts/finishSwigWrapperClasses.py:196
+  "--useSystemSix": "o",
+  "--lldbPythonPath": "m"}
 

labath wrote:
> Given that the arg is marked as mandatory here, is there a need for the check 
> in `get_framework_python_dir`? Maybe that could be an assert ?
Other mandatory parameters do not even have an assert... Remove the check in 
`get_framework_python_dir`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68442/new/

https://reviews.llvm.org/D68442



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68442: [lldb] Unifying lldb python path

2019-10-07 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 223638.
hhb marked an inline comment as done.
hhb added a comment.

Fix comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68442/new/

https://reviews.llvm.org/D68442

Files:
  lldb/CMakeLists.txt
  lldb/scripts/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py
  lldb/scripts/finishSwigWrapperClasses.py
  lldb/scripts/get_relative_lib_dir.py
  lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h

Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
@@ -48,8 +48,7 @@
 
 protected:
   static void ComputePythonDirForApple(llvm::SmallVectorImpl &path);
-  static void ComputePythonDirForPosix(llvm::SmallVectorImpl &path);
-  static void ComputePythonDirForWindows(llvm::SmallVectorImpl &path);
+  static void ComputePythonDir(llvm::SmallVectorImpl &path);
 };
 } // namespace lldb_private
 
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -305,39 +305,20 @@
   auto rend = llvm::sys::path::rend(path_ref);
   auto framework = std::find(rbegin, rend, "LLDB.framework");
   if (framework == rend) {
-ComputePythonDirForPosix(path);
+ComputePythonDir(path);
 return;
   }
   path.resize(framework - rend);
   llvm::sys::path::append(path, style, "LLDB.framework", "Resources", "Python");
 }
 
-void ScriptInterpreterPython::ComputePythonDirForPosix(
+void ScriptInterpreterPython::ComputePythonDir(
 llvm::SmallVectorImpl &path) {
-  auto style = llvm::sys::path::Style::posix;
-#if defined(LLDB_PYTHON_RELATIVE_LIBDIR)
   // Build the path by backing out of the lib dir, then building with whatever
   // the real python interpreter uses.  (e.g. lib for most, lib64 on RHEL
-  // x86_64).
-  llvm::sys::path::remove_filename(path, style);
-  llvm::sys::path::append(path, style, LLDB_PYTHON_RELATIVE_LIBDIR);
-#else
-  llvm::sys::path::append(path, style,
-  "python" + llvm::Twine(PY_MAJOR_VERSION) + "." +
-  llvm::Twine(PY_MINOR_VERSION),
-  "site-packages");
-#endif
-}
-
-void ScriptInterpreterPython::ComputePythonDirForWindows(
-llvm::SmallVectorImpl &path) {
-  auto style = llvm::sys::path::Style::windows;
-  llvm::sys::path::remove_filename(path, style);
-  llvm::sys::path::append(path, style, "lib", "site-packages");
-
-  // This will be injected directly through FileSpec.GetDirectory().SetString(),
-  // so we need to normalize manually.
-  std::replace(path.begin(), path.end(), '\\', '/');
+  // x86_64, or bin on Windows).
+  llvm::sys::path::remove_filename(path);
+  llvm::sys::path::append(path, LLDB_PYTHON_RELATIVE_LIBDIR);
 }
 
 FileSpec ScriptInterpreterPython::GetPythonDir() {
@@ -350,11 +331,10 @@
 
 #if defined(__APPLE__)
 ComputePythonDirForApple(path);
-#elif defined(_WIN32)
-ComputePythonDirForWindows(path);
 #else
-ComputePythonDirForPosix(path);
+ComputePythonDir(path);
 #endif
+llvm::sys::path::native(path);
 spec.GetDirectory().SetString(path);
 return spec;
   }();
Index: lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
===
--- lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
+++ lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
@@ -1,15 +1,7 @@
-if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
-  # Call a python script to gather the arch-specific libdir for
-  # modules like the lldb module.
-  execute_process(
-COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../scripts/get_relative_lib_dir.py
-RESULT_VARIABLE get_libdir_status
-OUTPUT_VARIABLE relative_libdir
-)
-  if (get_libdir_status EQUAL 0)
-add_definitions(-DLLDB_PYTHON_RELATIVE_LIBDIR="${relative_libdir}")
-  endif()
+if(NOT LLDB_PYTHON_RELATIVE_PATH)
+  message(FATAL_ERROR "LLDB_PYTHON_RELATIVE_PATH is not set.")
 endif()
+add_definitions(-DLLDB_PYTHON_RELATIVE_LIBDIR="${LLDB_PYTHON_RELATIVE_PATH}")
 
 add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN
   PythonDataObjects.cpp
Index: lldb/scripts/get_relative_lib_dir.py
===
--- lldb/scripts/get_relative_lib_dir.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import distutils.sysconfig
-import os
-import platform
-import re
-import sys
-
-
-def get_python_re

[Lldb-commits] [PATCH] D68442: [lldb] Unifying lldb python path

2019-10-07 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

In D68442#1698053 , @mgorny wrote:

> Cool work. I presume you've tested it. I can test it tomorrow if you need me 
> to. However, I can do that after the commit.


I'm doing a final round of testing on linux/darwin/windows(mingw). I'll commit 
after that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68442/new/

https://reviews.llvm.org/D68442



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68442: [lldb] Unifying lldb python path

2019-10-07 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 223689.
hhb added a comment.

Converts python output path to cmake format.

This looks like a bug on windows exists before this change...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68442/new/

https://reviews.llvm.org/D68442

Files:
  lldb/CMakeLists.txt
  lldb/scripts/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py
  lldb/scripts/finishSwigWrapperClasses.py
  lldb/scripts/get_relative_lib_dir.py
  lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h

Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
@@ -48,8 +48,7 @@
 
 protected:
   static void ComputePythonDirForApple(llvm::SmallVectorImpl &path);
-  static void ComputePythonDirForPosix(llvm::SmallVectorImpl &path);
-  static void ComputePythonDirForWindows(llvm::SmallVectorImpl &path);
+  static void ComputePythonDir(llvm::SmallVectorImpl &path);
 };
 } // namespace lldb_private
 
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -305,39 +305,20 @@
   auto rend = llvm::sys::path::rend(path_ref);
   auto framework = std::find(rbegin, rend, "LLDB.framework");
   if (framework == rend) {
-ComputePythonDirForPosix(path);
+ComputePythonDir(path);
 return;
   }
   path.resize(framework - rend);
   llvm::sys::path::append(path, style, "LLDB.framework", "Resources", "Python");
 }
 
-void ScriptInterpreterPython::ComputePythonDirForPosix(
+void ScriptInterpreterPython::ComputePythonDir(
 llvm::SmallVectorImpl &path) {
-  auto style = llvm::sys::path::Style::posix;
-#if defined(LLDB_PYTHON_RELATIVE_LIBDIR)
   // Build the path by backing out of the lib dir, then building with whatever
   // the real python interpreter uses.  (e.g. lib for most, lib64 on RHEL
-  // x86_64).
-  llvm::sys::path::remove_filename(path, style);
-  llvm::sys::path::append(path, style, LLDB_PYTHON_RELATIVE_LIBDIR);
-#else
-  llvm::sys::path::append(path, style,
-  "python" + llvm::Twine(PY_MAJOR_VERSION) + "." +
-  llvm::Twine(PY_MINOR_VERSION),
-  "site-packages");
-#endif
-}
-
-void ScriptInterpreterPython::ComputePythonDirForWindows(
-llvm::SmallVectorImpl &path) {
-  auto style = llvm::sys::path::Style::windows;
-  llvm::sys::path::remove_filename(path, style);
-  llvm::sys::path::append(path, style, "lib", "site-packages");
-
-  // This will be injected directly through FileSpec.GetDirectory().SetString(),
-  // so we need to normalize manually.
-  std::replace(path.begin(), path.end(), '\\', '/');
+  // x86_64, or bin on Windows).
+  llvm::sys::path::remove_filename(path);
+  llvm::sys::path::append(path, LLDB_PYTHON_RELATIVE_LIBDIR);
 }
 
 FileSpec ScriptInterpreterPython::GetPythonDir() {
@@ -350,11 +331,10 @@
 
 #if defined(__APPLE__)
 ComputePythonDirForApple(path);
-#elif defined(_WIN32)
-ComputePythonDirForWindows(path);
 #else
-ComputePythonDirForPosix(path);
+ComputePythonDir(path);
 #endif
+llvm::sys::path::native(path);
 spec.GetDirectory().SetString(path);
 return spec;
   }();
Index: lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
===
--- lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
+++ lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
@@ -1,15 +1,7 @@
-if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
-  # Call a python script to gather the arch-specific libdir for
-  # modules like the lldb module.
-  execute_process(
-COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../scripts/get_relative_lib_dir.py
-RESULT_VARIABLE get_libdir_status
-OUTPUT_VARIABLE relative_libdir
-)
-  if (get_libdir_status EQUAL 0)
-add_definitions(-DLLDB_PYTHON_RELATIVE_LIBDIR="${relative_libdir}")
-  endif()
+if(NOT LLDB_PYTHON_RELATIVE_PATH)
+  message(FATAL_ERROR "LLDB_PYTHON_RELATIVE_PATH is not set.")
 endif()
+add_definitions(-DLLDB_PYTHON_RELATIVE_LIBDIR="${LLDB_PYTHON_RELATIVE_PATH}")
 
 add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN
   PythonDataObjects.cpp
Index: lldb/scripts/get_relative_lib_dir.py
===
--- lldb/scripts/get_relative_lib_dir.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import distutils.sysconfig
-import os
-impo

[Lldb-commits] [PATCH] D68442: [lldb] Unifying lldb python path

2019-10-07 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 223701.
hhb added a comment.

Reverts the change related to python dir for windows.

FileSpec should always contain normalized path. I.e. using '/' even in windows.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68442/new/

https://reviews.llvm.org/D68442

Files:
  lldb/CMakeLists.txt
  lldb/scripts/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py
  lldb/scripts/finishSwigWrapperClasses.py
  lldb/scripts/get_relative_lib_dir.py
  lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
  lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h

Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.h
@@ -48,8 +48,7 @@
 
 protected:
   static void ComputePythonDirForApple(llvm::SmallVectorImpl &path);
-  static void ComputePythonDirForPosix(llvm::SmallVectorImpl &path);
-  static void ComputePythonDirForWindows(llvm::SmallVectorImpl &path);
+  static void ComputePythonDir(llvm::SmallVectorImpl &path);
 };
 } // namespace lldb_private
 
Index: lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
===
--- lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
+++ lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
@@ -305,39 +305,26 @@
   auto rend = llvm::sys::path::rend(path_ref);
   auto framework = std::find(rbegin, rend, "LLDB.framework");
   if (framework == rend) {
-ComputePythonDirForPosix(path);
+ComputePythonDir(path);
 return;
   }
   path.resize(framework - rend);
   llvm::sys::path::append(path, style, "LLDB.framework", "Resources", "Python");
 }
 
-void ScriptInterpreterPython::ComputePythonDirForPosix(
+void ScriptInterpreterPython::ComputePythonDir(
 llvm::SmallVectorImpl &path) {
-  auto style = llvm::sys::path::Style::posix;
-#if defined(LLDB_PYTHON_RELATIVE_LIBDIR)
   // Build the path by backing out of the lib dir, then building with whatever
   // the real python interpreter uses.  (e.g. lib for most, lib64 on RHEL
-  // x86_64).
-  llvm::sys::path::remove_filename(path, style);
-  llvm::sys::path::append(path, style, LLDB_PYTHON_RELATIVE_LIBDIR);
-#else
-  llvm::sys::path::append(path, style,
-  "python" + llvm::Twine(PY_MAJOR_VERSION) + "." +
-  llvm::Twine(PY_MINOR_VERSION),
-  "site-packages");
-#endif
-}
-
-void ScriptInterpreterPython::ComputePythonDirForWindows(
-llvm::SmallVectorImpl &path) {
-  auto style = llvm::sys::path::Style::windows;
-  llvm::sys::path::remove_filename(path, style);
-  llvm::sys::path::append(path, style, "lib", "site-packages");
+  // x86_64, or bin on Windows).
+  llvm::sys::path::remove_filename(path);
+  llvm::sys::path::append(path, LLDB_PYTHON_RELATIVE_LIBDIR);
 
+#if defined(_WIN32)
   // This will be injected directly through FileSpec.GetDirectory().SetString(),
   // so we need to normalize manually.
   std::replace(path.begin(), path.end(), '\\', '/');
+#endif
 }
 
 FileSpec ScriptInterpreterPython::GetPythonDir() {
@@ -350,10 +337,8 @@
 
 #if defined(__APPLE__)
 ComputePythonDirForApple(path);
-#elif defined(_WIN32)
-ComputePythonDirForWindows(path);
 #else
-ComputePythonDirForPosix(path);
+ComputePythonDir(path);
 #endif
 spec.GetDirectory().SetString(path);
 return spec;
Index: lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
===
--- lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
+++ lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt
@@ -1,15 +1,7 @@
-if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
-  # Call a python script to gather the arch-specific libdir for
-  # modules like the lldb module.
-  execute_process(
-COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../../../scripts/get_relative_lib_dir.py
-RESULT_VARIABLE get_libdir_status
-OUTPUT_VARIABLE relative_libdir
-)
-  if (get_libdir_status EQUAL 0)
-add_definitions(-DLLDB_PYTHON_RELATIVE_LIBDIR="${relative_libdir}")
-  endif()
+if(NOT LLDB_PYTHON_RELATIVE_PATH)
+  message(FATAL_ERROR "LLDB_PYTHON_RELATIVE_PATH is not set.")
 endif()
+add_definitions(-DLLDB_PYTHON_RELATIVE_LIBDIR="${LLDB_PYTHON_RELATIVE_PATH}")
 
 add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN
   PythonDataObjects.cpp
Index: lldb/scripts/get_relative_lib_dir.py
===
--- lldb/scripts/get_relative_lib_dir.py
+++ /dev/null
@@ -1,44 +0,0 @@
-import distutils.sysconfig
-impo

[Lldb-commits] [PATCH] D68442: [lldb] Unifying lldb python path

2019-10-07 Thread Haibo Huang via Phabricator via lldb-commits
hhb closed this revision.
hhb added a comment.

This is merged as 61f471a 
 and 
0016b45 . 
Closing...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68442/new/

https://reviews.llvm.org/D68442



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68728: [lldb] Put site-packages into a sub dir of CMAKE_CFG_INTDIR

2019-10-09 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 224159.
hhb added a comment.

Fix format


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68728/new/

https://reviews.llvm.org/D68728

Files:
  lldb/CMakeLists.txt


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -202,7 +202,7 @@
 if(LLDB_BUILD_FRAMEWORK)
   set(lldb_python_build_path 
"${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
 else()
-  set(lldb_python_build_path 
"${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
+  set(lldb_python_build_path 
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
 endif()
 
 # Add a Post-Build Event to copy over Python files and create the symlink


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -202,7 +202,7 @@
 if(LLDB_BUILD_FRAMEWORK)
   set(lldb_python_build_path "${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
 else()
-  set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
+  set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
 endif()
 
 # Add a Post-Build Event to copy over Python files and create the symlink
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68728: [lldb] Put site-packages into a sub dir of CMAKE_CFG_INTDIR

2019-10-09 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
hhb added a reviewer: tatyana-krasnukha.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.
hhb updated this revision to Diff 224159.
hhb added a comment.

Fix format


Fixes issue like D68719 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68728

Files:
  lldb/CMakeLists.txt


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -202,7 +202,7 @@
 if(LLDB_BUILD_FRAMEWORK)
   set(lldb_python_build_path 
"${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
 else()
-  set(lldb_python_build_path 
"${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
+  set(lldb_python_build_path 
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
 endif()
 
 # Add a Post-Build Event to copy over Python files and create the symlink


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -202,7 +202,7 @@
 if(LLDB_BUILD_FRAMEWORK)
   set(lldb_python_build_path "${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
 else()
-  set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
+  set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
 endif()
 
 # Add a Post-Build Event to copy over Python files and create the symlink
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68719: Fix build with Visual Studio

2019-10-09 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

I think this is caused by D68442 . Can you 
check whether D68728  fixes it?


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68719/new/

https://reviews.llvm.org/D68719



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68728: [lldb] Put site-packages into a sub dir of CMAKE_CFG_INTDIR

2019-10-09 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 224166.
hhb added a comment.

Simplify the path


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68728/new/

https://reviews.llvm.org/D68728

Files:
  lldb/CMakeLists.txt


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -202,8 +202,9 @@
 if(LLDB_BUILD_FRAMEWORK)
   set(lldb_python_build_path 
"${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
 else()
-  set(lldb_python_build_path 
"${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
+  set(lldb_python_build_path 
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
 endif()
+get_filename_component(lldb_python_build_path ${lldb_python_build_path} 
ABSOLUTE)
 
 # Add a Post-Build Event to copy over Python files and create the symlink
 # to liblldb.so for the Python API(hardlink on Windows).


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -202,8 +202,9 @@
 if(LLDB_BUILD_FRAMEWORK)
   set(lldb_python_build_path "${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
 else()
-  set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
+  set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
 endif()
+get_filename_component(lldb_python_build_path ${lldb_python_build_path} ABSOLUTE)
 
 # Add a Post-Build Event to copy over Python files and create the symlink
 # to liblldb.so for the Python API(hardlink on Windows).
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68728: [lldb] Put site-packages into a sub dir of CMAKE_CFG_INTDIR

2019-10-09 Thread Haibo Huang via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1a509417714d: [lldb] Put site-packages into a sub dir of 
CMAKE_CFG_INTDIR (authored by hhb).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68728/new/

https://reviews.llvm.org/D68728

Files:
  lldb/CMakeLists.txt


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -202,8 +202,9 @@
 if(LLDB_BUILD_FRAMEWORK)
   set(lldb_python_build_path 
"${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
 else()
-  set(lldb_python_build_path 
"${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
+  set(lldb_python_build_path 
"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
 endif()
+get_filename_component(lldb_python_build_path ${lldb_python_build_path} 
ABSOLUTE)
 
 # Add a Post-Build Event to copy over Python files and create the symlink
 # to liblldb.so for the Python API(hardlink on Windows).


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -202,8 +202,9 @@
 if(LLDB_BUILD_FRAMEWORK)
   set(lldb_python_build_path "${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
 else()
-  set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
+  set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
 endif()
+get_filename_component(lldb_python_build_path ${lldb_python_build_path} ABSOLUTE)
 
 # Add a Post-Build Event to copy over Python files and create the symlink
 # to liblldb.so for the Python API(hardlink on Windows).
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68719: Fix issue when building with Visual Studio

2019-10-10 Thread Haibo Huang via Phabricator via lldb-commits
hhb added inline comments.



Comment at: finishSwigPythonLLDB.py:380
 
-strSrc = os.path.normcase(os.path.join(strPrefix, vstrSrcFile))
-strRelSrc = os.path.relpath(strSrc, os.path.dirname(strTarget))

tatyana-krasnukha wrote:
> This command produces an incorrect path for Visual Studio since it 
> concatenates the root build directory with 'bin/liblldb.dll' bypassing 
> configuration name.
Hmm understood. The origin change is reverted in rG958091c209d0. So I don't 
think this is relevant any more. I'll redo the change. Can you help test that 
time? I don't have a visual studio...


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68719/new/

https://reviews.llvm.org/D68719



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68719: Fix issue when building with Visual Studio

2019-10-10 Thread Haibo Huang via Phabricator via lldb-commits
hhb added inline comments.



Comment at: finishSwigPythonLLDB.py:380
 
-strSrc = os.path.normcase(os.path.join(strPrefix, vstrSrcFile))
-strRelSrc = os.path.relpath(strSrc, os.path.dirname(strTarget))

hhb wrote:
> tatyana-krasnukha wrote:
> > This command produces an incorrect path for Visual Studio since it 
> > concatenates the root build directory with 'bin/liblldb.dll' bypassing 
> > configuration name.
> Hmm understood. The origin change is reverted in rG958091c209d0. So I don't 
> think this is relevant any more. I'll redo the change. Can you help test that 
> time? I don't have a visual studio...
Sorry rGc0da1282fc036908cc721ee74f574fbb99d5e506


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68719/new/

https://reviews.llvm.org/D68719



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68842: Clean up format in cmake file

2019-10-10 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.

Makes the indent consistent to other part of the file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68842

Files:
  lldb/CMakeLists.txt

Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -190,73 +190,73 @@
 endif()
 
 if (NOT LLDB_DISABLE_PYTHON)
-if(NOT LLDB_BUILD_FRAMEWORK)
-  set(use_python_wrapper_from_src_dir -m)
-endif()
-if(LLDB_USE_SYSTEM_SIX)
-  set(use_six_py_from_system --useSystemSix)
-endif()
-get_target_property(lldb_scripts_dir swig_wrapper BINARY_DIR)
-get_target_property(liblldb_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
+  if(NOT LLDB_BUILD_FRAMEWORK)
+set(use_python_wrapper_from_src_dir -m)
+  endif()
+  if(LLDB_USE_SYSTEM_SIX)
+set(use_six_py_from_system --useSystemSix)
+  endif()
+  get_target_property(lldb_scripts_dir swig_wrapper BINARY_DIR)
+  get_target_property(liblldb_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
 
-if(LLDB_BUILD_FRAMEWORK)
-  set(lldb_python_build_path "${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
-else()
-  set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
-endif()
-get_filename_component(lldb_python_build_path ${lldb_python_build_path} ABSOLUTE)
-
-# Add a Post-Build Event to copy over Python files and create the symlink
-# to liblldb.so for the Python API(hardlink on Windows).
-add_custom_target(finish_swig ALL
-COMMAND
-   ${PYTHON_EXECUTABLE} ${LLDB_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
-   --srcRoot=${LLDB_SOURCE_DIR}
-   --targetDir=${liblldb_build_dir}
-   --cfgBldDir=${lldb_scripts_dir}
-   --prefix=${CMAKE_BINARY_DIR}
-   --cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}
-   --lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}
-   --lldbPythonPath=${lldb_python_build_path}
-   ${use_python_wrapper_from_src_dir}
-   ${use_six_py_from_system}
-VERBATIM
-DEPENDS ${LLDB_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
-DEPENDS ${lldb_scripts_dir}/lldb.py
-COMMENT "Python script sym-linking LLDB Python API")
-
-add_dependencies(finish_swig swig_wrapper liblldb lldb-argdumper)
-set_target_properties(finish_swig swig_wrapper PROPERTIES FOLDER "lldb misc")
-
-# Ensure we do the python post-build step when building lldb.
-add_dependencies(lldb finish_swig)
-
-if(NOT LLDB_BUILD_FRAMEWORK)
-  # Install the LLDB python module
-  add_custom_target(lldb-python-scripts)
-  add_dependencies(lldb-python-scripts finish_swig)
-  install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/
-  DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
-  COMPONENT lldb-python-scripts)
-  if (NOT LLVM_ENABLE_IDE)
-add_llvm_install_targets(install-lldb-python-scripts
- COMPONENT lldb-python-scripts
- DEPENDS lldb-python-scripts)
-  endif()
+  if(LLDB_BUILD_FRAMEWORK)
+set(lldb_python_build_path "${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
+  else()
+set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
+  endif()
+  get_filename_component(lldb_python_build_path ${lldb_python_build_path} ABSOLUTE)
+
+  # Add a Post-Build Event to copy over Python files and create the symlink
+  # to liblldb.so for the Python API(hardlink on Windows).
+  add_custom_target(finish_swig ALL
+COMMAND
+  ${PYTHON_EXECUTABLE} ${LLDB_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
+--srcRoot=${LLDB_SOURCE_DIR}
+--targetDir=${liblldb_build_dir}
+--cfgBldDir=${lldb_scripts_dir}
+--prefix=${CMAKE_BINARY_DIR}
+--cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}
+--lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}
+--lldbPythonPath=${lldb_python_build_path}
+${use_python_wrapper_from_src_dir}
+${use_six_py_from_system}
+VERBATIM
+DEPENDS ${LLDB_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
+DEPENDS ${lldb_scripts_dir}/lldb.py
+COMMENT "Python script sym-linking LLDB Python API")
+
+  add_dependencies(finish_swig swig_wrapper liblldb lldb-argdumper)
+  set_target_properties(finish_swig swig_wrapper PROPERTIES FOLDER "lldb misc")
+
+  # Ensure we do the python post-build step when building lldb.
+  add_dependencies(lldb finish_swig)
+
+  if(NOT LLDB_BUILD_FRAMEWORK)
+# Install the LLDB python module
+add_custom_target(lldb-python-scripts)
+add_dependencies(lldb-python-scripts finish_swig)
+install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/
+DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
+ 

[Lldb-commits] [PATCH] D68842: Clean up format in cmake file

2019-10-10 Thread Haibo Huang via Phabricator via lldb-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7b9900dff3c0: Clean up format in cmake file (authored by 
hhb).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68842/new/

https://reviews.llvm.org/D68842

Files:
  lldb/CMakeLists.txt

Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -190,73 +190,73 @@
 endif()
 
 if (NOT LLDB_DISABLE_PYTHON)
-if(NOT LLDB_BUILD_FRAMEWORK)
-  set(use_python_wrapper_from_src_dir -m)
-endif()
-if(LLDB_USE_SYSTEM_SIX)
-  set(use_six_py_from_system --useSystemSix)
-endif()
-get_target_property(lldb_scripts_dir swig_wrapper BINARY_DIR)
-get_target_property(liblldb_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
+  if(NOT LLDB_BUILD_FRAMEWORK)
+set(use_python_wrapper_from_src_dir -m)
+  endif()
+  if(LLDB_USE_SYSTEM_SIX)
+set(use_six_py_from_system --useSystemSix)
+  endif()
+  get_target_property(lldb_scripts_dir swig_wrapper BINARY_DIR)
+  get_target_property(liblldb_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
 
-if(LLDB_BUILD_FRAMEWORK)
-  set(lldb_python_build_path "${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
-else()
-  set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
-endif()
-get_filename_component(lldb_python_build_path ${lldb_python_build_path} ABSOLUTE)
-
-# Add a Post-Build Event to copy over Python files and create the symlink
-# to liblldb.so for the Python API(hardlink on Windows).
-add_custom_target(finish_swig ALL
-COMMAND
-   ${PYTHON_EXECUTABLE} ${LLDB_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
-   --srcRoot=${LLDB_SOURCE_DIR}
-   --targetDir=${liblldb_build_dir}
-   --cfgBldDir=${lldb_scripts_dir}
-   --prefix=${CMAKE_BINARY_DIR}
-   --cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}
-   --lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}
-   --lldbPythonPath=${lldb_python_build_path}
-   ${use_python_wrapper_from_src_dir}
-   ${use_six_py_from_system}
-VERBATIM
-DEPENDS ${LLDB_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
-DEPENDS ${lldb_scripts_dir}/lldb.py
-COMMENT "Python script sym-linking LLDB Python API")
-
-add_dependencies(finish_swig swig_wrapper liblldb lldb-argdumper)
-set_target_properties(finish_swig swig_wrapper PROPERTIES FOLDER "lldb misc")
-
-# Ensure we do the python post-build step when building lldb.
-add_dependencies(lldb finish_swig)
-
-if(NOT LLDB_BUILD_FRAMEWORK)
-  # Install the LLDB python module
-  add_custom_target(lldb-python-scripts)
-  add_dependencies(lldb-python-scripts finish_swig)
-  install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/
-  DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
-  COMPONENT lldb-python-scripts)
-  if (NOT LLVM_ENABLE_IDE)
-add_llvm_install_targets(install-lldb-python-scripts
- COMPONENT lldb-python-scripts
- DEPENDS lldb-python-scripts)
-  endif()
+  if(LLDB_BUILD_FRAMEWORK)
+set(lldb_python_build_path "${liblldb_build_dir}/LLDB.framework/Resources/Python/lldb")
+  else()
+set(lldb_python_build_path "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
+  endif()
+  get_filename_component(lldb_python_build_path ${lldb_python_build_path} ABSOLUTE)
+
+  # Add a Post-Build Event to copy over Python files and create the symlink
+  # to liblldb.so for the Python API(hardlink on Windows).
+  add_custom_target(finish_swig ALL
+COMMAND
+  ${PYTHON_EXECUTABLE} ${LLDB_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
+--srcRoot=${LLDB_SOURCE_DIR}
+--targetDir=${liblldb_build_dir}
+--cfgBldDir=${lldb_scripts_dir}
+--prefix=${CMAKE_BINARY_DIR}
+--cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}
+--lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}
+--lldbPythonPath=${lldb_python_build_path}
+${use_python_wrapper_from_src_dir}
+${use_six_py_from_system}
+VERBATIM
+DEPENDS ${LLDB_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
+DEPENDS ${lldb_scripts_dir}/lldb.py
+COMMENT "Python script sym-linking LLDB Python API")
+
+  add_dependencies(finish_swig swig_wrapper liblldb lldb-argdumper)
+  set_target_properties(finish_swig swig_wrapper PROPERTIES FOLDER "lldb misc")
+
+  # Ensure we do the python post-build step when building lldb.
+  add_dependencies(lldb finish_swig)
+
+  if(NOT LLDB_BUILD_FRAMEWORK)
+# Install the LLDB python module
+add_custom_target(lldb-python-scripts)
+add_dependencies(lldb-python-script

[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-10 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 224545.
hhb added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68858/new/

https://reviews.llvm.org/D68858

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py

Index: lldb/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -245,284 +245,6 @@
 
 return (bOk, strMsg)
 
-#++---
-# Details:  Make the symbolic link on a Windows platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_windows(vstrSrcPath, vstrTargetPath):
-print(("Making symlink from %s to %s" % (vstrSrcPath, vstrTargetPath)))
-dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_windows()")
-bOk = True
-strErrMsg = ""
-# If the src file doesn't exist, this is an error and we should throw.
-src_stat = os.stat(vstrSrcPath)
-
-try:
-target_stat = os.stat(vstrTargetPath)
-# If the target file exists but refers to a different file, delete it so that we can
-# re-create the link.  This can happen if you run this script once (creating a link)
-# and then delete the source file (so that a brand new file gets created the next time
-# you compile and link), and then re-run this script, so that both the target hardlink
-# and the source file exist, but the target refers to an old copy of
-# the source.
-if (target_stat.st_ino == src_stat.st_ino) and (
-target_stat.st_dev == src_stat.st_dev):
-return (bOk, strErrMsg)
-
-os.remove(vstrTargetPath)
-except:
-# If the target file don't exist, ignore this exception, we will link
-# it shortly.
-pass
-
-try:
-csl = ctypes.windll.kernel32.CreateHardLinkW
-csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
-csl.restype = ctypes.c_ubyte
-if csl(vstrTargetPath, vstrSrcPath, 0) == 0:
-raise ctypes.WinError()
-except Exception as e:
-if e.errno != 17:
-bOk = False
-strErrMsg = "WinError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (
-vstrSrcPath, vstrTargetPath)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link on a UNIX style platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_other_platforms(vstrSrcPath, vstrTargetPath):
-dbg = utilsDebug.CDebugFnVerbose(
-"Python script make_symlink_other_platforms()")
-bOk = True
-strErrMsg = ""
-
-try:
-os.symlink(vstrSrcPath, vstrTargetPath)
-except OSError as e:
-bOk = False
-strErrMsg = "OSError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath, vstrTargetPath)
-except:
-bOk = False
-strErrMsg = strErrMsgUnexpected % sys.exec_info()[0]
-
-return (bOk, strErrMsg)
-
-
-def make_symlink_native(vDictArgs, strSrc, strTarget):
-eOSType = utilsOsType.determine_os_type()
-bDbg = "-d" in vDictArgs
-bOk = True
-strErrMsg = ""
-
-target_filename = os.path.basename(strTarget)
-if eOSType == utilsOsType.EnumOsType.Unknown:
-bOk = False
-strErrMsg = strErrMsgOsTypeUnknown
-elif eOSType == utilsOsType.EnumOsType.Windows:
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_windows(strSrc,
-  strTarget)
-else:
-if os.path.islink(strTarget):
-if bDbg:
-print((strMsgSymlinkExists % target_filename))
-return (bOk, strErrMsg)
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_other_platforms(strSrc,
-  strTarget)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link.
-# Args: vDictArgs   - (R) Pro

[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-10 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 224544.
hhb added a comment.

Fix format


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68858/new/

https://reviews.llvm.org/D68858

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py

Index: lldb/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -245,284 +245,6 @@
 
 return (bOk, strMsg)
 
-#++---
-# Details:  Make the symbolic link on a Windows platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_windows(vstrSrcPath, vstrTargetPath):
-print(("Making symlink from %s to %s" % (vstrSrcPath, vstrTargetPath)))
-dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_windows()")
-bOk = True
-strErrMsg = ""
-# If the src file doesn't exist, this is an error and we should throw.
-src_stat = os.stat(vstrSrcPath)
-
-try:
-target_stat = os.stat(vstrTargetPath)
-# If the target file exists but refers to a different file, delete it so that we can
-# re-create the link.  This can happen if you run this script once (creating a link)
-# and then delete the source file (so that a brand new file gets created the next time
-# you compile and link), and then re-run this script, so that both the target hardlink
-# and the source file exist, but the target refers to an old copy of
-# the source.
-if (target_stat.st_ino == src_stat.st_ino) and (
-target_stat.st_dev == src_stat.st_dev):
-return (bOk, strErrMsg)
-
-os.remove(vstrTargetPath)
-except:
-# If the target file don't exist, ignore this exception, we will link
-# it shortly.
-pass
-
-try:
-csl = ctypes.windll.kernel32.CreateHardLinkW
-csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
-csl.restype = ctypes.c_ubyte
-if csl(vstrTargetPath, vstrSrcPath, 0) == 0:
-raise ctypes.WinError()
-except Exception as e:
-if e.errno != 17:
-bOk = False
-strErrMsg = "WinError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (
-vstrSrcPath, vstrTargetPath)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link on a UNIX style platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_other_platforms(vstrSrcPath, vstrTargetPath):
-dbg = utilsDebug.CDebugFnVerbose(
-"Python script make_symlink_other_platforms()")
-bOk = True
-strErrMsg = ""
-
-try:
-os.symlink(vstrSrcPath, vstrTargetPath)
-except OSError as e:
-bOk = False
-strErrMsg = "OSError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath, vstrTargetPath)
-except:
-bOk = False
-strErrMsg = strErrMsgUnexpected % sys.exec_info()[0]
-
-return (bOk, strErrMsg)
-
-
-def make_symlink_native(vDictArgs, strSrc, strTarget):
-eOSType = utilsOsType.determine_os_type()
-bDbg = "-d" in vDictArgs
-bOk = True
-strErrMsg = ""
-
-target_filename = os.path.basename(strTarget)
-if eOSType == utilsOsType.EnumOsType.Unknown:
-bOk = False
-strErrMsg = strErrMsgOsTypeUnknown
-elif eOSType == utilsOsType.EnumOsType.Windows:
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_windows(strSrc,
-  strTarget)
-else:
-if os.path.islink(strTarget):
-if bDbg:
-print((strMsgSymlinkExists % target_filename))
-return (bOk, strErrMsg)
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_other_platforms(strSrc,
-  strTarget)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link.
-# Args: vDictArgs   - (R)

[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-10 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
hhb added a project: LLDB.
hhb updated this revision to Diff 224544.
hhb added a comment.
hhb updated this revision to Diff 224545.

Fix format


hhb added a comment.

Rebase


This is another attempt of D67993 .

This change removed hard coded relative paths. This way we can generate correct 
result when get_python_lib() returns a different path, or 
LLDB_PYTHON_RELATIVE_PATH is specified directly.

By moving things out of python, we are also able to correctly process more 
cross compile situations. E.g. .pyd vs .so for Windows.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68858

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py

Index: lldb/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -245,284 +245,6 @@
 
 return (bOk, strMsg)
 
-#++---
-# Details:  Make the symbolic link on a Windows platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_windows(vstrSrcPath, vstrTargetPath):
-print(("Making symlink from %s to %s" % (vstrSrcPath, vstrTargetPath)))
-dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_windows()")
-bOk = True
-strErrMsg = ""
-# If the src file doesn't exist, this is an error and we should throw.
-src_stat = os.stat(vstrSrcPath)
-
-try:
-target_stat = os.stat(vstrTargetPath)
-# If the target file exists but refers to a different file, delete it so that we can
-# re-create the link.  This can happen if you run this script once (creating a link)
-# and then delete the source file (so that a brand new file gets created the next time
-# you compile and link), and then re-run this script, so that both the target hardlink
-# and the source file exist, but the target refers to an old copy of
-# the source.
-if (target_stat.st_ino == src_stat.st_ino) and (
-target_stat.st_dev == src_stat.st_dev):
-return (bOk, strErrMsg)
-
-os.remove(vstrTargetPath)
-except:
-# If the target file don't exist, ignore this exception, we will link
-# it shortly.
-pass
-
-try:
-csl = ctypes.windll.kernel32.CreateHardLinkW
-csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
-csl.restype = ctypes.c_ubyte
-if csl(vstrTargetPath, vstrSrcPath, 0) == 0:
-raise ctypes.WinError()
-except Exception as e:
-if e.errno != 17:
-bOk = False
-strErrMsg = "WinError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (
-vstrSrcPath, vstrTargetPath)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link on a UNIX style platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_other_platforms(vstrSrcPath, vstrTargetPath):
-dbg = utilsDebug.CDebugFnVerbose(
-"Python script make_symlink_other_platforms()")
-bOk = True
-strErrMsg = ""
-
-try:
-os.symlink(vstrSrcPath, vstrTargetPath)
-except OSError as e:
-bOk = False
-strErrMsg = "OSError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath, vstrTargetPath)
-except:
-bOk = False
-strErrMsg = strErrMsgUnexpected % sys.exec_info()[0]
-
-return (bOk, strErrMsg)
-
-
-def make_symlink_native(vDictArgs, strSrc, strTarget):
-eOSType = utilsOsType.determine_os_type()
-bDbg = "-d" in vDictArgs
-bOk = True
-strErrMsg = ""
-
-target_filename = os.path.basename(strTarget)
-if eOSType == utilsOsType.EnumOsType.Unknown:
-bOk = False
-strErrMsg = strErrMsgOsTypeUnknown
-elif eOSType == utilsOsType.EnumOsType.Windows:
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_windows(strSrc,
-  strTarget)
-else:
-if os.path.islink(strTarget):
-if bDbg:
-print((strMsgSymlinkExists % target_filename)

[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-10 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 224546.
hhb added a comment.

Remove tailing whitespace


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68858/new/

https://reviews.llvm.org/D68858

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py

Index: lldb/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -245,284 +245,6 @@
 
 return (bOk, strMsg)
 
-#++---
-# Details:  Make the symbolic link on a Windows platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_windows(vstrSrcPath, vstrTargetPath):
-print(("Making symlink from %s to %s" % (vstrSrcPath, vstrTargetPath)))
-dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_windows()")
-bOk = True
-strErrMsg = ""
-# If the src file doesn't exist, this is an error and we should throw.
-src_stat = os.stat(vstrSrcPath)
-
-try:
-target_stat = os.stat(vstrTargetPath)
-# If the target file exists but refers to a different file, delete it so that we can
-# re-create the link.  This can happen if you run this script once (creating a link)
-# and then delete the source file (so that a brand new file gets created the next time
-# you compile and link), and then re-run this script, so that both the target hardlink
-# and the source file exist, but the target refers to an old copy of
-# the source.
-if (target_stat.st_ino == src_stat.st_ino) and (
-target_stat.st_dev == src_stat.st_dev):
-return (bOk, strErrMsg)
-
-os.remove(vstrTargetPath)
-except:
-# If the target file don't exist, ignore this exception, we will link
-# it shortly.
-pass
-
-try:
-csl = ctypes.windll.kernel32.CreateHardLinkW
-csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
-csl.restype = ctypes.c_ubyte
-if csl(vstrTargetPath, vstrSrcPath, 0) == 0:
-raise ctypes.WinError()
-except Exception as e:
-if e.errno != 17:
-bOk = False
-strErrMsg = "WinError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (
-vstrSrcPath, vstrTargetPath)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link on a UNIX style platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_other_platforms(vstrSrcPath, vstrTargetPath):
-dbg = utilsDebug.CDebugFnVerbose(
-"Python script make_symlink_other_platforms()")
-bOk = True
-strErrMsg = ""
-
-try:
-os.symlink(vstrSrcPath, vstrTargetPath)
-except OSError as e:
-bOk = False
-strErrMsg = "OSError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath, vstrTargetPath)
-except:
-bOk = False
-strErrMsg = strErrMsgUnexpected % sys.exec_info()[0]
-
-return (bOk, strErrMsg)
-
-
-def make_symlink_native(vDictArgs, strSrc, strTarget):
-eOSType = utilsOsType.determine_os_type()
-bDbg = "-d" in vDictArgs
-bOk = True
-strErrMsg = ""
-
-target_filename = os.path.basename(strTarget)
-if eOSType == utilsOsType.EnumOsType.Unknown:
-bOk = False
-strErrMsg = strErrMsgOsTypeUnknown
-elif eOSType == utilsOsType.EnumOsType.Windows:
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_windows(strSrc,
-  strTarget)
-else:
-if os.path.islink(strTarget):
-if bDbg:
-print((strMsgSymlinkExists % target_filename))
-return (bOk, strErrMsg)
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_other_platforms(strSrc,
-  strTarget)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link.
-# Args: vDictArgs 

[Lldb-commits] [PATCH] D68878: [lldb] Fix python packages install path

2019-10-11 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
hhb added a reviewer: mgorny.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D68878

Files:
  lldb/CMakeLists.txt


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -235,7 +235,7 @@
 # Install the LLDB python module
 add_custom_target(lldb-python-scripts)
 add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/
+install(DIRECTORY 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
 DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
 COMPONENT lldb-python-scripts)
 if (NOT LLVM_ENABLE_IDE)


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -235,7 +235,7 @@
 # Install the LLDB python module
 add_custom_target(lldb-python-scripts)
 add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/
+install(DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
 DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
 COMPONENT lldb-python-scripts)
 if (NOT LLVM_ENABLE_IDE)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68878: [lldb] Fix python packages install path

2019-10-11 Thread Haibo Huang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6aacd9687543: [lldb] Fix python packages install path 
(authored by hhb).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68878/new/

https://reviews.llvm.org/D68878

Files:
  lldb/CMakeLists.txt


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -235,7 +235,7 @@
 # Install the LLDB python module
 add_custom_target(lldb-python-scripts)
 add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/
+install(DIRECTORY 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
 DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
 COMPONENT lldb-python-scripts)
 if (NOT LLVM_ENABLE_IDE)


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -235,7 +235,7 @@
 # Install the LLDB python module
 add_custom_target(lldb-python-scripts)
 add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_PYTHON_RELATIVE_PATH}/
+install(DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
 DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
 COMPONENT lldb-python-scripts)
 if (NOT LLVM_ENABLE_IDE)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68719: Fix issue when building with Visual Studio

2019-10-11 Thread Haibo Huang via Phabricator via lldb-commits
hhb added inline comments.



Comment at: finishSwigPythonLLDB.py:380
 
-strSrc = os.path.normcase(os.path.join(strPrefix, vstrSrcFile))
-strRelSrc = os.path.relpath(strSrc, os.path.dirname(strTarget))

tatyana-krasnukha wrote:
> tatyana-krasnukha wrote:
> > hhb wrote:
> > > hhb wrote:
> > > > tatyana-krasnukha wrote:
> > > > > This command produces an incorrect path for Visual Studio since it 
> > > > > concatenates the root build directory with 'bin/liblldb.dll' 
> > > > > bypassing configuration name.
> > > > Hmm understood. The origin change is reverted in rG958091c209d0. So I 
> > > > don't think this is relevant any more. I'll redo the change. Can you 
> > > > help test that time? I don't have a visual studio...
> > > Sorry rGc0da1282fc036908cc721ee74f574fbb99d5e506
> > Yes, now it works well
> > Can you help test that time? I don't have a visual studio...
> 
> Yes, of course!
> 
> BTW, I suppose that '--cmakeBuildConfiguration' option can fix the issue for 
> XCode too. 
> 
> 
It does. But we have some other issue when LLDB_BUILD_FRAMEWORK is enabled.

Sent D68858. Wish it goes well this me. 😊


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68719/new/

https://reviews.llvm.org/D68719



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-11 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 224648.
hhb added a comment.

Fix file copy path


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68858/new/

https://reviews.llvm.org/D68858

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py

Index: lldb/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -245,284 +245,6 @@
 
 return (bOk, strMsg)
 
-#++---
-# Details:  Make the symbolic link on a Windows platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_windows(vstrSrcPath, vstrTargetPath):
-print(("Making symlink from %s to %s" % (vstrSrcPath, vstrTargetPath)))
-dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_windows()")
-bOk = True
-strErrMsg = ""
-# If the src file doesn't exist, this is an error and we should throw.
-src_stat = os.stat(vstrSrcPath)
-
-try:
-target_stat = os.stat(vstrTargetPath)
-# If the target file exists but refers to a different file, delete it so that we can
-# re-create the link.  This can happen if you run this script once (creating a link)
-# and then delete the source file (so that a brand new file gets created the next time
-# you compile and link), and then re-run this script, so that both the target hardlink
-# and the source file exist, but the target refers to an old copy of
-# the source.
-if (target_stat.st_ino == src_stat.st_ino) and (
-target_stat.st_dev == src_stat.st_dev):
-return (bOk, strErrMsg)
-
-os.remove(vstrTargetPath)
-except:
-# If the target file don't exist, ignore this exception, we will link
-# it shortly.
-pass
-
-try:
-csl = ctypes.windll.kernel32.CreateHardLinkW
-csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
-csl.restype = ctypes.c_ubyte
-if csl(vstrTargetPath, vstrSrcPath, 0) == 0:
-raise ctypes.WinError()
-except Exception as e:
-if e.errno != 17:
-bOk = False
-strErrMsg = "WinError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (
-vstrSrcPath, vstrTargetPath)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link on a UNIX style platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_other_platforms(vstrSrcPath, vstrTargetPath):
-dbg = utilsDebug.CDebugFnVerbose(
-"Python script make_symlink_other_platforms()")
-bOk = True
-strErrMsg = ""
-
-try:
-os.symlink(vstrSrcPath, vstrTargetPath)
-except OSError as e:
-bOk = False
-strErrMsg = "OSError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath, vstrTargetPath)
-except:
-bOk = False
-strErrMsg = strErrMsgUnexpected % sys.exec_info()[0]
-
-return (bOk, strErrMsg)
-
-
-def make_symlink_native(vDictArgs, strSrc, strTarget):
-eOSType = utilsOsType.determine_os_type()
-bDbg = "-d" in vDictArgs
-bOk = True
-strErrMsg = ""
-
-target_filename = os.path.basename(strTarget)
-if eOSType == utilsOsType.EnumOsType.Unknown:
-bOk = False
-strErrMsg = strErrMsgOsTypeUnknown
-elif eOSType == utilsOsType.EnumOsType.Windows:
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_windows(strSrc,
-  strTarget)
-else:
-if os.path.islink(strTarget):
-if bDbg:
-print((strMsgSymlinkExists % target_filename))
-return (bOk, strErrMsg)
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_other_platforms(strSrc,
-  strTarget)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link.
-# Args: vDictArgs

[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-11 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 224649.
hhb added a comment.

Fix typo


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68858/new/

https://reviews.llvm.org/D68858

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py

Index: lldb/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -245,284 +245,6 @@
 
 return (bOk, strMsg)
 
-#++---
-# Details:  Make the symbolic link on a Windows platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_windows(vstrSrcPath, vstrTargetPath):
-print(("Making symlink from %s to %s" % (vstrSrcPath, vstrTargetPath)))
-dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_windows()")
-bOk = True
-strErrMsg = ""
-# If the src file doesn't exist, this is an error and we should throw.
-src_stat = os.stat(vstrSrcPath)
-
-try:
-target_stat = os.stat(vstrTargetPath)
-# If the target file exists but refers to a different file, delete it so that we can
-# re-create the link.  This can happen if you run this script once (creating a link)
-# and then delete the source file (so that a brand new file gets created the next time
-# you compile and link), and then re-run this script, so that both the target hardlink
-# and the source file exist, but the target refers to an old copy of
-# the source.
-if (target_stat.st_ino == src_stat.st_ino) and (
-target_stat.st_dev == src_stat.st_dev):
-return (bOk, strErrMsg)
-
-os.remove(vstrTargetPath)
-except:
-# If the target file don't exist, ignore this exception, we will link
-# it shortly.
-pass
-
-try:
-csl = ctypes.windll.kernel32.CreateHardLinkW
-csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
-csl.restype = ctypes.c_ubyte
-if csl(vstrTargetPath, vstrSrcPath, 0) == 0:
-raise ctypes.WinError()
-except Exception as e:
-if e.errno != 17:
-bOk = False
-strErrMsg = "WinError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (
-vstrSrcPath, vstrTargetPath)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link on a UNIX style platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_other_platforms(vstrSrcPath, vstrTargetPath):
-dbg = utilsDebug.CDebugFnVerbose(
-"Python script make_symlink_other_platforms()")
-bOk = True
-strErrMsg = ""
-
-try:
-os.symlink(vstrSrcPath, vstrTargetPath)
-except OSError as e:
-bOk = False
-strErrMsg = "OSError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath, vstrTargetPath)
-except:
-bOk = False
-strErrMsg = strErrMsgUnexpected % sys.exec_info()[0]
-
-return (bOk, strErrMsg)
-
-
-def make_symlink_native(vDictArgs, strSrc, strTarget):
-eOSType = utilsOsType.determine_os_type()
-bDbg = "-d" in vDictArgs
-bOk = True
-strErrMsg = ""
-
-target_filename = os.path.basename(strTarget)
-if eOSType == utilsOsType.EnumOsType.Unknown:
-bOk = False
-strErrMsg = strErrMsgOsTypeUnknown
-elif eOSType == utilsOsType.EnumOsType.Windows:
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_windows(strSrc,
-  strTarget)
-else:
-if os.path.islink(strTarget):
-if bDbg:
-print((strMsgSymlinkExists % target_filename))
-return (bOk, strErrMsg)
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_other_platforms(strSrc,
-  strTarget)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link.
-# Args: vDictArgs   - (R) P

[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-11 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 224647.
hhb added a comment.

Fix file copy path


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68858/new/

https://reviews.llvm.org/D68858

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py

Index: lldb/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -245,284 +245,6 @@
 
 return (bOk, strMsg)
 
-#++---
-# Details:  Make the symbolic link on a Windows platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_windows(vstrSrcPath, vstrTargetPath):
-print(("Making symlink from %s to %s" % (vstrSrcPath, vstrTargetPath)))
-dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_windows()")
-bOk = True
-strErrMsg = ""
-# If the src file doesn't exist, this is an error and we should throw.
-src_stat = os.stat(vstrSrcPath)
-
-try:
-target_stat = os.stat(vstrTargetPath)
-# If the target file exists but refers to a different file, delete it so that we can
-# re-create the link.  This can happen if you run this script once (creating a link)
-# and then delete the source file (so that a brand new file gets created the next time
-# you compile and link), and then re-run this script, so that both the target hardlink
-# and the source file exist, but the target refers to an old copy of
-# the source.
-if (target_stat.st_ino == src_stat.st_ino) and (
-target_stat.st_dev == src_stat.st_dev):
-return (bOk, strErrMsg)
-
-os.remove(vstrTargetPath)
-except:
-# If the target file don't exist, ignore this exception, we will link
-# it shortly.
-pass
-
-try:
-csl = ctypes.windll.kernel32.CreateHardLinkW
-csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
-csl.restype = ctypes.c_ubyte
-if csl(vstrTargetPath, vstrSrcPath, 0) == 0:
-raise ctypes.WinError()
-except Exception as e:
-if e.errno != 17:
-bOk = False
-strErrMsg = "WinError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (
-vstrSrcPath, vstrTargetPath)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link on a UNIX style platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_other_platforms(vstrSrcPath, vstrTargetPath):
-dbg = utilsDebug.CDebugFnVerbose(
-"Python script make_symlink_other_platforms()")
-bOk = True
-strErrMsg = ""
-
-try:
-os.symlink(vstrSrcPath, vstrTargetPath)
-except OSError as e:
-bOk = False
-strErrMsg = "OSError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath, vstrTargetPath)
-except:
-bOk = False
-strErrMsg = strErrMsgUnexpected % sys.exec_info()[0]
-
-return (bOk, strErrMsg)
-
-
-def make_symlink_native(vDictArgs, strSrc, strTarget):
-eOSType = utilsOsType.determine_os_type()
-bDbg = "-d" in vDictArgs
-bOk = True
-strErrMsg = ""
-
-target_filename = os.path.basename(strTarget)
-if eOSType == utilsOsType.EnumOsType.Unknown:
-bOk = False
-strErrMsg = strErrMsgOsTypeUnknown
-elif eOSType == utilsOsType.EnumOsType.Windows:
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_windows(strSrc,
-  strTarget)
-else:
-if os.path.islink(strTarget):
-if bDbg:
-print((strMsgSymlinkExists % target_filename))
-return (bOk, strErrMsg)
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_other_platforms(strSrc,
-  strTarget)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link.
-# Args: vDictArgs

[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-11 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 224707.
hhb added a comment.

Adds VERBATIM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68858/new/

https://reviews.llvm.org/D68858

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py

Index: lldb/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -245,284 +245,6 @@
 
 return (bOk, strMsg)
 
-#++---
-# Details:  Make the symbolic link on a Windows platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_windows(vstrSrcPath, vstrTargetPath):
-print(("Making symlink from %s to %s" % (vstrSrcPath, vstrTargetPath)))
-dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_windows()")
-bOk = True
-strErrMsg = ""
-# If the src file doesn't exist, this is an error and we should throw.
-src_stat = os.stat(vstrSrcPath)
-
-try:
-target_stat = os.stat(vstrTargetPath)
-# If the target file exists but refers to a different file, delete it so that we can
-# re-create the link.  This can happen if you run this script once (creating a link)
-# and then delete the source file (so that a brand new file gets created the next time
-# you compile and link), and then re-run this script, so that both the target hardlink
-# and the source file exist, but the target refers to an old copy of
-# the source.
-if (target_stat.st_ino == src_stat.st_ino) and (
-target_stat.st_dev == src_stat.st_dev):
-return (bOk, strErrMsg)
-
-os.remove(vstrTargetPath)
-except:
-# If the target file don't exist, ignore this exception, we will link
-# it shortly.
-pass
-
-try:
-csl = ctypes.windll.kernel32.CreateHardLinkW
-csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
-csl.restype = ctypes.c_ubyte
-if csl(vstrTargetPath, vstrSrcPath, 0) == 0:
-raise ctypes.WinError()
-except Exception as e:
-if e.errno != 17:
-bOk = False
-strErrMsg = "WinError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (
-vstrSrcPath, vstrTargetPath)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link on a UNIX style platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_other_platforms(vstrSrcPath, vstrTargetPath):
-dbg = utilsDebug.CDebugFnVerbose(
-"Python script make_symlink_other_platforms()")
-bOk = True
-strErrMsg = ""
-
-try:
-os.symlink(vstrSrcPath, vstrTargetPath)
-except OSError as e:
-bOk = False
-strErrMsg = "OSError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath, vstrTargetPath)
-except:
-bOk = False
-strErrMsg = strErrMsgUnexpected % sys.exec_info()[0]
-
-return (bOk, strErrMsg)
-
-
-def make_symlink_native(vDictArgs, strSrc, strTarget):
-eOSType = utilsOsType.determine_os_type()
-bDbg = "-d" in vDictArgs
-bOk = True
-strErrMsg = ""
-
-target_filename = os.path.basename(strTarget)
-if eOSType == utilsOsType.EnumOsType.Unknown:
-bOk = False
-strErrMsg = strErrMsgOsTypeUnknown
-elif eOSType == utilsOsType.EnumOsType.Windows:
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_windows(strSrc,
-  strTarget)
-else:
-if os.path.islink(strTarget):
-if bDbg:
-print((strMsgSymlinkExists % target_filename))
-return (bOk, strErrMsg)
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_other_platforms(strSrc,
-  strTarget)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link.
-# Args: vDictArgs   - 

[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-14 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 224954.
hhb added a comment.

Fix the build for multi-config generator.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68858/new/

https://reviews.llvm.org/D68858

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py

Index: lldb/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -245,284 +245,6 @@
 
 return (bOk, strMsg)
 
-#++---
-# Details:  Make the symbolic link on a Windows platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_windows(vstrSrcPath, vstrTargetPath):
-print(("Making symlink from %s to %s" % (vstrSrcPath, vstrTargetPath)))
-dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_windows()")
-bOk = True
-strErrMsg = ""
-# If the src file doesn't exist, this is an error and we should throw.
-src_stat = os.stat(vstrSrcPath)
-
-try:
-target_stat = os.stat(vstrTargetPath)
-# If the target file exists but refers to a different file, delete it so that we can
-# re-create the link.  This can happen if you run this script once (creating a link)
-# and then delete the source file (so that a brand new file gets created the next time
-# you compile and link), and then re-run this script, so that both the target hardlink
-# and the source file exist, but the target refers to an old copy of
-# the source.
-if (target_stat.st_ino == src_stat.st_ino) and (
-target_stat.st_dev == src_stat.st_dev):
-return (bOk, strErrMsg)
-
-os.remove(vstrTargetPath)
-except:
-# If the target file don't exist, ignore this exception, we will link
-# it shortly.
-pass
-
-try:
-csl = ctypes.windll.kernel32.CreateHardLinkW
-csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
-csl.restype = ctypes.c_ubyte
-if csl(vstrTargetPath, vstrSrcPath, 0) == 0:
-raise ctypes.WinError()
-except Exception as e:
-if e.errno != 17:
-bOk = False
-strErrMsg = "WinError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (
-vstrSrcPath, vstrTargetPath)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link on a UNIX style platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_other_platforms(vstrSrcPath, vstrTargetPath):
-dbg = utilsDebug.CDebugFnVerbose(
-"Python script make_symlink_other_platforms()")
-bOk = True
-strErrMsg = ""
-
-try:
-os.symlink(vstrSrcPath, vstrTargetPath)
-except OSError as e:
-bOk = False
-strErrMsg = "OSError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath, vstrTargetPath)
-except:
-bOk = False
-strErrMsg = strErrMsgUnexpected % sys.exec_info()[0]
-
-return (bOk, strErrMsg)
-
-
-def make_symlink_native(vDictArgs, strSrc, strTarget):
-eOSType = utilsOsType.determine_os_type()
-bDbg = "-d" in vDictArgs
-bOk = True
-strErrMsg = ""
-
-target_filename = os.path.basename(strTarget)
-if eOSType == utilsOsType.EnumOsType.Unknown:
-bOk = False
-strErrMsg = strErrMsgOsTypeUnknown
-elif eOSType == utilsOsType.EnumOsType.Windows:
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_windows(strSrc,
-  strTarget)
-else:
-if os.path.islink(strTarget):
-if bDbg:
-print((strMsgSymlinkExists % target_filename))
-return (bOk, strErrMsg)
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_other_platforms(strSrc,
-  strTarget)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link.
-# Args:   

[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-14 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 224955.
hhb added a comment.

Oops fix typo.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68858/new/

https://reviews.llvm.org/D68858

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py

Index: lldb/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -245,284 +245,6 @@
 
 return (bOk, strMsg)
 
-#++---
-# Details:  Make the symbolic link on a Windows platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_windows(vstrSrcPath, vstrTargetPath):
-print(("Making symlink from %s to %s" % (vstrSrcPath, vstrTargetPath)))
-dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_windows()")
-bOk = True
-strErrMsg = ""
-# If the src file doesn't exist, this is an error and we should throw.
-src_stat = os.stat(vstrSrcPath)
-
-try:
-target_stat = os.stat(vstrTargetPath)
-# If the target file exists but refers to a different file, delete it so that we can
-# re-create the link.  This can happen if you run this script once (creating a link)
-# and then delete the source file (so that a brand new file gets created the next time
-# you compile and link), and then re-run this script, so that both the target hardlink
-# and the source file exist, but the target refers to an old copy of
-# the source.
-if (target_stat.st_ino == src_stat.st_ino) and (
-target_stat.st_dev == src_stat.st_dev):
-return (bOk, strErrMsg)
-
-os.remove(vstrTargetPath)
-except:
-# If the target file don't exist, ignore this exception, we will link
-# it shortly.
-pass
-
-try:
-csl = ctypes.windll.kernel32.CreateHardLinkW
-csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
-csl.restype = ctypes.c_ubyte
-if csl(vstrTargetPath, vstrSrcPath, 0) == 0:
-raise ctypes.WinError()
-except Exception as e:
-if e.errno != 17:
-bOk = False
-strErrMsg = "WinError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (
-vstrSrcPath, vstrTargetPath)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link on a UNIX style platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_other_platforms(vstrSrcPath, vstrTargetPath):
-dbg = utilsDebug.CDebugFnVerbose(
-"Python script make_symlink_other_platforms()")
-bOk = True
-strErrMsg = ""
-
-try:
-os.symlink(vstrSrcPath, vstrTargetPath)
-except OSError as e:
-bOk = False
-strErrMsg = "OSError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath, vstrTargetPath)
-except:
-bOk = False
-strErrMsg = strErrMsgUnexpected % sys.exec_info()[0]
-
-return (bOk, strErrMsg)
-
-
-def make_symlink_native(vDictArgs, strSrc, strTarget):
-eOSType = utilsOsType.determine_os_type()
-bDbg = "-d" in vDictArgs
-bOk = True
-strErrMsg = ""
-
-target_filename = os.path.basename(strTarget)
-if eOSType == utilsOsType.EnumOsType.Unknown:
-bOk = False
-strErrMsg = strErrMsgOsTypeUnknown
-elif eOSType == utilsOsType.EnumOsType.Windows:
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_windows(strSrc,
-  strTarget)
-else:
-if os.path.islink(strTarget):
-if bDbg:
-print((strMsgSymlinkExists % target_filename))
-return (bOk, strErrMsg)
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_other_platforms(strSrc,
-  strTarget)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link.
-# Args: vDictArgs   -

[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-14 Thread Haibo Huang via Phabricator via lldb-commits
hhb marked 3 inline comments as done.
hhb added inline comments.



Comment at: lldb/CMakeLists.txt:244
+  else()
+set(LIBLLDB_SYMLINK_DEST 
"${liblldb_build_dir}/liblldb${CMAKE_SHARED_LIBRARY_SUFFIX}")
+  endif()

tatyana-krasnukha wrote:
> This command still produces a path without configuration name, Visual Studio 
> failed to execute the post-build step.
> 
Thanks for testing and the patch! I found that CMAKE_CFG_INTDIR can actually be 
passed into function and expanded to $(Configure). At least in VS2019 
community... Can you try this new version? Thanks again!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68858/new/

https://reviews.llvm.org/D68858



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68910: use LLVM_LIBDIR_SUFFIX for python lib path

2019-10-15 Thread Haibo Huang via Phabricator via lldb-commits
hhb requested changes to this revision.
hhb added a comment.
This revision now requires changes to proceed.

Can you sync to the latest code and try again? Your problem is likely to be 
fixed in a previous change...


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68910/new/

https://reviews.llvm.org/D68910



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-15 Thread Haibo Huang via Phabricator via lldb-commits
hhb marked an inline comment as done.
hhb added a comment.

In D68858#1709458 , @tatyana-krasnukha 
wrote:

> Build and installation completed successfully! LGTM, though it would be good 
> if anyone tests this with Xcode.


I just tested Xcode. For xcode LLDB_BUILD_FRAMEWORK is on by default so that's 
what I did. Both release and debug build looks good. Obviously xcode did 
something different than VS...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68858/new/

https://reviews.llvm.org/D68858



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68910: python path should be platform-dependent

2019-10-15 Thread Haibo Huang via Phabricator via lldb-commits
hhb accepted this revision.
hhb added a comment.

In D68910#1710009 , @llunak wrote:

> How about this one?


This is fine for me. Actually it doesn't make any difference for all platforms 
I tried... Out of curiosity, is it possible to share the implementation of 
get_python_lib() in openSUSE? Thanks.


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68910/new/

https://reviews.llvm.org/D68910



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68910: python path should be platform-dependent

2019-10-15 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

  Python 3.6.8 (default, Apr 30 2019, 13:27:23) [GCC] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import distutils.sysconfig
  >>> print(distutils.sysconfig.get_python_lib(True, False, ''))
  lib64/python3.6/site-packages
  >>> print(distutils.sysconfig.get_python_lib(True, False, '/abc'))
  /abc/lib64/python3.6/site-packages
  >>> print(distutils.sysconfig.get_python_lib(True, False))
  /usr/lib64/python3.6/site-packages
  >>> print(distutils.sysconfig.get_python_lib(False, False, ''))
  lib/python3.6/site-packages
  >>> print(distutils.sysconfig.get_python_lib(False, False, '/abc'))
  /abc/lib/python3.6/site-packages
  >>> print(distutils.sysconfig.get_python_lib(False, False))
  /usr/lib/python3.6/site-packages

This is interesting...


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68910/new/

https://reviews.llvm.org/D68910



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68910: python path should be platform-dependent

2019-10-15 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

One additional statement in openSUSE comparing to standard python:

  libdir = plat_specific and get_config_var("platlibdir") or "lib"

Hmmm basically what does platform dependent mean...

Anyway this change looks good to me.


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68910/new/

https://reviews.llvm.org/D68910



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D68858: [lldb] Creates _liblldb symlink from cmake

2019-10-15 Thread Haibo Huang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG208e9c01fc09: [lldb] Creates _liblldb symlink from cmake 
(authored by hhb).

Changed prior to commit:
  https://reviews.llvm.org/D68858?vs=224955&id=225123#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68858/new/

https://reviews.llvm.org/D68858

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py

Index: lldb/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -245,284 +245,6 @@
 
 return (bOk, strMsg)
 
-#++---
-# Details:  Make the symbolic link on a Windows platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_windows(vstrSrcPath, vstrTargetPath):
-print(("Making symlink from %s to %s" % (vstrSrcPath, vstrTargetPath)))
-dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_windows()")
-bOk = True
-strErrMsg = ""
-# If the src file doesn't exist, this is an error and we should throw.
-src_stat = os.stat(vstrSrcPath)
-
-try:
-target_stat = os.stat(vstrTargetPath)
-# If the target file exists but refers to a different file, delete it so that we can
-# re-create the link.  This can happen if you run this script once (creating a link)
-# and then delete the source file (so that a brand new file gets created the next time
-# you compile and link), and then re-run this script, so that both the target hardlink
-# and the source file exist, but the target refers to an old copy of
-# the source.
-if (target_stat.st_ino == src_stat.st_ino) and (
-target_stat.st_dev == src_stat.st_dev):
-return (bOk, strErrMsg)
-
-os.remove(vstrTargetPath)
-except:
-# If the target file don't exist, ignore this exception, we will link
-# it shortly.
-pass
-
-try:
-csl = ctypes.windll.kernel32.CreateHardLinkW
-csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)
-csl.restype = ctypes.c_ubyte
-if csl(vstrTargetPath, vstrSrcPath, 0) == 0:
-raise ctypes.WinError()
-except Exception as e:
-if e.errno != 17:
-bOk = False
-strErrMsg = "WinError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (
-vstrSrcPath, vstrTargetPath)
-
-return (bOk, strErrMsg)
-
-#++---
-# Details:  Make the symbolic link on a UNIX style platform.
-# Args: vstrSrcFile - (R) Source file name.
-#   vstrTargetFile  - (R) Destination file name.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def make_symlink_other_platforms(vstrSrcPath, vstrTargetPath):
-dbg = utilsDebug.CDebugFnVerbose(
-"Python script make_symlink_other_platforms()")
-bOk = True
-strErrMsg = ""
-
-try:
-os.symlink(vstrSrcPath, vstrTargetPath)
-except OSError as e:
-bOk = False
-strErrMsg = "OSError(%d): %s %s" % (
-e.errno, e.strerror, strErrMsgMakeSymlink)
-strErrMsg += " Src:'%s' Target:'%s'" % (vstrSrcPath, vstrTargetPath)
-except:
-bOk = False
-strErrMsg = strErrMsgUnexpected % sys.exec_info()[0]
-
-return (bOk, strErrMsg)
-
-
-def make_symlink_native(vDictArgs, strSrc, strTarget):
-eOSType = utilsOsType.determine_os_type()
-bDbg = "-d" in vDictArgs
-bOk = True
-strErrMsg = ""
-
-target_filename = os.path.basename(strTarget)
-if eOSType == utilsOsType.EnumOsType.Unknown:
-bOk = False
-strErrMsg = strErrMsgOsTypeUnknown
-elif eOSType == utilsOsType.EnumOsType.Windows:
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_windows(strSrc,
-  strTarget)
-else:
-if os.path.islink(strTarget):
-if bDbg:
-print((strMsgSymlinkExists % target_filename))
-return (bOk, strErrMsg)
-if bDbg:
-print((strMsgSymlinkMk % (target_filename, strSrc, strTarget)))
-bOk, strErrMsg = make_symlink_other_platforms(strSrc,
-  strTarget)
-
-return 

[Lldb-commits] [PATCH] D69016: [lldb] move more things from python to cmake

2019-10-15 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
hhb added a reviewer: labath.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.

Move the copy of six.py, lldb.py and macosx/heap


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69016

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py

Index: lldb/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -74,56 +74,6 @@
 strErrMsgCopySixPyFailed = "Unable to copy '%s' to '%s'"
 
 
-def is_debug_interpreter():
-return hasattr(sys, 'gettotalrefcount')
-
-#++---
-# Details:  Copy files needed by lldb/macosx/heap.py to build libheap.dylib.
-# Args: vDictArgs   - (R) Program input parameters.
-#   vstrFrameworkPythonDir  - (R) Python framework directory.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def macosx_copy_file_for_heap(vDictArgs, vstrFrameworkPythonDir):
-dbg = utilsDebug.CDebugFnVerbose(
-"Python script macosx_copy_file_for_heap()")
-bOk = True
-strMsg = ""
-
-eOSType = utilsOsType.determine_os_type()
-if eOSType != utilsOsType.EnumOsType.Darwin:
-return (bOk, strMsg)
-
-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 = os.path.normpath(vDictArgs["--srcRoot"])
-strSrc = os.path.join(
-strRoot,
-"examples",
-"darwin",
-"heap_find",
-"heap",
-"heap_find.cpp")
-shutil.copy(strSrc, strHeapDir)
-strSrc = os.path.join(
-strRoot,
-"examples",
-"darwin",
-"heap_find",
-"heap",
-"Makefile")
-shutil.copy(strSrc, strHeapDir)
-
-return (bOk, strMsg)
-
 #++---
 # Details:  Create Python packages and Python __init__ files.
 # Args: vDictArgs   - (R) Program input parameters.
@@ -198,142 +148,6 @@
 
 return (bOk, strMsg)
 
-#++---
-# Details:  Copy the lldb.py file into the lldb package directory and rename
-#   to __init_.py.
-# Args: vDictArgs   - (R) Program input parameters.
-#   vstrFrameworkPythonDir  - (R) Python framework directory.
-#   vstrCfgBldDir   - (R) Config directory path.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def copy_lldbpy_file_to_lldb_pkg_dir(
-vDictArgs,
-vstrFrameworkPythonDir,
-vstrCfgBldDir):
-dbg = utilsDebug.CDebugFnVerbose(
-"Python script copy_lldbpy_file_to_lldb_pkg_dir()")
-bOk = True
-bDbg = "-d" in vDictArgs
-strMsg = ""
-
-strSrc = os.path.join(vstrCfgBldDir, "lldb.py")
-strSrc = os.path.normcase(strSrc)
-strDst = os.path.join(vstrFrameworkPythonDir, "__init__.py")
-strDst = os.path.normcase(strDst)
-
-if not os.path.exists(strSrc):
-strMsg = strErrMsgLLDBPyFileNotNotFound % strSrc
-return (bOk, strMsg)
-
-try:
-if bDbg:
-print((strMsgCopyLLDBPy % (strSrc, strDst)))
-shutil.copyfile(strSrc, strDst)
-except IOError as e:
-bOk = False
-strMsg = "I/O error(%d): %s %s" % (e.errno,
-   e.strerror, strErrMsgCpLldbpy)
-if e.errno == 2:
-strMsg += " Src:'%s' Dst:'%s'" % (strSrc, strDst)
-except:
-bOk = False
-strMsg = strErrMsgUnexpected % sys.exec_info()[0]
-
-return (bOk, strMsg)
-
-
-def copy_six(vDictArgs, vstrFrameworkPythonDir):
-dbg = utilsDebug.CDebugFnVerbose("Python script copy_six()")
-bDbg = "-d" in vDictArgs
-bOk = True
-strMsg = ""
-site_packages_dir = os.path.dirname(vstrFrameworkPythonDir)
-six_module_filename = "six.py"
-src_file = os.path.join(
-vDictArgs['--srcRoot'],
-"third_party",
-"Python",
-"module",
-"six",
-six_module_filename)
-src_file = os.path.normpath(src_file)
-target = os.path.join(site_packages_dir, six_module_filename)
-
-if bDbg:
-print((strMsgCopySixPy % (src_file, target)))
-try:
-shutil.copyfile(src_file, target)
-except:
-bOk = False
-strMsg = strErrMsgCopySixPyFailed % (src_file, target)
-
-return (bOk, strMsg)
-
-#++---
-# D

[Lldb-commits] [PATCH] D69019: [lldb] move package generation from python to cmake

2019-10-15 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
hhb added a project: LLDB.
hhb planned changes to this revision.

This is the last part. And we can remove the python script.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69019

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/createPythonInit.py
  lldb/scripts/Python/finishSwigPythonLLDB.py
  lldb/scripts/finishSwigWrapperClasses.py
  lldb/scripts/utilsArgsParse.py
  lldb/scripts/utilsDebug.py
  lldb/scripts/utilsOsType.py

Index: lldb/scripts/utilsOsType.py
===
--- lldb/scripts/utilsOsType.py
+++ /dev/null
@@ -1,103 +0,0 @@
-""" Utility module to determine the OS Python running on
-
---
-File: utilsOsType.py
-
-Overview:   Python module to supply functions and an enumeration to
-help determine the platform type, bit size and OS currently
-being used.
---
-
-"""
-
-# Python modules:
-import sys  # Provide system information
-
-# Third party modules:
-
-# In-house modules:
-
-# Instantiations:
-
-# Enumerations:
-#-
-# Details:  Class to implement a 'C' style enumeration type.
-# Gotchas:  None.
-# Authors:  Illya Rudkin 28/11/2013.
-# Changes:  None.
-#--
-if sys.version_info.major >= 3:
-from enum import Enum
-
-class EnumOsType(Enum):
-Unknown = 0
-Darwin = 1
-FreeBSD = 2
-Linux = 3
-NetBSD = 4
-OpenBSD = 5
-Windows = 6
-kFreeBSD = 7
-else:
-class EnumOsType(object):
-values = ["Unknown",
-  "Darwin",
-  "FreeBSD",
-  "Linux",
-  "NetBSD",
-  "OpenBSD",
-  "Windows",
-  "kFreeBSD"]
-
-class __metaclass__(type):
-#++
-# Details:  Fn acts as an enumeration.
-# Args: vName - (R) Enumeration to match.
-# Returns:  Int - Matching enumeration/index.
-# Throws:   None.
-#--
-
-def __getattr__(cls, vName):
-return cls.values.index(vName)
-
-#++---
-# Details:  Reverse fast lookup of the values list.
-# Args: vI - (R) Index / enumeration.
-# Returns:  Str - text description matching enumeration.
-# Throws:   None.
-#--
-def name_of(cls, vI):
-return EnumOsType.values[vI]
-
-#-
-#-
-#-
-
-#++---
-# Details:  Determine what operating system is currently running on.
-# Args: None.
-# Returns:  EnumOsType - The OS type being used ATM.
-# Throws:   None.
-#--
-
-
-def determine_os_type():
-eOSType = EnumOsType.Unknown
-
-strOS = sys.platform
-if strOS == "darwin":
-eOSType = EnumOsType.Darwin
-elif strOS.startswith("freebsd"):
-eOSType = EnumOsType.FreeBSD
-elif strOS.startswith("linux"):
-eOSType = EnumOsType.Linux
-elif strOS.startswith("netbsd"):
-eOSType = EnumOsType.NetBSD
-elif strOS.startswith("openbsd"):
-eOSType = EnumOsType.OpenBSD
-elif strOS == "win32":
-eOSType = EnumOsType.Windows
-elif strOS.startswith("gnukfreebsd"):
-eOSType = EnumOsType.kFreeBSD
-
-return eOSType
Index: lldb/scripts/utilsDebug.py
===
--- lldb/scripts/utilsDebug.py
+++ /dev/null
@@ -1,125 +0,0 @@
-""" Utility module to help debug Python scripts
-
---
-File: utilsDebug.py
-
-Overview:  Python module to supply functions to help debug Python
-   scripts.
-Gotchas:   None.
-Copyright: None.
---
-"""
-
-# Python modules:
-import sys
-
-# Third party modules:
-
-# In-house modules:
-
-# Instantiations:
-
-#-
-# Details: Class to implement simple stack function trace. Instantiation the
-#  class as the first function you want to trace. Example:
-#  obj = utilsDebug.CDebugFnVerbose("validate_arguments()")
-# Gotchas: This class will not work in properly in a multi-threaded
-#  environment.
-# Authors: Illya Rudkin 28/11/2013.
-# Changes: None.
-#

[Lldb-commits] [PATCH] D69016: [lldb] move more things from python to cmake

2019-10-16 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

In D69016#1710466 , @mgorny wrote:

> I'm not sure if I like the usage of `POST_BUILD` stuff (it provides less 
> control than separate targets) but overall this seems a good change. 
> Replacing ~250 lines of reinventing the wheel with ~20 lines.


Agreed. After I move all the things to cmake, it will be a good idea to 
refactor POST_BUILD to separate targets. And make sure all file dependencies 
are correct. For now I want to keep the same semantic.

In D69016#1710716 , @labath wrote:

> In D69016#1710380 , @davide wrote:
>
> > What are you trying to accomplish here?
>
>
> I believe the goal is to delete the custom python script completely and rely 
> on cmake to do this instead. Now that we no longer have two build systems to 
> worry about, I think this is a very good idea and it simplifies the code a 
> lot. I believe that at least @JDevlieghere was also in favour of this 
> direction.


Besides that, I want to make sure cross compiling is correct. In the old python 
script, we only detect the build platform, and make decision based on that. 
That's obviously wrong for cross compiling...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69016/new/

https://reviews.llvm.org/D69016



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69019: [lldb] move package generation from python to cmake

2019-10-16 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 225268.
hhb added a comment.

Format


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69019/new/

https://reviews.llvm.org/D69019

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/createPythonInit.py
  lldb/scripts/Python/finishSwigPythonLLDB.py
  lldb/scripts/finishSwigWrapperClasses.py
  lldb/scripts/utilsArgsParse.py
  lldb/scripts/utilsDebug.py
  lldb/scripts/utilsOsType.py

Index: lldb/scripts/utilsOsType.py
===
--- lldb/scripts/utilsOsType.py
+++ /dev/null
@@ -1,103 +0,0 @@
-""" Utility module to determine the OS Python running on
-
---
-File: utilsOsType.py
-
-Overview:   Python module to supply functions and an enumeration to
-help determine the platform type, bit size and OS currently
-being used.
---
-
-"""
-
-# Python modules:
-import sys  # Provide system information
-
-# Third party modules:
-
-# In-house modules:
-
-# Instantiations:
-
-# Enumerations:
-#-
-# Details:  Class to implement a 'C' style enumeration type.
-# Gotchas:  None.
-# Authors:  Illya Rudkin 28/11/2013.
-# Changes:  None.
-#--
-if sys.version_info.major >= 3:
-from enum import Enum
-
-class EnumOsType(Enum):
-Unknown = 0
-Darwin = 1
-FreeBSD = 2
-Linux = 3
-NetBSD = 4
-OpenBSD = 5
-Windows = 6
-kFreeBSD = 7
-else:
-class EnumOsType(object):
-values = ["Unknown",
-  "Darwin",
-  "FreeBSD",
-  "Linux",
-  "NetBSD",
-  "OpenBSD",
-  "Windows",
-  "kFreeBSD"]
-
-class __metaclass__(type):
-#++
-# Details:  Fn acts as an enumeration.
-# Args: vName - (R) Enumeration to match.
-# Returns:  Int - Matching enumeration/index.
-# Throws:   None.
-#--
-
-def __getattr__(cls, vName):
-return cls.values.index(vName)
-
-#++---
-# Details:  Reverse fast lookup of the values list.
-# Args: vI - (R) Index / enumeration.
-# Returns:  Str - text description matching enumeration.
-# Throws:   None.
-#--
-def name_of(cls, vI):
-return EnumOsType.values[vI]
-
-#-
-#-
-#-
-
-#++---
-# Details:  Determine what operating system is currently running on.
-# Args: None.
-# Returns:  EnumOsType - The OS type being used ATM.
-# Throws:   None.
-#--
-
-
-def determine_os_type():
-eOSType = EnumOsType.Unknown
-
-strOS = sys.platform
-if strOS == "darwin":
-eOSType = EnumOsType.Darwin
-elif strOS.startswith("freebsd"):
-eOSType = EnumOsType.FreeBSD
-elif strOS.startswith("linux"):
-eOSType = EnumOsType.Linux
-elif strOS.startswith("netbsd"):
-eOSType = EnumOsType.NetBSD
-elif strOS.startswith("openbsd"):
-eOSType = EnumOsType.OpenBSD
-elif strOS == "win32":
-eOSType = EnumOsType.Windows
-elif strOS.startswith("gnukfreebsd"):
-eOSType = EnumOsType.kFreeBSD
-
-return eOSType
Index: lldb/scripts/utilsDebug.py
===
--- lldb/scripts/utilsDebug.py
+++ /dev/null
@@ -1,125 +0,0 @@
-""" Utility module to help debug Python scripts
-
---
-File: utilsDebug.py
-
-Overview:  Python module to supply functions to help debug Python
-   scripts.
-Gotchas:   None.
-Copyright: None.
---
-"""
-
-# Python modules:
-import sys
-
-# Third party modules:
-
-# In-house modules:
-
-# Instantiations:
-
-#-
-# Details: Class to implement simple stack function trace. Instantiation the
-#  class as the first function you want to trace. Example:
-#  obj = utilsDebug.CDebugFnVerbose("validate_arguments()")
-# Gotchas: This class will not work in properly in a multi-threaded
-#  environment.
-# Authors: Illya Rudkin 28/11/2013.
-# Changes: None.
-#--
-
-
-class CD

[Lldb-commits] [PATCH] D69019: [lldb] move package generation from python to cmake

2019-10-16 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 225266.
hhb added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69019/new/

https://reviews.llvm.org/D69019

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/createPythonInit.py
  lldb/scripts/Python/finishSwigPythonLLDB.py
  lldb/scripts/finishSwigWrapperClasses.py
  lldb/scripts/utilsArgsParse.py
  lldb/scripts/utilsDebug.py
  lldb/scripts/utilsOsType.py

Index: lldb/scripts/utilsOsType.py
===
--- lldb/scripts/utilsOsType.py
+++ /dev/null
@@ -1,103 +0,0 @@
-""" Utility module to determine the OS Python running on
-
---
-File: utilsOsType.py
-
-Overview:   Python module to supply functions and an enumeration to
-help determine the platform type, bit size and OS currently
-being used.
---
-
-"""
-
-# Python modules:
-import sys  # Provide system information
-
-# Third party modules:
-
-# In-house modules:
-
-# Instantiations:
-
-# Enumerations:
-#-
-# Details:  Class to implement a 'C' style enumeration type.
-# Gotchas:  None.
-# Authors:  Illya Rudkin 28/11/2013.
-# Changes:  None.
-#--
-if sys.version_info.major >= 3:
-from enum import Enum
-
-class EnumOsType(Enum):
-Unknown = 0
-Darwin = 1
-FreeBSD = 2
-Linux = 3
-NetBSD = 4
-OpenBSD = 5
-Windows = 6
-kFreeBSD = 7
-else:
-class EnumOsType(object):
-values = ["Unknown",
-  "Darwin",
-  "FreeBSD",
-  "Linux",
-  "NetBSD",
-  "OpenBSD",
-  "Windows",
-  "kFreeBSD"]
-
-class __metaclass__(type):
-#++
-# Details:  Fn acts as an enumeration.
-# Args: vName - (R) Enumeration to match.
-# Returns:  Int - Matching enumeration/index.
-# Throws:   None.
-#--
-
-def __getattr__(cls, vName):
-return cls.values.index(vName)
-
-#++---
-# Details:  Reverse fast lookup of the values list.
-# Args: vI - (R) Index / enumeration.
-# Returns:  Str - text description matching enumeration.
-# Throws:   None.
-#--
-def name_of(cls, vI):
-return EnumOsType.values[vI]
-
-#-
-#-
-#-
-
-#++---
-# Details:  Determine what operating system is currently running on.
-# Args: None.
-# Returns:  EnumOsType - The OS type being used ATM.
-# Throws:   None.
-#--
-
-
-def determine_os_type():
-eOSType = EnumOsType.Unknown
-
-strOS = sys.platform
-if strOS == "darwin":
-eOSType = EnumOsType.Darwin
-elif strOS.startswith("freebsd"):
-eOSType = EnumOsType.FreeBSD
-elif strOS.startswith("linux"):
-eOSType = EnumOsType.Linux
-elif strOS.startswith("netbsd"):
-eOSType = EnumOsType.NetBSD
-elif strOS.startswith("openbsd"):
-eOSType = EnumOsType.OpenBSD
-elif strOS == "win32":
-eOSType = EnumOsType.Windows
-elif strOS.startswith("gnukfreebsd"):
-eOSType = EnumOsType.kFreeBSD
-
-return eOSType
Index: lldb/scripts/utilsDebug.py
===
--- lldb/scripts/utilsDebug.py
+++ /dev/null
@@ -1,125 +0,0 @@
-""" Utility module to help debug Python scripts
-
---
-File: utilsDebug.py
-
-Overview:  Python module to supply functions to help debug Python
-   scripts.
-Gotchas:   None.
-Copyright: None.
---
-"""
-
-# Python modules:
-import sys
-
-# Third party modules:
-
-# In-house modules:
-
-# Instantiations:
-
-#-
-# Details: Class to implement simple stack function trace. Instantiation the
-#  class as the first function you want to trace. Example:
-#  obj = utilsDebug.CDebugFnVerbose("validate_arguments()")
-# Gotchas: This class will not work in properly in a multi-threaded
-#  environment.
-# Authors: Illya Rudkin 28/11/2013.
-# Changes: None.
-#--
-
-
-class CD

[Lldb-commits] [PATCH] D69016: [lldb] move more things from python to cmake

2019-10-16 Thread Haibo Huang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1d4a40751ff3: [lldb] move more things from python to cmake 
(authored by hhb).

Changed prior to commit:
  https://reviews.llvm.org/D69016?vs=225151&id=225270#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69016/new/

https://reviews.llvm.org/D69016

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/finishSwigPythonLLDB.py

Index: lldb/scripts/Python/finishSwigPythonLLDB.py
===
--- lldb/scripts/Python/finishSwigPythonLLDB.py
+++ lldb/scripts/Python/finishSwigPythonLLDB.py
@@ -74,56 +74,6 @@
 strErrMsgCopySixPyFailed = "Unable to copy '%s' to '%s'"
 
 
-def is_debug_interpreter():
-return hasattr(sys, 'gettotalrefcount')
-
-#++---
-# Details:  Copy files needed by lldb/macosx/heap.py to build libheap.dylib.
-# Args: vDictArgs   - (R) Program input parameters.
-#   vstrFrameworkPythonDir  - (R) Python framework directory.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def macosx_copy_file_for_heap(vDictArgs, vstrFrameworkPythonDir):
-dbg = utilsDebug.CDebugFnVerbose(
-"Python script macosx_copy_file_for_heap()")
-bOk = True
-strMsg = ""
-
-eOSType = utilsOsType.determine_os_type()
-if eOSType != utilsOsType.EnumOsType.Darwin:
-return (bOk, strMsg)
-
-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 = os.path.normpath(vDictArgs["--srcRoot"])
-strSrc = os.path.join(
-strRoot,
-"examples",
-"darwin",
-"heap_find",
-"heap",
-"heap_find.cpp")
-shutil.copy(strSrc, strHeapDir)
-strSrc = os.path.join(
-strRoot,
-"examples",
-"darwin",
-"heap_find",
-"heap",
-"Makefile")
-shutil.copy(strSrc, strHeapDir)
-
-return (bOk, strMsg)
-
 #++---
 # Details:  Create Python packages and Python __init__ files.
 # Args: vDictArgs   - (R) Program input parameters.
@@ -198,142 +148,6 @@
 
 return (bOk, strMsg)
 
-#++---
-# Details:  Copy the lldb.py file into the lldb package directory and rename
-#   to __init_.py.
-# Args: vDictArgs   - (R) Program input parameters.
-#   vstrFrameworkPythonDir  - (R) Python framework directory.
-#   vstrCfgBldDir   - (R) Config directory path.
-# Returns:  Bool - True = function success, False = failure.
-#   Str - Error description on task failure.
-# Throws:   None.
-#--
-
-
-def copy_lldbpy_file_to_lldb_pkg_dir(
-vDictArgs,
-vstrFrameworkPythonDir,
-vstrCfgBldDir):
-dbg = utilsDebug.CDebugFnVerbose(
-"Python script copy_lldbpy_file_to_lldb_pkg_dir()")
-bOk = True
-bDbg = "-d" in vDictArgs
-strMsg = ""
-
-strSrc = os.path.join(vstrCfgBldDir, "lldb.py")
-strSrc = os.path.normcase(strSrc)
-strDst = os.path.join(vstrFrameworkPythonDir, "__init__.py")
-strDst = os.path.normcase(strDst)
-
-if not os.path.exists(strSrc):
-strMsg = strErrMsgLLDBPyFileNotNotFound % strSrc
-return (bOk, strMsg)
-
-try:
-if bDbg:
-print((strMsgCopyLLDBPy % (strSrc, strDst)))
-shutil.copyfile(strSrc, strDst)
-except IOError as e:
-bOk = False
-strMsg = "I/O error(%d): %s %s" % (e.errno,
-   e.strerror, strErrMsgCpLldbpy)
-if e.errno == 2:
-strMsg += " Src:'%s' Dst:'%s'" % (strSrc, strDst)
-except:
-bOk = False
-strMsg = strErrMsgUnexpected % sys.exec_info()[0]
-
-return (bOk, strMsg)
-
-
-def copy_six(vDictArgs, vstrFrameworkPythonDir):
-dbg = utilsDebug.CDebugFnVerbose("Python script copy_six()")
-bDbg = "-d" in vDictArgs
-bOk = True
-strMsg = ""
-site_packages_dir = os.path.dirname(vstrFrameworkPythonDir)
-six_module_filename = "six.py"
-src_file = os.path.join(
-vDictArgs['--srcRoot'],
-"third_party",
-"Python",
-"module",
-"six",
-six_module_filename)
-src_file = os.path.normpath(src_file)
-target = os.path.join(site_packages_dir, six_module_filename)
-
-if bDbg:
-print((strMsgCopySixPy % (src_file, target)))
-try:
-shutil.copyfile(src_file, target)
-except:
-bOk = False
-strMsg = strErrMsgCopySixPyFailed

[Lldb-commits] [PATCH] D69019: [lldb] move package generation from python to cmake

2019-10-25 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

In D69019#1721867 , @labath wrote:

> I'm sorry, this dropped off my radar. The only question I have here is about 
> the createPythonInit.py script. If we're moving stuff to cmake, I am 
> wondering if we shouldn't move that thing too? It doesn't look like the code 
> is doing anything which would be hard to replicate in cmake. WDYT ?


I didn't find a good way to generate file using cmake at build time... Did I 
miss something?

The closest way I see is to create a new .cmake script with file(WRITE ...) in 
it. And invoke cmake to run this new script at build time. But that doesn't 
seem much better than this simple python script.

In my opinion, python is better than cmake for string processing. As long as we 
don't reinvent too many cmake functionality in python, it is not a problem to 
have a small python script...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69019/new/

https://reviews.llvm.org/D69019



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69019: [lldb] move package generation from python to cmake

2019-10-27 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

In D69019#1722063 , @labath wrote:

> Right. I see what you mean.
>
> But... does this have to happen at build time? Since the list of files is 
> already known at configuration time, you should be able to generate the files 
> in the "cmake" step (but still leave the copying for the build step, so that 
> any changes to the files are reflected in rebuilds).
>
> (I'm not insisting on that -- I think that the current patch is already much 
> better than what we had before. If you think that the python script is better 
> than that, feel free to say so.)


That could be done... Except that the path of these files can be determined at 
build time, at least for multi-configuration generators. So we may need to 
write them to a temporary path at configuration time, and copy them to the 
right Debug / Release directory at build time.

Yea let's use python for now... 😊


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69019/new/

https://reviews.llvm.org/D69019



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69019: [lldb] move package generation from python to cmake

2019-10-28 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 226781.
hhb added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69019/new/

https://reviews.llvm.org/D69019

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/createPythonInit.py
  lldb/scripts/Python/finishSwigPythonLLDB.py
  lldb/scripts/finishSwigWrapperClasses.py
  lldb/scripts/utilsArgsParse.py
  lldb/scripts/utilsDebug.py
  lldb/scripts/utilsOsType.py

Index: lldb/scripts/utilsOsType.py
===
--- lldb/scripts/utilsOsType.py
+++ /dev/null
@@ -1,103 +0,0 @@
-""" Utility module to determine the OS Python running on
-
---
-File: utilsOsType.py
-
-Overview:   Python module to supply functions and an enumeration to
-help determine the platform type, bit size and OS currently
-being used.
---
-
-"""
-
-# Python modules:
-import sys  # Provide system information
-
-# Third party modules:
-
-# In-house modules:
-
-# Instantiations:
-
-# Enumerations:
-#-
-# Details:  Class to implement a 'C' style enumeration type.
-# Gotchas:  None.
-# Authors:  Illya Rudkin 28/11/2013.
-# Changes:  None.
-#--
-if sys.version_info.major >= 3:
-from enum import Enum
-
-class EnumOsType(Enum):
-Unknown = 0
-Darwin = 1
-FreeBSD = 2
-Linux = 3
-NetBSD = 4
-OpenBSD = 5
-Windows = 6
-kFreeBSD = 7
-else:
-class EnumOsType(object):
-values = ["Unknown",
-  "Darwin",
-  "FreeBSD",
-  "Linux",
-  "NetBSD",
-  "OpenBSD",
-  "Windows",
-  "kFreeBSD"]
-
-class __metaclass__(type):
-#++
-# Details:  Fn acts as an enumeration.
-# Args: vName - (R) Enumeration to match.
-# Returns:  Int - Matching enumeration/index.
-# Throws:   None.
-#--
-
-def __getattr__(cls, vName):
-return cls.values.index(vName)
-
-#++---
-# Details:  Reverse fast lookup of the values list.
-# Args: vI - (R) Index / enumeration.
-# Returns:  Str - text description matching enumeration.
-# Throws:   None.
-#--
-def name_of(cls, vI):
-return EnumOsType.values[vI]
-
-#-
-#-
-#-
-
-#++---
-# Details:  Determine what operating system is currently running on.
-# Args: None.
-# Returns:  EnumOsType - The OS type being used ATM.
-# Throws:   None.
-#--
-
-
-def determine_os_type():
-eOSType = EnumOsType.Unknown
-
-strOS = sys.platform
-if strOS == "darwin":
-eOSType = EnumOsType.Darwin
-elif strOS.startswith("freebsd"):
-eOSType = EnumOsType.FreeBSD
-elif strOS.startswith("linux"):
-eOSType = EnumOsType.Linux
-elif strOS.startswith("netbsd"):
-eOSType = EnumOsType.NetBSD
-elif strOS.startswith("openbsd"):
-eOSType = EnumOsType.OpenBSD
-elif strOS == "win32":
-eOSType = EnumOsType.Windows
-elif strOS.startswith("gnukfreebsd"):
-eOSType = EnumOsType.kFreeBSD
-
-return eOSType
Index: lldb/scripts/utilsDebug.py
===
--- lldb/scripts/utilsDebug.py
+++ /dev/null
@@ -1,125 +0,0 @@
-""" Utility module to help debug Python scripts
-
---
-File: utilsDebug.py
-
-Overview:  Python module to supply functions to help debug Python
-   scripts.
-Gotchas:   None.
-Copyright: None.
---
-"""
-
-# Python modules:
-import sys
-
-# Third party modules:
-
-# In-house modules:
-
-# Instantiations:
-
-#-
-# Details: Class to implement simple stack function trace. Instantiation the
-#  class as the first function you want to trace. Example:
-#  obj = utilsDebug.CDebugFnVerbose("validate_arguments()")
-# Gotchas: This class will not work in properly in a multi-threaded
-#  environment.
-# Authors: Illya Rudkin 28/11/2013.
-# Changes: None.
-#--
-
-
-class CD

[Lldb-commits] [PATCH] D69019: [lldb] move package generation from python to cmake

2019-10-28 Thread Haibo Huang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG99046b873f7f: [lldb] move package generation from python to 
cmake (authored by hhb).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69019/new/

https://reviews.llvm.org/D69019

Files:
  lldb/CMakeLists.txt
  lldb/scripts/Python/createPythonInit.py
  lldb/scripts/Python/finishSwigPythonLLDB.py
  lldb/scripts/finishSwigWrapperClasses.py
  lldb/scripts/utilsArgsParse.py
  lldb/scripts/utilsDebug.py
  lldb/scripts/utilsOsType.py

Index: lldb/scripts/utilsOsType.py
===
--- lldb/scripts/utilsOsType.py
+++ /dev/null
@@ -1,103 +0,0 @@
-""" Utility module to determine the OS Python running on
-
---
-File: utilsOsType.py
-
-Overview:   Python module to supply functions and an enumeration to
-help determine the platform type, bit size and OS currently
-being used.
---
-
-"""
-
-# Python modules:
-import sys  # Provide system information
-
-# Third party modules:
-
-# In-house modules:
-
-# Instantiations:
-
-# Enumerations:
-#-
-# Details:  Class to implement a 'C' style enumeration type.
-# Gotchas:  None.
-# Authors:  Illya Rudkin 28/11/2013.
-# Changes:  None.
-#--
-if sys.version_info.major >= 3:
-from enum import Enum
-
-class EnumOsType(Enum):
-Unknown = 0
-Darwin = 1
-FreeBSD = 2
-Linux = 3
-NetBSD = 4
-OpenBSD = 5
-Windows = 6
-kFreeBSD = 7
-else:
-class EnumOsType(object):
-values = ["Unknown",
-  "Darwin",
-  "FreeBSD",
-  "Linux",
-  "NetBSD",
-  "OpenBSD",
-  "Windows",
-  "kFreeBSD"]
-
-class __metaclass__(type):
-#++
-# Details:  Fn acts as an enumeration.
-# Args: vName - (R) Enumeration to match.
-# Returns:  Int - Matching enumeration/index.
-# Throws:   None.
-#--
-
-def __getattr__(cls, vName):
-return cls.values.index(vName)
-
-#++---
-# Details:  Reverse fast lookup of the values list.
-# Args: vI - (R) Index / enumeration.
-# Returns:  Str - text description matching enumeration.
-# Throws:   None.
-#--
-def name_of(cls, vI):
-return EnumOsType.values[vI]
-
-#-
-#-
-#-
-
-#++---
-# Details:  Determine what operating system is currently running on.
-# Args: None.
-# Returns:  EnumOsType - The OS type being used ATM.
-# Throws:   None.
-#--
-
-
-def determine_os_type():
-eOSType = EnumOsType.Unknown
-
-strOS = sys.platform
-if strOS == "darwin":
-eOSType = EnumOsType.Darwin
-elif strOS.startswith("freebsd"):
-eOSType = EnumOsType.FreeBSD
-elif strOS.startswith("linux"):
-eOSType = EnumOsType.Linux
-elif strOS.startswith("netbsd"):
-eOSType = EnumOsType.NetBSD
-elif strOS.startswith("openbsd"):
-eOSType = EnumOsType.OpenBSD
-elif strOS == "win32":
-eOSType = EnumOsType.Windows
-elif strOS.startswith("gnukfreebsd"):
-eOSType = EnumOsType.kFreeBSD
-
-return eOSType
Index: lldb/scripts/utilsDebug.py
===
--- lldb/scripts/utilsDebug.py
+++ /dev/null
@@ -1,125 +0,0 @@
-""" Utility module to help debug Python scripts
-
---
-File: utilsDebug.py
-
-Overview:  Python module to supply functions to help debug Python
-   scripts.
-Gotchas:   None.
-Copyright: None.
---
-"""
-
-# Python modules:
-import sys
-
-# Third party modules:
-
-# In-house modules:
-
-# Instantiations:
-
-#-
-# Details: Class to implement simple stack function trace. Instantiation the
-#  class as the first function you want to trace. Example:
-#  obj = utilsDebug.CDebugFnVerbose("validate_arguments()")
-# Gotchas: This class will not work in properly in a multi-

[Lldb-commits] [PATCH] D69589: [lldb] Refactor all POST_BUILD commands into targets

2019-10-29 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.

This makes all dependencies correct.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69589

Files:
  lldb/CMakeLists.txt
  lldb/scripts/CMakeLists.txt

Index: lldb/scripts/CMakeLists.txt
===
--- lldb/scripts/CMakeLists.txt
+++ lldb/scripts/CMakeLists.txt
@@ -54,4 +54,5 @@
   ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
   ${CMAKE_CURRENT_BINARY_DIR}/lldb.py
 )
+set_target_properties(swig_wrapper PROPERTIES FOLDER "lldb misc")
 
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -99,77 +99,105 @@
 
   # Add a Post-Build Event to copy over Python files and create the symlink
   # to liblldb.so for the Python API(hardlink on Windows).
-  add_custom_target(finish_swig ALL VERBATIM
-COMMAND ${CMAKE_COMMAND} -E make_directory ${lldb_python_build_path}
-DEPENDS ${lldb_scripts_dir}/lldb.py
-COMMENT "Python script sym-linking LLDB Python API")
+  add_custom_target(lldb_python_packages ALL
+COMMENT "Copy over Python files and create symlinks for LLDB Python API.")
+  set_target_properties(lldb_python_packages PROPERTIES FOLDER "lldb misc")
+
+  function(add_copy_file_target Name)
+cmake_parse_arguments(ARG "" "DEST_DIR;DEST_FILE_NAME" "FILES" ${ARGN})
+add_custom_command(OUTPUT ${ARG_DEST_DIR} VERBATIM
+  COMMAND ${CMAKE_COMMAND} -E make_directory ${ARG_DEST_DIR})
+foreach(src_file ${ARG_FILES})
+  if(ARG_DEST_FILE_NAME)
+set(file_name ${ARG_DEST_FILE_NAME})
+  else()
+get_filename_component(file_name ${src_file} NAME)
+  endif()
+  set(dest_file ${ARG_DEST_DIR}/${file_name})
+  list(APPEND DEST_FILES ${dest_file})
+  add_custom_command(OUTPUT ${dest_file} VERBATIM
+COMMAND ${CMAKE_COMMAND} -E copy ${src_file} ${dest_file}
+DEPENDS ${ARG_DEST_DIR} ${src_file})
+endforeach()
+add_custom_target(${Name} DEPENDS ${DEST_FILES} ${ARG_DEST_DIR})
+  endfunction()
 
   if(NOT LLDB_USE_SYSTEM_SIX)
-add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
-  COMMAND ${CMAKE_COMMAND} -E copy
-"${LLDB_SOURCE_DIR}/third_party/Python/module/six/six.py"
-"${lldb_python_build_path}/../six.py")
+add_copy_file_target(lldb_python_six
+  FILES"${LLDB_SOURCE_DIR}/third_party/Python/module/six/six.py"
+  DEST_DIR "${lldb_python_build_path}/..")
+add_dependencies(lldb_python_packages lldb_python_six)
   endif()
 
-  add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
-COMMAND ${CMAKE_COMMAND} -E copy
-  "${lldb_scripts_dir}/lldb.py"
-  "${lldb_python_build_path}/__init__.py")
+  add_copy_file_target(lldb_python_init
+FILES  "${lldb_scripts_dir}/lldb.py"
+DEST_DIR   "${lldb_python_build_path}"
+DEST_FILE_NAME "__init__.py")
+  add_dependencies(lldb_python_packages lldb_python_init)
 
   if(APPLE)
-SET(lldb_python_heap_dir "${lldb_python_build_path}/macosx/heap")
-add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
-  COMMAND ${CMAKE_COMMAND} -E make_directory ${lldb_python_heap_dir}
-  COMMAND ${CMAKE_COMMAND} -E copy
-"${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/heap_find.cpp"
-"${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/Makefile"
-${lldb_python_heap_dir})
+add_copy_file_target(lldb_python_heap
+  FILES"${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/heap_find.cpp"
+   "${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/Makefile"
+  DEST_DIR "${lldb_python_build_path}/macosx/heap")
+add_dependencies(lldb_python_packages lldb_python_heap)
   endif()
 
-  function(create_python_package target pkg_dir)
+  add_copy_file_target(lldb_python_embeded_interpreter
+FILES"${LLDB_SOURCE_DIR}/source/Interpreter/embedded_interpreter.py"
+DEST_DIR "${lldb_python_build_path}")
+  add_dependencies(lldb_python_packages lldb_python_embeded_interpreter)
+
+  function(add_lldb_python_package_target Name PKG_DIR)
 cmake_parse_arguments(ARG "" "" "FILES" ${ARGN})
-if(ARG_FILES)
-  set(copy_cmd COMMAND ${CMAKE_COMMAND} -E copy ${ARG_FILES} ${pkg_dir})
-endif()
-add_custom_command(TARGET ${target} POST_BUILD VERBATIM
-  COMMAND ${CMAKE_COMMAND} -E make_directory ${pkg_dir}
-  ${copy_cmd}
+set(ABS_PKG_DIR "${lldb_python_build_path}/${PKG_DIR}")
+add_copy_file_target("${Name}_srcs" FILES ${ARG_FILES} DEST_DIR ${ABS_PKG_DIR})
+add_custom_command(OUTPUT "${ABS_PKG_DIR}/__init__.py" VERBATIM
   COMMAND ${PYTHON_EXECUTABLE} "${LLDB_SOURCE_DIR}/scripts/Python/createPythonInit.py"
-${pkg_dir} ${ARG_FILES}
-  WORKING_DIRECTORY ${lldb_python_build_path})
+${PKG_DIR} ${ARG_FILES}
+  WORKING_DIRECTORY ${lldb_python_build_path}
+  DEPENDS "${Na

[Lldb-commits] [PATCH] D69589: [lldb] Refactor all POST_BUILD commands into targets

2019-10-30 Thread Haibo Huang via Phabricator via lldb-commits
hhb marked an inline comment as done.
hhb added a comment.

In D69589#1726812 , @labath wrote:

> This looks reasonable to me. I'm just wondering, now that these are separate 
> targets, I guess that means they can be run in random order, right? Will that 
> cause any problems, for instance when creating a package and its subpackage 
> (formatters and formatters/cpp maybe)?


I try to avoid that problem by creating directory every time. Other than that I 
don't think there's any dependencies between two subpackages...

But in general, yes, that's something we should be careful of...




Comment at: lldb/CMakeLists.txt:133
+  add_copy_file_target(lldb_python_init
+FILES  "${lldb_scripts_dir}/lldb.py"
+DEST_DIR   "${lldb_python_build_path}"

labath wrote:
> Would it be possible to just make the swig step place this file into the 
> correct place directly?
The difficulty is that, there is a config time path dependency like this:

swig_wrapper -> liblldb -> finish_swig (renamed to lldb_python_packages in this 
change)

Where liblldb uses the path of LLDBWrapPython.cpp in swig_wrapper. And here we 
reference the path of liblldb, to calculate the right path for python packages.

That means when swig_wrapper is created, we don't have a good way to figure out 
the right path for python packages and put the file there directly.

The best way to solve this is to hard code liblldb path for framework build. 
I.e. replace line 92 here:

```
get_target_property(liblldb_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
```

With something more constant. This removes the liblldb -> finish_swig 
dependency. Then all the code here can be moved to scripts/CMakeLists.txt (I 
think they belong there better anyway). And swig_wrapper can get access to 
python package path.

The only question is whether we can / should "predict" liblldb path for 
framework... I'll look more into this. But it probably deserves a separate 
change.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69589/new/

https://reviews.llvm.org/D69589



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69630: [lldb] Record framework build path and use it everywhere

2019-10-30 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
hhb added a reviewer: labath.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.

This avoids config time dependencies on liblldb. And enables other
refactoring.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69630

Files:
  lldb/cmake/modules/AddLLDB.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/cmake/modules/LLDBFramework.cmake
  lldb/test/API/CMakeLists.txt
  lldb/tools/debugserver/source/CMakeLists.txt
  lldb/tools/driver/CMakeLists.txt
  lldb/tools/lldb-vscode/CMakeLists.txt

Index: lldb/tools/lldb-vscode/CMakeLists.txt
===
--- lldb/tools/lldb-vscode/CMakeLists.txt
+++ lldb/tools/lldb-vscode/CMakeLists.txt
@@ -33,10 +33,9 @@
 if(LLDB_BUILD_FRAMEWORK)
   # In the build-tree, we know the exact path to the framework directory.
   # The installed framework can be in different locations.
-  get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
   lldb_setup_rpaths(lldb-vscode
 BUILD_RPATH
-  "${framework_build_dir}"
+  "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}"
 INSTALL_RPATH
   "@loader_path/../../../SharedFrameworks"
   "@loader_path/../../System/Library/PrivateFrameworks"
Index: lldb/tools/driver/CMakeLists.txt
===
--- lldb/tools/driver/CMakeLists.txt
+++ lldb/tools/driver/CMakeLists.txt
@@ -33,10 +33,9 @@
 if(LLDB_BUILD_FRAMEWORK)
   # In the build-tree, we know the exact path to the framework directory.
   # The installed framework can be in different locations.
-  get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
   lldb_setup_rpaths(lldb
 BUILD_RPATH
-  "${framework_build_dir}"
+  "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}"
 INSTALL_RPATH
   "@loader_path/../../../SharedFrameworks"
   "@loader_path/../../System/Library/PrivateFrameworks"
Index: lldb/tools/debugserver/source/CMakeLists.txt
===
--- lldb/tools/debugserver/source/CMakeLists.txt
+++ lldb/tools/debugserver/source/CMakeLists.txt
@@ -219,8 +219,7 @@
 set(pass_entitlements --entitlements ${entitlements})
   endif()
 
-  get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
-  set(copy_location ${framework_build_dir}/LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources/debugserver)
+  set(copy_location ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources/debugserver)
 
   add_custom_command(TARGET debugserver POST_BUILD
 COMMAND ${CMAKE_COMMAND} -E
Index: lldb/test/API/CMakeLists.txt
===
--- lldb/test/API/CMakeLists.txt
+++ lldb/test/API/CMakeLists.txt
@@ -107,8 +107,7 @@
 
 if(CMAKE_HOST_APPLE)
   if(LLDB_BUILD_FRAMEWORK)
-get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
-list(APPEND LLDB_TEST_COMMON_ARGS --framework ${framework_build_dir}/LLDB.framework)
+list(APPEND LLDB_TEST_COMMON_ARGS --framework ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework)
   endif()
 
   # Use the same identity for testing
Index: lldb/cmake/modules/LLDBFramework.cmake
===
--- lldb/cmake/modules/LLDBFramework.cmake
+++ lldb/cmake/modules/LLDBFramework.cmake
@@ -1,10 +1,4 @@
-# Path relative to the root binary directory
-get_filename_component(
-  framework_target_dir ${LLDB_FRAMEWORK_BUILD_DIR} ABSOLUTE
-  BASE_DIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}
-)
-
-message(STATUS "LLDB.framework: build path is '${framework_target_dir}'")
+message(STATUS "LLDB.framework: build path is '${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}'")
 message(STATUS "LLDB.framework: install path is '${LLDB_FRAMEWORK_INSTALL_DIR}'")
 message(STATUS "LLDB.framework: resources subdirectory is 'Versions/${LLDB_FRAMEWORK_VERSION}/Resources'")
 
@@ -15,7 +9,7 @@
 
   OUTPUT_NAME LLDB
   VERSION ${LLDB_VERSION}
-  LIBRARY_OUTPUT_DIRECTORY ${framework_target_dir}
+  LIBRARY_OUTPUT_DIRECTORY ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
 
   # Compatibility version
   SOVERSION "1.0.0"
@@ -29,8 +23,8 @@
 # Used in llvm_add_library() to set default output directories for multi-config
 # generators. Overwrite to account for special framework output directory.
 set_output_directory(liblldb
-  BINARY_DIR ${framework_target_dir}
-  LIBRARY_DIR ${framework_target_dir}
+  BINARY_DIR ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
+  LIBRARY_DIR ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
 )
 
 lldb_add_post_install_steps_darwin(liblldb ${LLDB_FRAMEWORK_INSTALL_DIR})
@@ -51,7 +45,7 @@
 add_custom_command(TARGET liblldb POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E create_symlink
   Versions/Current/Headers
-  ${framework_target_dir}/LLDB.framework/Headers
+  ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Headers
   COMMENT "

[Lldb-commits] [PATCH] D69630: [lldb] Record framework build path and use it everywhere

2019-10-30 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 227145.
hhb added a comment.

Update one more place


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69630/new/

https://reviews.llvm.org/D69630

Files:
  lldb/CMakeLists.txt
  lldb/cmake/modules/AddLLDB.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/cmake/modules/LLDBFramework.cmake
  lldb/test/API/CMakeLists.txt
  lldb/tools/debugserver/source/CMakeLists.txt
  lldb/tools/driver/CMakeLists.txt
  lldb/tools/lldb-vscode/CMakeLists.txt

Index: lldb/tools/lldb-vscode/CMakeLists.txt
===
--- lldb/tools/lldb-vscode/CMakeLists.txt
+++ lldb/tools/lldb-vscode/CMakeLists.txt
@@ -33,10 +33,9 @@
 if(LLDB_BUILD_FRAMEWORK)
   # In the build-tree, we know the exact path to the framework directory.
   # The installed framework can be in different locations.
-  get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
   lldb_setup_rpaths(lldb-vscode
 BUILD_RPATH
-  "${framework_build_dir}"
+  "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}"
 INSTALL_RPATH
   "@loader_path/../../../SharedFrameworks"
   "@loader_path/../../System/Library/PrivateFrameworks"
Index: lldb/tools/driver/CMakeLists.txt
===
--- lldb/tools/driver/CMakeLists.txt
+++ lldb/tools/driver/CMakeLists.txt
@@ -33,10 +33,9 @@
 if(LLDB_BUILD_FRAMEWORK)
   # In the build-tree, we know the exact path to the framework directory.
   # The installed framework can be in different locations.
-  get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
   lldb_setup_rpaths(lldb
 BUILD_RPATH
-  "${framework_build_dir}"
+  "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}"
 INSTALL_RPATH
   "@loader_path/../../../SharedFrameworks"
   "@loader_path/../../System/Library/PrivateFrameworks"
Index: lldb/tools/debugserver/source/CMakeLists.txt
===
--- lldb/tools/debugserver/source/CMakeLists.txt
+++ lldb/tools/debugserver/source/CMakeLists.txt
@@ -219,8 +219,7 @@
 set(pass_entitlements --entitlements ${entitlements})
   endif()
 
-  get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
-  set(copy_location ${framework_build_dir}/LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources/debugserver)
+  set(copy_location ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources/debugserver)
 
   add_custom_command(TARGET debugserver POST_BUILD
 COMMAND ${CMAKE_COMMAND} -E
Index: lldb/test/API/CMakeLists.txt
===
--- lldb/test/API/CMakeLists.txt
+++ lldb/test/API/CMakeLists.txt
@@ -107,8 +107,7 @@
 
 if(CMAKE_HOST_APPLE)
   if(LLDB_BUILD_FRAMEWORK)
-get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
-list(APPEND LLDB_TEST_COMMON_ARGS --framework ${framework_build_dir}/LLDB.framework)
+list(APPEND LLDB_TEST_COMMON_ARGS --framework ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework)
   endif()
 
   # Use the same identity for testing
Index: lldb/cmake/modules/LLDBFramework.cmake
===
--- lldb/cmake/modules/LLDBFramework.cmake
+++ lldb/cmake/modules/LLDBFramework.cmake
@@ -1,10 +1,4 @@
-# Path relative to the root binary directory
-get_filename_component(
-  framework_target_dir ${LLDB_FRAMEWORK_BUILD_DIR} ABSOLUTE
-  BASE_DIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}
-)
-
-message(STATUS "LLDB.framework: build path is '${framework_target_dir}'")
+message(STATUS "LLDB.framework: build path is '${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}'")
 message(STATUS "LLDB.framework: install path is '${LLDB_FRAMEWORK_INSTALL_DIR}'")
 message(STATUS "LLDB.framework: resources subdirectory is 'Versions/${LLDB_FRAMEWORK_VERSION}/Resources'")
 
@@ -15,7 +9,7 @@
 
   OUTPUT_NAME LLDB
   VERSION ${LLDB_VERSION}
-  LIBRARY_OUTPUT_DIRECTORY ${framework_target_dir}
+  LIBRARY_OUTPUT_DIRECTORY ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
 
   # Compatibility version
   SOVERSION "1.0.0"
@@ -29,8 +23,8 @@
 # Used in llvm_add_library() to set default output directories for multi-config
 # generators. Overwrite to account for special framework output directory.
 set_output_directory(liblldb
-  BINARY_DIR ${framework_target_dir}
-  LIBRARY_DIR ${framework_target_dir}
+  BINARY_DIR ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
+  LIBRARY_DIR ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
 )
 
 lldb_add_post_install_steps_darwin(liblldb ${LLDB_FRAMEWORK_INSTALL_DIR})
@@ -51,7 +45,7 @@
 add_custom_command(TARGET liblldb POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E create_symlink
   Versions/Current/Headers
-  ${framework_target_dir}/LLDB.framework/Headers
+  ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Headers
   COMMENT "LLDB.framework: create Headers symlink"
 )

[Lldb-commits] [PATCH] D69630: [lldb] Record framework build path and use it everywhere

2019-10-30 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 227172.
hhb added a comment.

Fix


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69630/new/

https://reviews.llvm.org/D69630

Files:
  lldb/CMakeLists.txt
  lldb/cmake/modules/AddLLDB.cmake
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/cmake/modules/LLDBFramework.cmake
  lldb/test/API/CMakeLists.txt
  lldb/tools/debugserver/source/CMakeLists.txt
  lldb/tools/driver/CMakeLists.txt
  lldb/tools/lldb-vscode/CMakeLists.txt

Index: lldb/tools/lldb-vscode/CMakeLists.txt
===
--- lldb/tools/lldb-vscode/CMakeLists.txt
+++ lldb/tools/lldb-vscode/CMakeLists.txt
@@ -33,10 +33,9 @@
 if(LLDB_BUILD_FRAMEWORK)
   # In the build-tree, we know the exact path to the framework directory.
   # The installed framework can be in different locations.
-  get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
   lldb_setup_rpaths(lldb-vscode
 BUILD_RPATH
-  "${framework_build_dir}"
+  "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}"
 INSTALL_RPATH
   "@loader_path/../../../SharedFrameworks"
   "@loader_path/../../System/Library/PrivateFrameworks"
Index: lldb/tools/driver/CMakeLists.txt
===
--- lldb/tools/driver/CMakeLists.txt
+++ lldb/tools/driver/CMakeLists.txt
@@ -33,10 +33,9 @@
 if(LLDB_BUILD_FRAMEWORK)
   # In the build-tree, we know the exact path to the framework directory.
   # The installed framework can be in different locations.
-  get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
   lldb_setup_rpaths(lldb
 BUILD_RPATH
-  "${framework_build_dir}"
+  "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}"
 INSTALL_RPATH
   "@loader_path/../../../SharedFrameworks"
   "@loader_path/../../System/Library/PrivateFrameworks"
Index: lldb/tools/debugserver/source/CMakeLists.txt
===
--- lldb/tools/debugserver/source/CMakeLists.txt
+++ lldb/tools/debugserver/source/CMakeLists.txt
@@ -219,8 +219,7 @@
 set(pass_entitlements --entitlements ${entitlements})
   endif()
 
-  get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
-  set(copy_location ${framework_build_dir}/LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources/debugserver)
+  set(copy_location ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources/debugserver)
 
   add_custom_command(TARGET debugserver POST_BUILD
 COMMAND ${CMAKE_COMMAND} -E
Index: lldb/test/API/CMakeLists.txt
===
--- lldb/test/API/CMakeLists.txt
+++ lldb/test/API/CMakeLists.txt
@@ -107,8 +107,7 @@
 
 if(CMAKE_HOST_APPLE)
   if(LLDB_BUILD_FRAMEWORK)
-get_target_property(framework_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY)
-list(APPEND LLDB_TEST_COMMON_ARGS --framework ${framework_build_dir}/LLDB.framework)
+list(APPEND LLDB_TEST_COMMON_ARGS --framework ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework)
   endif()
 
   # Use the same identity for testing
Index: lldb/cmake/modules/LLDBFramework.cmake
===
--- lldb/cmake/modules/LLDBFramework.cmake
+++ lldb/cmake/modules/LLDBFramework.cmake
@@ -1,10 +1,4 @@
-# Path relative to the root binary directory
-get_filename_component(
-  framework_target_dir ${LLDB_FRAMEWORK_BUILD_DIR} ABSOLUTE
-  BASE_DIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}
-)
-
-message(STATUS "LLDB.framework: build path is '${framework_target_dir}'")
+message(STATUS "LLDB.framework: build path is '${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}'")
 message(STATUS "LLDB.framework: install path is '${LLDB_FRAMEWORK_INSTALL_DIR}'")
 message(STATUS "LLDB.framework: resources subdirectory is 'Versions/${LLDB_FRAMEWORK_VERSION}/Resources'")
 
@@ -15,7 +9,7 @@
 
   OUTPUT_NAME LLDB
   VERSION ${LLDB_VERSION}
-  LIBRARY_OUTPUT_DIRECTORY ${framework_target_dir}
+  LIBRARY_OUTPUT_DIRECTORY ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
 
   # Compatibility version
   SOVERSION "1.0.0"
@@ -29,8 +23,8 @@
 # Used in llvm_add_library() to set default output directories for multi-config
 # generators. Overwrite to account for special framework output directory.
 set_output_directory(liblldb
-  BINARY_DIR ${framework_target_dir}
-  LIBRARY_DIR ${framework_target_dir}
+  BINARY_DIR ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
+  LIBRARY_DIR ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}
 )
 
 lldb_add_post_install_steps_darwin(liblldb ${LLDB_FRAMEWORK_INSTALL_DIR})
@@ -51,7 +45,7 @@
 add_custom_command(TARGET liblldb POST_BUILD
   COMMAND ${CMAKE_COMMAND} -E create_symlink
   Versions/Current/Headers
-  ${framework_target_dir}/LLDB.framework/Headers
+  ${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Headers
   COMMENT "LLDB.framework: create Headers symlink"
 )
 
Index: lldb/cma

[Lldb-commits] [PATCH] D69589: [lldb] Refactor all POST_BUILD commands into targets

2019-10-30 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 227204.
hhb added a comment.

When creating symlink, make the target depends on relative target path. So that 
if the target file doesn't exist, the build will fail.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69589/new/

https://reviews.llvm.org/D69589

Files:
  lldb/CMakeLists.txt
  lldb/scripts/CMakeLists.txt

Index: lldb/scripts/CMakeLists.txt
===
--- lldb/scripts/CMakeLists.txt
+++ lldb/scripts/CMakeLists.txt
@@ -54,4 +54,5 @@
   ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
   ${CMAKE_CURRENT_BINARY_DIR}/lldb.py
 )
+set_target_properties(swig_wrapper PROPERTIES FOLDER "lldb misc")
 
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -103,77 +103,105 @@
 
   # Add a Post-Build Event to copy over Python files and create the symlink
   # to liblldb.so for the Python API(hardlink on Windows).
-  add_custom_target(finish_swig ALL VERBATIM
-COMMAND ${CMAKE_COMMAND} -E make_directory ${lldb_python_build_path}
-DEPENDS ${lldb_scripts_dir}/lldb.py
-COMMENT "Python script sym-linking LLDB Python API")
+  add_custom_target(lldb_python_packages ALL
+COMMENT "Copy over Python files and create symlinks for LLDB Python API.")
+  set_target_properties(lldb_python_packages PROPERTIES FOLDER "lldb misc")
+
+  function(add_copy_file_target Name)
+cmake_parse_arguments(ARG "" "DEST_DIR;DEST_FILE_NAME" "FILES" ${ARGN})
+add_custom_command(OUTPUT ${ARG_DEST_DIR} VERBATIM
+  COMMAND ${CMAKE_COMMAND} -E make_directory ${ARG_DEST_DIR})
+foreach(src_file ${ARG_FILES})
+  if(ARG_DEST_FILE_NAME)
+set(file_name ${ARG_DEST_FILE_NAME})
+  else()
+get_filename_component(file_name ${src_file} NAME)
+  endif()
+  set(dest_file ${ARG_DEST_DIR}/${file_name})
+  list(APPEND DEST_FILES ${dest_file})
+  add_custom_command(OUTPUT ${dest_file} VERBATIM
+COMMAND ${CMAKE_COMMAND} -E copy ${src_file} ${dest_file}
+DEPENDS ${ARG_DEST_DIR} ${src_file})
+endforeach()
+add_custom_target(${Name} DEPENDS ${DEST_FILES} ${ARG_DEST_DIR})
+  endfunction()
 
   if(NOT LLDB_USE_SYSTEM_SIX)
-add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
-  COMMAND ${CMAKE_COMMAND} -E copy
-"${LLDB_SOURCE_DIR}/third_party/Python/module/six/six.py"
-"${lldb_python_build_path}/../six.py")
+add_copy_file_target(lldb_python_six
+  FILES"${LLDB_SOURCE_DIR}/third_party/Python/module/six/six.py"
+  DEST_DIR "${lldb_python_build_path}/..")
+add_dependencies(lldb_python_packages lldb_python_six)
   endif()
 
-  add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
-COMMAND ${CMAKE_COMMAND} -E copy
-  "${lldb_scripts_dir}/lldb.py"
-  "${lldb_python_build_path}/__init__.py")
+  add_copy_file_target(lldb_python_init
+FILES  "${lldb_scripts_dir}/lldb.py"
+DEST_DIR   "${lldb_python_build_path}"
+DEST_FILE_NAME "__init__.py")
+  add_dependencies(lldb_python_packages lldb_python_init)
 
   if(APPLE)
-SET(lldb_python_heap_dir "${lldb_python_build_path}/macosx/heap")
-add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
-  COMMAND ${CMAKE_COMMAND} -E make_directory ${lldb_python_heap_dir}
-  COMMAND ${CMAKE_COMMAND} -E copy
-"${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/heap_find.cpp"
-"${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/Makefile"
-${lldb_python_heap_dir})
+add_copy_file_target(lldb_python_heap
+  FILES"${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/heap_find.cpp"
+   "${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/Makefile"
+  DEST_DIR "${lldb_python_build_path}/macosx/heap")
+add_dependencies(lldb_python_packages lldb_python_heap)
   endif()
 
-  function(create_python_package target pkg_dir)
+  add_copy_file_target(lldb_python_embeded_interpreter
+FILES"${LLDB_SOURCE_DIR}/source/Interpreter/embedded_interpreter.py"
+DEST_DIR "${lldb_python_build_path}")
+  add_dependencies(lldb_python_packages lldb_python_embeded_interpreter)
+
+  function(add_lldb_python_package_target Name PKG_DIR)
 cmake_parse_arguments(ARG "" "" "FILES" ${ARGN})
-if(ARG_FILES)
-  set(copy_cmd COMMAND ${CMAKE_COMMAND} -E copy ${ARG_FILES} ${pkg_dir})
-endif()
-add_custom_command(TARGET ${target} POST_BUILD VERBATIM
-  COMMAND ${CMAKE_COMMAND} -E make_directory ${pkg_dir}
-  ${copy_cmd}
+set(ABS_PKG_DIR "${lldb_python_build_path}/${PKG_DIR}")
+add_copy_file_target("${Name}_srcs" FILES ${ARG_FILES} DEST_DIR ${ABS_PKG_DIR})
+add_custom_command(OUTPUT "${ABS_PKG_DIR}/__init__.py" VERBATIM
   COMMAND ${PYTHON_EXECUTABLE} "${LLDB_SOURCE_DIR}/scripts/Python/createPythonInit.py"
-${pkg_dir} ${ARG_FILES}
-  WORKING_DIRECTORY ${lldb

[Lldb-commits] [PATCH] D69589: [lldb] Refactor all POST_BUILD commands into targets

2019-11-04 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

In D69589#1731782 , @aadsm wrote:

> I fixed this locally by doing this (this fix doesn't really feel good but not 
> sure what's the best way to do it):


I found it confusing too. So finish_swig should depends on liblldb, because at 
least for windows, liblldb has to be exist before copying to python package 
path. And lldb correctly depends on both of them.

Then install-liblldb depends on liblldb. Which doesn't guarantee the build of 
finish_swig... Indeed your change may be the only way out...

This issue should be there before all recent changes. I'm not sure why it works 
before. Maybe by luck?

Do you want to upload a patch?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69589/new/

https://reviews.llvm.org/D69589



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69589: [lldb] Refactor all POST_BUILD commands into targets

2019-11-04 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

Alternatively we should not depends on install-liblldb to install python 
packages, but have a install command similar to what we did below for other 
platforms.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69589/new/

https://reviews.llvm.org/D69589



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69589: [lldb] Refactor all POST_BUILD commands into targets

2019-11-04 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

See D68370 . We probably need to do the same 
thing for darwin...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69589/new/

https://reviews.llvm.org/D69589



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69834: [lldb] Add a install target for lldb python on darwin

2019-11-04 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
hhb added a reviewer: aadsm.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.

Similar to D68370  but for darwin framework 
build.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69834

Files:
  lldb/CMakeLists.txt


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -216,18 +216,21 @@
   # Ensure we do the python post-build step when building lldb.
   add_dependencies(lldb finish_swig)
 
-  if(NOT LLDB_BUILD_FRAMEWORK)
-# Install the LLDB python module
-add_custom_target(lldb-python-scripts)
-add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
-DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
-COMPONENT lldb-python-scripts)
-if (NOT LLVM_ENABLE_IDE)
-  add_llvm_install_targets(install-lldb-python-scripts
-   COMPONENT lldb-python-scripts
-   DEPENDS lldb-python-scripts)
-endif()
+  # Install the LLDB python module
+  if(LLDB_BUILD_FRAMEWORK)
+set(LLDB_PYTHON_INSTALL_PATH 
${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Resources/Python)
+  else()
+set(LLDB_PYTHON_INSTALL_PATH ${LLDB_PYTHON_RELATIVE_PATH})
+  endif()
+  add_custom_target(lldb-python-scripts)
+  add_dependencies(lldb-python-scripts finish_swig)
+  install(DIRECTORY ${lldb_python_build_path}/../
+  DESTINATION ${LLDB_PYTHON_INSTALL_PATH}
+  COMPONENT lldb-python-scripts)
+  if (NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-lldb-python-scripts
+ COMPONENT lldb-python-scripts
+ DEPENDS finish_swig)
   endif()
 
   # Add a Post-Build Event to copy the custom Python DLL to the lldb binaries 
dir so that Windows can find it when launching


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -216,18 +216,21 @@
   # Ensure we do the python post-build step when building lldb.
   add_dependencies(lldb finish_swig)
 
-  if(NOT LLDB_BUILD_FRAMEWORK)
-# Install the LLDB python module
-add_custom_target(lldb-python-scripts)
-add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
-DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
-COMPONENT lldb-python-scripts)
-if (NOT LLVM_ENABLE_IDE)
-  add_llvm_install_targets(install-lldb-python-scripts
-   COMPONENT lldb-python-scripts
-   DEPENDS lldb-python-scripts)
-endif()
+  # Install the LLDB python module
+  if(LLDB_BUILD_FRAMEWORK)
+set(LLDB_PYTHON_INSTALL_PATH ${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Resources/Python)
+  else()
+set(LLDB_PYTHON_INSTALL_PATH ${LLDB_PYTHON_RELATIVE_PATH})
+  endif()
+  add_custom_target(lldb-python-scripts)
+  add_dependencies(lldb-python-scripts finish_swig)
+  install(DIRECTORY ${lldb_python_build_path}/../
+  DESTINATION ${LLDB_PYTHON_INSTALL_PATH}
+  COMPONENT lldb-python-scripts)
+  if (NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-lldb-python-scripts
+ COMPONENT lldb-python-scripts
+ DEPENDS finish_swig)
   endif()
 
   # Add a Post-Build Event to copy the custom Python DLL to the lldb binaries dir so that Windows can find it when launching
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69589: [lldb] Refactor all POST_BUILD commands into targets

2019-11-04 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

Sent D69834 . Haven't get a chance to test but 
you can see the idea...

Also please add lldb-python-scripts to your LLVM_DISTRIBUTION_COMPONENTS when 
testing.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69589/new/

https://reviews.llvm.org/D69589



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69834: [lldb] Add a install target for lldb python on darwin

2019-11-05 Thread Haibo Huang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6a79e083a0d1: [lldb] Add a install target for lldb python on 
darwin (authored by hhb).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69834/new/

https://reviews.llvm.org/D69834

Files:
  lldb/CMakeLists.txt


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -216,18 +216,21 @@
   # Ensure we do the python post-build step when building lldb.
   add_dependencies(lldb finish_swig)
 
-  if(NOT LLDB_BUILD_FRAMEWORK)
-# Install the LLDB python module
-add_custom_target(lldb-python-scripts)
-add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
-DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
-COMPONENT lldb-python-scripts)
-if (NOT LLVM_ENABLE_IDE)
-  add_llvm_install_targets(install-lldb-python-scripts
-   COMPONENT lldb-python-scripts
-   DEPENDS lldb-python-scripts)
-endif()
+  # Install the LLDB python module
+  if(LLDB_BUILD_FRAMEWORK)
+set(LLDB_PYTHON_INSTALL_PATH 
${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Resources/Python)
+  else()
+set(LLDB_PYTHON_INSTALL_PATH ${LLDB_PYTHON_RELATIVE_PATH})
+  endif()
+  add_custom_target(lldb-python-scripts)
+  add_dependencies(lldb-python-scripts finish_swig)
+  install(DIRECTORY ${lldb_python_build_path}/../
+  DESTINATION ${LLDB_PYTHON_INSTALL_PATH}
+  COMPONENT lldb-python-scripts)
+  if (NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-lldb-python-scripts
+ COMPONENT lldb-python-scripts
+ DEPENDS lldb-python-scripts)
   endif()
 
   # Add a Post-Build Event to copy the custom Python DLL to the lldb binaries 
dir so that Windows can find it when launching


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -216,18 +216,21 @@
   # Ensure we do the python post-build step when building lldb.
   add_dependencies(lldb finish_swig)
 
-  if(NOT LLDB_BUILD_FRAMEWORK)
-# Install the LLDB python module
-add_custom_target(lldb-python-scripts)
-add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
-DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
-COMPONENT lldb-python-scripts)
-if (NOT LLVM_ENABLE_IDE)
-  add_llvm_install_targets(install-lldb-python-scripts
-   COMPONENT lldb-python-scripts
-   DEPENDS lldb-python-scripts)
-endif()
+  # Install the LLDB python module
+  if(LLDB_BUILD_FRAMEWORK)
+set(LLDB_PYTHON_INSTALL_PATH ${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Resources/Python)
+  else()
+set(LLDB_PYTHON_INSTALL_PATH ${LLDB_PYTHON_RELATIVE_PATH})
+  endif()
+  add_custom_target(lldb-python-scripts)
+  add_dependencies(lldb-python-scripts finish_swig)
+  install(DIRECTORY ${lldb_python_build_path}/../
+  DESTINATION ${LLDB_PYTHON_INSTALL_PATH}
+  COMPONENT lldb-python-scripts)
+  if (NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-lldb-python-scripts
+ COMPONENT lldb-python-scripts
+ DEPENDS lldb-python-scripts)
   endif()
 
   # Add a Post-Build Event to copy the custom Python DLL to the lldb binaries dir so that Windows can find it when launching
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69834: [lldb] Add a install target for lldb python on darwin

2019-11-05 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 227956.
hhb added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69834/new/

https://reviews.llvm.org/D69834

Files:
  lldb/CMakeLists.txt


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -216,18 +216,21 @@
   # Ensure we do the python post-build step when building lldb.
   add_dependencies(lldb finish_swig)
 
-  if(NOT LLDB_BUILD_FRAMEWORK)
-# Install the LLDB python module
-add_custom_target(lldb-python-scripts)
-add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
-DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
-COMPONENT lldb-python-scripts)
-if (NOT LLVM_ENABLE_IDE)
-  add_llvm_install_targets(install-lldb-python-scripts
-   COMPONENT lldb-python-scripts
-   DEPENDS lldb-python-scripts)
-endif()
+  # Install the LLDB python module
+  if(LLDB_BUILD_FRAMEWORK)
+set(LLDB_PYTHON_INSTALL_PATH 
${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Resources/Python)
+  else()
+set(LLDB_PYTHON_INSTALL_PATH ${LLDB_PYTHON_RELATIVE_PATH})
+  endif()
+  add_custom_target(lldb-python-scripts)
+  add_dependencies(lldb-python-scripts finish_swig)
+  install(DIRECTORY ${lldb_python_build_path}/../
+  DESTINATION ${LLDB_PYTHON_INSTALL_PATH}
+  COMPONENT lldb-python-scripts)
+  if (NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-lldb-python-scripts
+ COMPONENT lldb-python-scripts
+ DEPENDS lldb-python-scripts)
   endif()
 
   # Add a Post-Build Event to copy the custom Python DLL to the lldb binaries 
dir so that Windows can find it when launching


Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -216,18 +216,21 @@
   # Ensure we do the python post-build step when building lldb.
   add_dependencies(lldb finish_swig)
 
-  if(NOT LLDB_BUILD_FRAMEWORK)
-# Install the LLDB python module
-add_custom_target(lldb-python-scripts)
-add_dependencies(lldb-python-scripts finish_swig)
-install(DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/
-DESTINATION ${LLDB_PYTHON_RELATIVE_PATH}
-COMPONENT lldb-python-scripts)
-if (NOT LLVM_ENABLE_IDE)
-  add_llvm_install_targets(install-lldb-python-scripts
-   COMPONENT lldb-python-scripts
-   DEPENDS lldb-python-scripts)
-endif()
+  # Install the LLDB python module
+  if(LLDB_BUILD_FRAMEWORK)
+set(LLDB_PYTHON_INSTALL_PATH ${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Resources/Python)
+  else()
+set(LLDB_PYTHON_INSTALL_PATH ${LLDB_PYTHON_RELATIVE_PATH})
+  endif()
+  add_custom_target(lldb-python-scripts)
+  add_dependencies(lldb-python-scripts finish_swig)
+  install(DIRECTORY ${lldb_python_build_path}/../
+  DESTINATION ${LLDB_PYTHON_INSTALL_PATH}
+  COMPONENT lldb-python-scripts)
+  if (NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-lldb-python-scripts
+ COMPONENT lldb-python-scripts
+ DEPENDS lldb-python-scripts)
   endif()
 
   # Add a Post-Build Event to copy the custom Python DLL to the lldb binaries dir so that Windows can find it when launching
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69589: [lldb] Refactor all POST_BUILD commands into targets

2019-11-05 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 227958.
hhb added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69589/new/

https://reviews.llvm.org/D69589

Files:
  lldb/CMakeLists.txt
  lldb/scripts/CMakeLists.txt

Index: lldb/scripts/CMakeLists.txt
===
--- lldb/scripts/CMakeLists.txt
+++ lldb/scripts/CMakeLists.txt
@@ -54,4 +54,5 @@
   ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
   ${CMAKE_CURRENT_BINARY_DIR}/lldb.py
 )
+set_target_properties(swig_wrapper PROPERTIES FOLDER "lldb misc")
 
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -103,77 +103,105 @@
 
   # Add a Post-Build Event to copy over Python files and create the symlink
   # to liblldb.so for the Python API(hardlink on Windows).
-  add_custom_target(finish_swig ALL VERBATIM
-COMMAND ${CMAKE_COMMAND} -E make_directory ${lldb_python_build_path}
-DEPENDS ${lldb_scripts_dir}/lldb.py
-COMMENT "Python script sym-linking LLDB Python API")
+  add_custom_target(finish_swig ALL
+COMMENT "Copy over Python files and create symlinks for LLDB Python API.")
+  set_target_properties(finish_swig PROPERTIES FOLDER "lldb misc")
+
+  function(add_copy_file_target Name)
+cmake_parse_arguments(ARG "" "DEST_DIR;DEST_FILE_NAME" "FILES" ${ARGN})
+add_custom_command(OUTPUT ${ARG_DEST_DIR} VERBATIM
+  COMMAND ${CMAKE_COMMAND} -E make_directory ${ARG_DEST_DIR})
+foreach(src_file ${ARG_FILES})
+  if(ARG_DEST_FILE_NAME)
+set(file_name ${ARG_DEST_FILE_NAME})
+  else()
+get_filename_component(file_name ${src_file} NAME)
+  endif()
+  set(dest_file ${ARG_DEST_DIR}/${file_name})
+  list(APPEND DEST_FILES ${dest_file})
+  add_custom_command(OUTPUT ${dest_file} VERBATIM
+COMMAND ${CMAKE_COMMAND} -E copy ${src_file} ${dest_file}
+DEPENDS ${ARG_DEST_DIR} ${src_file})
+endforeach()
+add_custom_target(${Name} DEPENDS ${DEST_FILES} ${ARG_DEST_DIR})
+  endfunction()
 
   if(NOT LLDB_USE_SYSTEM_SIX)
-add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
-  COMMAND ${CMAKE_COMMAND} -E copy
-"${LLDB_SOURCE_DIR}/third_party/Python/module/six/six.py"
-"${lldb_python_build_path}/../six.py")
+add_copy_file_target(lldb_python_six
+  FILES"${LLDB_SOURCE_DIR}/third_party/Python/module/six/six.py"
+  DEST_DIR "${lldb_python_build_path}/..")
+add_dependencies(finish_swig lldb_python_six)
   endif()
 
-  add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
-COMMAND ${CMAKE_COMMAND} -E copy
-  "${lldb_scripts_dir}/lldb.py"
-  "${lldb_python_build_path}/__init__.py")
+  add_copy_file_target(lldb_python_init
+FILES  "${lldb_scripts_dir}/lldb.py"
+DEST_DIR   "${lldb_python_build_path}"
+DEST_FILE_NAME "__init__.py")
+  add_dependencies(finish_swig lldb_python_init)
 
   if(APPLE)
-SET(lldb_python_heap_dir "${lldb_python_build_path}/macosx/heap")
-add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
-  COMMAND ${CMAKE_COMMAND} -E make_directory ${lldb_python_heap_dir}
-  COMMAND ${CMAKE_COMMAND} -E copy
-"${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/heap_find.cpp"
-"${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/Makefile"
-${lldb_python_heap_dir})
+add_copy_file_target(lldb_python_heap
+  FILES"${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/heap_find.cpp"
+   "${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/Makefile"
+  DEST_DIR "${lldb_python_build_path}/macosx/heap")
+add_dependencies(finish_swig lldb_python_heap)
   endif()
 
-  function(create_python_package target pkg_dir)
+  add_copy_file_target(lldb_python_embeded_interpreter
+FILES"${LLDB_SOURCE_DIR}/source/Interpreter/embedded_interpreter.py"
+DEST_DIR "${lldb_python_build_path}")
+  add_dependencies(finish_swig lldb_python_embeded_interpreter)
+
+  function(add_lldb_python_package_target Name PKG_DIR)
 cmake_parse_arguments(ARG "" "" "FILES" ${ARGN})
-if(ARG_FILES)
-  set(copy_cmd COMMAND ${CMAKE_COMMAND} -E copy ${ARG_FILES} ${pkg_dir})
-endif()
-add_custom_command(TARGET ${target} POST_BUILD VERBATIM
-  COMMAND ${CMAKE_COMMAND} -E make_directory ${pkg_dir}
-  ${copy_cmd}
+set(ABS_PKG_DIR "${lldb_python_build_path}/${PKG_DIR}")
+add_copy_file_target("${Name}_srcs" FILES ${ARG_FILES} DEST_DIR ${ABS_PKG_DIR})
+add_custom_command(OUTPUT "${ABS_PKG_DIR}/__init__.py" VERBATIM
   COMMAND ${PYTHON_EXECUTABLE} "${LLDB_SOURCE_DIR}/scripts/Python/createPythonInit.py"
-${pkg_dir} ${ARG_FILES}
-  WORKING_DIRECTORY ${lldb_python_build_path})
+${PKG_DIR} ${ARG_FILES}
+  WORKING_DIRECTORY ${lldb_python_build_path}
+  DEPENDS "${Name}_srcs")
+add_custom_target(${Name} DEPENDS "${ABS_P

[Lldb-commits] [PATCH] D69589: [lldb] Refactor all POST_BUILD commands into targets

2019-11-05 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 227974.
hhb added a comment.

Fix some naming


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69589/new/

https://reviews.llvm.org/D69589

Files:
  lldb/CMakeLists.txt
  lldb/scripts/CMakeLists.txt

Index: lldb/scripts/CMakeLists.txt
===
--- lldb/scripts/CMakeLists.txt
+++ lldb/scripts/CMakeLists.txt
@@ -54,4 +54,5 @@
   ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
   ${CMAKE_CURRENT_BINARY_DIR}/lldb.py
 )
+set_target_properties(swig_wrapper PROPERTIES FOLDER "lldb misc")
 
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -103,77 +103,105 @@
 
   # Add a Post-Build Event to copy over Python files and create the symlink
   # to liblldb.so for the Python API(hardlink on Windows).
-  add_custom_target(finish_swig ALL VERBATIM
-COMMAND ${CMAKE_COMMAND} -E make_directory ${lldb_python_build_path}
-DEPENDS ${lldb_scripts_dir}/lldb.py
-COMMENT "Python script sym-linking LLDB Python API")
+  add_custom_target(finish_swig ALL
+COMMENT "Copy over Python files and create symlinks for LLDB Python API.")
+  set_target_properties(finish_swig PROPERTIES FOLDER "lldb misc")
+
+  function(add_copy_file_target name)
+cmake_parse_arguments(ARG "" "DEST_DIR;DEST_FILE_NAME" "FILES" ${ARGN})
+add_custom_command(OUTPUT ${ARG_DEST_DIR} VERBATIM
+  COMMAND ${CMAKE_COMMAND} -E make_directory ${ARG_DEST_DIR})
+foreach(src_file ${ARG_FILES})
+  if(ARG_DEST_FILE_NAME)
+set(file_name ${ARG_DEST_FILE_NAME})
+  else()
+get_filename_component(file_name ${src_file} NAME)
+  endif()
+  set(dest_file ${ARG_DEST_DIR}/${file_name})
+  list(APPEND DEST_FILES ${dest_file})
+  add_custom_command(OUTPUT ${dest_file} VERBATIM
+COMMAND ${CMAKE_COMMAND} -E copy ${src_file} ${dest_file}
+DEPENDS ${ARG_DEST_DIR} ${src_file})
+endforeach()
+add_custom_target(${name} DEPENDS ${DEST_FILES} ${ARG_DEST_DIR})
+  endfunction()
 
   if(NOT LLDB_USE_SYSTEM_SIX)
-add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
-  COMMAND ${CMAKE_COMMAND} -E copy
-"${LLDB_SOURCE_DIR}/third_party/Python/module/six/six.py"
-"${lldb_python_build_path}/../six.py")
+add_copy_file_target(lldb_python_six
+  FILES"${LLDB_SOURCE_DIR}/third_party/Python/module/six/six.py"
+  DEST_DIR "${lldb_python_build_path}/..")
+add_dependencies(finish_swig lldb_python_six)
   endif()
 
-  add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
-COMMAND ${CMAKE_COMMAND} -E copy
-  "${lldb_scripts_dir}/lldb.py"
-  "${lldb_python_build_path}/__init__.py")
+  add_copy_file_target(lldb_python_init
+FILES  "${lldb_scripts_dir}/lldb.py"
+DEST_DIR   "${lldb_python_build_path}"
+DEST_FILE_NAME "__init__.py")
+  add_dependencies(finish_swig lldb_python_init)
 
   if(APPLE)
-SET(lldb_python_heap_dir "${lldb_python_build_path}/macosx/heap")
-add_custom_command(TARGET finish_swig POST_BUILD VERBATIM
-  COMMAND ${CMAKE_COMMAND} -E make_directory ${lldb_python_heap_dir}
-  COMMAND ${CMAKE_COMMAND} -E copy
-"${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/heap_find.cpp"
-"${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/Makefile"
-${lldb_python_heap_dir})
+add_copy_file_target(lldb_python_heap
+  FILES"${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/heap_find.cpp"
+   "${LLDB_SOURCE_DIR}/examples/darwin/heap_find/heap/Makefile"
+  DEST_DIR "${lldb_python_build_path}/macosx/heap")
+add_dependencies(finish_swig lldb_python_heap)
   endif()
 
-  function(create_python_package target pkg_dir)
+  add_copy_file_target(lldb_python_embeded_interpreter
+FILES"${LLDB_SOURCE_DIR}/source/Interpreter/embedded_interpreter.py"
+DEST_DIR "${lldb_python_build_path}")
+  add_dependencies(finish_swig lldb_python_embeded_interpreter)
+
+  function(add_lldb_python_package_target name pkg_dir)
 cmake_parse_arguments(ARG "" "" "FILES" ${ARGN})
-if(ARG_FILES)
-  set(copy_cmd COMMAND ${CMAKE_COMMAND} -E copy ${ARG_FILES} ${pkg_dir})
-endif()
-add_custom_command(TARGET ${target} POST_BUILD VERBATIM
-  COMMAND ${CMAKE_COMMAND} -E make_directory ${pkg_dir}
-  ${copy_cmd}
+set(ABS_PKG_DIR "${lldb_python_build_path}/${pkg_dir}")
+add_copy_file_target("${name}_srcs" FILES ${ARG_FILES} DEST_DIR ${ABS_PKG_DIR})
+add_custom_command(OUTPUT "${ABS_PKG_DIR}/__init__.py" VERBATIM
   COMMAND ${PYTHON_EXECUTABLE} "${LLDB_SOURCE_DIR}/scripts/Python/createPythonInit.py"
 ${pkg_dir} ${ARG_FILES}
-  WORKING_DIRECTORY ${lldb_python_build_path})
+  WORKING_DIRECTORY ${lldb_python_build_path}
+  DEPENDS "${name}_srcs")
+add_custom_target(${name} DEPENDS "${ABS_PKG_DIR}/__init__.py" "${

[Lldb-commits] [PATCH] D69589: [lldb] Refactor all POST_BUILD commands into targets

2019-11-05 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

In D69589#1733567 , @aadsm wrote:

> @hhb fwiw, I still get the same error with this diff (after applying it on 
> top of D69834 ). But D69834 
>  by itself works great!


Hmmm this change should not break it again... I rebased and cleaned up a 
little. Can you help try again?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69589/new/

https://reviews.llvm.org/D69589



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69589: [lldb] Refactor all POST_BUILD commands into targets

2019-11-06 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

In D69589#1734818 , @aadsm wrote:

> @hhb I just did, and get the same error as well :(
>  `ninja: error: 'bin/LLDB.framework/LLDB', needed by 
> 'bin/LLDB.framework/Resources/Python/lldb/_lldb.so', missing and no known 
> rule to make it`


Thanks for the testing. It is interesting and I can reproduce now by build, 
remove LLDB.framework and build again.

LLDB.framework/LLDB symlink is not created by any target I can find. I tried 
liblldb or lldb. Seems only a full build will create it? I'm not familiar with 
framework build. Will spend some time to look into it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69589/new/

https://reviews.llvm.org/D69589



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D69931: Add cmake variables to specify a python framework to ship with lldb

2019-11-07 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

In D69931#1736607 , @labath wrote:

> In principle, this looks pretty similar to D67942 
> , and my opinion on it is the same -- I 
> don't think we should be in the business of trying to package the transitive 
> set of lldb dependencies. I think the lldb install target should install the 
> stuff that it has built itself, and the rest should be up to some higher 
> level packaging system.


+1 it will never end if we go down this way.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69931/new/

https://reviews.llvm.org/D69931



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D65362: [CMake] Move project() call to main CMake file

2019-07-26 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.

The main CMake file don't have a project() call. In this case, cmake will run a 
dummy project(Project ) at the very beginning. Even before 
cmake_minimum_required. And a series of compiler detections will be triggered.

This is problematic if we depends on some policy to be set. E.g. CMP0056. 
try_compile will fail before we have a chance to do anything.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65362

Files:
  lldb/CMakeLists.txt
  lldb/cmake/modules/LLDBStandalone.cmake


Index: lldb/cmake/modules/LLDBStandalone.cmake
===
--- lldb/cmake/modules/LLDBStandalone.cmake
+++ lldb/cmake/modules/LLDBStandalone.cmake
@@ -1,5 +1,3 @@
-project(lldb)
-
 option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 
'install' target." OFF)
 
 find_package(LLVM REQUIRED CONFIG HINTS "${LLVM_DIR}" NO_CMAKE_FIND_ROOT_PATH)
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -14,6 +14,7 @@
 # If we are not building as part of LLVM, build LLDB as a standalone project,
 # using LLVM as an external library.
 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+  project(lldb)
   include(LLDBStandalone)
 endif()
 


Index: lldb/cmake/modules/LLDBStandalone.cmake
===
--- lldb/cmake/modules/LLDBStandalone.cmake
+++ lldb/cmake/modules/LLDBStandalone.cmake
@@ -1,5 +1,3 @@
-project(lldb)
-
 option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
 
 find_package(LLVM REQUIRED CONFIG HINTS "${LLVM_DIR}" NO_CMAKE_FIND_ROOT_PATH)
Index: lldb/CMakeLists.txt
===
--- lldb/CMakeLists.txt
+++ lldb/CMakeLists.txt
@@ -14,6 +14,7 @@
 # If we are not building as part of LLVM, build LLDB as a standalone project,
 # using LLVM as an external library.
 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+  project(lldb)
   include(LLDBStandalone)
 endif()
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D65362: [CMake] Move project() call to main CMake file

2019-07-29 Thread Haibo Huang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL367273: [CMake] Move project() call to main CMake file 
(authored by hhb, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D65362?vs=212037&id=212245#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65362/new/

https://reviews.llvm.org/D65362

Files:
  lldb/trunk/CMakeLists.txt
  lldb/trunk/cmake/modules/LLDBStandalone.cmake


Index: lldb/trunk/cmake/modules/LLDBStandalone.cmake
===
--- lldb/trunk/cmake/modules/LLDBStandalone.cmake
+++ lldb/trunk/cmake/modules/LLDBStandalone.cmake
@@ -1,5 +1,3 @@
-project(lldb)
-
 option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 
'install' target." OFF)
 
 find_package(LLVM REQUIRED CONFIG HINTS "${LLVM_DIR}" NO_CMAKE_FIND_ROOT_PATH)
Index: lldb/trunk/CMakeLists.txt
===
--- lldb/trunk/CMakeLists.txt
+++ lldb/trunk/CMakeLists.txt
@@ -14,6 +14,7 @@
 # If we are not building as part of LLVM, build LLDB as a standalone project,
 # using LLVM as an external library.
 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+  project(lldb)
   include(LLDBStandalone)
 endif()
 


Index: lldb/trunk/cmake/modules/LLDBStandalone.cmake
===
--- lldb/trunk/cmake/modules/LLDBStandalone.cmake
+++ lldb/trunk/cmake/modules/LLDBStandalone.cmake
@@ -1,5 +1,3 @@
-project(lldb)
-
 option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
 
 find_package(LLVM REQUIRED CONFIG HINTS "${LLVM_DIR}" NO_CMAKE_FIND_ROOT_PATH)
Index: lldb/trunk/CMakeLists.txt
===
--- lldb/trunk/CMakeLists.txt
+++ lldb/trunk/CMakeLists.txt
@@ -14,6 +14,7 @@
 # If we are not building as part of LLVM, build LLDB as a standalone project,
 # using LLVM as an external library.
 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+  project(lldb)
   include(LLDBStandalone)
 endif()
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D65691: Various build fixes for lldb on MinGW

2019-08-02 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
Herald added subscribers: lldb-commits, mstorsjo.
Herald added a project: LLDB.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65691

Files:
  lldb/include/lldb/Host/windows/PosixApi.h
  lldb/source/Host/windows/FileSystem.cpp
  lldb/source/Initialization/SystemInitializerCommon.cpp
  
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/tools/driver/Platform.h
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -50,7 +50,9 @@
 #include "VSCode.h"
 
 #if defined(_WIN32)
+#ifndef PATH_MAX
 #define PATH_MAX MAX_PATH
+#endif
 typedef int socklen_t;
 constexpr const char *dev_null_path = "nul";
 
Index: lldb/tools/lldb-vscode/VSCode.cpp
===
--- lldb/tools/lldb-vscode/VSCode.cpp
+++ lldb/tools/lldb-vscode/VSCode.cpp
@@ -16,7 +16,9 @@
 
 #if defined(_WIN32)
 #define NOMINMAX
+#ifndef __MINGW32__
 #include 
+#endif // __MINGW32__
 #include 
 #include 
 #endif
Index: lldb/tools/driver/Platform.h
===
--- lldb/tools/driver/Platform.h
+++ lldb/tools/driver/Platform.h
@@ -15,6 +15,10 @@
 #if defined(_MSC_VER)
 #include 
 #endif
+#if defined(__MINGW32__)
+// pid_t
+#include 
+#endif
 #include "lldb/Host/windows/windows.h"
 #include 
 
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -16,6 +16,10 @@
 #include 
 #include 
 #endif
+#ifdef __MINGW32__
+// usleep
+#include 
+#endif
 #include 
 #include 
 #include 
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
@@ -16,6 +16,11 @@
 #include 
 #include 
 
+#ifdef __MINGW32__
+// usleep
+#include 
+#endif
+
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Threading.h"
 
Index: lldb/source/Initialization/SystemInitializerCommon.cpp
===
--- lldb/source/Initialization/SystemInitializerCommon.cpp
+++ lldb/source/Initialization/SystemInitializerCommon.cpp
@@ -25,6 +25,8 @@
 #if defined(_WIN32)
 #include "Plugins/Process/Windows/Common/ProcessWindowsLog.h"
 #include "lldb/Host/windows/windows.h"
+// for _CrtSetReportMode
+#include 
 #endif
 
 #include "llvm/Support/TargetSelect.h"
Index: lldb/source/Host/windows/FileSystem.cpp
===
--- lldb/source/Host/windows/FileSystem.cpp
+++ lldb/source/Host/windows/FileSystem.cpp
@@ -12,6 +12,9 @@
 #include 
 #include 
 
+// For _SH_*
+#include 
+
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/windows/AutoHandle.h"
 #include "lldb/Host/windows/PosixApi.h"
Index: lldb/include/lldb/Host/windows/PosixApi.h
===
--- lldb/include/lldb/Host/windows/PosixApi.h
+++ lldb/include/lldb/Host/windows/PosixApi.h
@@ -45,6 +45,15 @@
 #define S_IRWXG 0
 #define S_IRWXO 0
 
+#ifdef __MINGW32__
+// pyconfig.h typedefs this.  We require python headers to be included before
+// any LLDB headers, but there's no way to prevent python's pid_t definition
+// from leaking, so this is the best option.
+#ifndef NO_PID_T
+#include 
+#endif
+#endif // __MINGW32__
+
 #ifdef _MSC_VER
 
 // PRIxxx format macros for printf()
@@ -80,6 +89,8 @@
 char *strcasestr(const char *s, const char *find);
 char *realpath(const char *name, char *resolved);
 
+#ifdef _MSC_VER
+
 int usleep(uint32_t useconds);
 char *basename(char *path);
 char *dirname(char *path);
@@ -87,6 +98,8 @@
 int strcasecmp(const char *s1, const char *s2);
 int strncasecmp(const char *s1, const char *s2, size_t n);
 
+#endif // _MSC_VER
+
 // empty functions
 inline int posix_openpt(int flag) { LLVM_BUILTIN_UNREACHABLE; }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D65691: Various build fixes for lldb on MinGW

2019-08-05 Thread Haibo Huang via Phabricator via lldb-commits
hhb added inline comments.



Comment at: lldb/tools/lldb-vscode/lldb-vscode.cpp:55
 #define PATH_MAX MAX_PATH
+#endif
 typedef int socklen_t;

amccarth wrote:
> Nothing in the rest of this .cpp file uses PATH_MAX, so just delete the 
> `#define` instead of executing it conditionally.
PATH_MAX is used in SendProcessEvent (line 283)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65691/new/

https://reviews.llvm.org/D65691



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D65691: Various build fixes for lldb on MinGW

2019-08-05 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 213448.
hhb marked 4 inline comments as done.
hhb added a comment.

Fix comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65691/new/

https://reviews.llvm.org/D65691

Files:
  lldb/include/lldb/Host/windows/PosixApi.h
  lldb/source/Host/windows/FileSystem.cpp
  lldb/source/Initialization/SystemInitializerCommon.cpp
  lldb/tools/driver/Platform.h
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -50,7 +50,9 @@
 #include "VSCode.h"
 
 #if defined(_WIN32)
+#ifndef PATH_MAX
 #define PATH_MAX MAX_PATH
+#endif
 typedef int socklen_t;
 constexpr const char *dev_null_path = "nul";
 
Index: lldb/tools/lldb-vscode/VSCode.cpp
===
--- lldb/tools/lldb-vscode/VSCode.cpp
+++ lldb/tools/lldb-vscode/VSCode.cpp
@@ -15,8 +15,10 @@
 #include "llvm/Support/FormatVariadic.h"
 
 #if defined(_WIN32)
+#ifndef __MINGW32__
 #define NOMINMAX
 #include 
+#endif // __MINGW32__
 #include 
 #include 
 #endif
Index: lldb/tools/driver/Platform.h
===
--- lldb/tools/driver/Platform.h
+++ lldb/tools/driver/Platform.h
@@ -15,6 +15,9 @@
 #if defined(_MSC_VER)
 #include 
 #endif
+#if HAVE_SYS_TYPES_H
+#include 
+#endif
 #include "lldb/Host/windows/windows.h"
 #include 
 
Index: lldb/source/Initialization/SystemInitializerCommon.cpp
===
--- lldb/source/Initialization/SystemInitializerCommon.cpp
+++ lldb/source/Initialization/SystemInitializerCommon.cpp
@@ -25,6 +25,7 @@
 #if defined(_WIN32)
 #include "Plugins/Process/Windows/Common/ProcessWindowsLog.h"
 #include "lldb/Host/windows/windows.h"
+#include 
 #endif
 
 #include "llvm/Support/TargetSelect.h"
Index: lldb/source/Host/windows/FileSystem.cpp
===
--- lldb/source/Host/windows/FileSystem.cpp
+++ lldb/source/Host/windows/FileSystem.cpp
@@ -8,6 +8,7 @@
 
 #include "lldb/Host/windows/windows.h"
 
+#include 
 #include 
 #include 
 #include 
Index: lldb/include/lldb/Host/windows/PosixApi.h
===
--- lldb/include/lldb/Host/windows/PosixApi.h
+++ lldb/include/lldb/Host/windows/PosixApi.h
@@ -45,6 +45,15 @@
 #define S_IRWXG 0
 #define S_IRWXO 0
 
+#ifdef __MINGW32__
+// pyconfig.h typedefs this.  We require python headers to be included before
+// any LLDB headers, but there's no way to prevent python's pid_t definition
+// from leaking, so this is the best option.
+#ifndef NO_PID_T
+#include 
+#endif
+#endif // __MINGW32__
+
 #ifdef _MSC_VER
 
 // PRIxxx format macros for printf()
@@ -80,6 +89,8 @@
 char *strcasestr(const char *s, const char *find);
 char *realpath(const char *name, char *resolved);
 
+#ifdef _MSC_VER
+
 int usleep(uint32_t useconds);
 char *basename(char *path);
 char *dirname(char *path);
@@ -87,6 +98,8 @@
 int strcasecmp(const char *s1, const char *s2);
 int strncasecmp(const char *s1, const char *s2, size_t n);
 
+#endif // _MSC_VER
+
 // empty functions
 inline int posix_openpt(int flag) { LLVM_BUILTIN_UNREACHABLE; }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D65691: Various build fixes for lldb on MinGW

2019-08-05 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 213505.
hhb added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65691/new/

https://reviews.llvm.org/D65691

Files:
  lldb/include/lldb/Host/windows/PosixApi.h
  lldb/source/Host/windows/FileSystem.cpp
  lldb/source/Initialization/SystemInitializerCommon.cpp
  lldb/tools/driver/Platform.h
  lldb/tools/lldb-vscode/VSCode.cpp
  lldb/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/tools/lldb-vscode/lldb-vscode.cpp
@@ -50,7 +50,9 @@
 #include "VSCode.h"
 
 #if defined(_WIN32)
+#ifndef PATH_MAX
 #define PATH_MAX MAX_PATH
+#endif
 typedef int socklen_t;
 constexpr const char *dev_null_path = "nul";
 
Index: lldb/tools/lldb-vscode/VSCode.cpp
===
--- lldb/tools/lldb-vscode/VSCode.cpp
+++ lldb/tools/lldb-vscode/VSCode.cpp
@@ -15,8 +15,10 @@
 #include "llvm/Support/FormatVariadic.h"
 
 #if defined(_WIN32)
+#ifndef __MINGW32__
 #define NOMINMAX
 #include 
+#endif // __MINGW32__
 #include 
 #include 
 #endif
Index: lldb/tools/driver/Platform.h
===
--- lldb/tools/driver/Platform.h
+++ lldb/tools/driver/Platform.h
@@ -15,6 +15,9 @@
 #if defined(_MSC_VER)
 #include 
 #endif
+#if HAVE_SYS_TYPES_H
+#include 
+#endif
 #include "lldb/Host/windows/windows.h"
 #include 
 
Index: lldb/source/Initialization/SystemInitializerCommon.cpp
===
--- lldb/source/Initialization/SystemInitializerCommon.cpp
+++ lldb/source/Initialization/SystemInitializerCommon.cpp
@@ -25,6 +25,7 @@
 #if defined(_WIN32)
 #include "Plugins/Process/Windows/Common/ProcessWindowsLog.h"
 #include "lldb/Host/windows/windows.h"
+#include 
 #endif
 
 #include "llvm/Support/TargetSelect.h"
Index: lldb/source/Host/windows/FileSystem.cpp
===
--- lldb/source/Host/windows/FileSystem.cpp
+++ lldb/source/Host/windows/FileSystem.cpp
@@ -8,6 +8,7 @@
 
 #include "lldb/Host/windows/windows.h"
 
+#include 
 #include 
 #include 
 #include 
Index: lldb/include/lldb/Host/windows/PosixApi.h
===
--- lldb/include/lldb/Host/windows/PosixApi.h
+++ lldb/include/lldb/Host/windows/PosixApi.h
@@ -45,6 +45,15 @@
 #define S_IRWXG 0
 #define S_IRWXO 0
 
+#ifdef __MINGW32__
+// pyconfig.h typedefs this.  We require python headers to be included before
+// any LLDB headers, but there's no way to prevent python's pid_t definition
+// from leaking, so this is the best option.
+#ifndef NO_PID_T
+#include 
+#endif
+#endif // __MINGW32__
+
 #ifdef _MSC_VER
 
 // PRIxxx format macros for printf()
@@ -80,12 +89,16 @@
 char *strcasestr(const char *s, const char *find);
 char *realpath(const char *name, char *resolved);
 
+#ifdef _MSC_VER
+
 char *basename(char *path);
 char *dirname(char *path);
 
 int strcasecmp(const char *s1, const char *s2);
 int strncasecmp(const char *s1, const char *s2, size_t n);
 
+#endif // _MSC_VER
+
 // empty functions
 inline int posix_openpt(int flag) { LLVM_BUILTIN_UNREACHABLE; }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D65691: Various build fixes for lldb on MinGW

2019-08-06 Thread Haibo Huang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL368069: Various build fixes for lldb on MinGW (authored by 
hhb, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D65691?vs=213505&id=213662#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65691/new/

https://reviews.llvm.org/D65691

Files:
  lldb/trunk/include/lldb/Host/windows/PosixApi.h
  lldb/trunk/source/Host/windows/FileSystem.cpp
  lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
  lldb/trunk/tools/driver/Platform.h
  lldb/trunk/tools/lldb-vscode/VSCode.cpp
  lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp

Index: lldb/trunk/source/Host/windows/FileSystem.cpp
===
--- lldb/trunk/source/Host/windows/FileSystem.cpp
+++ lldb/trunk/source/Host/windows/FileSystem.cpp
@@ -8,6 +8,7 @@
 
 #include "lldb/Host/windows/windows.h"
 
+#include 
 #include 
 #include 
 #include 
Index: lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
===
--- lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
+++ lldb/trunk/source/Initialization/SystemInitializerCommon.cpp
@@ -25,6 +25,7 @@
 #if defined(_WIN32)
 #include "Plugins/Process/Windows/Common/ProcessWindowsLog.h"
 #include "lldb/Host/windows/windows.h"
+#include 
 #endif
 
 #include "llvm/Support/TargetSelect.h"
Index: lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp
===
--- lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp
+++ lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp
@@ -50,7 +50,9 @@
 #include "VSCode.h"
 
 #if defined(_WIN32)
+#ifndef PATH_MAX
 #define PATH_MAX MAX_PATH
+#endif
 typedef int socklen_t;
 constexpr const char *dev_null_path = "nul";
 
Index: lldb/trunk/tools/lldb-vscode/VSCode.cpp
===
--- lldb/trunk/tools/lldb-vscode/VSCode.cpp
+++ lldb/trunk/tools/lldb-vscode/VSCode.cpp
@@ -15,8 +15,10 @@
 #include "llvm/Support/FormatVariadic.h"
 
 #if defined(_WIN32)
+#ifndef __MINGW32__
 #define NOMINMAX
 #include 
+#endif // __MINGW32__
 #include 
 #include 
 #endif
Index: lldb/trunk/tools/driver/Platform.h
===
--- lldb/trunk/tools/driver/Platform.h
+++ lldb/trunk/tools/driver/Platform.h
@@ -15,6 +15,9 @@
 #if defined(_MSC_VER)
 #include 
 #endif
+#if HAVE_SYS_TYPES_H
+#include 
+#endif
 #include "lldb/Host/windows/windows.h"
 #include 
 
Index: lldb/trunk/include/lldb/Host/windows/PosixApi.h
===
--- lldb/trunk/include/lldb/Host/windows/PosixApi.h
+++ lldb/trunk/include/lldb/Host/windows/PosixApi.h
@@ -45,6 +45,15 @@
 #define S_IRWXG 0
 #define S_IRWXO 0
 
+#ifdef __MINGW32__
+// pyconfig.h typedefs this.  We require python headers to be included before
+// any LLDB headers, but there's no way to prevent python's pid_t definition
+// from leaking, so this is the best option.
+#ifndef NO_PID_T
+#include 
+#endif
+#endif // __MINGW32__
+
 #ifdef _MSC_VER
 
 // PRIxxx format macros for printf()
@@ -80,12 +89,16 @@
 char *strcasestr(const char *s, const char *find);
 char *realpath(const char *name, char *resolved);
 
+#ifdef _MSC_VER
+
 char *basename(char *path);
 char *dirname(char *path);
 
 int strcasecmp(const char *s1, const char *s2);
 int strncasecmp(const char *s1, const char *s2, size_t n);
 
+#endif // _MSC_VER
+
 // empty functions
 inline int posix_openpt(int flag) { LLVM_BUILTIN_UNREACHABLE; }
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D65822: Detect HAVE_SYS_TYPES_H in lldb

2019-08-06 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
hhb added a reviewer: labath.
Herald added subscribers: lldb-commits, mgorny.
Herald added a project: LLDB.

After rL368069  I noticed that 
HAVE_SYS_TYPES_H is not defined in
Platform.h, or anywhere else in lldb. This change fixes that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65822

Files:
  lldb/cmake/modules/LLDBGenerateConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/source/Expression/UserExpression.cpp
  lldb/source/Expression/UtilityFunction.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
  lldb/tools/driver/Platform.h

Index: lldb/tools/driver/Platform.h
===
--- lldb/tools/driver/Platform.h
+++ lldb/tools/driver/Platform.h
@@ -9,6 +9,8 @@
 #ifndef lldb_Platform_h_
 #define lldb_Platform_h_
 
+#include "lldb/Host/Config.h"
+
 #if defined(_WIN32)
 
 #include 
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include "ClangUtilityFunction.h"
 #include "ClangExpressionDeclMap.h"
 #include "ClangExpressionParser.h"
@@ -14,6 +16,8 @@
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
+#else
+static_assert(false, "");
 #endif
 
 
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -6,9 +6,13 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
+#else
+static_assert(false, "");
 #endif
 
 #include 
Index: lldb/source/Expression/UtilityFunction.cpp
===
--- lldb/source/Expression/UtilityFunction.cpp
+++ lldb/source/Expression/UtilityFunction.cpp
@@ -6,9 +6,13 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
+#else
+static_assert(false, "");
 #endif
 
 
Index: lldb/source/Expression/UserExpression.cpp
===
--- lldb/source/Expression/UserExpression.cpp
+++ lldb/source/Expression/UserExpression.cpp
@@ -6,9 +6,13 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
+#else
+static_assert(false, "");
 #endif
 
 #include 
Index: lldb/include/lldb/Host/Config.h.cmake
===
--- lldb/include/lldb/Host/Config.h.cmake
+++ lldb/include/lldb/Host/Config.h.cmake
@@ -19,6 +19,8 @@
 
 #define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}"
 
+#cmakedefine01 HAVE_SYS_TYPES_H
+
 #cmakedefine01 HAVE_SYS_EVENT_H
 
 #cmakedefine01 HAVE_PPOLL
Index: lldb/cmake/modules/LLDBGenerateConfig.cmake
===
--- lldb/cmake/modules/LLDBGenerateConfig.cmake
+++ lldb/cmake/modules/LLDBGenerateConfig.cmake
@@ -12,6 +12,7 @@
 check_cxx_symbol_exists(accept4 "sys/socket.h" HAVE_ACCEPT4)
 
 check_include_file(termios.h HAVE_TERMIOS_H)
+check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
 check_include_files("sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
 
 check_cxx_symbol_exists(process_vm_readv "sys/uio.h" HAVE_PROCESS_VM_READV)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D65822: Detect HAVE_SYS_TYPES_H in lldb

2019-08-06 Thread Haibo Huang via Phabricator via lldb-commits
hhb added a comment.

I'm not really know how this works before, given no one includes Config.h. Or 
maybe sys/types.h is never needed?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65822/new/

https://reviews.llvm.org/D65822



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D65822: Detect HAVE_SYS_TYPES_H in lldb

2019-08-06 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 213688.
hhb added a comment.

Remove test code


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65822/new/

https://reviews.llvm.org/D65822

Files:
  lldb/cmake/modules/LLDBGenerateConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/source/Expression/UserExpression.cpp
  lldb/source/Expression/UtilityFunction.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
  lldb/tools/driver/Platform.h


Index: lldb/tools/driver/Platform.h
===
--- lldb/tools/driver/Platform.h
+++ lldb/tools/driver/Platform.h
@@ -9,6 +9,8 @@
 #ifndef lldb_Platform_h_
 #define lldb_Platform_h_
 
+#include "lldb/Host/Config.h"
+
 #if defined(_WIN32)
 
 #include 
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
@@ -6,6 +6,8 @@
 //
 
//===--===//
 
+#include "lldb/Host/Config.h"
+
 #include "ClangUtilityFunction.h"
 #include "ClangExpressionDeclMap.h"
 #include "ClangExpressionParser.h"
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -6,6 +6,8 @@
 //
 
//===--===//
 
+#include "lldb/Host/Config.h"
+
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
Index: lldb/source/Expression/UtilityFunction.cpp
===
--- lldb/source/Expression/UtilityFunction.cpp
+++ lldb/source/Expression/UtilityFunction.cpp
@@ -6,6 +6,8 @@
 //
 
//===--===//
 
+#include "lldb/Host/Config.h"
+
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
Index: lldb/source/Expression/UserExpression.cpp
===
--- lldb/source/Expression/UserExpression.cpp
+++ lldb/source/Expression/UserExpression.cpp
@@ -6,6 +6,8 @@
 //
 
//===--===//
 
+#include "lldb/Host/Config.h"
+
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
Index: lldb/include/lldb/Host/Config.h.cmake
===
--- lldb/include/lldb/Host/Config.h.cmake
+++ lldb/include/lldb/Host/Config.h.cmake
@@ -19,6 +19,8 @@
 
 #define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}"
 
+#cmakedefine01 HAVE_SYS_TYPES_H
+
 #cmakedefine01 HAVE_SYS_EVENT_H
 
 #cmakedefine01 HAVE_PPOLL
Index: lldb/cmake/modules/LLDBGenerateConfig.cmake
===
--- lldb/cmake/modules/LLDBGenerateConfig.cmake
+++ lldb/cmake/modules/LLDBGenerateConfig.cmake
@@ -12,6 +12,7 @@
 check_cxx_symbol_exists(accept4 "sys/socket.h" HAVE_ACCEPT4)
 
 check_include_file(termios.h HAVE_TERMIOS_H)
+check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
 check_include_files("sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
 
 check_cxx_symbol_exists(process_vm_readv "sys/uio.h" HAVE_PROCESS_VM_READV)


Index: lldb/tools/driver/Platform.h
===
--- lldb/tools/driver/Platform.h
+++ lldb/tools/driver/Platform.h
@@ -9,6 +9,8 @@
 #ifndef lldb_Platform_h_
 #define lldb_Platform_h_
 
+#include "lldb/Host/Config.h"
+
 #if defined(_WIN32)
 
 #include 
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include "ClangUtilityFunction.h"
 #include "ClangExpressionDeclMap.h"
 #include "ClangExpressionParser.h"
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
Index: lldb/source/Expression/UtilityFunction.cpp
===
--

[Lldb-commits] [PATCH] D65822: Detect HAVE_SYS_TYPES_H in lldb

2019-08-06 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 213687.
hhb added a comment.

Remove a test code.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65822/new/

https://reviews.llvm.org/D65822

Files:
  lldb/cmake/modules/LLDBGenerateConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/source/Expression/UserExpression.cpp
  lldb/source/Expression/UtilityFunction.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
  lldb/tools/driver/Platform.h

Index: lldb/tools/driver/Platform.h
===
--- lldb/tools/driver/Platform.h
+++ lldb/tools/driver/Platform.h
@@ -9,6 +9,8 @@
 #ifndef lldb_Platform_h_
 #define lldb_Platform_h_
 
+#include "lldb/Host/Config.h"
+
 #if defined(_WIN32)
 
 #include 
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include "ClangUtilityFunction.h"
 #include "ClangExpressionDeclMap.h"
 #include "ClangExpressionParser.h"
@@ -14,6 +16,8 @@
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
+#else
+static_assert(false, "");
 #endif
 
 
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -6,9 +6,13 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
+#else
+static_assert(false, "");
 #endif
 
 #include 
Index: lldb/source/Expression/UtilityFunction.cpp
===
--- lldb/source/Expression/UtilityFunction.cpp
+++ lldb/source/Expression/UtilityFunction.cpp
@@ -6,9 +6,13 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
+#else
+static_assert(false, "");
 #endif
 
 
Index: lldb/source/Expression/UserExpression.cpp
===
--- lldb/source/Expression/UserExpression.cpp
+++ lldb/source/Expression/UserExpression.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
Index: lldb/include/lldb/Host/Config.h.cmake
===
--- lldb/include/lldb/Host/Config.h.cmake
+++ lldb/include/lldb/Host/Config.h.cmake
@@ -19,6 +19,8 @@
 
 #define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}"
 
+#cmakedefine01 HAVE_SYS_TYPES_H
+
 #cmakedefine01 HAVE_SYS_EVENT_H
 
 #cmakedefine01 HAVE_PPOLL
Index: lldb/cmake/modules/LLDBGenerateConfig.cmake
===
--- lldb/cmake/modules/LLDBGenerateConfig.cmake
+++ lldb/cmake/modules/LLDBGenerateConfig.cmake
@@ -12,6 +12,7 @@
 check_cxx_symbol_exists(accept4 "sys/socket.h" HAVE_ACCEPT4)
 
 check_include_file(termios.h HAVE_TERMIOS_H)
+check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
 check_include_files("sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
 
 check_cxx_symbol_exists(process_vm_readv "sys/uio.h" HAVE_PROCESS_VM_READV)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D65822: Detect HAVE_SYS_TYPES_H in lldb

2019-08-06 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 213689.
hhb added a comment.
Herald added a subscriber: mstorsjo.

Add one more place


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65822/new/

https://reviews.llvm.org/D65822

Files:
  lldb/cmake/modules/LLDBGenerateConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/windows/PosixApi.h
  lldb/source/Expression/UserExpression.cpp
  lldb/source/Expression/UtilityFunction.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
  lldb/tools/driver/Platform.h

Index: lldb/tools/driver/Platform.h
===
--- lldb/tools/driver/Platform.h
+++ lldb/tools/driver/Platform.h
@@ -9,6 +9,8 @@
 #ifndef lldb_Platform_h_
 #define lldb_Platform_h_
 
+#include "lldb/Host/Config.h"
+
 #if defined(_WIN32)
 
 #include 
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include "ClangUtilityFunction.h"
 #include "ClangExpressionDeclMap.h"
 #include "ClangExpressionParser.h"
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
Index: lldb/source/Expression/UtilityFunction.cpp
===
--- lldb/source/Expression/UtilityFunction.cpp
+++ lldb/source/Expression/UtilityFunction.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
Index: lldb/source/Expression/UserExpression.cpp
===
--- lldb/source/Expression/UserExpression.cpp
+++ lldb/source/Expression/UserExpression.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
Index: lldb/include/lldb/Host/windows/PosixApi.h
===
--- lldb/include/lldb/Host/windows/PosixApi.h
+++ lldb/include/lldb/Host/windows/PosixApi.h
@@ -9,6 +9,7 @@
 #ifndef liblldb_Host_windows_PosixApi_h
 #define liblldb_Host_windows_PosixApi_h
 
+#include "lldb/Host/Config.h"
 #include "llvm/Support/Compiler.h"
 #if !defined(_WIN32)
 #error "windows/PosixApi.h being #included on non Windows system!"
@@ -45,7 +46,7 @@
 #define S_IRWXG 0
 #define S_IRWXO 0
 
-#ifdef __MINGW32__
+#if HAVE_SYS_TYPES_H
 // pyconfig.h typedefs this.  We require python headers to be included before
 // any LLDB headers, but there's no way to prevent python's pid_t definition
 // from leaking, so this is the best option.
Index: lldb/include/lldb/Host/Config.h.cmake
===
--- lldb/include/lldb/Host/Config.h.cmake
+++ lldb/include/lldb/Host/Config.h.cmake
@@ -19,6 +19,8 @@
 
 #define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}"
 
+#cmakedefine01 HAVE_SYS_TYPES_H
+
 #cmakedefine01 HAVE_SYS_EVENT_H
 
 #cmakedefine01 HAVE_PPOLL
Index: lldb/cmake/modules/LLDBGenerateConfig.cmake
===
--- lldb/cmake/modules/LLDBGenerateConfig.cmake
+++ lldb/cmake/modules/LLDBGenerateConfig.cmake
@@ -12,6 +12,7 @@
 check_cxx_symbol_exists(accept4 "sys/socket.h" HAVE_ACCEPT4)
 
 check_include_file(termios.h HAVE_TERMIOS_H)
+check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
 check_include_files("sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
 
 check_cxx_symbol_exists(process_vm_readv "sys/uio.h" HAVE_PROCESS_VM_READV)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D65822: Detect HAVE_SYS_TYPES_H in lldb

2019-08-06 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 213726.
hhb added a comment.

Fix comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65822/new/

https://reviews.llvm.org/D65822

Files:
  lldb/cmake/modules/LLDBGenerateConfig.cmake
  lldb/include/lldb/Host/Config.h.cmake
  lldb/include/lldb/Host/windows/PosixApi.h
  lldb/source/Expression/UserExpression.cpp
  lldb/source/Expression/UtilityFunction.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
  lldb/tools/driver/Platform.h

Index: lldb/tools/driver/Platform.h
===
--- lldb/tools/driver/Platform.h
+++ lldb/tools/driver/Platform.h
@@ -9,6 +9,8 @@
 #ifndef lldb_Platform_h_
 #define lldb_Platform_h_
 
+#include "lldb/Host/Config.h"
+
 #if defined(_WIN32)
 
 #include 
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include "ClangUtilityFunction.h"
 #include "ClangExpressionDeclMap.h"
 #include "ClangExpressionParser.h"
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
Index: lldb/source/Expression/UtilityFunction.cpp
===
--- lldb/source/Expression/UtilityFunction.cpp
+++ lldb/source/Expression/UtilityFunction.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
Index: lldb/source/Expression/UserExpression.cpp
===
--- lldb/source/Expression/UserExpression.cpp
+++ lldb/source/Expression/UserExpression.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
Index: lldb/include/lldb/Host/windows/PosixApi.h
===
--- lldb/include/lldb/Host/windows/PosixApi.h
+++ lldb/include/lldb/Host/windows/PosixApi.h
@@ -9,6 +9,7 @@
 #ifndef liblldb_Host_windows_PosixApi_h
 #define liblldb_Host_windows_PosixApi_h
 
+#include "lldb/Host/Config.h"
 #include "llvm/Support/Compiler.h"
 #if !defined(_WIN32)
 #error "windows/PosixApi.h being #included on non Windows system!"
@@ -45,14 +46,14 @@
 #define S_IRWXG 0
 #define S_IRWXO 0
 
-#ifdef __MINGW32__
+#if HAVE_SYS_TYPES_H
 // pyconfig.h typedefs this.  We require python headers to be included before
 // any LLDB headers, but there's no way to prevent python's pid_t definition
 // from leaking, so this is the best option.
 #ifndef NO_PID_T
 #include 
 #endif
-#endif // __MINGW32__
+#endif // HAVE_SYS_TYPES_H
 
 #ifdef _MSC_VER
 
Index: lldb/include/lldb/Host/Config.h.cmake
===
--- lldb/include/lldb/Host/Config.h.cmake
+++ lldb/include/lldb/Host/Config.h.cmake
@@ -19,6 +19,8 @@
 
 #define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}"
 
+#cmakedefine01 HAVE_SYS_TYPES_H
+
 #cmakedefine01 HAVE_SYS_EVENT_H
 
 #cmakedefine01 HAVE_PPOLL
Index: lldb/cmake/modules/LLDBGenerateConfig.cmake
===
--- lldb/cmake/modules/LLDBGenerateConfig.cmake
+++ lldb/cmake/modules/LLDBGenerateConfig.cmake
@@ -12,6 +12,7 @@
 check_cxx_symbol_exists(accept4 "sys/socket.h" HAVE_ACCEPT4)
 
 check_include_file(termios.h HAVE_TERMIOS_H)
+check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
 check_include_files("sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
 
 check_cxx_symbol_exists(process_vm_readv "sys/uio.h" HAVE_PROCESS_VM_READV)
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D65822: Detect HAVE_SYS_TYPES_H in lldb

2019-08-06 Thread Haibo Huang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL368125: Detect HAVE_SYS_TYPES_H in lldb (authored by hhb, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D65822?vs=213726&id=213796#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65822/new/

https://reviews.llvm.org/D65822

Files:
  lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake
  lldb/trunk/include/lldb/Host/Config.h.cmake
  lldb/trunk/include/lldb/Host/windows/PosixApi.h
  lldb/trunk/source/Expression/UserExpression.cpp
  lldb/trunk/source/Expression/UtilityFunction.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
  lldb/trunk/tools/driver/Platform.h

Index: lldb/trunk/include/lldb/Host/windows/PosixApi.h
===
--- lldb/trunk/include/lldb/Host/windows/PosixApi.h
+++ lldb/trunk/include/lldb/Host/windows/PosixApi.h
@@ -9,6 +9,7 @@
 #ifndef liblldb_Host_windows_PosixApi_h
 #define liblldb_Host_windows_PosixApi_h
 
+#include "lldb/Host/Config.h"
 #include "llvm/Support/Compiler.h"
 #if !defined(_WIN32)
 #error "windows/PosixApi.h being #included on non Windows system!"
@@ -45,14 +46,14 @@
 #define S_IRWXG 0
 #define S_IRWXO 0
 
-#ifdef __MINGW32__
+#if HAVE_SYS_TYPES_H
 // pyconfig.h typedefs this.  We require python headers to be included before
 // any LLDB headers, but there's no way to prevent python's pid_t definition
 // from leaking, so this is the best option.
 #ifndef NO_PID_T
 #include 
 #endif
-#endif // __MINGW32__
+#endif // HAVE_SYS_TYPES_H
 
 #ifdef _MSC_VER
 
Index: lldb/trunk/include/lldb/Host/Config.h.cmake
===
--- lldb/trunk/include/lldb/Host/Config.h.cmake
+++ lldb/trunk/include/lldb/Host/Config.h.cmake
@@ -19,6 +19,8 @@
 
 #define LLDB_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}"
 
+#cmakedefine01 HAVE_SYS_TYPES_H
+
 #cmakedefine01 HAVE_SYS_EVENT_H
 
 #cmakedefine01 HAVE_PPOLL
Index: lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake
===
--- lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake
+++ lldb/trunk/cmake/modules/LLDBGenerateConfig.cmake
@@ -12,6 +12,7 @@
 check_cxx_symbol_exists(accept4 "sys/socket.h" HAVE_ACCEPT4)
 
 check_include_file(termios.h HAVE_TERMIOS_H)
+check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
 check_include_files("sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
 
 check_cxx_symbol_exists(process_vm_readv "sys/uio.h" HAVE_PROCESS_VM_READV)
Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUtilityFunction.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include "ClangUtilityFunction.h"
 #include "ClangExpressionDeclMap.h"
 #include "ClangExpressionParser.h"
Index: lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
===
--- lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ lldb/trunk/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
Index: lldb/trunk/source/Expression/UtilityFunction.cpp
===
--- lldb/trunk/source/Expression/UtilityFunction.cpp
+++ lldb/trunk/source/Expression/UtilityFunction.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
Index: lldb/trunk/source/Expression/UserExpression.cpp
===
--- lldb/trunk/source/Expression/UserExpression.cpp
+++ lldb/trunk/source/Expression/UserExpression.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 
+#include "lldb/Host/Config.h"
+
 #include 
 #if HAVE_SYS_TYPES_H
 #include 
Index: lldb/trunk/tools/driver/Platform.h
===
--- lldb/trunk/tools/driver/Platform.h
+++ lldb/trunk/tools/driver/Platform.h
@@ -9,6 +9,8 @@
 #ifndef lldb_Platform_h_
 #define lldb_Platform_h_
 
+#include "lldb/Host/Config.h"
+
 #if defined(_WIN32)
 
 #include 
___
lldb-commits mailing list
lldb-commits@lis

[Lldb-commits] [PATCH] D65965: [lldb] Fix HAVE_LIBCOMPRESSION

2019-08-08 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
hhb added a reviewer: labath.
hhb added a project: LLDB.
Herald added a subscriber: lldb-commits.

This test doesn't make sense. Change to be consistent with what we did
in GDBRemoteCommunication.cpp.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D65965

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp


Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -36,10 +36,7 @@
 
 #include "llvm/ADT/StringSwitch.h"
 
-#if defined(__APPLE__)
-#ifndef HAVE_LIBCOMPRESSION
-#define HAVE_LIBCOMPRESSION
-#endif
+#if defined(HAVE_LIBCOMPRESSION)
 #include 
 #endif
 


Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -36,10 +36,7 @@
 
 #include "llvm/ADT/StringSwitch.h"
 
-#if defined(__APPLE__)
-#ifndef HAVE_LIBCOMPRESSION
-#define HAVE_LIBCOMPRESSION
-#endif
+#if defined(HAVE_LIBCOMPRESSION)
 #include 
 #endif
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D65965: [lldb] Fix HAVE_LIBCOMPRESSION

2019-08-08 Thread Haibo Huang via Phabricator via lldb-commits
hhb updated this revision to Diff 214212.
hhb added a comment.

And we should really include Config.h


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65965/new/

https://reviews.llvm.org/D65965

Files:
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp


Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -36,10 +36,7 @@
 
 #include "llvm/ADT/StringSwitch.h"
 
-#if defined(__APPLE__)
-#ifndef HAVE_LIBCOMPRESSION
-#define HAVE_LIBCOMPRESSION
-#endif
+#if defined(HAVE_LIBCOMPRESSION)
 #include 
 #endif
 
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -14,6 +14,7 @@
 #include 
 
 #include "lldb/Core/StreamFile.h"
+#include "lldb/Host/Config.h"
 #include "lldb/Host/ConnectionFileDescriptor.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/Host.h"


Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -36,10 +36,7 @@
 
 #include "llvm/ADT/StringSwitch.h"
 
-#if defined(__APPLE__)
-#ifndef HAVE_LIBCOMPRESSION
-#define HAVE_LIBCOMPRESSION
-#endif
+#if defined(HAVE_LIBCOMPRESSION)
 #include 
 #endif
 
Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
===
--- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -14,6 +14,7 @@
 #include 
 
 #include "lldb/Core/StreamFile.h"
+#include "lldb/Host/Config.h"
 #include "lldb/Host/ConnectionFileDescriptor.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/Host.h"
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D65965: [lldb] Fix HAVE_LIBCOMPRESSION

2019-08-08 Thread Haibo Huang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL368352: [lldb] Fix HAVE_LIBCOMPRESSION (authored by hhb, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D65965?vs=214212&id=214240#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65965/new/

https://reviews.llvm.org/D65965

Files:
  lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp


Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
===
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -14,6 +14,7 @@
 #include 
 
 #include "lldb/Core/StreamFile.h"
+#include "lldb/Host/Config.h"
 #include "lldb/Host/ConnectionFileDescriptor.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/Host.h"
Index: 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ 
lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -36,10 +36,7 @@
 
 #include "llvm/ADT/StringSwitch.h"
 
-#if defined(__APPLE__)
-#ifndef HAVE_LIBCOMPRESSION
-#define HAVE_LIBCOMPRESSION
-#endif
+#if defined(HAVE_LIBCOMPRESSION)
 #include 
 #endif
 


Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
===
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
@@ -14,6 +14,7 @@
 #include 
 
 #include "lldb/Core/StreamFile.h"
+#include "lldb/Host/Config.h"
 #include "lldb/Host/ConnectionFileDescriptor.h"
 #include "lldb/Host/FileSystem.h"
 #include "lldb/Host/Host.h"
Index: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
===
--- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
+++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
@@ -36,10 +36,7 @@
 
 #include "llvm/ADT/StringSwitch.h"
 
-#if defined(__APPLE__)
-#ifndef HAVE_LIBCOMPRESSION
-#define HAVE_LIBCOMPRESSION
-#endif
+#if defined(HAVE_LIBCOMPRESSION)
 #include 
 #endif
 
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D66034: Detects whether RESOURCE_TYPE_IO is defined.

2019-08-09 Thread Haibo Huang via Phabricator via lldb-commits
hhb created this revision.
hhb added a reviewer: JDevlieghere.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
hhb added a subscriber: kongyi.

This fixes lldb build on macOS SDK prior to 10.12.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D66034

Files:
  lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp


Index: lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
===
--- lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -313,6 +313,8 @@
   subcode_desc = nullptr;
   subcode_label = "unused";
   break;
+#if defined(RESOURCE_TYPE_IO)
+   // RESOURCE_TYPE_IO is introduced in macOS SDK 10.12.
 case RESOURCE_TYPE_IO:
   exc_desc = "EXC_RESOURCE RESOURCE_TYPE_IO";
   snprintf(code_desc_buf, sizeof(code_desc_buf), "%d MB",
@@ -320,6 +322,7 @@
   snprintf(subcode_desc_buf, sizeof(subcode_desc_buf), "%d MB",
 (int)EXC_RESOURCE_IO_OBSERVED(m_exc_subcode));;
   break;
+#endif
 }
   }
 #endif


Index: lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
===
--- lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -313,6 +313,8 @@
   subcode_desc = nullptr;
   subcode_label = "unused";
   break;
+#if defined(RESOURCE_TYPE_IO)
+   // RESOURCE_TYPE_IO is introduced in macOS SDK 10.12.
 case RESOURCE_TYPE_IO:
   exc_desc = "EXC_RESOURCE RESOURCE_TYPE_IO";
   snprintf(code_desc_buf, sizeof(code_desc_buf), "%d MB",
@@ -320,6 +322,7 @@
   snprintf(subcode_desc_buf, sizeof(subcode_desc_buf), "%d MB",
 (int)EXC_RESOURCE_IO_OBSERVED(m_exc_subcode));;
   break;
+#endif
 }
   }
 #endif
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D66034: Detects whether RESOURCE_TYPE_IO is defined.

2019-08-09 Thread Haibo Huang via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL368496: Detects whether RESOURCE_TYPE_IO is defined. 
(authored by hhb, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66034?vs=214465&id=214472#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66034/new/

https://reviews.llvm.org/D66034

Files:
  lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp


Index: lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp
===
--- lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -313,6 +313,8 @@
   subcode_desc = nullptr;
   subcode_label = "unused";
   break;
+#if defined(RESOURCE_TYPE_IO)
+   // RESOURCE_TYPE_IO is introduced in macOS SDK 10.12.
 case RESOURCE_TYPE_IO:
   exc_desc = "EXC_RESOURCE RESOURCE_TYPE_IO";
   snprintf(code_desc_buf, sizeof(code_desc_buf), "%d MB",
@@ -320,6 +322,7 @@
   snprintf(subcode_desc_buf, sizeof(subcode_desc_buf), "%d MB",
 (int)EXC_RESOURCE_IO_OBSERVED(m_exc_subcode));;
   break;
+#endif
 }
   }
 #endif


Index: lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp
===
--- lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ lldb/trunk/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -313,6 +313,8 @@
   subcode_desc = nullptr;
   subcode_label = "unused";
   break;
+#if defined(RESOURCE_TYPE_IO)
+   // RESOURCE_TYPE_IO is introduced in macOS SDK 10.12.
 case RESOURCE_TYPE_IO:
   exc_desc = "EXC_RESOURCE RESOURCE_TYPE_IO";
   snprintf(code_desc_buf, sizeof(code_desc_buf), "%d MB",
@@ -320,6 +322,7 @@
   snprintf(subcode_desc_buf, sizeof(subcode_desc_buf), "%d MB",
 (int)EXC_RESOURCE_IO_OBSERVED(m_exc_subcode));;
   break;
+#endif
 }
   }
 #endif
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


  1   2   >