Skip to content

Commit

Permalink
runtime: config overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
visualfc committed Feb 6, 2025
1 parent bfe7218 commit 5e6e6b8
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion compiler/cl/builtin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ func TestIntVal(t *testing.T) {
}

func TestIgnoreName(t *testing.T) {
if !ignoreName("runtime/foo") || !ignoreName("internal/abi") {
if !ignoreName("runtime/foo.bar") || ignoreName("internal/abi.Type") {
t.Fatal("ignoreName failed")
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/internal/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ func Do(args []string, conf *Config) ([]Package, error) {
Fset: token.NewFileSet(),
}

if len(overlayFiles) > 0 {
if len(llruntime.OverlayFiles) > 0 {
cfg.Overlay = make(map[string][]byte)
for file, src := range overlayFiles {
for file, src := range llruntime.OverlayFiles {
overlay := unsafe.Slice(unsafe.StringData(src), len(src))
cfg.Overlay[filepath.Join(env.GOROOT(), "src", file)] = overlay
}
Expand Down
File renamed without changes.
File renamed without changes.
11 changes: 6 additions & 5 deletions runtime/runtime.go → runtime/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func SkipToBuild(pkgPath string) bool {
if _, ok := hasAltPkg[pkgPath]; ok {
return false
}
if _, ok := supportInternal[pkgPath]; ok {
if _, ok := supportedInternal[pkgPath]; ok {
return false
}
switch pkgPath {
Expand All @@ -27,13 +27,14 @@ func IgnoreName(name string) bool {
}
*/
const internal = "internal/"
return (strings.HasPrefix(name, internal) && IsSupportInternal(name)) ||
return (strings.HasPrefix(name, internal) && !IsSupportedInternal(name)) ||
strings.HasPrefix(name, "runtime/") || strings.HasPrefix(name, "arena.") ||
strings.HasPrefix(name, "maps.") || strings.HasPrefix(name, "plugin.")
}

func IsSupportInternal(path string) (b bool) {
_, b = supportInternal[path]
func IsSupportedInternal(name string) (b bool) {
paths := strings.Split(name, ".")
_, b = supportedInternal[paths[0]]
return
}

Expand Down Expand Up @@ -75,7 +76,7 @@ var hasAltPkg = map[string]none{
"io": {},
}

var supportInternal = map[string]none{
var supportedInternal = map[string]none{
"internal/abi": {},
"internal/bytealg": {},
"internal/itoa": {},
Expand Down
4 changes: 2 additions & 2 deletions compiler/internal/build/overlay.go → runtime/overlay.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package build
package runtime

import (
_ "embed"
Expand All @@ -10,7 +10,7 @@ var go_parser_resolver string
//go:embed _overlay/net/textproto/textproto.go
var net_textproto string

var overlayFiles = map[string]string{
var OverlayFiles = map[string]string{
"math/exp_amd64.go": "package math;",
"go/parser/resolver.go": go_parser_resolver,
"net/textproto/textproto.go": net_textproto,
Expand Down

0 comments on commit 5e6e6b8

Please sign in to comment.