File tree Expand file tree Collapse file tree 7 files changed +58
-5
lines changed Expand file tree Collapse file tree 7 files changed +58
-5
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ bzl_library(
19
19
srcs = glob (["*.bzl" ]),
20
20
visibility = ["//visibility:public" ],
21
21
deps = [
22
+ "//cc/private:paths_bzl" ,
22
23
"//cc/private/rules_impl:native_bzl" ,
23
24
],
24
25
)
@@ -29,6 +30,7 @@ bzl_library(
29
30
visibility = ["//visibility:public" ],
30
31
deps = [
31
32
":visibility_bzl" ,
33
+ "//cc/private:paths_bzl" ,
32
34
"//cc/private/rules_impl:objc_common" ,
33
35
],
34
36
)
Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
"""Utility functions for C++ rules."""
15
15
16
- load ("@bazel_skylib//lib:paths.bzl" , "paths" )
17
16
load ("//cc:find_cc_toolchain.bzl" , "CC_TOOLCHAIN_TYPE" )
17
+ load ("//cc/private:paths.bzl" , "is_path_absolute" )
18
18
load ("//cc/private/rules_impl:objc_common.bzl" , "objc_common" )
19
19
load (":cc_common.bzl" , "cc_common" )
20
20
load (
@@ -808,7 +808,7 @@ def _include_dirs(ctx, additional_make_variable_substitutions):
808
808
package_source_root = _package_source_root (ctx .label .workspace_name , package , sibling_repository_layout )
809
809
for include in ctx .attr .includes :
810
810
includes_attr = _expand (ctx , include , additional_make_variable_substitutions )
811
- if paths . is_absolute (includes_attr ):
811
+ if is_path_absolute (includes_attr ):
812
812
continue
813
813
includes_path = get_relative_path (package_exec_path , includes_attr )
814
814
if not sibling_repository_layout and path_contains_up_level_references (includes_path ):
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ Only use those within C++ implementation. The others need to go through cc_commo
19
19
"""
20
20
21
21
load ("@bazel_skylib//lib:paths.bzl" , "paths" )
22
+ load ("//cc/private:paths.bzl" , "is_path_absolute" )
22
23
23
24
# LINT.IfChange(forked_exports)
24
25
@@ -198,7 +199,7 @@ def repository_exec_path(repository, sibling_repository_layout):
198
199
# LINT.ThenChange(https://github.com/bazelbuild/bazel/blob/master/src/main/starlark/builtins_bzl/common/cc/cc_helper_internal.bzl:forked_exports)
199
200
200
201
def get_relative_path (path_a , path_b ):
201
- if paths . is_absolute (path_b ):
202
+ if is_path_absolute (path_b ):
202
203
return path_b
203
204
return paths .normalize (paths .join (path_a , path_b ))
204
205
Original file line number Diff line number Diff line change 12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
14
15
+ load ("@bazel_skylib//:bzl_library.bzl" , "bzl_library" )
16
+
15
17
filegroup (
16
18
name = "srcs" ,
17
19
srcs = glob ([
18
20
"**/BUILD" ,
21
+ "*.bzl" ,
19
22
]) + [
20
23
"//cc/private/rules_impl:srcs" ,
21
24
"//cc/private/toolchain:srcs" ,
22
25
],
23
26
visibility = ["//visibility:public" ],
24
27
)
28
+
29
+ bzl_library (
30
+ name = "paths_bzl" ,
31
+ srcs = ["paths.bzl" ],
32
+ visibility = ["//cc:__subpackages__" ],
33
+ )
Original file line number Diff line number Diff line change
1
+ # Copyright 2025 The Bazel Authors. All rights reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Paths utility functions."""
16
+
17
+ def is_path_absolute (path ):
18
+ """Checks whether a path is absolute or not.
19
+
20
+ Note that is does not take the execution platform into account.
21
+
22
+ This was implemented to replace skylib's paths.is_absolute, which
23
+ only checks for the presence of a colon character in the second position
24
+ of the paths
25
+
26
+ Args:
27
+ path: A path (as a string).
28
+
29
+ Returns:
30
+ `True` if `path` is an absolute path.
31
+ """
32
+
33
+ if path .startswith ("/" ):
34
+ return True
35
+
36
+ # Check for DOS-style absolute paths for Windows
37
+ return len (path ) >= 3 and \
38
+ path [0 ].isalpha () and \
39
+ path [1 ] == ":" and \
40
+ path [2 ] in ("/" , "\\ " )
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ bzl_library(
22
22
"//cc:action_names_bzl" ,
23
23
"//cc:cc_toolchain_config_lib_bzl" ,
24
24
"//cc:find_cc_toolchain_bzl" ,
25
+ "//cc/private:paths_bzl" ,
25
26
"//cc/private/rules_impl:cc_flags_supplier_lib_bzl" ,
26
27
"//cc/private/rules_impl:native_bzl" ,
27
28
"//cc/toolchains/impl:toolchain_impl_rules" ,
Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
"""All providers for rule-based bazel toolchain config."""
15
15
16
- load ("@bazel_skylib//lib:paths.bzl" , "paths" )
17
16
load ("@bazel_skylib//rules/directory:providers.bzl" , "DirectoryInfo" )
17
+ load ("//cc/private:paths.bzl" , "is_path_absolute" )
18
18
load ("//cc/toolchains/impl:args_utils.bzl" , "validate_env_variables" , "validate_nested_args" )
19
19
load (
20
20
"//cc/toolchains/impl:collect.bzl" ,
@@ -51,7 +51,7 @@ def _cc_args_impl(ctx):
51
51
)
52
52
53
53
for path in ctx .attr .allowlist_absolute_include_directories :
54
- if not paths . is_absolute (path ):
54
+ if not is_path_absolute (path ):
55
55
fail ("`{}` is not an absolute paths" .format (path ))
56
56
57
57
nested = None
You can’t perform that action at this time.
0 commit comments