Skip to content

Commit

Permalink
Merge branch 'main' into feature/fgrg_rofi_bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
mvertens authored Aug 11, 2024
2 parents c3a4ec0 + 46c1074 commit 42131d0
Showing 1 changed file with 42 additions and 24 deletions.
66 changes: 42 additions & 24 deletions cime_config/buildlib
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ def buildlib(bldroot, libroot, case):
strthread = "nothreads"
mpilib = case.get_value("MPILIB")
compiler = case.get_value("COMPILER")
sharedpath = os.path.join(compiler, mpilib, strdebug, strthread, "nuopc")

sharedpath = os.path.join(compiler, mpilib, strdebug, strthread)
sharedroot = case.get_value("SHAREDLIBROOT")
cdepsblddir = os.path.join(sharedroot, sharedpath, "CDEPS")

logger.info("Running cmake for CDEPS")
srcpath = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
cmake_flags = get_standard_cmake_args(case, os.path.join(sharedpath, "cdeps"))
Expand Down Expand Up @@ -147,31 +149,47 @@ def buildlib(bldroot, libroot, case):
else:
bld_time = src_time - 1

# if any file in src is newer than CmakeFiles in the build directory, rerun cmake
# Make sure that no other process is currently trying to build this library, done with a simple lockfile
if os.path.exists(cdepsblddir):
logger.info("{} already exists, checking for lockfile".format(cdepsblddir))
while os.path.exists(os.path.join(cdepsblddir,"lockfile")):
logger.info("Waiting for lockfile in {}".format(cdepsblddir))
time.sleep(10)
else:
logger.info("{} does not exist, creating lockfile".format(cdepsblddir))
os.makedirs(cdepsblddir)
with open(os.path.join(cdepsblddir,"lockfile"),"w") as fd:
fd.write(str(os.getpid()))

try:
# if any file in src is newer than CmakeFiles in the build directory, rerun cmake
if src_time > bld_time:
logger.info("cmake_flags {}".format(cmake_flags))
s, o, e = run_cmd(
"cmake {} ".format(cmake_flags), from_dir=bldroot, verbose=True
)
expect(not s, "ERROR from cmake output={}, error={}".format(o, e))
else:
# The dwav_lib is the last file built in cdeps, wait for it to be built
dwav_lib = os.path.join(bldroot, "dwav", "libdwav.a")
time_to_wait = 600
time_counter = 0
while not os.path.exists(dwav_lib):
time.sleep(1)
time_counter += 1
if time_counter > time_to_wait:
break
expect(time_counter <= time_to_wait, " Timeout waiting for {}".format(dwav_lib))

if src_time > bld_time:
logger.info("cmake_flags {}".format(cmake_flags))
s, o, e = run_cmd(
"cmake {} ".format(cmake_flags), from_dir=bldroot, verbose=True
"make install VERBOSE=1 DESTDIR={}".format(libroot),
from_dir=bldroot,
verbose=True,
)
expect(not s, "ERROR from cmake output={}, error={}".format(o, e))
else:
# The dwav_lib is the last file built in cdeps, wait for it to be built
dwav_lib = os.path.join(bldroot, "dwav", "libdwav.a")
time_to_wait = 300
time_counter = 0
while not os.path.exists(dwav_lib):
time.sleep(1)
time_counter += 1
if time_counter > time_to_wait:
break
expect(time_counter <= time_to_wait, " Timeout waiting for {}".format(dwav_lib))

s, o, e = run_cmd(
"make install VERBOSE=1 DESTDIR={}".format(libroot),
from_dir=bldroot,
verbose=True,
)
finally:
if os.path.exists(os.path.join(cdepsblddir,"lockfile")):
os.remove(os.path.join(cdepsblddir,"lockfile"))

expect(not s, "ERROR from make output={}, error={}".format(o, e))
logger.info("make output={}\nerror={}".format(o, e))
if compiler == "gnu" and case.get_value("DEBUG"):
Expand Down

0 comments on commit 42131d0

Please sign in to comment.