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
17 if len(sys.argv) != 3:
18 print "usage: " + sys.argv[0] + " TARGET_DIR LLVM_BUILD_DIR"
21 target_dir = sys.argv[1]
22 llvm_build_dir = sys.argv[2]
24 if not os.path.isdir(target_dir):
25 print target_dir + " doesn't exist"
28 if not os.path.isdir(llvm_build_dir):
29 llvm_build_dir = re.sub ("-macosx-", "-iphoneos-", llvm_build_dir)
31 if not os.path.isdir(llvm_build_dir):
32 llvm_build_dir = re.sub ("-iphoneos-", "-appletvos-", llvm_build_dir)
34 if not os.path.isdir(llvm_build_dir):
35 llvm_build_dir = re.sub ("-appletvos-", "-watchos-", llvm_build_dir)
37 if not os.path.isdir(llvm_build_dir):
38 print llvm_build_dir + " doesn't exist"
41 resources = os.path.join(target_dir, "LLDB.framework", "Resources")
43 if not os.path.isdir(resources):
44 print resources + " must exist"
47 clang_dir = os.path.join(llvm_build_dir, "lib", "clang")
49 if not os.path.isdir(clang_dir):
50 print clang_dir + " must exist"
55 for subdir in os.listdir(clang_dir):
56 if (re.match("^[0-9]+(\.[0-9]+)*$", subdir)):
57 version_dir = os.path.join(clang_dir, subdir)
60 if version_dir == None:
61 print "Couldn't find a subdirectory of the form #(.#)... in " + clang_dir
64 if not os.path.isdir(version_dir):
65 print version_dir + " is not a directory"
68 # Just checking... we're actually going to copy all of version_dir
69 include_dir = os.path.join(version_dir, "include")
71 if not os.path.isdir(include_dir):
72 print version_dir + " is not a directory"
75 clang_resources = os.path.join(resources, "Clang")
77 if os.path.isdir(clang_resources):
78 shutil.rmtree(clang_resources)
80 shutil.copytree(version_dir, clang_resources)