Skip to content

Commit f327741

Browse files
committed
generalize err and warn utilities for different build scripts
1 parent 50394b1 commit f327741

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

scripts/_build_helper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ def run(cmd, env=None, cwd=None):
2727
)
2828

2929

30-
def warn(msg: str):
31-
print(f"[build_locally][error] {msg}", file=sys.stderr)
30+
def warn(msg: str, script: str):
31+
print(f"[{script}][warning] {msg}", file=sys.stderr)
3232

3333

34-
def err(msg: str):
35-
print(f"[build_locally][error] {msg}", file=sys.stderr)
34+
def err(msg: str, script: str):
35+
print(f"[{script}][error] {msg}", file=sys.stderr)
3636

3737

3838
def make_cmake_args(

scripts/build_locally.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def parse_args():
170170

171171
def main():
172172
if sys.platform not in ["cygwin", "win32", "linux"]:
173-
err(f"{sys.platform} not supported")
173+
err(f"{sys.platform} not supported", "build_locally")
174174
args = parse_args()
175175
setup_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
176176

@@ -183,7 +183,10 @@ def main():
183183
clean_build_dir(setup_dir)
184184

185185
if args.no_level_zero and args.target_level_zero:
186-
err("Cannot combine --no-level-zero and --target-level-zero")
186+
err(
187+
"Cannot combine --no-level-zero and --target-level-zero",
188+
"build_locally",
189+
)
187190

188191
# Level Zero state (on unless explicitly disabled)
189192
if args.no_level_zero:
@@ -204,7 +207,7 @@ def main():
204207

205208
# handle architecture conflicts
206209
if args.target_hip is not None and not args.target_hip.strip():
207-
err("--target-hip requires an explicit architecture")
210+
err("--target-hip requires an explicit architecture", "build_locally")
208211

209212
# CUDA/HIP targets
210213
if args.target_cuda:
@@ -221,7 +224,7 @@ def main():
221224

222225
# ignore pre-existing CMAKE_ARGS for determinism in build driver
223226
if "CMAKE_ARGS" in env and env["CMAKE_ARGS"].strip():
224-
warn("Ignoring pre-existing CMAKE_ARGS in environment")
227+
warn("Ignoring pre-existing CMAKE_ARGS in environment", "build_locally")
225228
del env["CMAKE_ARGS"]
226229

227230
env["CMAKE_ARGS"] = cmake_args

scripts/gen_coverage.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ def parse_args():
173173
def main():
174174
is_linux = "linux" in sys.platform
175175
if not is_linux:
176-
err(f"{sys.platform} not supported")
176+
err(f"{sys.platform} not supported", "gen_coverage")
177177
args = parse_args()
178178
setup_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
179179

@@ -189,7 +189,10 @@ def main():
189189
clean_build_dir(setup_dir)
190190

191191
if args.no_level_zero and args.target_level_zero:
192-
err("Cannot combine --no-level-zero and --target-level-zero")
192+
err(
193+
"Cannot combine --no-level-zero and --target-level-zero",
194+
"gen_coverage",
195+
)
193196

194197
# Level Zero state (on unless explicitly disabled)
195198
if args.no_level_zero:
@@ -216,7 +219,7 @@ def main():
216219
env = os.environ.copy()
217220

218221
if "CMAKE_ARGS" in env and env["CMAKE_ARGS"].strip():
219-
warn("Ignoring pre-existing CMAKE_ARGS in environment")
222+
warn("Ignoring pre-existing CMAKE_ARGS in environment", "gen_coverage")
220223
del env["CMAKE_ARGS"]
221224

222225
if bin_llvm:

0 commit comments

Comments
 (0)