Skip to content

Commit

Permalink
Fix cmake for non-binary opts
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemartinlogan committed Jan 15, 2024
1 parent 8a17341 commit bce1a4d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 4 additions & 0 deletions jarvis_util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@
from jarvis_util.serialize.pickle import *
from jarvis_util.serialize.json_file import *
from jarvis_util.shell.filesystem import *
from jarvis_util.shell.pbs_exec import *
from jarvis_util.shell.exec import *
from jarvis_util.shell.exec_info import *
from jarvis_util.shell.ssh_exec import *
from jarvis_util.shell.pssh_exec import *
from jarvis_util.shell.process import *
from jarvis_util.shell.pscp import *
from jarvis_util.shell.slurm_exec import *
from jarvis_util.shell.scp import *
from jarvis_util.shell.compile import *
from jarvis_util.shell.mpi_exec import *
from jarvis_util.shell.local_exec import *
from jarvis_util.introspect.system_info import *
from jarvis_util.introspect.monitor import *
from jarvis_util.jutil_manager import *
2 changes: 2 additions & 0 deletions jarvis_util/introspect/monitor.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from jarvis_util.shell.exec import Exec

class Callgrind(Exec):
def __init__(self, cmd, exec_info=None):
super().__init__(f'valgrind --tool=callgrind {cmd}')
Expand Down
12 changes: 9 additions & 3 deletions jarvis_util/shell/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .filesystem import Mkdir

class Cmake(Exec):
def __init__(self, root_dir, out_dir, opts, exec_info):
def __init__(self, root_dir, out_dir, opts=None, exec_info=None):
"""
Run cmake
Expand All @@ -13,6 +13,8 @@ def __init__(self, root_dir, out_dir, opts, exec_info):
:param opts: A dict mapping cmake keys to values
:param exec_info: The execution info
"""
if exec_info is None:
exec_info = LocalExecInfo()
self.opts = opts
self.root_dir = root_dir
self.out_dir = out_dir
Expand All @@ -26,11 +28,15 @@ def __init__(self, root_dir, out_dir, opts, exec_info):
else:
self.cmd.append(f'-D{key}=OFF')
else:
self.cmd.append(f'-D{key}:{val}')
self.cmd.append(f'-D{key}={val}')
self.cmd = ' '.join(self.cmd)
super().__init__(self.cmd, exec_info.mod(cwd=self.out_dir))

class Make(Exec):
def __init__(selfs, build_dir, nthreads, install, exec_info):
def __init__(selfs, build_dir, nthreads=8, install=False,
exec_info=None):
if exec_info is None:
exec_info = LocalExecInfo()
if install:
cmd = f'make -j{nthreads} install'
else:
Expand Down

0 comments on commit bce1a4d

Please sign in to comment.