Skip to content

Commit 3eac5bc

Browse files
committed
Use --ccache-skip to detect ccache instead of using symlinks
1 parent 56c9a9d commit 3eac5bc

1 file changed

Lines changed: 19 additions & 12 deletions

File tree

src/tools.bzl

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def _codechecker_local_repository_impl(repository_ctx):
8787

8888
analyzers = repository_ctx.execute([codechecker_bin_path, "analyzers"])
8989

90-
parsed_analyzers = []
90+
parsed_analyzers = {}
9191

9292
lines = analyzers.stdout.strip().split('\n')
9393
for line in lines:
@@ -100,18 +100,25 @@ def _codechecker_local_repository_impl(repository_ctx):
100100
if 'NOT' not in parts:
101101
path = parts[1]
102102
version = parts[2]
103-
parsed_analyzers.append(
104-
{'tool_name': tool_name, 'path': path, 'version': version}
103+
parsed_analyzers[tool_name] = {'path': path, 'version': version}
104+
bash_bin = repository_ctx.which("bash")
105+
clang_ccache = repository_ctx.execute(
106+
[
107+
bash_bin, "-c",
108+
"{} -xc -c - --ccache-skip </dev/null".format(
109+
parsed_analyzers["clangsa"]["path"])]
110+
)
111+
gcc_ccache = repository_ctx.execute(
112+
[
113+
bash_bin, "-c",
114+
"{} -xc -c - --ccache-skip </dev/null".format(
115+
parsed_analyzers["gcc"]["path"]
105116
)
106-
107-
ccache_bin_path = repository_ctx.which("ccache")
108-
readlink_bin = repository_ctx.which("readlink")
109-
for item in parsed_analyzers:
110-
realpath = repository_ctx.execute(
111-
[readlink_bin, "-f", item["path"]]
112-
).stdout
113-
if realpath.strip() == str(ccache_bin_path) and ccache_disable != "1":
114-
fail("ERROR! ccache detected")
117+
]
118+
)
119+
if (clang_ccache.return_code == 0 or gcc_ccache.return_code == 0) and \
120+
ccache_disable != "1":
121+
fail("ERROR! ccache detected")
115122

116123
defs = "CODECHECKER_BIN_PATH = '{}'\n".format(codechecker_bin_path) + \
117124
"CCACHE_DISABLE = '{}'\n".format(ccache_disable)

0 commit comments

Comments
 (0)