{"action":"created","issue":{"url":"https://api.github.com/repos/gopherjs/gopherjs/issues/787","repository_url":"https://api.github.com/repos/gopherjs/gopherjs","labels_url":"https://api.github.com/repos/gopherjs/gopherjs/issues/787/labels{/name}","comments_url":"https://api.github.com/repos/gopherjs/gopherjs/issues/787/comments","events_url":"https://api.github.com/repos/gopherjs/gopherjs/issues/787/events","html_url":"https://github.com/gopherjs/gopherjs/pull/787","id":312260164,"number":787,"title":"Embed core GopherJS packages into build system; enable vendoring of GopherJS.","user":{"login":"shurcooL","id":1924134,"avatar_url":"https://avatars3.githubusercontent.com/u/1924134?v=4","gravatar_id":"","url":"https://api.github.com/users/shurcooL","html_url":"https://github.com/shurcooL","followers_url":"https://api.github.com/users/shurcooL/followers","following_url":"https://api.github.com/users/shurcooL/following{/other_user}","gists_url":"https://api.github.com/users/shurcooL/gists{/gist_id}","starred_url":"https://api.github.com/users/shurcooL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shurcooL/subscriptions","organizations_url":"https://api.github.com/users/shurcooL/orgs","repos_url":"https://api.github.com/users/shurcooL/repos","events_url":"https://api.github.com/users/shurcooL/events{/privacy}","received_events_url":"https://api.github.com/users/shurcooL/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2018-04-08T01:25:42Z","updated_at":"2018-04-08T17:37:23Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/gopherjs/gopherjs/pulls/787","html_url":"https://github.com/gopherjs/gopherjs/pull/787","diff_url":"https://github.com/gopherjs/gopherjs/pull/787.diff","patch_url":"https://github.com/gopherjs/gopherjs/pull/787.patch"},"body":"This change brings two major features:\r\n\r\n- It allows the `gopherjs` binary to be completely standalone and not require GopherJS source code to be in $GOPATH. Only $GOROOT is required.\r\n- It allows the source code of `gopherjs` to be vendored in a Go project, and the vendored copy of `gopherjs` will be able to compile Go code successfully.\r\n\r\nThe approach taken to make these things possible is as follows.\r\n\r\nAs of commit ab917e062e6a7940608ee3c9d422382784f5a7ab, the natives (GopherJS-specific overrides for the Go standard library packages) are embedded in the GopherJS build system via a virtual filesystem. We re-generate the VFS whenever natives are modified.\r\n\r\nDoing that made it possible to compile most parts of the Go standard library with GopherJS without needing the `github.com/gopherjs/gopherjs` repository in $GOPATH. However, without the `github.com/gopherjs/gopherjs/js` and `github.com/gopherjs/gopherjs/nosync` packages, compiling the Go standard library is not possible. Those two packages are core to the GopherJS compiler and are needed to build `runtime`, etc.\r\n\r\nTherefore, since natives are already embedded, it makes a lot of sense to also embed the 2 small additional `github.com/gopherjs/gopherjs/js` and `github.com/gopherjs/gopherjs/nosync` packages analogously. Then, the VFS is used whenever the source of those two packages is accessed.\r\n\r\nAs a result, a compiled `gopherjs` binary can successfully compile Go code even if the GopherJS repository is not located in $GOPATH.\r\n\r\nAdditionally, the `natives` and `gopherjspkg` packages are very friendly towards being vendored. That means the entire GopherJS project can be vendored in another Go project, and then used to compile Go code.\r\n\r\nFixes #462.\r\nFixes #415."},"comment":{"url":"https://api.github.com/repos/gopherjs/gopherjs/issues/comments/379567704","html_url":"https://github.com/gopherjs/gopherjs/pull/787#issuecomment-379567704","issue_url":"https://api.github.com/repos/gopherjs/gopherjs/issues/787","id":379567704,"user":{"login":"shurcooL","id":1924134,"avatar_url":"https://avatars3.githubusercontent.com/u/1924134?v=4","gravatar_id":"","url":"https://api.github.com/users/shurcooL","html_url":"https://github.com/shurcooL","followers_url":"https://api.github.com/users/shurcooL/followers","following_url":"https://api.github.com/users/shurcooL/following{/other_user}","gists_url":"https://api.github.com/users/shurcooL/gists{/gist_id}","starred_url":"https://api.github.com/users/shurcooL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shurcooL/subscriptions","organizations_url":"https://api.github.com/users/shurcooL/orgs","repos_url":"https://api.github.com/users/shurcooL/repos","events_url":"https://api.github.com/users/shurcooL/events{/privacy}","received_events_url":"https://api.github.com/users/shurcooL/received_events","type":"User","site_admin":false},"created_at":"2018-04-08T17:37:23Z","updated_at":"2018-04-08T17:37:23Z","author_association":"MEMBER","body":"@hajimehoshi I followed your edited instructions and got a different outcome. Notably, `gopherjs` didn't build because you forgot to vendor one of its new dependencies. After I fetched that dependency, it built successfully, and the `gopherjstest/main.go` program was executed by GopherJS successfully.\r\n\r\nI think you made a mistake somewhere, and ended up using the `master` branch of GopherJS instead of this PR. I suggest you try those instructions a second time.\r\n\r\nSee the log from my terminal for reference:\r\n\r\n<details><br>\r\n\r\n```bash\r\nLast login: Sun Apr  8 13:11:18 on ttys000\r\n~ $ cd /tmp/\r\ntmp $ ls\r\ncom.apple.launchd.0q00aXw85q\tpowerlog\r\ncom.apple.launchd.v3Mhw42Gmb\r\ntmp $ NEWGOPATH=/tmp/go2\r\ntmp $ ls $NEWGOPATH\r\nls: /tmp/go2: No such file or directory\r\ntmp $ rm -rf $NEWGOPATH\r\ntmp $ GOPATH=$NEWGOPATH go get github.com/gopherjs/gopherjs\r\ntmp $ tree $NEWGOPATH | head\r\n/tmp/go2\r\n├── bin\r\n│   └── gopherjs\r\n└── src\r\n    ├── github.com\r\n    │   ├── fsnotify\r\n    │   │   └── fsnotify\r\n    │   │       ├── AUTHORS\r\n    │   │       ├── CHANGELOG.md\r\n    │   │       ├── CONTRIBUTING.md\r\ntmp $ (cd $NEWGOPATH/src/github.com/gopherjs/gopherjs; git checkout origin/embed-core-pkgs)\r\nNote: checking out 'origin/embed-core-pkgs'.\r\n\r\nYou are in 'detached HEAD' state. You can look around, make experimental\r\nchanges and commit them, and you can discard any commits you make in this\r\nstate without impacting any branches by performing another checkout.\r\n\r\nIf you want to create a new branch to retain commits you create, you may\r\ndo so (now or later) by using -b with the checkout command again. Example:\r\n\r\n  git checkout -b <new-branch-name>\r\n\r\nHEAD is now at 9b293ec... README: Remove note saying vendoring GopherJS is unsupported.\r\ntmp $ mkdir -p $NEWGOPATH/src/foobarbaz/hajimehoshi/gopherjstest\r\ntmp $ echo 'package main                                                                                                                                                                                          \r\n>                                                                                                                                                                                                             \r\n> import \"github.com/gopherjs/gopherjs/js\"                                                                                                                                                                    \r\n>                                                                                                                                                                                                             \r\n> func main() {                                                                                                                                                                                               \r\n>     js.Global.Get(\"console\").Call(\"log\", \"Hello\")                                                                                                                                                           \r\n> }' > $NEWGOPATH/src/foobarbaz/hajimehoshi/gopherjstest/main.go\r\ntmp $ tree /tmp/go2/src/foobarbaz/\r\n/tmp/go2/src/foobarbaz/\r\n└── hajimehoshi\r\n    └── gopherjstest\r\n        └── main.go\r\n\r\n2 directories, 1 file\r\ntmp $ mkdir -p $NEWGOPATH/src/foobarbaz/hajimehoshi/gopherjstest/vendor/github.com/gopherjs\r\ntmp $ ls go2/src/\r\nfoobarbaz\tgithub.com\tgolang.org\r\ntmp $ cp -r $NEWGOPATH/src/github.com $NEWGOPATH/src/foobarbaz/hajimehoshi/gopherjstest/vendor\r\ntmp $ cp -r $NEWGOPATH/src/golang.org $NEWGOPATH/src/foobarbaz/hajimehoshi/gopherjstest/vendor\r\ntmp $ cd go2\r\ngo2 $ ls\r\nbin\tsrc\r\ngo2 $ ls src/\r\nfoobarbaz/  github.com/ golang.org/ \r\ngo2 $ ls src/foobarbaz/hajimehoshi/gopherjstest/vendor/\r\ngithub.com\tgolang.org\r\ngo2 $ rm -rf $NEWGOPATH/src/github.com/gopherjs/gopherjs\r\ngo2 $ ls -la bin/gopherjs \r\n-rwxr-xr-x  1 Dmitri  staff  12955388 Apr  8 13:24 bin/gopherjs\r\ngo2 $ GOPATH=$NEWGOPATH go install -v foobarbaz/hajimehoshi/gopherjstest/vendor/github.com/gopherjs/gopherjs\r\nsrc/foobarbaz/hajimehoshi/gopherjstest/vendor/github.com/gopherjs/gopherjs/build/build.go:27:2: cannot find package \"github.com/shurcooL/httpfs/vfsutil\" in any of:\r\n\t/tmp/go2/src/foobarbaz/hajimehoshi/gopherjstest/vendor/github.com/shurcooL/httpfs/vfsutil (vendor tree)\r\n\t/usr/local/go/src/github.com/shurcooL/httpfs/vfsutil (from $GOROOT)\r\n\t/tmp/go2/src/github.com/shurcooL/httpfs/vfsutil (from $GOPATH)\r\ngo2 $ (mkdir /tmp/go2/src/foobarbaz/hajimehoshi/gopherjstest/vendor/github.com/shurcooL; cd /tmp/go2/src/foobarbaz/hajimehoshi/gopherjstest/vendor/github.com/shurcooL; git clone https://github.com/shurcooL/httpfs)\r\nCloning into 'httpfs'...\r\nremote: Counting objects: 197, done.\r\nremote: Total 197 (delta 0), reused 0 (delta 0), pack-reused 197\r\nReceiving objects: 100% (197/197), 32.35 KiB | 1.08 MiB/s, done.\r\nResolving deltas: 100% (82/82), done.\r\ngo2 $ GOPATH=$NEWGOPATH go install -v foobarbaz/hajimehoshi/gopherjstest/vendor/github.com/gopherjs/gopherjs\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/github.com/gopherjs/gopherjs/compiler/prelude\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/golang.org/x/sys/unix\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/github.com/neelance/sourcemap\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/github.com/kisielk/gotool/internal/load\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/golang.org/x/tools/go/buildutil\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/github.com/gopherjs/gopherjs/compiler/astutil\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/github.com/gopherjs/gopherjs/compiler/typesutil\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/github.com/spf13/pflag\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/github.com/gopherjs/gopherjs/compiler/vendor/github.com/neelance/astrewrite\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/golang.org/x/tools/go/gcimporter15\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/golang.org/x/tools/go/types/typeutil\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/github.com/gopherjs/gopherjs/compiler/filter\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/github.com/gopherjs/gopherjs/compiler/analysis\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/github.com/gopherjs/gopherjs/compiler/gopherjspkg\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/github.com/gopherjs/gopherjs/compiler/natives\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/github.com/shurcooL/httpfs/vfsutil\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/github.com/kisielk/gotool\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/github.com/gopherjs/gopherjs/compiler\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/github.com/gopherjs/gopherjs/internal/sysutil\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/github.com/fsnotify/fsnotify\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/golang.org/x/crypto/ssh/terminal\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/github.com/spf13/cobra\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/github.com/gopherjs/gopherjs/build\r\nfoobarbaz/hajimehoshi/gopherjstest/vendor/github.com/gopherjs/gopherjs\r\ngo2 $ GOPATH=$NEWGOPATH go build foobarbaz/hajimehoshi/gopherjstest\r\ngo2 $ GOPATH=$NEWGOPATH $NEWGOPATH/bin/gopherjs run $NEWGOPATH/src/foobarbaz/hajimehoshi/gopherjstest/main.go\r\nHello\r\ngo2 $ \r\n```\r\n\r\n</details>"}}
{"actor":{"display_login":"shurcooL"}}