Skip to content

Commit 347b813

Browse files
committed
nacl: retrieve initial script over http
1 parent f1a3bd1 commit 347b813

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

contrib/nacl/app.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ handlers:
1010
upload: load81.html
1111
- url: /static
1212
static_dir: static
13+
- url: /examples
14+
static_dir: examples
1315
- url: /load81-i686-nacl.nexe
1416
static_files: load81-i686-nacl.nexe
1517
upload: load81-i686-nacl.nexe

contrib/nacl/build.sh

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
2-
# TODO use the common Makfile instead of duplicating it.
2+
# TODO use the common Makefile instead of duplicating it.
33
set -ex
44

55
if [ -z $NACL_SDK_ROOT ]
@@ -13,7 +13,8 @@ TOOLCHAIN=$NACL_SDK_ROOT/toolchain/linux_x86_newlib
1313
NACL_ROOT=$(dirname $(which $0))
1414
ROOT=$(readlink -f $NACL_ROOT/../..)
1515
PKGS="sdl SDL_gfx"
16-
EXAMPLE=asteroids.lua
16+
17+
ln -sf $ROOT/examples $NACL_ROOT/examples
1718

1819
for HOST in i686-nacl x86_64-nacl
1920
do
@@ -26,18 +27,14 @@ do
2627
else
2728
BFDNAME=elf64-nacl
2829
fi
29-
cp $ROOT/examples/$EXAMPLE example.lua
30-
$HOST-objcopy -I binary -O $BFDNAME -B $BFDARCH example.lua example.o
31-
rm example.lua
3230
CFLAGS="-O2 -Wall -W -D main=load81_main `pkg-config --cflags $PKGS`"
3331
LDFLAGS=""
3432
for X in read write open close seek mount; do
3533
LDFLAGS="$LDFLAGS -Xlinker --wrap -Xlinker $X"
3634
done
3735
LIBS="`pkg-config --libs $PKGS` -llua -lm -lppapi -lppapi_cpp -lnacl-mounts -lstdc++ -lnosys"
38-
SRCS="$ROOT/load81.c $ROOT/editor.c $ROOT/framebuffer.c nacl.cc example.o"
36+
SRCS="$ROOT/load81.c $ROOT/editor.c $ROOT/framebuffer.c nacl.cc"
3937
$CC $CFLAGS $LDFLAGS $SRCS $LIBS -o load81-$HOST.nexe
40-
rm example.o
4138
$HOST-strip load81-$HOST.nexe
4239
done
4340

contrib/nacl/static/load81.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
demo_src = 'function draw() background(100, 50, 50) end'
1+
var initial_script = "examples/asteroids.lua";
22

33
$(document).ready(function(){
44
var nacl_module = null;
55
var src = null;
66

77
function main() {
8-
start_game(demo_src);
8+
xhr = new XMLHttpRequest();
9+
xhr.open("GET", initial_script);
10+
xhr.onload = function (event) {
11+
// TODO check for failure
12+
start_game(xhr.responseText);
13+
}
14+
xhr.send();
915
}
1016

1117
function switch_screen(id) {

0 commit comments

Comments
 (0)