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

Conversation

dmitshur
Copy link
Member

It does require Go to be at /usr/local/go. This can be improved in the future. It doesn't require Go to be in any hardcoded location.

It uses a temporary staging folder to perform the operations.

  • No longer require your GOROOT to be writeable.
  • No longer require your GOPATH list to contain no more than 1 workspace.
  • It has no side-effects, for example, it no longer leaves the $GOPATH/bin/playground.js.map file behind.

Fixes #36.

@dmitshur dmitshur force-pushed the make-rebuilding-playground-easy branch from a778959 to 1db5d32 Compare February 21, 2016 03:15
dmitshur added a commit that referenced this pull request Feb 21, 2016
This is based on work in #41, which allows this entire step to be done
in a matter of seconds by simply running one command:

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

And it works even with multiple GOPATHs, and non-writeable GOROOT. \o/
@dominikh
Copy link
Member

Why not use $(go env GOROOT) instead of hard-coding /usr/local/go?

@dmitshur
Copy link
Member Author

That's a good idea, thanks.

I didn't include it in the first version because I knew I couldn't just get GOROOT env var, as it may not be set. But using $(go env GOROOT) will take care of that.

I'll update to include that enhancement (within an hour).


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`
Copy link
Member

Choose a reason for hiding this comment

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

I suggest using $() instead of backticks. Backticks aren't technically deprecated, though style guidelines usually suggest sticking to $().

Same for line 24 (which you didn't touch in this PR)

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good, I'll do that. I didn't know what the difference between two was, but I went with backticks because I've used them more in the past.

@dmitshur dmitshur force-pushed the make-rebuilding-playground-easy branch from c379508 to 382e053 Compare February 21, 2016 04:53
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.

dmitshur added a commit that referenced this pull request Feb 21, 2016
This is based on work in #41, which allows this entire step to be done
in a matter of seconds by simply running one command:

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

And it works even with multiple GOPATHs, and non-writeable GOROOT. \o/
@dominikh
Copy link
Member

LGTM otherwise. There are some improvements that could be made to the shell script, but they're not strictly necessary for this PR.

It uses a temporary staging folder to perform the operations.

-	No longer require your GOROOT to be writeable.
-	No longer require your GOPATH list to contain no more than
	1 workspace.
-	It has no side-effects, for example, it no longer leaves the
	$GOPATH/bin/playground.js.map file behind.

Fixes #36.

It doesn't fix a part of #36, but a new issue #43 is created to track that.
@dmitshur dmitshur force-pushed the make-rebuilding-playground-easy branch from 084b4e9 to 84b8935 Compare February 21, 2016 05:06
@dmitshur
Copy link
Member Author

Thanks. Squashed and merged as 84b8935.

@dmitshur dmitshur merged commit 84b8935 into master Feb 21, 2016
@dmitshur dmitshur deleted the make-rebuilding-playground-easy branch February 21, 2016 05:09
dmitshur added a commit that referenced this pull request Feb 21, 2016
This is based on work in #41, which allows this entire step to be done
in a matter of seconds by simply running one command:

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

And it works even with multiple GOPATHs, and non-writeable GOROOT. \o/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants