Skip to content

Commit d054cd1

Browse files
authored
rtl: Implement dev-container setup for generated RTL project (#790)
1 parent e63edec commit d054cd1

File tree

7 files changed

+162
-4
lines changed

7 files changed

+162
-4
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "rtl (base: rtl-test-base)",
3+
"dockerComposeFile": "docker-compose.yaml",
4+
"service": "dev",
5+
"workspaceFolder": "/rtl",
6+
"shutdownAction": "stopCompose",
7+
"remoteUser": "root",
8+
"customizations": {
9+
"jetbrains": {
10+
"plugins": [
11+
"org.intellij.scala"
12+
]
13+
}
14+
}
15+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
services:
2+
dev:
3+
image: [(${image})]
4+
working_dir: /rtl
5+
6+
command: sleep infinity
7+
tty: true
8+
stdin_open: true
9+
10+
volumes:
11+
# Additional mounts
12+
# - ../vadl/test/resources/scripts/rtl:/scripts
13+
14+
# Persist tool caches
15+
- m2:/root/.m2
16+
- gradle:/root/.gradle
17+
- sdkman:/root/.sdkman
18+
volumes:
19+
m2:
20+
gradle:
21+
sdkman:

vadl/main/resources/templates/rtl/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ SCALAFMT_FILE = scalafmt-$(SCALAFMT_ARCH)-$(SCALAFMT_OS).zip
5757
SCALAFMT_URL = https://github.com/scalameta/scalafmt/releases/download/v$(SCALAFMT_VER)/$(SCALAFMT_FILE)
5858

5959
.scalafmt/$(SCALAFMT_FILE):
60-
mkdir -p $@
60+
mkdir -p $(dir $@)
6161
curl -L --output $@ "$(SCALAFMT_URL)"
6262
.scalafmt/scalafmt$(SCALAFMT_EXT): .scalafmt/$(SCALAFMT_FILE)
6363
unzip -od .scalafmt/ $<

vadl/main/vadl/pass/PassOrders.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@
131131
import vadl.rtl.passes.EmitElfSimPass;
132132
import vadl.rtl.passes.EmitModulesPass;
133133
import vadl.rtl.passes.EmitRVFIOutputsPass;
134+
import vadl.rtl.passes.EmitRtlDevcontainerConfigPass;
135+
import vadl.rtl.passes.EmitRtlDevcontainerDockerComposePass;
134136
import vadl.rtl.passes.EmitRtlMakefilePass;
135137
import vadl.rtl.passes.EmitScalafmtConfigPass;
136138
import vadl.rtl.passes.EmitSimMemCppPass;
@@ -792,6 +794,9 @@ private static void addRtlEmitPasses(PassOrder order, RtlConfiguration config) {
792794
// build files
793795
.add(new EmitScalafmtConfigPass(config))
794796
.add(new EmitRtlMakefilePass(config))
797+
// devcontainer
798+
.add(new EmitRtlDevcontainerConfigPass(config))
799+
.add(new EmitRtlDevcontainerDockerComposePass(config))
795800
.add(new CleanupEmitDirectoryPass(config));
796801
}
797802

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// SPDX-FileCopyrightText : © 2026 TU Wien <vadl@tuwien.ac.at>
2+
// SPDX-License-Identifier: GPL-3.0-or-later
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
package vadl.rtl.passes;
18+
19+
import java.util.Map;
20+
import vadl.configuration.GeneralConfiguration;
21+
import vadl.pass.PassResults;
22+
import vadl.template.AbstractTemplateRenderingPass;
23+
import vadl.viam.Specification;
24+
25+
/**
26+
* Emit the RTL Devcontainer JSON Config.
27+
*/
28+
public class EmitRtlDevcontainerConfigPass extends AbstractTemplateRenderingPass {
29+
30+
/**
31+
* Construct the RTL Devcontainer JSON emit pass.
32+
*
33+
* @param configuration the configuration
34+
*/
35+
public EmitRtlDevcontainerConfigPass(GeneralConfiguration configuration) {
36+
super(configuration, "rtl");
37+
}
38+
39+
@Override
40+
protected String getTemplatePath() {
41+
return "rtl/.devcontainer/devcontainer.json";
42+
}
43+
44+
@Override
45+
protected String getOutputPath() {
46+
return ".devcontainer/devcontainer.json";
47+
}
48+
49+
@Override
50+
protected Map<String, Object> createVariables(PassResults passResults,
51+
Specification specification) {
52+
return Map.of();
53+
}
54+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// SPDX-FileCopyrightText : © 2026 TU Wien <vadl@tuwien.ac.at>
2+
// SPDX-License-Identifier: GPL-3.0-or-later
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU General Public License as published by
6+
// the Free Software Foundation, either version 3 of the License, or
7+
// (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
17+
package vadl.rtl.passes;
18+
19+
import java.util.Map;
20+
import vadl.configuration.GeneralConfiguration;
21+
import vadl.pass.PassResults;
22+
import vadl.template.AbstractTemplateRenderingPass;
23+
import vadl.viam.Specification;
24+
25+
/**
26+
* Emit the RTL Devcontainer Docker Compose Specification.
27+
*/
28+
public class EmitRtlDevcontainerDockerComposePass extends AbstractTemplateRenderingPass {
29+
30+
public static final String RTL_BASE_IMAGE = "ghcr.io/openvadl/rtl-test-base"
31+
+ "@sha256:975bacbae46da25dda52340a18772d349c7e43e3dd8aae43be61f254fc728ca8";
32+
33+
/**
34+
* Construct the RTL Devcontainer Docker Compose emit pass.
35+
*
36+
* @param configuration the configuration
37+
*/
38+
public EmitRtlDevcontainerDockerComposePass(GeneralConfiguration configuration) {
39+
super(configuration, "rtl");
40+
}
41+
42+
@Override
43+
protected String getTemplatePath() {
44+
return "rtl/.devcontainer/docker-compose.yaml";
45+
}
46+
47+
@Override
48+
protected String getOutputPath() {
49+
return ".devcontainer/docker-compose.yaml";
50+
}
51+
52+
@Override
53+
protected String lineComment() {
54+
return "#";
55+
}
56+
57+
@Override
58+
protected Map<String, Object> createVariables(PassResults passResults,
59+
Specification specification) {
60+
return Map.of(
61+
"image", RTL_BASE_IMAGE
62+
);
63+
}
64+
}

vadl/test/vadl/rtl/RtlDockerTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package vadl.rtl;
1818

19+
import static vadl.rtl.passes.EmitRtlDevcontainerDockerComposePass.RTL_BASE_IMAGE;
20+
1921
import java.io.IOException;
2022
import java.nio.file.Path;
2123
import java.util.Set;
@@ -28,9 +30,6 @@
2830

2931
public abstract class RtlDockerTest extends DockerExecutionTest {
3032

31-
private static final String RTL_BASE_IMAGE =
32-
"ghcr.io/openvadl/rtl-test-base@sha256:975bacbae46da25dda52340a18772d349c7e43e3dd8aae43be61f254fc728ca8";
33-
3433
private static final ConcurrentHashMap<String, ImageFromDockerfile> imageCache =
3534
new ConcurrentHashMap<>();
3635

0 commit comments

Comments
 (0)