11 class BuildError(Exception):
17 self.m_string = string
19 self.m_inferior_error = inferior_error
22 if self.m_path and self.m_string:
23 return "Build error: %s (referring to %s)" % (
24 self.m_string, self.m_path)
26 return "Build error (referring to %s)" % (self.m_path)
28 return "Build error: %s" % (self.m_string)
38 lldb_repository_url="http://llvm.org/svn/llvm-project/lldb/trunk",
39 llvm_repository_url="http://llvm.org/svn/llvm-project/llvm/trunk",
40 clang_repository_url="http://llvm.org/svn/llvm-project/cfe/trunk",
42 self.m_build_directory_path = os.path.abspath(build_directory_path)
43 self.m_log_path = os.path.abspath(log_path)
44 self.m_lldb_repository_url = lldb_repository_url
45 self.m_llvm_repository_url = llvm_repository_url
46 self.m_clang_repository_url = clang_repository_url
47 self.m_revision = revision
48 self.m_log_stream = None
51 if os.path.exists(self.m_build_directory_path):
53 string="Build directory exists",
54 path=self.m_build_directory_path)
55 if os.path.exists(self.m_log_path):
56 raise BuildError(string="Log file exists", path=self.m_log_path)
57 self.m_log_stream = open(self.m_log_path, 'w')
58 os.mkdir(self.m_build_directory_path)
61 os.chdir(self.m_build_directory_path)
65 if self.m_revision is not None:
66 cmdline_prefix = ["svn", "-r %s" % (self.m_revision), "co"]
68 cmdline_prefix = ["svn", "co"]
70 returncode = subprocess.call(
72 self.m_lldb_repository_url,
74 stdout=self.m_log_stream,
75 stderr=self.m_log_stream)
77 raise BuildError(string="Couldn't checkout LLDB")
81 returncode = subprocess.call(
83 self.m_llvm_repository_url,
85 stdout=self.m_log_stream,
86 stderr=self.m_log_stream)
89 raise BuildError(string="Couldn't checkout LLVM")
91 os.symlink("llvm.checkout", "llvm")
93 os.chdir("llvm/tools")
95 returncode = subprocess.call(
97 self.m_clang_repository_url,
99 stdout=self.m_log_stream,
100 stderr=self.m_log_stream)
103 raise BuildError(string="Couldn't checkout Clang")
106 os.chdir(self.m_build_directory_path)
107 os.chdir("lldb/llvm")
109 returncode = subprocess.call(["./configure",
110 "--disable-optimized",
111 "--enable-assertions",
112 "--enable-targets=x86,x86_64,arm"],
113 stdout=self.m_log_stream,
114 stderr=self.m_log_stream)
117 raise BuildError(string="Couldn't configure LLVM/Clang")
119 returncode = subprocess.call(["make"],
120 stdout=self.m_log_stream,
121 stderr=self.m_log_stream)
124 raise BuildError(string="Couldn't build LLVM/Clang")
126 os.chdir(self.m_build_directory_path)
129 returncode = subprocess.call(["xcodebuild",
130 "-project", "lldb.xcodeproj",
131 "-target", "lldb-tool",
132 "-configuration", "Debug",
134 "LLVM_CONFIGURATION=Debug+Asserts",
136 stdout=self.m_log_stream,
137 stderr=self.m_log_stream)
140 raise BuildError(string="Couldn't build LLDB")
143 os.chdir(self.m_build_directory_path)
144 os.chdir("lldb/test")
146 returncode = subprocess.call(["./dotest.py", "-t"],
147 stdout=self.m_log_stream,
148 stderr=self.m_log_stream)
152 self.m_log_stream.close()
153 shutil.rmtree(self.m_build_directory_path)
164 parser = argparse.ArgumentParser(
165 description="Try to build LLDB/LLVM/Clang and run the full test suite.")
170 help="A (nonexistent) path to put temporary build products into",
176 help="The name of a (nonexistent) log file",
182 help="The LLVM revision to use",
186 parser = GetArgParser()
187 arg_dict = vars(parser.parse_args())
189 build_bot = LLDBBuildBot(build_directory_path=arg_dict["build_path"],
190 log_path=arg_dict["log_file"],
191 revision=arg_dict["revision"])
195 except BuildError as err: