summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2014-12-05 01:15:04 +0000
committerSean Callanan <scallanan@apple.com>2014-12-05 01:15:04 +0000
commitb1e1c62fac12bf5c48b57d5e90d65bf1e48170b7 (patch)
tree22430c5c4cb147aef6a05464f1c4836c273a109a
parent0e2618857c81ab37cdfacdc407620449a17f12ef (diff)
downloadbcm5719-llvm-b1e1c62fac12bf5c48b57d5e90d65bf1e48170b7.tar.gz
bcm5719-llvm-b1e1c62fac12bf5c48b57d5e90d65bf1e48170b7.zip
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. llvm-svn: 223430
-rw-r--r--lldb/include/lldb/Host/HostInfoBase.h1
-rw-r--r--lldb/include/lldb/Host/macosx/HostInfoMacOSX.h1
-rw-r--r--lldb/scripts/package-clang-headers.py71
-rw-r--r--lldb/source/Host/common/HostInfoBase.cpp12
-rw-r--r--lldb/source/Host/macosx/HostInfoMacOSX.mm20
5 files changed, 105 insertions, 0 deletions
diff --git a/lldb/include/lldb/Host/HostInfoBase.h b/lldb/include/lldb/Host/HostInfoBase.h
index 8cea4d6bacf..5a8a0632950 100644
--- a/lldb/include/lldb/Host/HostInfoBase.h
+++ b/lldb/include/lldb/Host/HostInfoBase.h
@@ -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);
diff --git a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
index ec76bb003ec..3b62c7fb906 100644
--- a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
+++ b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
@@ -38,6 +38,7 @@ class HostInfoMacOSX : public HostInfoPosix
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);
};
diff --git a/lldb/scripts/package-clang-headers.py b/lldb/scripts/package-clang-headers.py
new file mode 100644
index 00000000000..f2b7a2429d2
--- /dev/null
+++ b/lldb/scripts/package-clang-headers.py
@@ -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)
diff --git a/lldb/source/Host/common/HostInfoBase.cpp b/lldb/source/Host/common/HostInfoBase.cpp
index 9af71ec9bcc..9eab299f3b8 100644
--- a/lldb/source/Host/common/HostInfoBase.cpp
+++ b/lldb/source/Host/common/HostInfoBase.cpp
@@ -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 type, FileSpec &file_spec)
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)
@@ -289,6 +295,12 @@ HostInfoBase::ComputeSystemPluginsDirectory(FileSpec &file_spec)
}
bool
+HostInfoBase::ComputeClangDirectory(FileSpec &file_spec)
+{
+ return false;
+}
+
+bool
HostInfoBase::ComputeUserPluginsDirectory(FileSpec &file_spec)
{
// TODO(zturner): Figure out how to compute the user plugins directory for all platforms.
diff --git a/lldb/source/Host/macosx/HostInfoMacOSX.mm b/lldb/source/Host/macosx/HostInfoMacOSX.mm
index a6a65531454..a22674e63aa 100644
--- a/lldb/source/Host/macosx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/HostInfoMacOSX.mm
@@ -208,6 +208,26 @@ HostInfoMacOSX::ComputePythonDirectory(FileSpec &file_spec)
}
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;
OpenPOWER on IntegriCloud