Author: nico
Date: Wed Apr  3 05:33:19 2019
New Revision: 357574

gn build: Add build files for clangd xpc framework code

This is a bit of a larger change since this is the first (and as far as
I can tell only) place where the LLVM build produces macOS framework

GN has some built-in support for this, so use that.
`gn help create_bundle` has a terse description (but it's a bit
outdated: `deps` must be `public_deps` and the conditionals in the
example in the help aren't quite right on non-iOS).

We need a new 'copy_bundle_data' tool, and since we copy the clangd.xpc
bundle as bundle_data into ClangdXPC.framework it needs to be able to
handle directories in addition to files.

GN also insists we have a compile_xcassets tool even though it's not
used. I just made that run `false`.

Despite GN's support for bundles, we still need to manually create the
expected symlink structure in the .framework bundle. Since this code
never runs on Windows, it's safe to create the symlinks before the
symlink targets exist, so we can just make the bundle depend on the
steps that create the symlinks. For this to work, change the symlink
script to create the symlink's containing directory if it doesn't yet

I locally verified that CMake and GN build create the same bundle
structure. (I noticed that both builds set LC_ID_DYLIB to the pre-copy
libClangdXPCLib.dylib name, but that seems to not cause any issues and
it happens in the CMake build too.)

(Also add an error message to clangd-xpc-test-client for when loading
the dylib fails – this was useful while locally debugging this.)

Differential Revision:


Modified: clang-tools-extra/trunk/clangd/xpc/framework/CMakeLists.txt
--- clang-tools-extra/trunk/clangd/xpc/framework/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/xpc/framework/CMakeLists.txt Wed Apr  3 
05:33:19 2019
@@ -1,6 +1,7 @@
-    ClangdXPC.cpp)
+  ClangdXPC.cpp
 add_clang_library(ClangdXPCLib SHARED

Modified: clang-tools-extra/trunk/clangd/xpc/test-client/ClangdXPCTestClient.cpp
--- clang-tools-extra/trunk/clangd/xpc/test-client/ClangdXPCTestClient.cpp 
+++ clang-tools-extra/trunk/clangd/xpc/test-client/ClangdXPCTestClient.cpp Wed 
Apr  3 05:33:19 2019
@@ -49,8 +49,10 @@ int main(int argc, char *argv[]) {
   // Open the ClangdXPC dylib in the framework.
   std::string LibPath = getLibraryPath();
   void *dlHandle = dlopen(LibPath.c_str(), RTLD_LOCAL | RTLD_FIRST);
-  if (!dlHandle)
+  if (!dlHandle) {
+    llvm::errs() << "Failed to load framework from \'" << LibPath << "\'\n";
     return 1;
+  }
   // Lookup the XPC service bundle name, and launch it.
   clangd_xpc_get_bundle_identifier_t clangd_xpc_get_bundle_identifier =

cfe-commits mailing list

Reply via email to