Skip to content

Commit 40f0b4c

Browse files
rmalmainaurelf
andauthored
Add a docker-compose file for development (#61)
* Add docker-compose for SymQEMU * Add docker compose information to readme. * Remove $ in doc for easy cut and paste --------- Co-authored-by: Aurelien Francillon <[email protected]>
1 parent 33cd24f commit 40f0b4c

File tree

4 files changed

+100
-25
lines changed

4 files changed

+100
-25
lines changed

Dockerfile

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# prepare machine
2-
FROM ubuntu:22.04 as builder
2+
FROM ubuntu:22.04 as base
33

44
RUN apt update && apt install -y \
55
ninja-build \
@@ -35,20 +35,33 @@ RUN if [ $LLVM_VERSION -eq 12 ] || [ $LLVM_VERSION -eq 13 ] || [ $LLVM_VERSION
3535
else mkdir /llvm && cd /llvm && wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && ./llvm.sh ${LLVM_VERSION}; \
3636
fi
3737

38+
RUN <<EOF cat > /configure_symqemu.sh
39+
../configure \
40+
--audio-drv-list= \
41+
--disable-sdl \
42+
--disable-gtk \
43+
--disable-vte \
44+
--disable-opengl \
45+
--disable-virglrenderer \
46+
--target-list=x86_64-linux-user,riscv64-linux-user \
47+
--enable-debug \
48+
--enable-debug-tcg \
49+
--symcc-rt-llvm-version="$LLVM_VERSION" \
50+
--disable-werror
51+
EOF
52+
53+
RUN chmod u+x /configure_symqemu.sh
54+
55+
FROM base as symqemu-dev
56+
57+
WORKDIR /symqemu_source
58+
59+
FROM base as symqemu
60+
3861
COPY . /symqemu_source
3962
WORKDIR /symqemu_source
4063

41-
RUN mkdir build && cd build && ../configure \
42-
--audio-drv-list= \
43-
--disable-sdl \
44-
--disable-gtk \
45-
--disable-vte \
46-
--disable-opengl \
47-
--disable-virglrenderer \
48-
--target-list=x86_64-linux-user,riscv64-linux-user \
49-
--enable-debug \
50-
--enable-debug-tcg \
51-
--symcc-rt-llvm-version="$LLVM_VERSION"
64+
RUN mkdir build && cd build && /configure_symqemu.sh
5265

5366
RUN cd build && make -j
5467

README.md

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ First of all, make sure the
1313
[symcc-rt](https://github.com/eurecom-s3/symcc-rt.git) submodule is initialized:
1414

1515
``` shell
16-
$ git submodule update --init --recursive subprojects/symcc-rt
16+
git submodule update --init --recursive subprojects/symcc-rt
1717
```
1818

1919
Make sure that QEMU's build dependencies are installed. Most package managers
@@ -23,18 +23,18 @@ or `dnf builddep qemu` on Fedora and CentOS.
2323
The following invocation is known to work on Ubuntu 22.04 and Arch:
2424

2525
``` shell
26-
$ mkdir build
27-
$ cd build
28-
$ ../configure \
29-
--audio-drv-list= \
30-
--disable-sdl \
31-
--disable-gtk \
32-
--disable-vte \
33-
--disable-opengl \
34-
--disable-virglrenderer \
35-
--disable-werror \
36-
--target-list=x86_64-linux-user
37-
$ make -j
26+
mkdir build
27+
cd build
28+
../configure \
29+
--audio-drv-list= \
30+
--disable-sdl \
31+
--disable-gtk \
32+
--disable-vte \
33+
--disable-opengl \
34+
--disable-virglrenderer \
35+
--disable-werror \
36+
--target-list=x86_64-linux-user
37+
make -j
3838
```
3939

4040
This will build a relatively stripped-down emulator targeting 64-bit x86
@@ -99,6 +99,46 @@ You can use the docker with:
9999
docker run -it --rm symqemu
100100
```
101101
102+
## Build with Docker Compose
103+
104+
Sometimes, it is more convenient to use docker-compose while developing SymQEMU,
105+
especially to avoid rebuilding for each change. It can both build `symqemu` and
106+
`symqemu-dev`.
107+
108+
Beware however, test the container and the host directory will be synchronized:
109+
each change in the container's source folder will be reflected on the host and
110+
vice versa (except for the build sub-folder).
111+
112+
A script is available to quickly get docker-compose: `./dev.sh`. Alternatively
113+
the following commands can be used:
114+
115+
- Build the `symqemu-dev` service:
116+
```bash
117+
docker-compose build symqemu-dev
118+
```
119+
120+
- Start the service:
121+
```bash
122+
docker-compose up -d symqemu-dev
123+
```
124+
125+
- Attach to the container:
126+
```bash
127+
docker-compose exec -it symqemu-dev /bin/bash
128+
```
129+
130+
- Building and testing in one line (configure only needed the first time, it is
131+
automatically rerun when needed):
132+
133+
```bash
134+
docker-compose exec -it symqemu-dev /bin/bash -c "cd build && /configure_symqemu.sh && make -j && make check"
135+
```
136+
137+
- Running SymQEMU integration tests:
138+
```bash
139+
docker-compose exec -it symqemu-dev /bin/bash -c "cd /symqemu_source/tests/symqemu && python3 -m unittest test.py"
140+
```
141+
102142
## Contributing
103143
104144
Use the GitHub project for reporting issues, and proposing changes.

dev.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
docker-compose build symqemu-dev
4+
docker-compose up -d symqemu-dev
5+
docker-compose exec -it symqemu-dev /bin/bash

docker-compose.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
services:
2+
symqemu-dev:
3+
build:
4+
context: .
5+
dockerfile: Dockerfile
6+
target: symqemu-dev
7+
volumes:
8+
- ./:/symqemu_source
9+
- /symqemu_source/build
10+
command: tail -f /dev/null
11+
12+
symqemu:
13+
build:
14+
context: .
15+
dockerfile: Dockerfile
16+
target: symqemu
17+
command: tail -f /dev/null

0 commit comments

Comments
 (0)