Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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 7 commits into from
Apr 21, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
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
dmitshur committed Apr 20, 2018
commit a4af087c07864b4fe10e2c086e3cbca697f91ada
12 changes: 12 additions & 0 deletions 12 compiler/gopherjspkg/doc.go
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
Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

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 on vfsgendev being in PATH?

Copy link
Member Author

@dmitshur dmitshur Apr 20, 2018

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 as natives.

Copy link
Member

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

31 changes: 31 additions & 0 deletions 31 compiler/gopherjspkg/fs.go
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
}
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.