Skip to content

Commit 91e117f

Browse files
authored
xvfb.sh (#114)
1 parent fc05e22 commit 91e117f

File tree

8 files changed

+117
-12
lines changed

8 files changed

+117
-12
lines changed

.dockerignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
*
22
!/.bazelrc
33
!/BUILD
4+
!/data/
45
!/resolved.bzl
5-
!/variables.bzl
66
!/third_party
7+
!/variables.bzl
78
!/voidstar
89
!/WORKSPACE
10+
!/xvfb.sh

.github/workflows/workflow.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ jobs:
2929
- uses: actions/checkout@v2
3030
- run: DOCKER_BUILDKIT=1 docker build -o=./bin/ --target=voidstar . --progress=plain
3131
- run: ./bin/voidstar --help
32+
- uses: Wandalen/wretry.action@v1.0.11
33+
with:
34+
command: DOCKER_BUILDKIT=1 docker build -o=. --target=video-gcc . --progress=plain
35+
attempt_limit: 20
36+
attempt_delay: 1000
3237

3338
build_on_ubuntu_with_clang:
3439
name: Build on ubuntu with Clang
@@ -41,7 +46,11 @@ jobs:
4146
- uses: actions/checkout@v2
4247
- run: DOCKER_BUILDKIT=1 docker build -o=./bin/ --target=voidstar-clang . --progress=plain
4348
- run: ./bin/voidstar --help
44-
49+
- uses: Wandalen/wretry.action@v1.0.11
50+
with:
51+
command: DOCKER_BUILDKIT=1 docker build -o=. --target=video-clang . --progress=plain
52+
attempt_limit: 20
53+
attempt_delay: 1000
4554

4655
build_on_macos:
4756
name: Build on macos

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
/bazelisk
55

66
/bin/*
7+
/video.webm

Dockerfile

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ RUN \
1818
ca-certificates \
1919
clang \
2020
curl \
21+
ffmpeg \
2122
git \
2223
gzip \
2324
libgl1-mesa-dev \
2425
python3 \
2526
software-properties-common \
2627
tar \
2728
unzip \
29+
xauth \
2830
xorg-dev \
31+
xvfb \
2932
&& update-alternatives --install /usr/bin/python python /usr/bin/python3 1
3033
RUN \
3134
--mount=type=cache,target=/var/cache/apt \
@@ -77,8 +80,6 @@ RUN \
7780
&& bazel build --repo_env=CC=clang voidstar \
7881
# Necessary as COPY --from does not follow symlinks
7982
&& cp /app/bazel-bin/voidstar/voidstar /
80-
FROM scratch AS voidstar-clang
81-
COPY --from=builder-clang /voidstar /
8283

8384
# voidstar GCC
8485
FROM base AS builder-gcc
@@ -88,5 +89,31 @@ RUN \
8889
&& bazel build voidstar \
8990
# Necessary as COPY --from does not follow symlinks
9091
&& cp /app/bazel-bin/voidstar/voidstar /
92+
93+
94+
# xvfb GCC
95+
FROM builder-gcc AS xvfb-gcc
96+
ARG WxHxD=800x600x24
97+
ARG BIN=/voidstar
98+
ARG FILE=./data/BigPictureBG.tga
99+
ARG OUT=video.webm
100+
RUN ./xvfb.sh
101+
FROM scratch AS video-gcc
102+
COPY --from=xvfb-gcc /app/video.webm /
103+
104+
# xvfb Clang
105+
FROM builder-clang AS xvfb-clang
106+
ARG WxHxD=800x600x24
107+
ARG BIN=/voidstar
108+
ARG FILE=./data/BigPictureBG.tga
109+
ARG OUT=video.webm
110+
RUN ./xvfb.sh
111+
FROM scratch AS video-clang
112+
COPY --from=xvfb-clang /app/video.webm /
113+
114+
115+
FROM scratch AS voidstar-clang
116+
COPY --from=builder-clang /voidstar /
117+
91118
FROM scratch AS voidstar
92119
COPY --from=builder-gcc /voidstar /

snap/snapcraft.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: voidstar
2-
version: v1.34.1 # FIXME: 'git'
2+
version: v1.35.0 # FIXME: 'git'
33
summary: void* casts files onto 2D/3D colored spaces for your mind blowing needs # 79 char long summary
44
description: |
55
Usage:

voidstar/managers/glfw3.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,11 @@ bool GLFW3Manager::updateFirst(float deltaTime, glm::mat4* MVP) {
229229
// User loaded a different file
230230
file_changed || false) {
231231
if (args_->move_window) slide_window_right();
232-
bool slid = slide_window(scene_->selected(), scene_->indices());
233-
if (!slid && args_->move_window) args_->move_window = false;
232+
auto slid = slide_window(scene_->selected(), scene_->indices());
233+
if (previously_slid_ != slid)
234+
std::cout << "#selected: " << slid << std::endl;
235+
previously_slid_ = slid;
236+
if (slid < 1 && args_->move_window) args_->move_window = false;
234237
}
235238

236239
return true;

voidstar/managers/manager.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "voidstar/managers/events.h"
88
#include "voidstar/registrar.h"
99
#include "voidstar/scenes/scene.h"
10-
#include "voidstar/size2str.h"
1110

1211
class Manager {
1312
public:
@@ -62,7 +61,8 @@ class Manager {
6261
: args_->sliding_window_length;
6362
}
6463

65-
bool slide_window(VertIndices& selected, const VertIndices& indices) {
64+
size_t previously_slid_ = 0;
65+
size_t slide_window(VertIndices& selected, const VertIndices& indices) {
6666
using offset_t = VertIndices::const_iterator::difference_type;
6767
const offset_t woffset = static_cast<offset_t>(sliding_window_offset_);
6868
const offset_t wlength = static_cast<offset_t>(sliding_window_length_);
@@ -75,10 +75,9 @@ class Manager {
7575
selected.assign(left, right);
7676
sliding_window_left_ = &left[0];
7777
sliding_window_right_ = &right[0];
78-
std::cout << "#selected: " << size2str(selected.size()) << std::endl;
79-
return true;
78+
return selected.size();
8079
}
81-
return false;
80+
return 0;
8281
}
8382

8483
protected:

xvfb.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash -eux
2+
set -o pipefail
3+
4+
_kill_procs() {
5+
kill -TERM $companion
6+
wait $companion
7+
kill -TERM $xvfb
8+
}
9+
trap _kill_procs SIGTERM
10+
11+
display=99
12+
13+
wxhxd=${WxHxD:-800x600x24}
14+
bin=${BIN:-./bin/voidstar}
15+
file=${FILE:-"$bin"}
16+
out=${OUT:-video.webm}
17+
18+
case "$file" in
19+
http://*|https://*)
20+
curl -fsSLo /file "$file"
21+
file=/file
22+
# ls -lh "$file"; exit 42
23+
;;*) ;;
24+
esac
25+
26+
rm -rf /tmp/xvfb-run.*
27+
28+
xvfb-run \
29+
--server-num="$display" \
30+
--error-file=/dev/stdout \
31+
-s "-screen 0 $wxhxd" \
32+
"$bin" \
33+
--move \
34+
--exit-at-fin \
35+
"$file" &
36+
xvfb=$!
37+
38+
touch ~/.Xauthority
39+
xauth generate :0 . trusted || true
40+
xauth list
41+
42+
ls /tmp/xvfb*/Xauthority >/dev/null
43+
44+
XAUTHORITY=$(echo /tmp/xvfb*/Xauthority) \
45+
ffmpeg \
46+
-r 30 \
47+
-f x11grab \
48+
-draw_mouse 0 \
49+
-s "$(cut -dx -f1-2 <<<"$wxhxd")" \
50+
-i :"$display" \
51+
-c:v libvpx \
52+
-quality realtime \
53+
-cpu-used 0 \
54+
-b:v 384k \
55+
-qmin 10 \
56+
-qmax 42 \
57+
-maxrate 384k \
58+
-bufsize 1000k \
59+
-an "$out" &
60+
companion=$!
61+
62+
wait $xvfb
63+
kill -TERM $companion
64+
wait $companion || true

0 commit comments

Comments
 (0)