Skip to content

Commit

Permalink
Vendor GOROOT packages before compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
chriso committed Sep 23, 2023
1 parent 0ce0861 commit e10100a
Show file tree
Hide file tree
Showing 6 changed files with 1,042 additions and 0 deletions.
15 changes: 15 additions & 0 deletions compiler/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,21 @@ func (c *compiler) compile(path string) error {
pkgColors[fn] = color
}

var needVendoring []*packages.Package
for p := range colorsByPkg {
if p.Module == nil || p.Module.Dir != moduleDir {
needVendoring = append(needVendoring, p)
break
}
}
if len(needVendoring) > 0 {
log.Printf("vendoring packages")
newRoot := filepath.Join(moduleDir, "goroot")
if err := vendor(newRoot, needVendoring); err != nil {
return err
}
}

for p, colors := range colorsByPkg {
if p.Module == nil || p.Module.Dir != moduleDir {
return fmt.Errorf("not implemented: compilation for packages outside module (need to compile %s)", p.PkgPath)
Expand Down
1 change: 1 addition & 0 deletions compiler/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.21.0
require (
github.com/google/go-cmp v0.5.9
github.com/stealthrocket/coroutine v0.0.0-20230906012022-7474cda88ddc
golang.org/x/sync v0.3.0
golang.org/x/tools v0.13.0
)

Expand Down
1 change: 1 addition & 0 deletions compiler/testdata/http/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/goroot
Loading

0 comments on commit e10100a

Please sign in to comment.