3 # package-clang-headers.py
5 # The Clang module loader depends on built-in headers for the Clang compiler.
6 # We grab these from the Clang build and move them into the LLDB module.
8 # TARGET_DIR is where the lldb framework/shared library gets put.
9 # LLVM_BUILD_DIR is where LLVM and Clang got built
10 # LLVM_BUILD_DIR/lib/clang should exist and contain headers
19 if len(sys.argv) != 3:
20 print "usage: " + sys.argv[0] + " TARGET_DIR LLVM_BUILD_DIR"
23 target_dir = sys.argv[1]
24 llvm_build_dir = lldbbuild.expected_package_build_path_for("llvm")
26 if not os.path.isdir(target_dir):
27 print target_dir + " doesn't exist"
30 if not os.path.isdir(llvm_build_dir):
31 llvm_build_dir = re.sub("-macosx-", "-iphoneos-", llvm_build_dir)
33 if not os.path.isdir(llvm_build_dir):
34 llvm_build_dir = re.sub("-iphoneos-", "-appletvos-", llvm_build_dir)
36 if not os.path.isdir(llvm_build_dir):
37 llvm_build_dir = re.sub("-appletvos-", "-watchos-", llvm_build_dir)
39 if not os.path.isdir(llvm_build_dir):
40 print llvm_build_dir + " doesn't exist"
43 resources = os.path.join(target_dir, "LLDB.framework", "Resources")
45 if not os.path.isdir(resources):
46 print resources + " must exist"
49 clang_dir = os.path.join(llvm_build_dir, "lib", "clang")
51 if not os.path.isdir(clang_dir):
52 print clang_dir + " must exist"
57 for subdir in os.listdir(clang_dir):
58 if (re.match("^[0-9]+(\.[0-9]+)*$", subdir)):
59 version_dir = os.path.join(clang_dir, subdir)
62 if version_dir is None:
63 print "Couldn't find a subdirectory of the form #(.#)... in " + clang_dir
66 if not os.path.isdir(version_dir):
67 print version_dir + " is not a directory"
70 # Just checking... we're actually going to copy all of version_dir
71 include_dir = os.path.join(version_dir, "include")
73 if not os.path.isdir(include_dir):
74 print version_dir + " is not a directory"
77 clang_resources = os.path.join(resources, "Clang")
79 if os.path.isdir(clang_resources):
80 shutil.rmtree(clang_resources)
82 shutil.copytree(version_dir, clang_resources)