Skip to content

playground: Improve update.sh to be more general. #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions playground/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ A secondary motivation is making the playground usable for other projects, such

## Development

To update the entire playground environment, run the `update.sh` script. It will install your local version of gopherjs compiler, rebuild and copy the standard library into the `pkg` directory, and build the playground.
To update the entire playground environment, just run `go generate github.com/gopherjs/gopherjs.github.io/playground`. It will install your local version of GopherJS compiler, build the playground, make a temporary copy of Go to /tmp/gopherjsplayground_goroot, rebuild and copy the standard library into the `pkg` directory.

Working on the application itself is made easier by using the `gopherjs serve` command to rebuild and serve the playground every time you refresh the browser.
Working on the playground application itself is made easier by using the `gopherjs serve` command to rebuild and serve the playground every time you refresh the browser.

```bash
gopherjs serve
Expand Down
3 changes: 3 additions & 0 deletions playground/gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//go:generate ./update.sh

package main
29 changes: 22 additions & 7 deletions playground/update.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
#! /bin/sh
#!/bin/sh
set -e

go install github.com/gopherjs/gopherjs/...

go generate github.com/gopherjs/gopherjs.github.io/playground/internal/imports

gopherjs install -m github.com/gopherjs/gopherjs.github.io/playground github.com/gopherjs/gopherjs/js
cp $GOPATH/bin/playground.js $GOPATH/src/github.com/gopherjs/gopherjs.github.io/playground/playground.js
cp $GOPATH/bin/playground.js.map $GOPATH/src/github.com/gopherjs/gopherjs.github.io/playground/playground.js.map
# Build playground itself.
gopherjs build -m

PKG=$GOPATH/src/github.com/gopherjs/gopherjs.github.io/playground/pkg
# The GOPATH workspace where the GopherJS project is.
GOPHERJSGOPATH=$(go list -f '{{.Root}}' github.com/gopherjs/gopherjs)

PKG=pkg
rm -r $PKG

# Use an empty GOPATH workspace with just gopherjs,
# so that all the standard library packages get written to GOROOT/pkg.
export GOPATH=/tmp/gopherjsplayground_gopath
mkdir -p $GOPATH/src/github.com/gopherjs/gopherjs
cp -r $GOPHERJSGOPATH/src/github.com/gopherjs/gopherjs/* $GOPATH/src/github.com/gopherjs/gopherjs

gopherjs install -m github.com/gopherjs/gopherjs/js github.com/gopherjs/gopherjs/nosync
mkdir -p $PKG/github.com/gopherjs/gopherjs
cp $GOPATH/pkg/darwin_js_min/github.com/gopherjs/gopherjs/js.a $PKG/github.com/gopherjs/gopherjs/js.a
cp $GOPATH/pkg/darwin_js_min/github.com/gopherjs/gopherjs/nosync.a $PKG/github.com/gopherjs/gopherjs/nosync.a

gopherjs install -m github.com/gopherjs/gopherjs/js archive/tar archive/zip bufio bytes compress/bzip2 compress/flate compress/gzip compress/lzw compress/zlib container/heap container/list container/ring crypto/aes crypto/cipher crypto/des crypto/dsa crypto/ecdsa crypto/elliptic crypto/hmac crypto/md5 crypto/rand crypto/rc4 crypto/rsa crypto/sha1 crypto/sha256 crypto/sha512 crypto/subtle database/sql/driver debug/gosym debug/pe encoding/ascii85 encoding/asn1 encoding/base32 encoding/base64 encoding/binary encoding/csv encoding/gob encoding/hex encoding/json encoding/pem encoding/xml errors fmt go/ast go/doc go/format go/printer go/token hash/adler32 hash/crc32 hash/crc64 hash/fnv html html/template image image/color image/draw image/gif image/jpeg image/png index/suffixarray io io/ioutil math math/big math/cmplx math/rand mime net/http/cookiejar net/http/fcgi net/http/httptest net/http/httputil net/mail net/smtp net/textproto net/url path path/filepath reflect regexp regexp/syntax sort strconv strings sync/atomic testing testing/iotest testing/quick text/scanner text/tabwriter text/template text/template/parse time unicode unicode/utf16 unicode/utf8
# Make a copy of GOROOT that is user-writeable,
# use it to build and copy out standard library packages.
cp -r $(go env GOROOT) /tmp/gopherjsplayground_goroot
export GOROOT=/tmp/gopherjsplayground_goroot
gopherjs install -m archive/tar archive/zip bufio bytes compress/bzip2 compress/flate compress/gzip compress/lzw compress/zlib container/heap container/list container/ring crypto/aes crypto/cipher crypto/des crypto/dsa crypto/ecdsa crypto/elliptic crypto/hmac crypto/md5 crypto/rand crypto/rc4 crypto/rsa crypto/sha1 crypto/sha256 crypto/sha512 crypto/subtle database/sql/driver debug/gosym debug/pe encoding/ascii85 encoding/asn1 encoding/base32 encoding/base64 encoding/binary encoding/csv encoding/gob encoding/hex encoding/json encoding/pem encoding/xml errors fmt go/ast go/doc go/format go/printer go/token hash/adler32 hash/crc32 hash/crc64 hash/fnv html html/template image image/color image/draw image/gif image/jpeg image/png index/suffixarray io io/ioutil math math/big math/cmplx math/rand mime net/http/cookiejar net/http/fcgi net/http/httptest net/http/httputil net/mail net/smtp net/textproto net/url path path/filepath reflect regexp regexp/syntax runtime/internal/sys sort strconv strings sync/atomic testing testing/iotest testing/quick text/scanner text/tabwriter text/template text/template/parse time unicode unicode/utf16 unicode/utf8
cp -r $GOROOT/pkg/darwin_js_min/* $PKG
cp -r $GOROOT/pkg/darwin_amd64_js_min/* $PKG

rename 's/\.a/\.a.js/' `find $PKG -name "*.a"`
rm -r /tmp/gopherjsplayground_goroot
rm -r /tmp/gopherjsplayground_gopath

rename 's/\.a/\.a.js/' $(find $PKG -name "*.a")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(GitHub is hiding my previous, still relevant, comment about this line because it subtly changed; leaving this comment so it's not forgotten)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be written with find -exec instead.

I agree. I mentioned this in #36 too:

  • It requires rename command, which can be acquired with brew install rename but if possible, it'd be better not to require it. It can be replaced with a < 50 line Go program inside the repo, that way no external dependencies are needed.

I consider it out of scope of this PR (meaning I don't want to block this PR from being merged until it's done), but it's a welcome followup.