File tree Expand file tree Collapse file tree 5 files changed +61
-4
lines changed
utils/bazel/llvm-project-overlay Expand file tree Collapse file tree 5 files changed +61
-4
lines changed Original file line number Diff line number Diff line change 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 ("//:vars.bzl" , "LLVM_VERSION_MAJOR" )
6+ load ("//clang:defs.bzl" , "BUILTIN_HEADERS_GEN_DIR" )
7+ load ("defs.bzl" , "symlink" )
8+
9+ package (
10+ default_visibility = ["//visibility:public" ],
11+ features = ["layering_check" ],
12+ )
13+
14+ licenses (["notice" ])
15+
16+ symlink (
17+ name = "builtin_headers" ,
18+ srcs = ["//clang:builtin_headers_gen" ],
19+ destination = "lib/clang/{0}/include" .format (LLVM_VERSION_MAJOR ),
20+ partition = BUILTIN_HEADERS_GEN_DIR ,
21+ )
Original file line number Diff line number Diff line change @@ -370,6 +370,7 @@ cc_library(
370370cc_binary (
371371 name = "clang-tidy" ,
372372 srcs = ["tool/ClangTidyToolMain.cpp" ],
373+ data = ["//clang-tools-extra:builtin_headers" ],
373374 stamp = 0 ,
374375 deps = [":tool" ],
375376)
Original file line number Diff line number Diff line change 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:paths.bzl" , "paths" )
6+
7+ def _symlink_impl (ctx ):
8+ copied_files = []
9+ for input_file in ctx .files .srcs :
10+ (_ , _ , relative_filename ) = input_file .path .rpartition (ctx .attr .partition )
11+ output_file = ctx .actions .declare_file (paths .join (ctx .attr .destination , relative_filename ))
12+ ctx .actions .symlink (
13+ target_file = input_file ,
14+ output = output_file ,
15+ )
16+ copied_files .append (output_file )
17+ return DefaultInfo (files = depset (copied_files ))
18+
19+ symlink = rule (
20+ implementation = _symlink_impl ,
21+ attrs = {
22+ "destination" : attr .string (mandatory = True ),
23+ "partition" : attr .string (mandatory = True ),
24+ "srcs" : attr .label_list (allow_files = True ),
25+ },
26+ )
Original file line number Diff line number Diff line change 1414 "LLVM_VERSION_MINOR" ,
1515 "LLVM_VERSION_PATCH" ,
1616)
17+ load ("defs.bzl" , "BUILTIN_HEADERS_GEN_DIR" )
1718
1819package (
1920 default_visibility = ["//visibility:public" ],
@@ -1696,14 +1697,17 @@ builtin_headers = glob(
16961697genrule (
16971698 name = "builtin_headers_gen" ,
16981699 srcs = builtin_headers ,
1699- outs = [hdr .replace ("lib/Headers/" , "staging/include/" ) for hdr in builtin_headers ],
1700+ outs = [
1701+ header .replace ("lib/Headers/" , BUILTIN_HEADERS_GEN_DIR )
1702+ for header in builtin_headers
1703+ ],
17001704 cmd = """
17011705 for src in $(SRCS); do
1702- relsrc=$${src#*"$(WORKSPACE_ROOT)"/clang/lib/Headers}
1703- target=$(@D)/staging/include/ $$relsrc
1706+ relsrc=$${{ src#*"$(WORKSPACE_ROOT)"/clang/lib/Headers} }
1707+ target=$(@D)/{resource_dir} $$relsrc
17041708 mkdir -p $$(dirname $$target)
17051709 cp $$src $$target
1706- done""" ,
1710+ done""" . format ( resource_dir = BUILTIN_HEADERS_GEN_DIR ) ,
17071711 output_to_bindir = 1 ,
17081712 toolchains = [
17091713 ":workspace_root" ,
Original file line number Diff line number Diff line change 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+ BUILTIN_HEADERS_GEN_DIR = "staging/include/"
You can’t perform that action at this time.
0 commit comments