2014-12-05 09:15:04 +08:00
|
|
|
#! /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
|
|
|
|
|
modify Xcode build to use cmake/ninja for internal llvm/clang
This change restores the Xcode build to working after Makefile support
was stripped from LLVM and clang recently.
With this change, the Xcode build now requires cmake (2.8.12.2+).
The cmake must either be on the path that Xcode sees, or it must
exist in one of the following locations:
* /usr/local/bin/cmake
* /opt/local/bin/cmake
* $HOME/bin/cmake
If the ninja build tool is present on the path, it will be used.
If not, ninja will be cloned (via git), bootstrap-built, and
used for the llvm/clang build.
LLDB now requires a minimum deployment target of OS X 10.9. Prior
to this, it was 10.8. The llvm/clang cmake build will not run
with Xcode 7.2 or Xcode 7.3 beta's compiler with the minimum
deployment target set to anything lower than 10.9. This is
related to #include <atomic>.
When llvm or clang source code does not exist in the lldb tree,
it will be cloned via git using http://llvm.org/git/{project}.git.
Previously it used SVN. If this causes any heartache, we can
make this smarter, autodetect an embedded svn and use svn instead.
(And/or use SVN if a git command is not available).
This change also fixes an lldb-mi linkage failure (needed
libncurses) as exposed by one of the LLVM libs.
llvm-svn: 259027
2016-01-28 15:36:44 +08:00
|
|
|
import lldbbuild
|
|
|
|
|
2014-12-05 09:15:04 +08:00
|
|
|
if len(sys.argv) != 3:
|
2016-09-07 04:57:50 +08:00
|
|
|
print "usage: " + sys.argv[0] + " TARGET_DIR LLVM_BUILD_DIR"
|
|
|
|
sys.exit(1)
|
2014-12-05 09:15:04 +08:00
|
|
|
|
|
|
|
target_dir = sys.argv[1]
|
modify Xcode build to use cmake/ninja for internal llvm/clang
This change restores the Xcode build to working after Makefile support
was stripped from LLVM and clang recently.
With this change, the Xcode build now requires cmake (2.8.12.2+).
The cmake must either be on the path that Xcode sees, or it must
exist in one of the following locations:
* /usr/local/bin/cmake
* /opt/local/bin/cmake
* $HOME/bin/cmake
If the ninja build tool is present on the path, it will be used.
If not, ninja will be cloned (via git), bootstrap-built, and
used for the llvm/clang build.
LLDB now requires a minimum deployment target of OS X 10.9. Prior
to this, it was 10.8. The llvm/clang cmake build will not run
with Xcode 7.2 or Xcode 7.3 beta's compiler with the minimum
deployment target set to anything lower than 10.9. This is
related to #include <atomic>.
When llvm or clang source code does not exist in the lldb tree,
it will be cloned via git using http://llvm.org/git/{project}.git.
Previously it used SVN. If this causes any heartache, we can
make this smarter, autodetect an embedded svn and use svn instead.
(And/or use SVN if a git command is not available).
This change also fixes an lldb-mi linkage failure (needed
libncurses) as exposed by one of the LLVM libs.
llvm-svn: 259027
2016-01-28 15:36:44 +08:00
|
|
|
llvm_build_dir = lldbbuild.expected_package_build_path_for("llvm")
|
2014-12-05 09:15:04 +08:00
|
|
|
|
|
|
|
if not os.path.isdir(target_dir):
|
|
|
|
print target_dir + " doesn't exist"
|
2016-09-07 04:57:50 +08:00
|
|
|
sys.exit(1)
|
2014-12-05 09:15:04 +08:00
|
|
|
|
2015-02-21 14:13:51 +08:00
|
|
|
if not os.path.isdir(llvm_build_dir):
|
2016-09-07 04:57:50 +08:00
|
|
|
llvm_build_dir = re.sub("-macosx-", "-iphoneos-", llvm_build_dir)
|
2015-02-21 14:13:51 +08:00
|
|
|
|
2015-11-06 07:42:18 +08:00
|
|
|
if not os.path.isdir(llvm_build_dir):
|
2016-09-07 04:57:50 +08:00
|
|
|
llvm_build_dir = re.sub("-iphoneos-", "-appletvos-", llvm_build_dir)
|
2015-11-06 07:42:18 +08:00
|
|
|
|
|
|
|
if not os.path.isdir(llvm_build_dir):
|
2016-09-07 04:57:50 +08:00
|
|
|
llvm_build_dir = re.sub("-appletvos-", "-watchos-", llvm_build_dir)
|
2015-11-06 07:42:18 +08:00
|
|
|
|
2014-12-05 09:15:04 +08:00
|
|
|
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
|
|
|
|
|
2016-09-07 04:57:50 +08:00
|
|
|
if version_dir is None:
|
2014-12-05 09:15:04 +08:00
|
|
|
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)
|