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