5
5
"""Helper macros to configure the LLVM overlay project."""
6
6
7
7
load ("@bazel_tools//tools/build_defs/repo:utils.bzl" , "maybe" )
8
+ load ("@bazel_skylib//lib:paths.bzl" , "paths" )
8
9
load (":zlib.bzl" , "llvm_zlib_disable" , "llvm_zlib_system" )
9
10
load (":terminfo.bzl" , "llvm_terminfo_disable" , "llvm_terminfo_system" )
10
11
@@ -32,11 +33,23 @@ DEFAULT_TARGETS = [
32
33
]
33
34
34
35
def _overlay_directories (repository_ctx ):
35
- src_path = repository_ctx .path (Label ("//:WORKSPACE" )).dirname
36
- bazel_path = src_path .get_child ("utils" ).get_child ("bazel" )
37
- overlay_path = bazel_path .get_child ("llvm-project-overlay" )
38
- script_path = bazel_path .get_child ("overlay_directories.py" )
36
+ src_workspace_path = str (repository_ctx .path (
37
+ repository_ctx .attr .src_workspace ,
38
+ ).dirname )
39
+
40
+ src_path = paths .join (src_workspace_path , repository_ctx .attr .src_path )
41
+
42
+ overlay_workspace_path = str (repository_ctx .path (
43
+ repository_ctx .attr .overlay_workspace ,
44
+ ).dirname )
45
+ overlay_path = paths .join (
46
+ overlay_workspace_path ,
47
+ repository_ctx .attr .overlay_path ,
48
+ )
39
49
50
+ overlay_script = repository_ctx .path (
51
+ repository_ctx .attr ._overlay_script ,
52
+ )
40
53
python_bin = repository_ctx .which ("python3" )
41
54
if not python_bin :
42
55
# Windows typically just defines "python" as python3. The script itself
@@ -48,7 +61,7 @@ def _overlay_directories(repository_ctx):
48
61
49
62
cmd = [
50
63
python_bin ,
51
- script_path ,
64
+ overlay_script ,
52
65
"--src" ,
53
66
src_path ,
54
67
"--overlay" ,
@@ -85,6 +98,14 @@ llvm_configure = repository_rule(
85
98
local = True ,
86
99
configure = True ,
87
100
attrs = {
101
+ "_overlay_script" : attr .label (
102
+ default = Label ("//:overlay_directories.py" ),
103
+ allow_single_file = True ,
104
+ ),
105
+ "overlay_workspace" : attr .label (default = Label ("//:WORKSPACE" )),
106
+ "overlay_path" : attr .string (default = DEFAULT_OVERLAY_PATH ),
107
+ "src_workspace" : attr .label (default = Label ("//:WORKSPACE" )),
108
+ "src_path" : attr .string (mandatory = True ),
88
109
"targets" : attr .string_list (default = DEFAULT_TARGETS ),
89
110
},
90
111
)
0 commit comments