Skip to content

Commit

Permalink
Refactor bootstrap building
Browse files Browse the repository at this point in the history
  • Loading branch information
mrautio committed Apr 17, 2020
1 parent c830fdc commit 8fa14d5
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.git
node_modules
test/conformance/WebGL
2 changes: 2 additions & 0 deletions .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
run: docker build -t duktape-webgl-generator -f generator/Dockerfile .
- name: Generate bindings
run: docker run -t --read-only duktape-webgl-generator > examples/00_bootstrap/dukwebgl.h
- name: Build bootstrap
run: docker build -t duktape-webgl-bootstrap examples/00_bootstrap
- name: Build examples
run: docker build -t duktape-webgl-examples examples
- name: Test bindings and examples
Expand Down
1 change: 1 addition & 0 deletions examples/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.exe
17 changes: 17 additions & 0 deletions examples/00_bootstrap/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:12-stretch

RUN apt-get update && apt-get install -y xvfb libgcc-6-dev libsdl2-dev libglew-dev duktape-dev imagemagick

ENV XDG_RUNTIME_DIR=/tmp
WORKDIR /tmp

COPY * /tmp/

# Compile the main bootstrap
RUN make

# Compile the C++ test program, to verify that C++ compilation is OK
RUN ln -s bootstrap.c bootstrap.cpp && make test-cpp-compile

RUN cp bootstrap.exe /usr/bin/ && rm -rf /tmp/*

8 changes: 4 additions & 4 deletions examples/00_bootstrap/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
.DEFAULT_GOAL := all

CFLAGS=-pedantic -Wall -Werror -Wformat -Wformat-security -fstack-protector -pie -fPIE -D_FORTIFY_SOURCE=2 -O2 -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack
LDFLAGS=-lSDL2 -lduktape -lGLEW -lGL
CFLAGS=-pedantic -Wall -Werror -Wformat -Wformat-security -fstack-protector -pie -fPIE -D_FORTIFY_SOURCE=2 -O2 -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack -I/usr/share/duktape
LDFLAGS=-lm -lSDL2 -lGLEW -lGL

.PHONY: all
all:
gcc bootstrap.c -std=c99 ${CFLAGS} ${LDFLAGS} -o bootstrap.exe
gcc bootstrap.c /usr/share/duktape/duktape.c -std=c99 ${CFLAGS} ${LDFLAGS} -o bootstrap.exe

.PHONY: test-cpp-compile
test-cpp-compile:
g++ bootstrap.cpp -std=c++11 ${CFLAGS} ${LDFLAGS} -o bootstrap_cpp.exe
g++ bootstrap.cpp /usr/share/duktape/duktape.c -std=c++11 ${CFLAGS} ${LDFLAGS} -o bootstrap_cpp.exe
1 change: 1 addition & 0 deletions examples/00_bootstrap/bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <SDL2/SDL.h>

/* Include Duktape before duktape-webgl */
#include <duk_config.h>
#include <duktape.h>

/* Include duktape-webgl */
Expand Down
11 changes: 1 addition & 10 deletions examples/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
FROM ubuntu:latest
FROM duktape-webgl-bootstrap:latest

RUN apt-get update && apt-get install -y xvfb libgcc-8-dev libsdl2-dev libglew-dev duktape-dev imagemagick

ENV XDG_RUNTIME_DIR=/tmp
WORKDIR /tmp

COPY docker_entrypoint.sh .
Expand All @@ -17,10 +14,4 @@ ADD 02_hello_triangle 02_hello_triangle
ADD 03_draw_image 03_draw_image
ADD 04_render_to_texture 04_render_to_texture

# Compile the main bootstrap
RUN cd 00_bootstrap && make

# Compile the C++ test program, to verify that C++ compilation is OK
RUN cd 00_bootstrap && ln -s bootstrap.c bootstrap.cpp && make test-cpp-compile

CMD ["sh", "docker_entrypoint.sh"]
1 change: 1 addition & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Luckily there are plenty of good tutorials, so if you're interested in learning
* Note that dukwebgl.h header file is not available by default so you need to place the header to 00\_bootstrap directory

```
docker build -t duktape-webgl-bootstrap 00_bootstrap
docker build -t duktape-webgl-examples . && docker run --rm -t duktape-webgl-examples
```

Expand Down
14 changes: 7 additions & 7 deletions examples/docker_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ export DISPLAY=:99
sleep 5s

# run tests
00_bootstrap/bootstrap.exe 00_bootstrap/exit_success.js
00_bootstrap/bootstrap.exe 00_bootstrap/exit_failure.js || assert_ret $? 1
00_bootstrap/bootstrap.exe 00_bootstrap/exit_failure_invalid_gl_call.js || assert_ret $? 1
00_bootstrap/bootstrap.exe 01_grey_screen/grey_screen.js || assert_ret $? 1 && screenshot_diff screenshot_01_actual.png 01_grey_screen/screenshot_grey_screen.png
00_bootstrap/bootstrap.exe 02_hello_triangle/hello_triangle.js || assert_ret $? 1 && screenshot_diff screenshot_02_actual.png 02_hello_triangle/screenshot_hello_triangle.png
00_bootstrap/bootstrap.exe 03_draw_image/draw_image.js || assert_ret $? 1 && screenshot_diff screenshot_03_actual.png 03_draw_image/screenshot_draw_image.png
00_bootstrap/bootstrap.exe 04_render_to_texture/render_to_texture.js || assert_ret $? 1 && screenshot_diff screenshot_04_actual.png 04_render_to_texture/screenshot_render_to_texture.png
bootstrap.exe 00_bootstrap/exit_success.js
bootstrap.exe 00_bootstrap/exit_failure.js || assert_ret $? 1
bootstrap.exe 00_bootstrap/exit_failure_invalid_gl_call.js || assert_ret $? 1
bootstrap.exe 01_grey_screen/grey_screen.js || assert_ret $? 1 && screenshot_diff screenshot_01_actual.png 01_grey_screen/screenshot_grey_screen.png
bootstrap.exe 02_hello_triangle/hello_triangle.js || assert_ret $? 1 && screenshot_diff screenshot_02_actual.png 02_hello_triangle/screenshot_hello_triangle.png
bootstrap.exe 03_draw_image/draw_image.js || assert_ret $? 1 && screenshot_diff screenshot_03_actual.png 03_draw_image/screenshot_draw_image.png
bootstrap.exe 04_render_to_texture/render_to_texture.js || assert_ret $? 1 && screenshot_diff screenshot_04_actual.png 04_render_to_texture/screenshot_render_to_texture.png

0 comments on commit 8fa14d5

Please sign in to comment.