Skip to content

Commit 466add4

Browse files
committed
[scoreboard] Create output dir if it is missing
1 parent 71df69c commit 466add4

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

scoreboard/CMakeLists.txt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,3 @@ add_custom_target(
1111
${OUTPUT_DIR}
1212
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
1313
COMMENT "Running main.py")
14-
15-
add_custom_command(
16-
TARGET generate_scoreboard
17-
POST_BUILD
18-
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/static
19-
${OUTPUT_DIR}/static
20-
COMMENT "Copying static directory to binary directory")

scoreboard/main.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import argparse
66
import subprocess
77
import yaml
8+
import shutil
89
from jinja2 import Environment, FileSystemLoader
910
import logging
1011

@@ -228,10 +229,22 @@ def main():
228229
)
229230
args = parser.parse_args()
230231

231-
output_file = Path(args.output) / "index.html"
232+
output_path = Path(args.output)
233+
output_path.mkdir(parents=True, exist_ok=True)
234+
output_file = output_path / "index.html"
232235
with open(output_file, "w") as file:
233236
file.write(html_content)
234237

238+
static_src = script_dir / "static"
239+
static_dst = output_path / "static"
240+
if static_src.exists():
241+
if static_dst.exists():
242+
shutil.rmtree(static_dst)
243+
shutil.copytree(static_src, static_dst)
244+
logger.info("Static directory copied to %s", static_dst)
245+
else:
246+
logger.warning("Static directory not found at %s", static_src)
247+
235248
logger.info("HTML page generated at %s", output_file)
236249

237250

0 commit comments

Comments
 (0)