[Lldb-commits] [lldb] r223430 - Add support for embedding Clang compiler headers
Sean Callanan
scallanan at apple.com
Thu Dec 4 17:15:05 PST 2014
Author: spyffe
Date: Thu Dec 4 19:15:04 2014
New Revision: 223430
URL: http://llvm.org/viewvc/llvm-project?rev=223430&view=rev
Log:
Add support for embedding Clang compiler headers
like tgmath.h and stdarg.h into the LLDB installation,
and then finding them through the Host infrastructure.
Also add a script to actually do this on Mac OS X.
Added:
lldb/trunk/scripts/package-clang-headers.py
Modified:
lldb/trunk/include/lldb/Host/HostInfoBase.h
lldb/trunk/include/lldb/Host/macosx/HostInfoMacOSX.h
lldb/trunk/source/Host/common/HostInfoBase.cpp
lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm
Modified: lldb/trunk/include/lldb/Host/HostInfoBase.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/HostInfoBase.h?rev=223430&r1=223429&r2=223430&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/HostInfoBase.h (original)
+++ lldb/trunk/include/lldb/Host/HostInfoBase.h Thu Dec 4 19:15:04 2014
@@ -118,6 +118,7 @@ class HostInfoBase
static bool ComputeTempFileDirectory(FileSpec &file_spec);
static bool ComputeHeaderDirectory(FileSpec &file_spec);
static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
+ static bool ComputeClangDirectory(FileSpec &file_spec);
static bool ComputeUserPluginsDirectory(FileSpec &file_spec);
static void ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64);
Modified: lldb/trunk/include/lldb/Host/macosx/HostInfoMacOSX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/macosx/HostInfoMacOSX.h?rev=223430&r1=223429&r2=223430&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/macosx/HostInfoMacOSX.h (original)
+++ lldb/trunk/include/lldb/Host/macosx/HostInfoMacOSX.h Thu Dec 4 19:15:04 2014
@@ -38,6 +38,7 @@ class HostInfoMacOSX : public HostInfoPo
static void ComputeHostArchitectureSupport(ArchSpec &arch_32, ArchSpec &arch_64);
static bool ComputeHeaderDirectory(FileSpec &file_spec);
static bool ComputePythonDirectory(FileSpec &file_spec);
+ static bool ComputeClangDirectory(FileSpec &file_spec);
static bool ComputeSystemPluginsDirectory(FileSpec &file_spec);
static bool ComputeUserPluginsDirectory(FileSpec &file_spec);
};
Added: lldb/trunk/scripts/package-clang-headers.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/package-clang-headers.py?rev=223430&view=auto
==============================================================================
--- lldb/trunk/scripts/package-clang-headers.py (added)
+++ lldb/trunk/scripts/package-clang-headers.py Thu Dec 4 19:15:04 2014
@@ -0,0 +1,71 @@
+#! /usr/bin/env python
+
+# package-clang-headers.py
+#
+# The Clang module loader depends on built-in headers for the Clang compiler.
+# We grab these from the Clang build and move them into the LLDB module.
+
+# TARGET_DIR is where the lldb framework/shared library gets put.
+# LLVM_BUILD_DIR is where LLVM and Clang got built
+# LLVM_BUILD_DIR/lib/clang should exist and contain headers
+
+import os
+import re
+import shutil
+import sys
+
+if len(sys.argv) != 3:
+ print "usage: " + sys.argv[0] + " TARGET_DIR LLVM_BUILD_DIR"
+ sys.exit(1)
+
+target_dir = sys.argv[1]
+llvm_build_dir = sys.argv[2]
+
+if not os.path.isdir(target_dir):
+ print target_dir + " doesn't exist"
+ sys.exit(1)
+
+if not os.path.isdir(llvm_build_dir):
+ print llvm_build_dir + " doesn't exist"
+ sys.exit(1)
+
+resources = os.path.join(target_dir, "LLDB.framework", "Resources")
+
+if not os.path.isdir(resources):
+ print resources + " must exist"
+ sys.exit(1)
+
+clang_dir = os.path.join(llvm_build_dir, "lib", "clang")
+
+if not os.path.isdir(clang_dir):
+ print clang_dir + " must exist"
+ sys.exit(1)
+
+version_dir = None
+
+for subdir in os.listdir(clang_dir):
+ if (re.match("^[0-9]+(\.[0-9]+)*$", subdir)):
+ version_dir = os.path.join(clang_dir, subdir)
+ break
+
+if version_dir == None:
+ print "Couldn't find a subdirectory of the form #(.#)... in " + clang_dir
+ sys.exit(1)
+
+if not os.path.isdir(version_dir):
+ print version_dir + " is not a directory"
+ sys.exit(1)
+
+# Just checking... we're actually going to copy all of version_dir
+include_dir = os.path.join(version_dir, "include")
+
+if not os.path.isdir(include_dir):
+ print version_dir + " is not a directory"
+ sys.exit(1)
+
+clang_resources = os.path.join(resources, "Clang")
+
+if os.path.isdir(clang_resources):
+ shutil.rmtree(clang_resources)
+
+shutil.copytree(version_dir, clang_resources)
Modified: lldb/trunk/source/Host/common/HostInfoBase.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/HostInfoBase.cpp?rev=223430&r1=223429&r2=223430&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/HostInfoBase.cpp (original)
+++ lldb/trunk/source/Host/common/HostInfoBase.cpp Thu Dec 4 19:15:04 2014
@@ -54,6 +54,7 @@ struct HostInfoBaseFields
FileSpec m_lldb_support_exe_dir;
FileSpec m_lldb_headers_dir;
FileSpec m_lldb_python_dir;
+ FileSpec m_lldb_clang_resource_dir;
FileSpec m_lldb_system_plugin_dir;
FileSpec m_lldb_user_plugin_dir;
FileSpec m_lldb_tmp_dir;
@@ -196,6 +197,11 @@ HostInfoBase::GetLLDBPath(lldb::PathType
if (log)
log->Printf("HostInfoBase::GetLLDBPath(ePathTypePythonDir) => '%s'", g_fields->m_lldb_python_dir.GetPath().c_str());
break;
+ case lldb::ePathTypeClangDir:
+ COMPUTE_LLDB_PATH(ComputeClangDirectory, g_fields->m_lldb_clang_resource_dir)
+ if (log)
+ log->Printf("HostInfoBase::GetLLDBPath(ePathTypeClangResourceDir) => '%s'", g_fields->m_lldb_clang_resource_dir.GetPath().c_str());
+ break;
case lldb::ePathTypeLLDBSystemPlugins:
COMPUTE_LLDB_PATH(ComputeSystemPluginsDirectory, g_fields->m_lldb_system_plugin_dir)
if (log)
@@ -288,6 +294,12 @@ HostInfoBase::ComputeSystemPluginsDirect
return false;
}
+bool
+HostInfoBase::ComputeClangDirectory(FileSpec &file_spec)
+{
+ return false;
+}
+
bool
HostInfoBase::ComputeUserPluginsDirectory(FileSpec &file_spec)
{
Modified: lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm?rev=223430&r1=223429&r2=223430&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm (original)
+++ lldb/trunk/source/Host/macosx/HostInfoMacOSX.mm Thu Dec 4 19:15:04 2014
@@ -208,6 +208,26 @@ HostInfoMacOSX::ComputePythonDirectory(F
}
bool
+HostInfoMacOSX::ComputeClangDirectory(FileSpec &file_spec)
+{
+ FileSpec lldb_file_spec;
+ if (!GetLLDBPath (lldb::ePathTypeLLDBShlibDir, lldb_file_spec))
+ return false;
+
+ char raw_path[PATH_MAX];
+ lldb_file_spec.GetPath (raw_path, sizeof (raw_path));
+
+ char *framework_pos = ::strstr (raw_path, "LLDB.framework");
+ if (framework_pos)
+ {
+ framework_pos += strlen("LLDB.framework");
+ ::strncpy (framework_pos, "/Resources/Clang", PATH_MAX - (framework_pos - raw_path));
+ }
+ file_spec.SetFile (raw_path, true);
+ return true;
+}
+
+bool
HostInfoMacOSX::ComputeSystemPluginsDirectory(FileSpec &file_spec)
{
FileSpec lldb_file_spec;
More information about the lldb-commits
mailing list