Skip to content

Commit

Permalink
Merge pull request #1299 from LLNL/task/white238/move_to_tee
Browse files Browse the repository at this point in the history
Use `tee` instead of reading log files to the screen in Build scripts
  • Loading branch information
white238 committed Mar 25, 2024
2 parents d7aea21 + fb8ec96 commit ba885a1
Showing 1 changed file with 30 additions and 47 deletions.
77 changes: 30 additions & 47 deletions scripts/llnl_scripts/llnl_lc_build_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,14 @@ def build_and_test_host_config(test_root, host_config,
cfg_output_file = pjoin(test_root,"output.log.%s.configure.txt" % host_config_root)
print("[starting configure of %s]" % host_config)
print("[log file: %s]" % cfg_output_file)
res = sexe("%s config-build.py -bp %s -ip %s -bt %s -hc %s %s" % (sys.executable, build_dir, install_dir, build_type, host_config, extra_cmake_options),
output_file = cfg_output_file,
echo=True)

if report_to_stdout:
with open(cfg_output_file, 'r', encoding='utf8') as build_out:
print(build_out.read())
cmd = "{0} config-build.py -bp {1} -ip {2} -bt {3} -hc {4} {5} | tee {6}".format(sys.executable,
build_dir,
install_dir,
build_type,
host_config,
extra_cmake_options,
cfg_output_file)
res = sexe(cmd, echo=True)

if res != 0:
print("[ERROR: Configure for host-config: %s failed]\n" % host_config)
Expand All @@ -231,13 +232,8 @@ def build_and_test_host_config(test_root, host_config,
bld_output_file = pjoin(build_dir,"output.log.make.txt")
print("[starting build]")
print("[log file: %s]" % bld_output_file)
res = sexe("cd %s && make -j 16 VERBOSE=1 " % build_dir,
output_file = bld_output_file,
echo=True)

if report_to_stdout:
with open(bld_output_file, 'r', encoding='utf8') as build_out:
print(build_out.read())
cmd = "cd {0} && make -j 16 VERBOSE=1 | tee {1}".format(build_dir, bld_output_file)
res = sexe(cmd, echo=True)

if res != 0:
print("[ERROR: Build for host-config: %s failed]\n" % host_config)
Expand All @@ -249,15 +245,10 @@ def build_and_test_host_config(test_root, host_config,
print("[log file: %s]" % tst_output_file)

parallel_test = "" if test_serial else "-j16"
tst_cmd = "cd %s && make CTEST_OUTPUT_ON_FAILURE=1 test ARGS=\"--no-compress-output -T Test -VV %s\"" % (build_dir, parallel_test)

res = sexe(tst_cmd,
output_file = tst_output_file,
echo=True)

if report_to_stdout:
with open(tst_output_file, 'r', encoding='utf8') as test_out:
print(test_out.read())
tst_cmd = "cd {0} && make CTEST_OUTPUT_ON_FAILURE=1 test ARGS=\"--no-compress-output -T Test -VV {1}\" | tee {2}".format(build_dir,
parallel_test,
tst_output_file)
res = sexe(tst_cmd, echo=True)

# Convert CTest output to JUnit, do not overwrite previous res
print("[Checking to see if xsltproc exists...]")
Expand All @@ -284,26 +275,20 @@ def build_and_test_host_config(test_root, host_config,
print("[starting docs generation]")
print("[log file: %s]" % docs_output_file)

res = sexe("cd %s && make -j16 docs " % build_dir,
output_file = docs_output_file,
echo=True)

if report_to_stdout:
with open(docs_output_file, 'r', encoding='utf8') as docs_out:
print(docs_out.read())
docs_cmd = "cd {0} && make -j16 docs | tee {1}".format(build_dir, docs_output_file)
res = sexe(docs_cmd, echo=True)

if res != 0:
print("[ERROR: Docs generation for host-config: %s failed]\n\n" % host_config)
return res

# install the code
inst_output_file = pjoin(build_dir,"output.log.make.install.txt")
install_output_file = pjoin(build_dir,"output.log.make.install.txt")
print("[starting install]")
print("[log file: %s]" % inst_output_file)
print("[log file: %s]" % install_output_file)

res = sexe("cd %s && make -j16 install " % build_dir,
output_file = inst_output_file,
echo=True)
install_cmd = "cd {0} && make -j16 install | tee {1}".format(build_dir, install_output_file)
res = sexe(install_cmd, echo=True)

if res != 0:
print("[ERROR: Install for host-config: %s failed]\n\n" % host_config)
Expand Down Expand Up @@ -333,17 +318,16 @@ def build_and_test_host_config(test_root, host_config,
"mkdir build",
"cd build",
"""echo "[Configuring '{}' example]" """.format("using-with-cmake"),
"cmake -C ../host-config.cmake ..",
"cmake -C ../host-config.cmake .. | tee -a {0}".format(install_example_output_file),
"""echo "[Building '{}' example]" """.format("using-with-cmake"),
"make ",
"make | tee -a {0}".format(install_example_output_file),
"""echo "[Running '{}' example]" """.format("using-with-cmake"),
"./example",
"./example | tee -a {0}".format(install_example_output_file),
"""echo "[Done]" """
]

res = sexe(" && ".join(example_commands),
output_file = install_example_output_file,
echo=True)
cmd = " && ".join(example_commands)
res = sexe(cmd, echo=True)

if res != 0:
print("[ERROR: Installed 'using-with-cmake' example for host-config: %s failed]\n\n" % host_config)
Expand All @@ -362,17 +346,16 @@ def build_and_test_host_config(test_root, host_config,
"mkdir build",
"cd build",
"""echo "[Configuring '{}' example]" """.format("using-with-blt"),
"cmake -C ../host-config.cmake ..",
"cmake -C ../host-config.cmake .. | tee -a {0}".format(install_example_output_file),
"""echo "[Building '{}' example]" """.format("using-with-blt"),
"make ",
"make | tee -a {0}".format(install_example_output_file),
"""echo "[Running '{}' example]" """.format("using-with-blt"),
"./bin/example",
"./bin/example | tee -a {0}".format(install_example_output_file),
"""echo "[Done]" """
]

res = sexe(" && ".join(example_commands),
output_file = install_example_output_file,
echo=True)
cmd = " && ".join(example_commands)
res = sexe(cmd, echo=True)

if res != 0:
print("[ERROR: Installed 'using-with-blt' example for host-config: %s failed]\n\n" % host_config)
Expand Down

0 comments on commit ba885a1

Please sign in to comment.