Skip to content

Commit

Permalink
allow to set build directory
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-François <[email protected]>
  • Loading branch information
bilboquet committed Dec 10, 2024
1 parent 52d7fc0 commit 02575ac
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
15 changes: 13 additions & 2 deletions massa_test_framework/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def __init__(self, server: Server, compile_opts: CompileOpts):
self.server = server
self.compile_opts = compile_opts

self._repo = ""
self._repo: Path = Path("")
self._target = ""
self._patches: Dict[str, bytes | str | Path | PatchConstant] = {}

Expand Down Expand Up @@ -115,7 +115,18 @@ def compile(self) -> None:
Raise:
RuntimeError: if git clone return non 0, cargo build return non 0, patch cannot be applied
"""
tmp_folder = self.server.mkdtemp(prefix="compile_massa_")
# build or rebuild into the predefined directory
if self.compile_opts.already_compiled is not None:
# assuming we are in compile it means me want to rebuild
# and reuse the same folder
# TODO: if the folder exists do a git pull instead of clone
# for now we assume the user just want to reuse he folder name
tmp_folder = self.compile_opts.already_compiled
if tmp_folder.exists():
self.server.rmtree(str(tmp_folder))
#self.server.mkdir(tmp_folder)
else: # use a temporary folder
tmp_folder = self.server.mkdtemp(prefix="compile_massa_")
# print(self.compile_opts)
# print(type(self.compile_opts))
cmd = ["git", "clone"]
Expand Down
5 changes: 5 additions & 0 deletions massa_test_framework/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@ def remove(self, path: str) -> None:
os.unlink(path)
else:
self.server.remove(str(path))
def rmtree(self, path: str) -> None:
if self.server_opts.local:
shutil.rmtree(path)
else:
raise NotImplementedError("Not implemented for remote server")

def stop(self, process):
if self.server_opts.local:
Expand Down

0 comments on commit 02575ac

Please sign in to comment.