Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Dockerfile.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM ubuntu:22.04

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
g++ && rm -rf /var/lib/apt/lists/*

COPY . /src
WORKDIR /src

7 changes: 5 additions & 2 deletions mkconcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,8 +842,8 @@ def cleanup_script_files():
logging.info("assuming .m extension for Dockerfile")
with open(src_path) as fsource:
source_content = fsource.read()
except:
logging.error(f"{CONCOREPATH} is not correct path to concore")
except OSError as e:
logging.error(f"Cannot read Dockerfile template '{src_path}': {e}")
sys.exit(1)
dockerfile_parent = os.path.dirname(dockerfile_path)
if dockerfile_parent:
Expand All @@ -862,6 +862,9 @@ def cleanup_script_files():
if langext=="sh":
fcopy.write('CMD ["./'+sourcecode+'" ,"/opt/mcr/v910"]') # 5/19/21
#["./run_pmmat.sh", "/opt/mcr/MATLAB/MATLAB_Runtime/v910"]
if langext=="cpp":
fcopy.write('RUN g++ ./'+sourcecode+'\n')
fcopy.write('CMD ["./a.out"]\n')
if langext=="v":
fcopy.write('RUN iverilog ./'+sourcecode+'\n') # 7/02/21
fcopy.write('CMD ["./a.out"]\n') # 7/02/21
Expand Down
33 changes: 33 additions & 0 deletions tests/test_docker_cpp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import subprocess
import sys
from pathlib import Path

REPO = Path(__file__).resolve().parent.parent


def test_dockerfile_cpp_template_exists():
assert (REPO / "Dockerfile.cpp").is_file()


def test_docker_build_for_cpp_node(tmp_path):
out = tmp_path / "study"
result = subprocess.run(
[
sys.executable,
str(REPO / "mkconcore.py"),
str(REPO / "testsou" / "testSM1.graphml"),
str(REPO / "testsou"),
str(out),
"docker",
],
capture_output=True,
text=True,
)
assert result.returncode == 0, result.stdout + result.stderr
dockerfiles = sorted((out / "src").glob("Dockerfile.*"))
assert dockerfiles
for df in dockerfiles:
text = df.read_text()
assert "g++" in text
assert "RUN g++ ./" in text
assert 'CMD ["./a.out"]' in text
Loading