-
Notifications
You must be signed in to change notification settings - Fork 570
Embed core GopherJS packages into build system; enable vendoring of GopherJS. #787
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
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f681903
build: Make fewer copies of NewBuildContext.
dmitshur a4af087
compiler/gopherjspkg: Add package.
dmitshur c121b3d
build: Load js, nosync packages from gopherjspkg rather than GOPATH.
dmitshur b90dbcb
build, compiler/typesutil: Don't use vendor directory to resolve js, …
dmitshur b24e356
Restore support for testing js package.
dmitshur d0d69c0
tests: Add test that GopherJS can be vendored.
dmitshur c8e5f7c
README: Remove note saying vendoring GopherJS is unsupported.
dmitshur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
compiler/gopherjspkg: Add package.
This package embeds the core GopherJS packages (js, nosync). It's similar to how native overrides for stdlib are embedded in the compiler/natives package. Pick only files in /fs and /nosync, and no subdirectories (if any are added, they won't get included by default).
- Loading branch information
commit a4af087c07864b4fe10e2c086e3cbca697f91ada
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Package gopherjspkg provides core GopherJS packages via a virtual filesystem. | ||
// | ||
// Core GopherJS packages are packages that are critical for GopherJS compiler | ||
// operation. They are needed to build the Go standard library with GopherJS. | ||
// Currently, they include: | ||
// | ||
// github.com/gopherjs/gopherjs/js | ||
// github.com/gopherjs/gopherjs/nosync | ||
// | ||
package gopherjspkg | ||
|
||
//go:generate vfsgendev -source="github.com/gopherjs/gopherjs/compiler/gopherjspkg".FS -tag=gopherjsdev | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// +build gopherjsdev | ||
|
||
package gopherjspkg | ||
|
||
import ( | ||
"go/build" | ||
"log" | ||
"net/http" | ||
"os" | ||
pathpkg "path" | ||
|
||
"github.com/shurcooL/httpfs/filter" | ||
) | ||
|
||
// FS is a virtual filesystem that contains core GopherJS packages. | ||
var FS = filter.Keep( | ||
http.Dir(importPathToDir("github.com/gopherjs/gopherjs")), | ||
func(path string, fi os.FileInfo) bool { | ||
return path == "/" || | ||
path == "/js" || (pathpkg.Dir(path) == "/js" && !fi.IsDir()) || | ||
path == "/nosync" || (pathpkg.Dir(path) == "/nosync" && !fi.IsDir()) | ||
}, | ||
) | ||
|
||
func importPathToDir(importPath string) string { | ||
p, err := build.Import(importPath, "", build.FindOnly) | ||
if err != nil { | ||
log.Fatalln(err) | ||
} | ||
return p.Dir | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does
vfgendev
come from?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://github.com/gopherjs/gopherjs/wiki/Developer-Guidelines#code-generation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please can we make this
go:generate
directive not rely onvfsgendev
being inPATH
?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's out of scope for this PR. This
gopherjspkg
package is the same in structure asnatives
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. This would be better solved in any case by golang/go#22726