1 import("//llvm/utils/gn/build/symlink_or_copy.gni")
2 import("//llvm/utils/gn/build/write_cmake_config.gni")
4 # create_clangd_xpc_framework() in cmake creates both the ClangdXPC.framework
5 # bundle and the clangd.xpc bundle within it in a single action.
6 # Since GN has some native support for macOS bundles, it's more natural
7 # to have one create_bundle() each for both ClangdXPC.framework and clangd.xpc.
8 # See `llvm/utils/gn/gn.py help create_bundle` and ../cmake/modules.
10 ######################################################################
13 write_cmake_config("XPCServiceInfo.plist") {
14 input = "../cmake/XPCServiceInfo.plist.in"
15 output = "$target_gen_dir/XPCServiceInfo.plist"
16 service_name = "clangd"
18 "CLANGD_XPC_SERVICE_NAME=$service_name",
19 "CLANGD_XPC_SERVICE_BUNDLE_NAME=org.llvm.$service_name",
23 bundle_data("clangxpc_bundle_xpc_service_info_plist") {
25 ":XPCServiceInfo.plist",
28 "$target_gen_dir/XPCServiceInfo.plist",
31 "{{bundle_contents_dir}}/Info.plist",
35 bundle_data("clangxpc_bundle_xpc_service_executable") {
37 "//clang-tools-extra/clangd/tool:clangd",
40 "$root_out_dir/bin/clangd",
43 "{{bundle_executable_dir}}/{{source_file_part}}",
47 create_bundle("clangd.xpc") {
48 # .app directory structure.
49 # Since this target only exists to be copied into ClangdXPC.framework,
50 # put it in $target_gen_dir, not $root_out_dir.
51 bundle_root_dir = "$target_gen_dir/$target_name"
52 bundle_contents_dir = "$bundle_root_dir/Contents"
53 bundle_executable_dir = "$bundle_contents_dir/MacOS"
56 ":clangxpc_bundle_xpc_service_executable",
57 ":clangxpc_bundle_xpc_service_info_plist",
61 ######################################################################
64 write_cmake_config("Info.plist") {
65 input = "../cmake/Info.plist.in"
66 output = "$target_gen_dir/Info.plist"
67 values = [ "CLANGD_XPC_FRAMEWORK_NAME=ClangdXPC" ]
70 bundle_data("clangdxpc_bundle_info_plist") {
75 "$target_gen_dir/Info.plist",
78 "{{bundle_resources_dir}}/{{source_file_part}}",
82 shared_library("ClangdXPCLib") {
84 "//clang-tools-extra/clangd/tool:clangd",
91 bundle_data("clangdxpc_bundle_executable") {
96 "$root_out_dir/lib/libClangdXPCLib.dylib",
99 "{{bundle_executable_dir}}/ClangdXPC",
103 bundle_data("clangdxpc_bundle_xpc") {
108 "$target_gen_dir/clangd.xpc",
111 "{{bundle_contents_dir}}/XPCServices/{{source_file_part}}",
115 # .framework bundle symlinks:
116 # - ./ClangdXPC -> Versions/Current/ClangdXPC
117 # - ./Resources -> Versions/Current/Resources
118 # - ./XPCServices -> Versions/Current/XPCServices
119 # - ./Versions/Current -> Versions/A
120 # Since bundles are a mac thing, we know that symlink_or_copy() will symlink
121 # and not copy, and hence creating the symlink before the target exists is safe.
127 foreach(target, symlinks) {
128 symlink_or_copy("clangdxpc_symlink_$target") {
129 source = "Versions/Current/$target"
130 output = "$root_out_dir/lib/ClangdXPC.framework/$target"
133 symlink_or_copy("clangdxpc_symlink_Versions_Current") {
135 output = "$root_out_dir/lib/ClangdXPC.framework/Versions/Current"
138 create_bundle("ClangdXPC.framework") {
139 # .framework directory structure.
140 bundle_root_dir = "$root_out_dir/lib/$target_name"
141 bundle_contents_dir = "$bundle_root_dir/Versions/A"
142 bundle_executable_dir = "$bundle_contents_dir"
143 bundle_resources_dir = "$bundle_contents_dir/Resources"
146 ":clangdxpc_bundle_executable",
147 ":clangdxpc_bundle_info_plist",
148 ":clangdxpc_bundle_xpc",
149 ":clangdxpc_symlink_Versions_Current",
151 foreach(target, symlinks) {
152 deps += [ ":clangdxpc_symlink_$target" ]