Debian Codegraph @

utils/bazel/llvm-project-overlay/lldb/BUILD.bazel

raw
1 # This file is licensed under the Apache License v2.0 with LLVM Exceptions.
2 # See https://llvm.org/LICENSE.txt for license information.
3 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5 load("@bazel_skylib//lib:selects.bzl", "selects")
6 load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
7 load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
8 load("@build_bazel_apple_support//rules:apple_genrule.bzl", "apple_genrule")
9 load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_import", "cc_library", "objc_library")
10 load("@rules_python//python:defs.bzl", "py_binary")
11 load("//:vars.bzl", "LLVM_VERSION_MAJOR", "LLVM_VERSION_MINOR", "LLVM_VERSION_PATCH", "LLVM_VERSION_SUFFIX", "PACKAGE_VERSION")
12 load("//lldb/source/Plugins:plugin_config.bzl", "DEFAULT_PLUGINS", "DEFAULT_SCRIPT_PLUGINS", "OBJCPP_COPTS")
13 load("//mlir:build_defs.bzl", "cc_headers_only")
14 load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library")
15
16 package(
17 default_visibility = ["//visibility:public"],
18 features = ["layering_check"],
19 )
20
21 licenses(["notice"])
22
23 exports_files([
24 "LICENSE.TXT",
25 "source/API/liblldb-private.exports",
26 "source/API/liblldb.exports",
27 ])
28
29 bool_flag(
30 name = "enable_curses",
31 build_setting_default = False,
32 )
33
34 config_setting(
35 name = "curses_enabled_setting",
36 flag_values = {":enable_curses": "true"},
37 )
38
39 selects.config_setting_group(
40 name = "curses_enabled",
41 match_any = [
42 ":curses_enabled_setting",
43 "@platforms//os:macos",
44 ],
45 )
46
47 bool_flag(
48 name = "enable_libedit",
49 build_setting_default = False,
50 )
51
52 config_setting(
53 name = "libedit_enabled_setting",
54 flag_values = {":enable_libedit": "true"},
55 )
56
57 selects.config_setting_group(
58 name = "libedit_enabled",
59 match_any = [
60 ":libedit_enabled_setting",
61 "@platforms//os:macos",
62 ],
63 )
64
65 selects.config_setting_group(
66 name = "needs_libbsd",
67 match_all = [
68 ":libedit_enabled_setting",
69 "@platforms//os:linux",
70 ],
71 )
72
73 _VERSION_SUBSTITUTIONS = {
74 "@LLDB_VERSION@": PACKAGE_VERSION,
75 "@LLDB_VERSION_MAJOR@": LLVM_VERSION_MAJOR,
76 "@LLDB_VERSION_MINOR@": LLVM_VERSION_MINOR,
77 "@LLDB_VERSION_PATCH@": LLVM_VERSION_PATCH,
78 "@LLDB_VERSION_SUFFIX@": LLVM_VERSION_SUFFIX,
79 '#cmakedefine LLDB_FULL_VERSION_STRING "@LLDB_FULL_VERSION_STRING@"': "/* #undef LLDB_FULL_VERSION_STRING */",
80 }
81
82 genrule(
83 name = "vcs_version_gen",
84 outs = ["VCSVersion.inc"],
85 cmd = "echo '#undef LLDB_REVISION' >> $@\n" +
86 "echo '#undef LLDB_REPOSITORY' >> $@\n",
87 )
88
89 expand_template(
90 name = "version_inc_gen",
91 out = "Version/Version.inc",
92 substitutions = _VERSION_SUBSTITUTIONS,
93 template = "include/lldb/Version/Version.inc.in",
94 )
95
96 cc_library(
97 name = "Version",
98 srcs = [
99 "source/Version/Version.cpp",
100 ":vcs_version_gen",
101 ":version_inc_gen",
102 ],
103 hdrs = ["include/lldb/Version/Version.h"],
104 features = ["-layering_check"], # Version.inc breaks this unintentionally
105 includes = ["include"],
106 deps = ["//clang:basic"],
107 )
108
109 expand_template(
110 name = "ConfigHeader",
111 out = "include/lldb/Host/Config.h",
112 substitutions = {
113 "#cmakedefine01 HAVE_PTSNAME_R": "#define HAVE_PTSNAME_R 1",
114 "#cmakedefine01 LLDB_ENABLE_TERMIOS": "#define LLDB_ENABLE_TERMIOS 1",
115
116 # TODO: Add LZMA support by including the library in bazel
117 "#cmakedefine01 LLDB_ENABLE_LZMA": "#define LLDB_ENABLE_LZMA 0",
118
119 # TODO: lua support
120 "#cmakedefine01 LLDB_ENABLE_LUA": "#define LLDB_ENABLE_LUA 0",
121
122 # TODO: curl support
123 "#cmakedefine01 LLVM_ENABLE_CURL": "#define LLVM_ENABLE_CURL 0",
124
125 # TODO: python support
126 # Note this substitution has to be defined before LLDB_ENABLE_PYTHON.
127 # Otherwise it will get replaced to 0_LIMITED_API.
128 "#cmakedefine01 LLDB_ENABLE_PYTHON_LIMITED_API": "#define LLDB_ENABLE_PYTHON_LIMITED_API 0",
129 "#cmakedefine01 LLDB_ENABLE_PYTHON": "#define LLDB_ENABLE_PYTHON 0",
130 # Only enabled by default on Windows
131 "#cmakedefine01 LLDB_EMBED_PYTHON_HOME": "#define LLDB_EMBED_PYTHON_HOME 0",
132 # Only used if LLDB_EMBED_PYTHON_HOME is true
133 "#cmakedefine LLDB_PYTHON_HOME R\"(${LLDB_PYTHON_HOME})\"": "#define LLDB_PYTHON_HOME \"\"",
134
135 # Unsupported
136 "#cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H": "#define CURSES_HAVE_NCURSES_CURSES_H 0",
137 "#cmakedefine01 LLDB_ENABLE_FBSDVMCORE": "#define LLDB_ENABLE_FBSDVMCORE 0",
138
139 # Defaults that could be configurable if needed
140 "#cmakedefine01 LLDB_ENABLE_POSIX": "#define LLDB_ENABLE_POSIX 1",
141 "#cmakedefine LLDB_GLOBAL_INIT_DIRECTORY R\"(${LLDB_GLOBAL_INIT_DIRECTORY})\"": "#define LLDB_GLOBAL_INIT_DIRECTORY \"\"",
142 "${LLDB_INSTALL_LIBDIR_BASENAME}": "lib",
143 "${LLDB_BUG_REPORT_URL}": "",
144 } | select({
145 "@platforms//os:macos": {
146 "#cmakedefine01 HAVE_LIBCOMPRESSION": "#define HAVE_LIBCOMPRESSION 1",
147 "#cmakedefine01 HAVE_NR_PROCESS_VM_READV": "#define HAVE_NR_PROCESS_VM_READV 0",
148 "#cmakedefine01 HAVE_PPOLL": "#define HAVE_PPOLL 0",
149 "#cmakedefine01 HAVE_PROCESS_VM_READV": "#define HAVE_PROCESS_VM_READV 0",
150 "#cmakedefine01 HAVE_SYS_EVENT_H": "#define HAVE_SYS_EVENT_H 1",
151 "#cmakedefine01 LLDB_ENABLE_LIBXML2": "#define LLDB_ENABLE_LIBXML2 1",
152 "#cmakedefine01 LLDB_HAVE_EL_RFUNC_T": "#define LLDB_HAVE_EL_RFUNC_T 0",
153 },
154 "@platforms//os:linux": {
155 "#cmakedefine01 HAVE_LIBCOMPRESSION": "#define HAVE_LIBCOMPRESSION 0",
156 "#cmakedefine01 HAVE_NR_PROCESS_VM_READV": "#define HAVE_NR_PROCESS_VM_READV 1",
157 "#cmakedefine01 HAVE_PPOLL": "#define HAVE_PPOLL 1",
158 "#cmakedefine01 HAVE_PROCESS_VM_READV": "#define HAVE_PROCESS_VM_READV 1",
159 "#cmakedefine01 HAVE_SYS_EVENT_H": "#define HAVE_SYS_EVENT_H 0",
160 "#cmakedefine01 LLDB_ENABLE_LIBXML2": "#define LLDB_ENABLE_LIBXML2 0",
161 "#cmakedefine01 LLDB_HAVE_EL_RFUNC_T": "#define LLDB_HAVE_EL_RFUNC_T 1",
162 },
163 }) | select({
164 ":curses_enabled": {
165 "#cmakedefine01 LLDB_ENABLE_CURSES": "#define LLDB_ENABLE_CURSES 1",
166 },
167 "//conditions:default": {
168 "#cmakedefine01 LLDB_ENABLE_CURSES": "#define LLDB_ENABLE_CURSES 0",
169 },
170 }) | select({
171 ":libedit_enabled": {
172 "#cmakedefine01 LLDB_EDITLINE_USE_WCHAR": "#define LLDB_EDITLINE_USE_WCHAR 1",
173 "#cmakedefine01 LLDB_ENABLE_LIBEDIT": "#define LLDB_ENABLE_LIBEDIT 1",
174 },
175 "//conditions:default": {
176 "#cmakedefine01 LLDB_EDITLINE_USE_WCHAR": "#define LLDB_EDITLINE_USE_WCHAR 0",
177 "#cmakedefine01 LLDB_ENABLE_LIBEDIT": "#define LLDB_ENABLE_LIBEDIT 0",
178 },
179 }),
180 template = "include/lldb/Host/Config.h.cmake",
181 )
182
183 cc_library(
184 name = "Config",
185 hdrs = [":ConfigHeader"],
186 include_prefix = "lldb/Host",
187 )
188
189 cc_binary(
190 name = "lldb-tblgen",
191 srcs = glob([
192 "utils/TableGen/*.cpp",
193 "utils/TableGen/*.h",
194 ]),
195 deps = [
196 "//llvm:CodeGenTypes",
197 "//llvm:Support",
198 "//llvm:TableGen",
199 "//llvm:TargetParser",
200 "//llvm:config",
201 ],
202 )
203
204 py_binary(
205 name = "generate-sbapi-dwarf-enum",
206 srcs = ["scripts/generate-sbapi-dwarf-enum.py"],
207 )
208
209 genrule(
210 name = "lldb-sbapi-dwarf-enums",
211 srcs = ["//llvm:include/llvm/BinaryFormat/Dwarf.def"],
212 outs = ["include/lldb/API/SBLanguages.h"],
213 cmd = "$(location :generate-sbapi-dwarf-enum) $(location //llvm:include/llvm/BinaryFormat/Dwarf.def) --output $@",
214 tools = [":generate-sbapi-dwarf-enum"],
215 )
216
217 cc_library(
218 name = "API",
219 srcs = glob([
220 "source/API/**/*.cpp",
221 "source/API/**/*.h",
222 ]),
223 hdrs = glob(["include/lldb/API/**/*.h"]) + [":lldb-sbapi-dwarf-enums"],
224 includes = ["include"],
225 deps = [
226 ":Breakpoint",
227 ":Commands",
228 ":Core",
229 ":DataFormatters",
230 ":Expression",
231 ":Headers",
232 ":Host",
233 ":Initialization",
234 ":InterpreterHeaders",
235 ":Symbol",
236 ":SymbolHeaders",
237 ":Target",
238 ":TargetHeaders",
239 ":Utility",
240 ":Version",
241 "//lldb/source/Plugins:PluginExpressionParserClang",
242 "//lldb/source/Plugins:PluginExpressionParserClangHeaders",
243 "//lldb/source/Plugins:PluginsConfig",
244 "//llvm:AllTargetsDisassemblers",
245 "//llvm:ExecutionEngine",
246 "//llvm:MCJIT",
247 "//llvm:Support",
248 "//llvm:config",
249 ] + [
250 "//lldb/source/Plugins:Plugin{}".format(x)
251 for x in DEFAULT_PLUGINS + DEFAULT_SCRIPT_PLUGINS
252 ] + select({
253 "@platforms//os:macos": [
254 "//lldb/source/Plugins:PluginProcessMacOSXKernel",
255 "//lldb/source/Plugins:PluginSymbolLocatorDebugSymbols",
256 "//lldb/source/Plugins:PluginSymbolVendorMacOSX",
257 ],
258 "@platforms//os:linux": [
259 "//lldb/source/Plugins:PluginProcessLinux",
260 ],
261 "//conditions:default": [],
262 }),
263 alwayslink = True,
264 )
265
266 cc_library(
267 name = "Breakpoint",
268 srcs = glob(["source/Breakpoint/**/*.cpp"]),
269 hdrs = glob(["include/lldb/Breakpoint/**/*.h"]),
270 includes = ["include"],
271 deps = [
272 ":Core",
273 ":DataFormattersHeaders",
274 ":Expression",
275 ":Headers",
276 ":InterpreterHeaders",
277 ":SymbolHeaders",
278 ":TargetHeaders",
279 ":Utility",
280 "//llvm:Support",
281 ],
282 )
283
284 cc_library(
285 name = "DataFormatters",
286 srcs = glob([
287 "source/DataFormatters/**/*.cpp",
288 "source/DataFormatters/**/*.h",
289 ]),
290 hdrs = glob(["include/lldb/DataFormatters/**/*.h"]),
291 includes = ["include"],
292 textual_hdrs = glob(["source/DataFormatters/**/*.def"]),
293 deps = [
294 ":CoreHeaders",
295 ":Headers",
296 ":InterpreterHeaders",
297 ":SymbolHeaders",
298 ":TargetHeaders",
299 ":Utility",
300 "//llvm:Support",
301 "//llvm:Telemetry",
302 ],
303 )
304
305 cc_library(
306 name = "Expression",
307 srcs = glob(["source/Expression/**/*.cpp"]),
308 hdrs = glob(["include/lldb/Expression/**/*.h"]) + [":lldb-sbapi-dwarf-enums"],
309 includes = ["include"],
310 deps = [
311 ":Core",
312 ":Headers",
313 ":Host",
314 ":InterpreterHeaders",
315 ":SymbolHeaders",
316 ":TargetHeaders",
317 ":Utility",
318 "//lldb/source/Plugins:PluginSymbolFileDWARFHeaders",
319 "//llvm:BinaryFormat",
320 "//llvm:Core",
321 "//llvm:DebugInfoDWARF",
322 "//llvm:DebugInfoDWARFLowLevel",
323 "//llvm:ExecutionEngine",
324 "//llvm:Support",
325 ],
326 )
327
328 cc_library(
329 name = "Initialization",
330 srcs = glob(["source/Initialization/**/*.cpp"]),
331 hdrs = glob(["include/lldb/Initialization/**/*.h"]),
332 includes = ["include"],
333 deps = [
334 ":Core",
335 ":Headers",
336 ":Host",
337 ":TargetHeaders",
338 ":Utility",
339 ":Version",
340 "//lldb/source/Plugins:PluginProcessGDBRemote",
341 "//lldb/source/Plugins:PluginProcessPOSIX",
342 "//llvm:Support",
343 ],
344 )
345
346 gentbl_cc_library(
347 name = "InterpreterProperties",
348 strip_include_prefix = "source/Interpreter",
349 tbl_outs = {
350 "source/Interpreter/InterpreterProperties.inc": ["-gen-lldb-property-defs"],
351 "source/Interpreter/InterpreterPropertiesEnum.inc": ["-gen-lldb-property-enum-defs"],
352 },
353 tblgen = ":lldb-tblgen",
354 td_file = "source/Interpreter/InterpreterProperties.td",
355 deps = [":CoreTdFiles"],
356 )
357
358 cc_library(
359 name = "APIHeaders",
360 hdrs = glob(["include/lldb/API/**/*.h"]),
361 includes = ["include"],
362 )
363
364 cc_library(
365 name = "InterpreterHeaders",
366 hdrs = glob(["include/lldb/Interpreter/**/*.h"]),
367 includes = ["include"],
368 deps = [":APIHeaders"],
369 )
370
371 cc_library(
372 name = "BreakpointHeaders",
373 hdrs = glob(["include/lldb/Breakpoint/**/*.h"]),
374 includes = ["include"],
375 )
376
377 cc_library(
378 name = "ExpressionHeaders",
379 hdrs = glob(["include/lldb/Expression/**/*.h"]) + [":lldb-sbapi-dwarf-enums"],
380 includes = ["include"],
381 deps = ["//llvm:ExecutionEngine"],
382 )
383
384 cc_library(
385 name = "DataFormattersHeaders",
386 hdrs = glob(["include/lldb/DataFormatters/**/*.h"]),
387 includes = ["include"],
388 )
389
390 cc_library(
391 name = "Interpreter",
392 srcs = glob(["source/Interpreter/**/*.cpp"]),
393 deps = [
394 ":API",
395 ":Commands",
396 ":Core",
397 ":DataFormatters",
398 ":Headers",
399 ":Host",
400 ":InterpreterHeaders",
401 ":InterpreterProperties",
402 ":SymbolHeaders",
403 ":TargetHeaders",
404 ":Utility",
405 "//llvm:Support",
406 "//llvm:Telemetry",
407 ],
408 )
409
410 td_library(
411 name = "CommandsTdFiles",
412 srcs = glob(["source/Commands/**/*.td"]),
413 )
414
415 gentbl_cc_library(
416 name = "CommandOptions",
417 strip_include_prefix = "source/Commands",
418 tbl_outs = {"source/Commands/CommandOptions.inc": ["-gen-lldb-option-defs"]},
419 tblgen = ":lldb-tblgen",
420 td_file = "source/Commands/Options.td",
421 deps = [":CommandsTdFiles"],
422 )
423
424 cc_library(
425 name = "Commands",
426 srcs = glob(["source/Commands/**/*.cpp"]),
427 hdrs = glob(["source/Commands/**/*.h"]),
428 includes = ["source"],
429 deps = [
430 ":Breakpoint",
431 ":CommandOptions",
432 ":Core",
433 ":DataFormatters",
434 ":Expression",
435 ":Headers",
436 ":Host",
437 ":InterpreterHeaders",
438 ":SymbolHeaders",
439 ":Target",
440 ":TargetHeaders",
441 ":Utility",
442 ":Version",
443 "//clang:codegen",
444 "//clang:driver",
445 "//clang:frontend",
446 "//clang:serialization",
447 "//llvm:Support",
448 ],
449 )
450
451 cc_library(
452 name = "SymbolHeaders",
453 hdrs = glob(["include/lldb/Symbol/**/*.h"]),
454 includes = ["include"],
455 )
456
457 cc_library(
458 name = "Symbol",
459 srcs = glob(["source/Symbol/**/*.cpp"]),
460 deps = [
461 ":Core",
462 ":Expression",
463 ":Headers",
464 ":Host",
465 ":SymbolHeaders",
466 ":TargetHeaders",
467 ":Utility",
468 ":UtilityPrivateHeaders",
469 "//llvm:BinaryFormat",
470 "//llvm:DebugInfo",
471 "//llvm:DebugInfoDWARF",
472 "//llvm:DebugInfoDWARFLowLevel",
473 "//llvm:Support",
474 ],
475 )
476
477 cc_library(
478 name = "HostMacOSXHeaders",
479 hdrs = glob([
480 "include/lldb/Host/*.h",
481 "include/lldb/Host/macosx/*.h",
482 "include/lldb/Host/posix/*.h",
483 ]),
484 includes = ["include"],
485 deps = [":UtilityHeaders"],
486 )
487
488 cc_library(
489 name = "HostMacOSXPrivateHeaders",
490 hdrs = glob([
491 "source/Host/macosx/cfcpp/*.h",
492 "source/Host/macosx/objcxx/*.h",
493 ]),
494 includes = ["source"],
495 tags = ["nobuildkite"],
496 target_compatible_with = select({
497 "@platforms//os:macos": [],
498 "//conditions:default": ["@platforms//:incompatible"],
499 }),
500 deps = [":UtilityHeaders"],
501 )
502
503 objc_library(
504 name = "HostMacOSXObjCXX",
505 copts = OBJCPP_COPTS,
506 non_arc_srcs = glob(["source/Host/macosx/objcxx/*.mm"]),
507 tags = ["nobuildkite"],
508 target_compatible_with = select({
509 "@platforms//os:macos": [],
510 "//conditions:default": ["@platforms//:incompatible"],
511 }),
512 deps = [
513 ":Headers",
514 ":HostMacOSXHeaders",
515 ":HostMacOSXPrivateHeaders",
516 ":UtilityHeaders",
517 "//llvm:Support",
518 "//llvm:TargetParser",
519 ],
520 )
521
522 cc_library(
523 name = "Host",
524 srcs = glob([
525 "source/Host/common/**/*.cpp",
526 ]) + select({
527 "@platforms//os:linux": glob(
528 [
529 "source/Host/posix/**/*.cpp",
530 "source/Host/linux/**/*.cpp",
531 ],
532 exclude = ["source/Host/linux/android/**/*.cpp"],
533 ),
534 "@platforms//os:macos": glob(
535 [
536 "source/Host/macosx/cfcpp/*.cpp",
537 "source/Host/posix/**/*.cpp",
538 ],
539 ),
540 }),
541 hdrs = [":ConfigHeader"] + glob([
542 "include/lldb/Host/*.h",
543 "include/lldb/Host/common/*.h",
544 ]) + select({
545 "@platforms//os:macos": glob([
546 "include/lldb/Host/macosx/*.h",
547 "include/lldb/Host/posix/*.h",
548 ]),
549 "@platforms//os:linux": glob([
550 "include/lldb/Host/linux/*.h",
551 "include/lldb/Host/posix/*.h",
552 ]),
553 }),
554 features = ["-layering_check"], # histedit.h breaks this.
555 includes = ["include"],
556 # TODO: Move this to Config library when https://github.com/bazelbuild/bazel/issues/21884 is fixed
557 linkopts = select({
558 "@platforms//os:macos": [
559 "-lcompression",
560 "-lxml2",
561 "-Wl,-framework,CoreServices",
562 "-Wl,-framework,Security",
563 ],
564 "//conditions:default": [],
565 }) + select({
566 ":curses_enabled": [
567 "-lcurses",
568 "-lpanel",
569 ],
570 "//conditions:default": [],
571 }) + select({
572 ":libedit_enabled": [
573 "-ledit",
574 ],
575 "//conditions:default": [],
576 }) + select({
577 ":needs_libbsd": [
578 "-lbsd",
579 ],
580 "//conditions:default": [],
581 }),
582 deps = [
583 ":Headers",
584 ":UtilityHeaders",
585 "//llvm:Object",
586 "//llvm:Support",
587 "//llvm:TargetParser",
588 "//llvm:config",
589 ] + select({
590 "@platforms//os:macos": [
591 ":HostMacOSXObjCXX",
592 ":HostMacOSXPrivateHeaders",
593 ],
594 "//conditions:default": [],
595 }),
596 )
597
598 cc_headers_only(
599 name = "HostHeaders",
600 src = ":Host",
601 )
602
603 td_library(
604 name = "CoreTdFiles",
605 srcs = glob([
606 "source/Core/**/*.td",
607 "include/lldb/Core/*.td",
608 ]),
609 )
610
611 gentbl_cc_library(
612 name = "CoreProperties",
613 strip_include_prefix = "source/Core",
614 tbl_outs = {
615 "source/Core/CoreProperties.inc": ["-gen-lldb-property-defs"],
616 "source/Core/CorePropertiesEnum.inc": ["-gen-lldb-property-enum-defs"],
617 },
618 tblgen = ":lldb-tblgen",
619 td_file = "source/Core/CoreProperties.td",
620 deps = [":CoreTdFiles"],
621 )
622
623 cc_library(
624 name = "CoreHeaders",
625 hdrs = glob([
626 "include/lldb/Core/**/*.h",
627 "include/lldb/ValueObject/**/*.h", # This should be its own library.
628 ]),
629 includes = ["include"],
630 deps = [
631 ":BreakpointHeaders",
632 ":CoreProperties",
633 ":DataFormattersHeaders",
634 ":ExpressionHeaders",
635 ":Host",
636 ":InterpreterHeaders",
637 ":SymbolHeaders",
638 ":TargetHeaders",
639 "//clang:driver",
640 "//llvm:Demangle",
641 "//llvm:Support",
642 "//llvm:TargetParser",
643 ],
644 )
645
646 cc_library(
647 name = "Core",
648 srcs = glob(
649 [
650 "source/Core/**/*.cpp",
651 "source/ValueObject/**/*.cpp", # This should be its own library.
652 ],
653 ),
654 hdrs = glob(
655 [
656 "include/lldb/Core/**/*.h",
657 "include/lldb/ValueObject/**/*.h", # This should be its own library.
658 ],
659 ),
660 includes = ["include"],
661 deps = [
662 ":BreakpointHeaders",
663 ":CoreHeaders",
664 ":CoreProperties",
665 ":DataFormattersHeaders",
666 ":ExpressionHeaders",
667 ":Headers",
668 ":Host",
669 ":InterpreterHeaders",
670 ":SymbolHeaders",
671 ":TargetHeaders",
672 ":Utility",
673 ":Version",
674 "//clang:driver",
675 "//lldb/source/Plugins:PluginCPlusPlusLanguageHeaders",
676 "//lldb/source/Plugins:PluginObjCLanguageHeaders",
677 "//llvm:BinaryFormat",
678 "//llvm:Demangle",
679 "//llvm:Support",
680 "//llvm:TargetParser",
681 "//llvm:Telemetry",
682 "//llvm:config",
683 ],
684 )
685
686 gentbl_cc_library(
687 name = "TargetProperties",
688 strip_include_prefix = "source/Target",
689 tbl_outs = {
690 "source/Target/TargetProperties.inc": ["-gen-lldb-property-defs"],
691 "source/Target/TargetPropertiesEnum.inc": ["-gen-lldb-property-enum-defs"],
692 },
693 tblgen = ":lldb-tblgen",
694 td_file = "source/Target/TargetProperties.td",
695 deps = [":CoreTdFiles"],
696 )
697
698 cc_library(
699 name = "AppleArm64ExceptionClass",
700 hdrs = ["include/lldb/Target/AppleArm64ExceptionClass.def"],
701 strip_include_prefix = "include/lldb/Target",
702 )
703
704 cc_library(
705 name = "TargetHeaders",
706 hdrs = glob(["include/lldb/Target/**/*.h"]),
707 includes = ["include"],
708 deps = [
709 ":AppleArm64ExceptionClass",
710 ":BreakpointHeaders",
711 ],
712 )
713
714 cc_library(
715 name = "Target",
716 srcs = glob(["source/Target/**/*.cpp"]),
717 deps = [
718 ":BreakpointHeaders",
719 ":Core",
720 ":DataFormattersHeaders",
721 ":ExpressionHeaders",
722 ":Headers",
723 ":Host",
724 ":InterpreterHeaders",
725 ":Symbol",
726 ":SymbolHeaders",
727 ":TargetHeaders",
728 ":TargetProperties",
729 ":Utility",
730 "//clang:codegen",
731 "//lldb/source/Plugins:PluginProcessUtility",
732 "//llvm:BinaryFormat",
733 "//llvm:MC",
734 "//llvm:Support",
735 ],
736 )
737
738 cc_library(
739 name = "Headers",
740 hdrs = glob(["include/lldb/lldb-*.h"]) + [
741 "include/lldb/Symbol/SaveCoreOptions.h",
742 ],
743 includes = ["include"],
744 )
745
746 cc_library(
747 name = "UtilityPrivateHeaders",
748 hdrs = glob(["source/Utility/**/*.h"]),
749 includes = ["source"],
750 deps = [":Headers"],
751 )
752
753 cc_library(
754 name = "UtilityHeaders",
755 hdrs = glob(["include/lldb/Utility/**/*.h"]),
756 includes = ["include"],
757 )
758
759 cc_library(
760 name = "Utility",
761 srcs = glob(["source/Utility/**/*.cpp"]),
762 hdrs = glob(["include/lldb/Utility/**/*.h"]),
763 includes = ["include"],
764 deps = [
765 ":CoreHeaders",
766 ":Headers",
767 ":TargetHeaders",
768 ":UtilityPrivateHeaders",
769 "//llvm:BinaryFormat",
770 "//llvm:Support",
771 "//llvm:TargetParser",
772 "//llvm:config",
773 ],
774 )
775
776 genrule(
777 name = "gen_exports_file_linux",
778 srcs = ["//lldb:source/API/liblldb-private.exports"],
779 outs = ["exports_linux.txt"],
780 cmd = """
781 cat > $(OUTS) <<EOF
782 {
783 global:
784 $$(sed 's/$$/;/g' $(SRCS))
785 };
786 EOF
787 """,
788 )
789
790 genrule(
791 name = "gen_exports_file_macos",
792 srcs = ["//lldb:source/API/liblldb-private.exports"],
793 outs = ["exports_macos.txt"],
794 cmd = "sed 's/^/_/g' $(SRCS) > $(OUTS)",
795 )
796
797 # Create a shared library using linkshared=True for liblldb. This uses
798 # cc_binary instead of cc_shared_library since the latter expects you to
799 # re-export all transitive dependencies vs them being relinked into other
800 # binaries.
801 cc_binary(
802 name = "lldb{}".format(PACKAGE_VERSION),
803 additional_linker_inputs = select({
804 "@platforms//os:linux": [
805 ":gen_exports_file_linux",
806 ],
807 "@platforms//os:macos": [
808 ":gen_exports_file_macos",
809 ],
810 "//conditions:default": [],
811 }),
812 linkopts = select({
813 "@platforms//os:linux": [
814 "-Wl,--export-dynamic-symbol-list=$(location :gen_exports_file_linux)",
815 ],
816 "@platforms//os:macos": [
817 "-Wl,-exported_symbols_list,$(location :gen_exports_file_macos)",
818 ],
819 "//conditions:default": [],
820 }),
821 linkshared = True,
822 deps = [
823 ":API",
824 ":Interpreter",
825 ],
826 )
827
828 # cc_binary targets using linkshared=True to build a shared library cannot be
829 # imported directly and instead need to be referenced indirectly through
830 # cc_import
831 cc_import(
832 name = "liblldb.wrapper",
833 shared_library = "lldb{}".format(PACKAGE_VERSION),
834 )
835
836 gentbl_cc_library(
837 name = "lldb_options_inc_gen",
838 strip_include_prefix = ".",
839 tbl_outs = {"Options.inc": ["-gen-opt-parser-defs"]},
840 tblgen = "//llvm:llvm-tblgen",
841 td_file = "tools/driver/Options.td",
842 deps = ["//llvm:OptParserTdFiles"],
843 )
844
845 alias(
846 name = "gdb-server",
847 actual = select({
848 "@platforms//os:macos": ":debugserver",
849 "//conditions:default": ":lldb-server",
850 }),
851 )
852
853 cc_binary(
854 name = "lldb",
855 srcs = glob([
856 "tools/driver/*.cpp",
857 "tools/driver/*.h",
858 ]),
859 deps = [
860 ":APIHeaders",
861 ":HostHeaders",
862 ":UtilityHeaders",
863 ":liblldb.wrapper",
864 ":lldb_options_inc_gen",
865 "//llvm:Option",
866 "//llvm:Support",
867 ],
868 )
869
870 cc_library(
871 name = "DebugServerCommonMacOSXHeaders",
872 hdrs = glob(["tools/debugserver/source/MacOSX/**/*.h"]),
873 strip_include_prefix = "tools/debugserver/source/MacOSX",
874 )
875
876 cc_library(
877 name = "DebugServerCommonHeaders",
878 hdrs = glob(["tools/debugserver/source/**/*.h"]),
879 strip_include_prefix = "tools/debugserver/source",
880 deps = [":DebugServerCommonMacOSXHeaders"],
881 )
882
883 objc_library(
884 name = "DebugServerMacOSX",
885 copts = OBJCPP_COPTS,
886 non_arc_srcs = glob(["tools/debugserver/source/MacOSX/*.mm"]),
887 tags = ["nobuildkite"],
888 target_compatible_with = select({
889 "@platforms//os:macos": [],
890 "//conditions:default": ["@platforms//:incompatible"],
891 }),
892 deps = [
893 ":DebugServerCommonHeaders",
894 ":DebugServerCommonMacOSXHeaders",
895 ],
896 )
897
898 cc_library(
899 name = "DebugServerCommon",
900 srcs = glob(
901 ["tools/debugserver/source/**/*.cpp"],
902 exclude = ["tools/debugserver/source/debugserver.cpp"],
903 ),
904 local_defines = ["LLDB_USE_OS_LOG"],
905 tags = ["nobuildkite"],
906 deps = [
907 ":DebugServerCommonHeaders",
908 ":DebugServerCommonMacOSXHeaders",
909 ":DebugServerMacOSX",
910 ":Host",
911 ],
912 )
913
914 apple_genrule(
915 name = "mach_gen",
916 srcs = ["tools/debugserver/source/MacOSX/dbgnub-mig.defs"],
917 outs = [
918 "mach_exc.h",
919 "mach_excServer.c",
920 "mach_excUser.c",
921 ],
922 cmd = "mig -header $(location :mach_exc.h) -server $(location :mach_excServer.c) -user $(location :mach_excUser.c) $(SRCS)",
923 tags = [
924 "manual",
925 "nobuildkite",
926 ],
927 target_compatible_with = select({
928 "@platforms//os:macos": [],
929 "//conditions:default": ["@platforms//:incompatible"],
930 }),
931 )
932
933 expand_template(
934 name = "debugserver_version_gen",
935 out = "debugserver_vers.c",
936 substitutions = _VERSION_SUBSTITUTIONS,
937 template = "tools/debugserver/source/debugserver_vers.c.in",
938 )
939
940 cc_binary(
941 name = "debugserver_unsigned",
942 srcs = [
943 "tools/debugserver/source/debugserver.cpp",
944 ":debugserver_version_gen",
945 ":mach_gen",
946 ],
947 tags = ["nobuildkite"],
948 target_compatible_with = select({
949 "@platforms//os:macos": [],
950 "//conditions:default": ["@platforms//:incompatible"],
951 }),
952 deps = [
953 ":DebugServerCommon",
954 ":DebugServerCommonHeaders",
955 ":DebugServerCommonMacOSXHeaders",
956 ],
957 )
958
959 apple_genrule(
960 name = "debugserver_signed",
961 srcs = [":debugserver_unsigned"],
962 outs = ["debugserver"],
963 cmd = "cp $(SRCS) $(OUTS) && xcrun codesign -f -s - --entitlements $(location tools/debugserver/resources/debugserver-macosx-entitlements.plist) $(OUTS)",
964 tags = [
965 "manual",
966 "nobuildkite",
967 ],
968 target_compatible_with = select({
969 "@platforms//os:macos": [],
970 "//conditions:default": ["@platforms//:incompatible"],
971 }),
972 tools = [
973 "tools/debugserver/resources/debugserver-macosx-entitlements.plist",
974 ],
975 )
976
977 cc_binary(
978 name = "lldb-argdumper",
979 srcs = glob(["tools/argdumper/*.cpp"]),
980 deps = ["//llvm:Support"],
981 )
982
983 gentbl_cc_library(
984 name = "lldb_server_opts_gen",
985 strip_include_prefix = ".",
986 tbl_outs = {"LLGSOptions.inc": ["-gen-opt-parser-defs"]},
987 tblgen = "//llvm:llvm-tblgen",
988 td_file = "tools/lldb-server/LLGSOptions.td",
989 deps = ["//llvm:OptParserTdFiles"],
990 )
991
992 gentbl_cc_library(
993 name = "lldb_platform_opts_gen",
994 strip_include_prefix = ".",
995 tbl_outs = {"PlatformOptions.inc": ["-gen-opt-parser-defs"]},
996 tblgen = "//llvm:llvm-tblgen",
997 td_file = "tools/lldb-server/PlatformOptions.td",
998 deps = ["//llvm:OptParserTdFiles"],
999 )
1000
1001 cc_binary(
1002 name = "lldb-server",
1003 srcs = glob([
1004 "tools/lldb-server/*.cpp",
1005 "tools/lldb-server/*.h",
1006 ]),
1007 target_compatible_with = select({
1008 "@platforms//os:linux": [],
1009 "@platforms//os:macos": [],
1010 # TODO: This can theoretically support more platforms, but it hasn't been tested yet
1011 "//conditions:default": ["@platforms//:incompatible"],
1012 }),
1013 deps = [
1014 ":Host",
1015 ":Initialization",
1016 ":Interpreter",
1017 ":Utility",
1018 ":Version",
1019 ":lldb_platform_opts_gen",
1020 ":lldb_server_opts_gen",
1021 "//lldb:Target",
1022 "//lldb:TargetHeaders",
1023 "//lldb/source/Plugins:PluginCPlusPlusLanguage",
1024 "//lldb/source/Plugins:PluginExpressionParserClang",
1025 "//lldb/source/Plugins:PluginInstructionARM",
1026 "//lldb/source/Plugins:PluginInstructionARM64",
1027 "//lldb/source/Plugins:PluginInstructionLoongArch",
1028 "//lldb/source/Plugins:PluginInstructionMIPS",
1029 "//lldb/source/Plugins:PluginInstructionMIPS64",
1030 "//lldb/source/Plugins:PluginInstructionRISCV",
1031 "//lldb/source/Plugins:PluginObjCLanguage",
1032 "//lldb/source/Plugins:PluginProcessGDBRemote",
1033 "//lldb/source/Plugins:PluginProcessWasm",
1034 "//lldb/source/Plugins:PluginSymbolFileDWARF",
1035 "//lldb/source/Plugins:PluginSymbolFileNativePDB",
1036 "//lldb/source/Plugins:PluginSymbolFilePDB",
1037 "//lldb/source/Plugins:PluginTypeSystemClang",
1038 "//llvm:Option",
1039 "//llvm:Support",
1040 ] + select({
1041 "@platforms//os:linux": [
1042 "//lldb/source/Plugins:PluginObjectFileELF",
1043 "//lldb/source/Plugins:PluginProcessLinux",
1044 ],
1045 "@platforms//os:macos": [
1046 "//lldb/source/Plugins:PluginObjectFileMachO",
1047 ],
1048 "//conditions:default": [],
1049 }),
1050 )
1051
1052 expand_template(
1053 name = "lldb-dap-plist",
1054 out = "lldb-dap-Info.plist",
1055 substitutions = {
1056 "${LLDB_VERSION}": PACKAGE_VERSION,
1057 },
1058 template = "tools/lldb-dap/tool/lldb-dap-Info.plist.in",
1059 )
1060
1061 gentbl_cc_library(
1062 name = "lldb_dap_opts_gen",
1063 strip_include_prefix = "tools/lldb-dap",
1064 tbl_outs = {"tools/lldb-dap/Options.inc": ["-gen-opt-parser-defs"]},
1065 tblgen = "//llvm:llvm-tblgen",
1066 td_file = "tools/lldb-dap/tool/Options.td",
1067 deps = ["//llvm:OptParserTdFiles"],
1068 )
1069
1070 cc_binary(
1071 name = "lldb-dap",
1072 srcs = glob([
1073 "tools/lldb-dap/**/*.cpp",
1074 "tools/lldb-dap/**/*.h",
1075 ]),
1076 additional_linker_inputs = [
1077 ":lldb-dap-plist",
1078 ],
1079 includes = ["tools/lldb-dap"],
1080 linkopts = select({
1081 "@platforms//os:macos": [
1082 "-Wl,-sectcreate,__TEXT,__info_plist,$(location :lldb-dap-plist)",
1083 ],
1084 "//conditions:default": [],
1085 }),
1086 deps = [
1087 ":lldb_dap_opts_gen",
1088 "//lldb:APIHeaders",
1089 "//lldb:Headers",
1090 "//lldb:Host",
1091 "//lldb:Utility",
1092 "//lldb:liblldb.wrapper",
1093 "//llvm:Option",
1094 "//llvm:Support",
1095 "//llvm:config",
1096 ],
1097 )