55"""Helper macros to configure the LLVM overlay project."""
66
77load ("@bazel_tools//tools/build_defs/repo:utils.bzl" , "maybe" )
8+ load ("@bazel_skylib//lib:paths.bzl" , "paths" )
89load (":zlib.bzl" , "llvm_zlib_disable" , "llvm_zlib_system" )
910load (":terminfo.bzl" , "llvm_terminfo_disable" , "llvm_terminfo_system" )
1011
@@ -32,11 +33,23 @@ DEFAULT_TARGETS = [
3233]
3334
3435def _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+ )
3949
50+ overlay_script = repository_ctx .path (
51+ repository_ctx .attr ._overlay_script ,
52+ )
4053 python_bin = repository_ctx .which ("python3" )
4154 if not python_bin :
4255 # Windows typically just defines "python" as python3. The script itself
@@ -48,7 +61,7 @@ def _overlay_directories(repository_ctx):
4861
4962 cmd = [
5063 python_bin ,
51- script_path ,
64+ overlay_script ,
5265 "--src" ,
5366 src_path ,
5467 "--overlay" ,
@@ -85,6 +98,14 @@ llvm_configure = repository_rule(
8598 local = True ,
8699 configure = True ,
87100 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 ),
88109 "targets" : attr .string_list (default = DEFAULT_TARGETS ),
89110 },
90111)
0 commit comments