|
1 | 1 | """A test rule to run clang-tidy""" |
2 | 2 |
|
3 | | -load("@bazel_skylib//lib:shell.bzl", "shell") |
4 | 3 | load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES") |
5 | 4 | load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain") |
6 | 5 | load(":clang_tidy.bzl", "deps_flags", "is_c_translation_unit", "rule_sources", "safe_flags", "toolchain_flags") |
7 | 6 |
|
| 7 | +def _quote(s): |
| 8 | + # Copied from https://github.com/bazelbuild/bazel-skylib/blob/main/lib/shell.bzl |
| 9 | + return "'" + s.replace("'", "'\\''") + "'" |
| 10 | + |
8 | 11 | # Tests run with a different directory structure than normal compiles. This |
9 | 12 | # fixes up include paths or any other arguments that are sensitive to this |
10 | 13 | def _fix_argument_path(ctx, arg): |
|
77 | 80 | output = ctx.outputs.executable.path, |
78 | 81 | c_sources = " ".join([x.short_path for x in srcs if is_c_translation_unit(x, ctx.attr.tags)]), |
79 | 82 | cxx_sources = " ".join([x.short_path for x in srcs if not is_c_translation_unit(x, ctx.attr.tags)]), |
80 | | - c_flags = " ".join([shell.quote(_fix_argument_path(ctx, x)) for x in ccinfo_copts + c_flags]), |
81 | | - cxx_flags = " ".join([shell.quote(_fix_argument_path(ctx, x)) for x in ccinfo_copts + cxx_flags]), |
| 83 | + c_flags = " ".join([_quote(_fix_argument_path(ctx, x)) for x in ccinfo_copts + c_flags]), |
| 84 | + cxx_flags = " ".join([_quote(_fix_argument_path(ctx, x)) for x in ccinfo_copts + cxx_flags]), |
82 | 85 | ), |
83 | 86 | ) |
84 | 87 |
|
|
0 commit comments