[lit] Improve lit.Run class
[llvm-complete.git] / utils / gn / secondary / clang-tools-extra / clangd / xpc / framework / BUILD.gn
blob9b11f265da36ece8b54cee5c76457a7c7f4643ef
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 ######################################################################
11 # clangd.xpc bundle
13 write_cmake_config("XPCServiceInfo.plist") {
14   input = "../cmake/XPCServiceInfo.plist.in"
15   output = "$target_gen_dir/XPCServiceInfo.plist"
16   service_name = "clangd"
17   values = [
18     "CLANGD_XPC_SERVICE_NAME=$service_name",
19     "CLANGD_XPC_SERVICE_BUNDLE_NAME=org.llvm.$service_name",
20   ]
23 bundle_data("clangxpc_bundle_xpc_service_info_plist") {
24   public_deps = [
25     ":XPCServiceInfo.plist",
26   ]
27   sources = [
28     "$target_gen_dir/XPCServiceInfo.plist",
29   ]
30   outputs = [
31     "{{bundle_contents_dir}}/Info.plist",
32   ]
35 bundle_data("clangxpc_bundle_xpc_service_executable") {
36   public_deps = [
37     "//clang-tools-extra/clangd/tool:clangd",
38   ]
39   sources = [
40     "$root_out_dir/bin/clangd",
41   ]
42   outputs = [
43     "{{bundle_executable_dir}}/{{source_file_part}}",
44   ]
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"
55   deps = [
56     ":clangxpc_bundle_xpc_service_executable",
57     ":clangxpc_bundle_xpc_service_info_plist",
58   ]
61 ######################################################################
62 # ClangdXPC.framework
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") {
71   public_deps = [
72     ":Info.plist",
73   ]
74   sources = [
75     "$target_gen_dir/Info.plist",
76   ]
77   outputs = [
78     "{{bundle_resources_dir}}/{{source_file_part}}",
79   ]
82 shared_library("ClangdXPCLib") {
83   deps = [
84     "//clang-tools-extra/clangd/tool:clangd",
85   ]
86   sources = [
87     "ClangdXPC.cpp",
88   ]
91 bundle_data("clangdxpc_bundle_executable") {
92   public_deps = [
93     ":ClangdXPCLib",
94   ]
95   sources = [
96     "$root_out_dir/lib/libClangdXPCLib.dylib",
97   ]
98   outputs = [
99     "{{bundle_executable_dir}}/ClangdXPC",
100   ]
103 bundle_data("clangdxpc_bundle_xpc") {
104   public_deps = [
105     ":clangd.xpc",
106   ]
107   sources = [
108     "$target_gen_dir/clangd.xpc",
109   ]
110   outputs = [
111     "{{bundle_contents_dir}}/XPCServices/{{source_file_part}}",
112   ]
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.
122 symlinks = [
123   "ClangdXPC",
124   "Resources",
125   "XPCServices",
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"
131   }
133 symlink_or_copy("clangdxpc_symlink_Versions_Current") {
134   source = "A"
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"
145   deps = [
146     ":clangdxpc_bundle_executable",
147     ":clangdxpc_bundle_info_plist",
148     ":clangdxpc_bundle_xpc",
149     ":clangdxpc_symlink_Versions_Current",
150   ]
151   foreach(target, symlinks) {
152     deps += [ ":clangdxpc_symlink_$target" ]
153   }