Skip to content

Commit 1943d17

Browse files
oharboeclaude
andcommitted
bazel: replace genrule echo with write_file for hermeticity
Use skylib write_file instead of genrule with echo -e to generate StaConfig.hh. This avoids depending on the host shell and sets a better example for contributors who copy existing patterns. Remaining hermeticity nits for later: - BUILD.bazel OpenRoadVersion genrule uses grep/cut/printf Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent a0b6294 commit 1943d17

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

BUILD

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2025, The OpenROAD Authors
33

4+
load("@bazel_skylib//rules:write_file.bzl", "write_file")
45
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
56
load("@rules_cc//cc:cc_library.bzl", "cc_library")
67
load("//bazel:bison.bzl", "genyacc")
@@ -174,17 +175,17 @@ tcl_encode_sta(
174175
char_array_name = "tcl_inits",
175176
)
176177

177-
genrule(
178+
write_file(
178179
name = "StaConfig",
179-
srcs = [],
180-
outs = ["include/sta/StaConfig.hh"],
181-
cmd = """echo -e '
182-
#pragma once
183-
#define STA_VERSION "2.7.0"
184-
#define STA_GIT_SHA1 "f21d4a3878e2531e3af4930818d9b5968aad9416"
185-
#define SSTA 0
186-
#define ZLIB_FOUND' > \"$@\"
187-
""",
180+
out = "include/sta/StaConfig.hh",
181+
content = [
182+
"#pragma once",
183+
'#define STA_VERSION "2.7.0"',
184+
'#define STA_GIT_SHA1 "f21d4a3878e2531e3af4930818d9b5968aad9416"',
185+
"#define SSTA 0",
186+
"#define ZLIB_FOUND",
187+
"",
188+
],
188189
visibility = ["//:__subpackages__"],
189190
)
190191

0 commit comments

Comments
 (0)