[Lldb-commits] [PATCH] D65114: [LLDB] Add utility to streamline Xcode project generation.
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 22 14:18:21 PDT 2019
JDevlieghere created this revision.
JDevlieghere added reviewers: lanza, clayborg, sgraenitz, jasonmolenda.
Herald added a subscriber: teemperor.
Herald added a project: LLDB.
JDevlieghere added a comment.
Currently outstanding questions are:
@clayborg
> Not sure why we need two different build directories? Can we just use the mono-repo style build and use "cmake -G Xcode"? Or is this just to appease the Apple build process?
@lanza
> This could probably be just a 10 line make file that you just make -f lldb/utils/xcode.mk. Not sure if you guys are a fan of this method, but we tend to find it to be much more manageable than custom python scripts.
This is a follow-up to D65109 <https://reviews.llvm.org/D65109> which removes the Xcode project. It seems that the script to generate the Xcode project was the most controversial, so I've split it off into a separate review.
>From the original patch:
> I created a new script to streamline the process: it creates two build directories in the current directory. The first directory is for LLVM and Clang which uses Ninja to build. The second directory is for LLBD, which configures a standalone build using the Xcode generator.
Repository:
rLLDB LLDB
https://reviews.llvm.org/D65114
Files:
lldb/utils/xcode.py
Index: lldb/utils/xcode.py
===================================================================
--- /dev/null
+++ lldb/utils/xcode.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+
+import sys
+import os
+import errno
+import subprocess
+import six
+from contextlib import contextmanager
+
+
+def mkdir(directory):
+ try:
+ os.makedirs(directory)
+ except OSError as e:
+ if e.errno != errno.EEXIST:
+ raise
+
+
+ at contextmanager
+def cwd(path):
+ oldpwd = os.getcwd()
+ os.chdir(path)
+ try:
+ yield
+ finally:
+ os.chdir(oldpwd)
+
+
+def build_llvm(llvm_path):
+ """Configures and builds LLVM & Clang with Ninja."""
+ build_path = os.path.join(os.getcwd(), 'llvm-build')
+ mkdir(build_path)
+ with cwd(build_path):
+ cmake_cmd = [
+ "cmake {}".format(llvm_path), "-GNinja",
+ "-DCMAKE_BUILD_TYPE='Release'", "-DLLVM_ENABLE_ASSERTIONS:BOOL=ON",
+ "-DLLVM_ENABLE_PROJECTS='clang;libcxx;libcxxabi'"
+ ]
+ subprocess.call(' '.join(cmake_cmd), shell=True)
+ subprocess.call('ninja', shell=True)
+ return build_path
+
+
+def configure_lldb(llvm_build_path, lldb_path, args):
+ """Configures an standalone build of LLDB with the Xcode generator."""
+ build_path = os.path.join(os.getcwd(), 'lldb-build')
+ cache_path = os.path.join(lldb_path, 'cmake', 'caches',
+ 'Apple-lldb-Xcode.cmake')
+ llvm_dir = os.path.join(llvm_build_path, 'lib', 'cmake', 'llvm')
+ clang_dir = os.path.join(llvm_build_path, 'lib', 'cmake', 'clang')
+ mkdir(build_path)
+ with cwd(build_path):
+ cmake_cmd = [
+ "cmake {}".format(lldb_path), "-GXcode", "-C{}".format(cache_path),
+ "-DLLVM_DIR='{}'".format(llvm_dir),
+ "-DClang_DIR='{}'".format(clang_dir)
+ ]
+ cmake_cmd.extend(args)
+ subprocess.call(' '.join(cmake_cmd), shell=True)
+ subprocess.call('open lldb.xcodeproj', shell=True)
+ return build_path
+
+
+def main():
+ """Generate an Xcode project for LLDB from CMake.
+
+ This scripts creates two build directories in the current directory: one
+ for LLVM and one for LLDB. The LLVM build uses the Ninja generator, the
+ LLDB build uses the Xcode generator.
+ """
+ args = sys.argv[1:]
+ lldb_path = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
+ llvm_path = os.path.join(os.path.dirname(lldb_path), 'llvm')
+
+ if not os.path.exists(llvm_path):
+ printf('This script only works with the LLVM monorepo')
+ exit(1)
+
+ llvm_build_path = build_llvm(llvm_path)
+ lldb_build_path = configure_lldb(llvm_build_path, lldb_path, args)
+
+
+if __name__ == "__main__":
+ main()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65114.211187.patch
Type: text/x-patch
Size: 2763 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190722/8db01174/attachment.bin>
More information about the lldb-commits
mailing list