[clang-tools-extra] [clangd] Make sure ninja can clean "ClangdXPC.framework" (PR #75669)

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 15 15:14:23 PST 2023


https://github.com/jansvoboda11 created https://github.com/llvm/llvm-project/pull/75669

After building the ClangdXPC target, `ninja clean` fails with the following error:

```
ninja: error: remove(lib/ClangdXPC.framework): Directory not empty
ninja: error: remove(<build>/lib/ClangdXPC.framework): Directory not empty
```

I did not find better way to make this work. I guess we could list all generated files (and directories) in `OUTPUT` of the custom command, but that seems fairly tedious/fragile.

>From f1785d70c9fb9eb9d23f7aa365f3f6993ad7206c Mon Sep 17 00:00:00 2001
From: Jan Svoboda <jan_svoboda at apple.com>
Date: Fri, 15 Dec 2023 15:07:00 -0800
Subject: [PATCH] [clangd] Make sure ninja can clean "ClangdXPC.framework"

After building the ClangdXPC target, `ninja clean` fails with the following error:

```
ninja: error: remove(lib/ClangdXPC.framework): Directory not empty
ninja: error: remove(<build>/lib/ClangdXPC.framework): Directory not empty
```

I did not find better way to make this work. I guess we could list all generated files (and directories) in `OUTPUT` of the custom command, but that seems fairly tedious/fragile.
---
 .../clangd/xpc/cmake/modules/CreateClangdXPCFramework.cmake | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/clang-tools-extra/clangd/xpc/cmake/modules/CreateClangdXPCFramework.cmake b/clang-tools-extra/clangd/xpc/cmake/modules/CreateClangdXPCFramework.cmake
index 46738a204ace14..d5ba44962dd528 100644
--- a/clang-tools-extra/clangd/xpc/cmake/modules/CreateClangdXPCFramework.cmake
+++ b/clang-tools-extra/clangd/xpc/cmake/modules/CreateClangdXPCFramework.cmake
@@ -71,6 +71,12 @@ macro(create_clangd_xpc_framework target name)
     ${CLANGD_FRAMEWORK_LOCATION}
   )
 
+  set_property(
+    TARGET ClangdXPC
+    APPEND
+    PROPERTY ADDITIONAL_CLEAN_FILES ${CLANGD_FRAMEWORK_LOCATION}
+  )
+
   # clangd is already signed as a standalone executable, so it must be forced.
   llvm_codesign(ClangdXPC BUNDLE_PATH "${CLANGD_FRAMEWORK_OUT_LOCATION}/XPCServices/${CLANGD_XPC_SERVICE_NAME}.xpc/" FORCE)
   # ClangdXPC library is already signed as a standalone library, so it must be forced.



More information about the cfe-commits mailing list