mirror of
https://github.com/golang/go
synced 2024-11-21 21:04:41 -07:00
make Native Client support build again,
add README explaining how to try the web demos. Fixes #339. R=r CC=barry.d.silverman, bss, vadim https://golang.org/cl/165057
This commit is contained in:
parent
11384eecf8
commit
609eeee817
11
src/all-nacl.bash
Normal file → Executable file
11
src/all-nacl.bash
Normal file → Executable file
@ -5,6 +5,9 @@
|
||||
|
||||
# TODO(rsc): delete in favor of all.bash once nacl support is complete
|
||||
|
||||
export GOARCH=386
|
||||
export GOOS=nacl
|
||||
|
||||
set -e
|
||||
bash make.bash
|
||||
|
||||
@ -22,6 +25,14 @@ make install
|
||||
make install
|
||||
) || exit $?
|
||||
|
||||
(xcd pkg/exp/4s
|
||||
make
|
||||
) || exit $?
|
||||
|
||||
(xcd pkg/exp/spacewar
|
||||
make
|
||||
) || exit $?
|
||||
|
||||
(xcd ../test
|
||||
./run-nacl
|
||||
) || exit $?
|
||||
|
@ -82,7 +82,7 @@ bash clean.bash
|
||||
for i in lib9 libbio libmach cmd pkg libcgo cmd/cgo cmd/ebnflint cmd/godoc cmd/gofmt cmd/goyacc cmd/hgpatch
|
||||
do
|
||||
case "$i-$GOOS" in
|
||||
libcgo-nacl)
|
||||
libcgo-nacl | cmd/*-nacl)
|
||||
;;
|
||||
*)
|
||||
# The ( ) here are to preserve the current directory
|
||||
|
@ -50,6 +50,7 @@ DIRS=\
|
||||
encoding/pem\
|
||||
exec\
|
||||
exp/datafmt\
|
||||
exp/draw\
|
||||
exp/eval\
|
||||
exp/exception\
|
||||
exp/iterable\
|
||||
@ -105,6 +106,7 @@ DIRS=\
|
||||
|
||||
NOTEST=\
|
||||
debug/proc\
|
||||
exp/draw\
|
||||
go/ast\
|
||||
go/doc\
|
||||
go/token\
|
||||
|
@ -5,6 +5,8 @@
|
||||
// This is a simple demo of Go running under Native Client.
|
||||
// It is a tetris clone built on top of the exp/nacl/av and exp/draw
|
||||
// packages.
|
||||
//
|
||||
// See ../nacl/README for how to run it.
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -1,10 +1,26 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Go in Native Client</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>games/4s</h1>
|
||||
<embed name="nacl_module" id="pluginobj" src="8.out" type="application/x-nacl-srpc" width=400 height=600>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
<h1>games/4s</h1>
|
||||
<table><tr><td valign=top>
|
||||
<embed name="nacl_module" id="pluginobj" src="8.out" type="application/x-nacl-srpc" width=400 height=600>
|
||||
<td valign=top>
|
||||
This is a simple block stacking game, a port of Plan 9's
|
||||
<a href="http://plan9.bell-labs.com/magic/man2html/1/games">games/4s</a>
|
||||
<br><br>
|
||||
To play using the keyboard:
|
||||
as the blocks fall, the <i>a</i>, <i>s</i>, <i>d</i>, and <i>f</i> keys
|
||||
move the block left, rotate the block left, rotate the block right,
|
||||
anad move the block right, respectively.
|
||||
To drop a block, type the space key.
|
||||
<b>You may need to click on the game window to
|
||||
focus the keyboard on it.</b>
|
||||
<br><br>
|
||||
To play using the mouse:
|
||||
as the blocks fall, moving the mouse horizontally positions
|
||||
the block; left or right clicks rotate the block left or right.
|
||||
A middle click drops the block.
|
||||
(Unfortunately, some environments seem to intercept
|
||||
the middle click before it gets to Native Client.)
|
||||
<br><br>
|
||||
To pause the game, type <i>z</i>, <i>p</i>, or the escape key.
|
||||
</table>
|
||||
|
9
src/pkg/exp/4s/5s.go
Normal file
9
src/pkg/exp/4s/5s.go
Normal file
@ -0,0 +1,9 @@
|
||||
// Copyright 2009 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Hack to produce a binary that defaults to 5s.
|
||||
|
||||
package main
|
||||
|
||||
func init() { pieces4 = pieces5 }
|
26
src/pkg/exp/4s/5s.html
Normal file
26
src/pkg/exp/4s/5s.html
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
|
||||
<h1>games/5s</h1>
|
||||
<table><tr><td valign=top>
|
||||
<embed name="nacl_module" id="pluginobj" src="8.5s" type="application/x-nacl-srpc" width=400 height=600>
|
||||
<td valign=top>
|
||||
This is a simple block stacking game, a port of Plan 9's
|
||||
<a href="http://plan9.bell-labs.com/magic/man2html/1/games">games/5s</a>
|
||||
<br><br>
|
||||
To play using the keyboard:
|
||||
as the blocks fall, the <i>a</i>, <i>s</i>, <i>d</i>, and <i>f</i> keys
|
||||
move the block left, rotate the block left, rotate the block right,
|
||||
anad move the block right, respectively.
|
||||
To drop a block, type the space key.
|
||||
<b>You may need to click on the game window to
|
||||
focus the keyboard on it.</b>
|
||||
<br><br>
|
||||
To play using the mouse:
|
||||
as the blocks fall, moving the mouse horizontally positions
|
||||
the block; left or right clicks rotate the block left or right.
|
||||
A middle click drops the block.
|
||||
(Unfortunately, some environments seem to intercept
|
||||
the middle click before it gets to Native Client.)
|
||||
<br><br>
|
||||
To pause the game, type <i>z</i>, <i>p</i>, or the escape key.
|
||||
</table>
|
@ -2,13 +2,19 @@
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file.
|
||||
|
||||
all: 8.out
|
||||
all: 8.out 8.5s
|
||||
|
||||
4s.8: 4s.go data.go xs.go
|
||||
8g 4s.go data.go xs.go
|
||||
|
||||
5s.8: 5s.go 4s.go data.go xs.go
|
||||
8g 5s.go 4s.go data.go xs.go
|
||||
|
||||
8.out: 4s.8
|
||||
8l 4s.8
|
||||
|
||||
8.5s: 5s.8
|
||||
8l -o 8.5s 5s.8
|
||||
|
||||
clean:
|
||||
rm -f *.8 8.out
|
||||
|
@ -726,7 +726,7 @@ func Play(pp []Piece, ctxt draw.Context) {
|
||||
pieces = pp;
|
||||
N = len(pieces[0].d);
|
||||
initPieces();
|
||||
rand.Seed(int32(time.Nanoseconds() % (1e9 - 1)));
|
||||
rand.Seed(int64(time.Nanoseconds() % (1e9 - 1)));
|
||||
whitemask = draw.White.SetAlpha(0x7F);
|
||||
tsleep = 50;
|
||||
timerc = time.Tick(int64(tsleep/2) * 1e6);
|
||||
|
36
src/pkg/exp/nacl/README
Normal file
36
src/pkg/exp/nacl/README
Normal file
@ -0,0 +1,36 @@
|
||||
Native Client support is still incomplete:
|
||||
Native Client does not yet allow runtime code generation,
|
||||
so Go's many uses of closures do not work.
|
||||
|
||||
To try Native Client by running 4s (tetris) or 5s or Spacewar:
|
||||
|
||||
1. Build the Go distribution for your native system.
|
||||
|
||||
2. Download Native Client and install it.
|
||||
http://nativeclient.googlecode.com/svn/trunk/src/native_client/documentation/getting_started.html
|
||||
* You can stop after step 4 on those instructions
|
||||
(the ./scons --prebuilt firefox_install).
|
||||
|
||||
3. (optional) Install "./build/native_client/scons-out/opt-*/staging/sel_ldr"
|
||||
from the Native Client distribution somewhere in your path as "nacl".
|
||||
This will let you run binaries using "nacl 8.out".
|
||||
|
||||
4. Build the Go distribution again, this time for Native Client:
|
||||
cd $GOROOT/src
|
||||
./all-nacl.bash
|
||||
* If you didn't do step 3, the tests at the end will fail, but that's okay.
|
||||
* If you are on a Mac, your dock will flicker as the "nacl" binary
|
||||
starts and stops while the tests run. You can stop the tests at any time.
|
||||
|
||||
5. Run "godoc --http=:5103".
|
||||
* This will run the godoc built for your host OS, not Native Client,
|
||||
because all-nacl.bash doesn't install a nacl godoc.
|
||||
* Note that there is a colon before the 5103 in the argument
|
||||
(shorthand for 0.0.0.0:5103).
|
||||
* The port must be 5103: that's the only port that Native Client
|
||||
trusts to run binaries from.
|
||||
|
||||
6. Open Firefox and visit one of:
|
||||
* http://localhost:5103/src/pkg/exp/4s/4s.html
|
||||
* http://localhost:5103/src/pkg/exp/4s/5s.html [sic]
|
||||
* http://localhost:5103/src/pkg/exp/spacewar/spacewar.html
|
@ -21,6 +21,7 @@
|
||||
|
||||
// This package and spacewar.go implement a simple PDP-1 emulator
|
||||
// complete enough to run the original PDP-1 video game Spacewar!
|
||||
// See ../../nacl/README for details on running them.
|
||||
//
|
||||
// They are a translation of the Java emulator pdp1.java in
|
||||
// http://spacewar.oversigma.com/sources/sources.zip.
|
||||
|
@ -19,6 +19,8 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
// See ../../nacl/README.
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
@ -1,10 +1,21 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Go in Native Client</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Spacewar</h1>
|
||||
<embed name="nacl_module" id="pluginobj" src="8.out" type="application/x-nacl-srpc" width=512 height=512>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<h1>Spacewar</h1>
|
||||
<table>
|
||||
<tr><td valign=top>
|
||||
<embed name="nacl_module" id="pluginobj" src="8.out" type="application/x-nacl-srpc" width=512 height=512>
|
||||
<td valign=top>
|
||||
This is a Go translation of the Java emulator pdp1.java in
|
||||
<a href="http://spacewar.oversigma.com/sources/sources.zip">http://spacewar.oversigma.com/sources/sources.zip</a>.
|
||||
See <a href="pdp1.go">pdp1.go</a>, <a href="spacewar.go">spacewar.go</a>,
|
||||
and
|
||||
<a href="http://spacewar.oversigma.com/readme.html">http://spacewar.oversigma.com/readme.html</a>.
|
||||
<br><br>
|
||||
The <i>a</i>, <i>s</i>, <i>d</i>, <i>f</i> keys control one of the spaceships. The <i>k</i>,
|
||||
<i>l</i>, <i>;</i>, <i>'</i> keys control the other. The controls are spin one
|
||||
way, spin the other, thrust, and fire.
|
||||
<br>
|
||||
<br>
|
||||
<b>You may need to click on the game window to
|
||||
focus the keyboard on it.</b>
|
||||
|
||||
</table>
|
||||
|
@ -236,7 +236,9 @@ const (
|
||||
TCP_NODELAY;
|
||||
WNOHANG;
|
||||
WSTOPPED;
|
||||
_PTRACE_TRACEME;
|
||||
PTRACE_TRACEME;
|
||||
SO_BROADCAST = 0;
|
||||
SHUT_RDWR = 0;
|
||||
)
|
||||
|
||||
func Accept(fd int) (nfd int, sa Sockaddr, errno int) {
|
||||
@ -263,6 +265,16 @@ func SetsockoptInt(fd, level, opt int, value int) (errno int) {
|
||||
return ENACL
|
||||
}
|
||||
|
||||
func Shutdown(fd, how int) (errno int) { return ENACL }
|
||||
|
||||
func Recvfrom(fd int, p []byte, flags int) (n int, from Sockaddr, errno int) {
|
||||
return 0, nil, ENACL
|
||||
}
|
||||
|
||||
func Sendto(fd int, p []byte, flags int, to Sockaddr) (errno int) {
|
||||
return ENACL
|
||||
}
|
||||
|
||||
func SetsockoptTimeval(fd, level, opt int, tv *Timeval) (errno int) {
|
||||
return ENACL
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ enum {
|
||||
$SYS_CHDIR = 0,
|
||||
$SYS_DUP2 = 0,
|
||||
$SYS_FCNTL = 0,
|
||||
$SYS_EXECVE = 0
|
||||
$SYS_EXECVE = 0,
|
||||
};
|
||||
|
||||
// Basic types
|
||||
|
@ -31,6 +31,7 @@ const (
|
||||
O_SYNC = 0x1000;
|
||||
O_TRUNC = 0x200;
|
||||
O_CLOEXEC = 0;
|
||||
O_EXCL = 0;
|
||||
F_GETFD = 0x1;
|
||||
F_SETFD = 0x2;
|
||||
F_GETFL = 0x3;
|
||||
|
@ -5,6 +5,9 @@
|
||||
|
||||
case X"$GOARCH" in
|
||||
X386)
|
||||
# After downloading the Native Client binary distribution,
|
||||
# copy build/native_client/scons-out/opt-*/obj/src/trusted/service_runtime/sel_ldr
|
||||
# into your path as "nacl"
|
||||
export A=8
|
||||
export E=nacl
|
||||
;;
|
||||
|
Loading…
Reference in New Issue
Block a user