compiler: implement custom logic for go1.15
For some reason `foo.go` is interpreted as an http URL, and even if we replace it with `./foo.go` there is an errors with file missing on disk. Because `CompileWithOptions` should be able to compile file under any circumstances, we allocate temporary directory base on version used to compile a binary. Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
cae5b8541d
commit
ad65d1fa1f
15 changed files with 28 additions and 16 deletions
|
@ -1,5 +1,5 @@
|
|||
module github.com/nspcc-dev/neo-go/examples/engine
|
||||
|
||||
go 1.15
|
||||
go 1.16
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220118080652-4eddfdbbc652
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module github.com/nspcc-dev/neo-go/examples/events
|
||||
|
||||
go 1.15
|
||||
go 1.16
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220118080652-4eddfdbbc652
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module github.com/nspcc-dev/neo-go/examples/iterator
|
||||
|
||||
go 1.15
|
||||
go 1.16
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220118080652-4eddfdbbc652
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module github.com/nspcc-dev/neo-go/examples/nft-nd-nns
|
||||
|
||||
go 1.15
|
||||
go 1.16
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220118080652-4eddfdbbc652 // indirect
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module github.com/nspcc-dev/neo-go/examples/nft-nd
|
||||
|
||||
go 1.15
|
||||
go 1.16
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220118080652-4eddfdbbc652
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module github.com/nspcc-dev/neo-go/examples/oracle
|
||||
|
||||
go 1.15
|
||||
go 1.16
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220118080652-4eddfdbbc652
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module github.com/nspcc-dev/neo-go/examples/runtime
|
||||
|
||||
go 1.15
|
||||
go 1.16
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220118080652-4eddfdbbc652
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module github.com/nspcc-dev/neo-go/examples/storage
|
||||
|
||||
go 1.15
|
||||
go 1.16
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220118080652-4eddfdbbc652
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module github.com/nspcc-dev/neo-go/examples/timer
|
||||
|
||||
go 1.15
|
||||
go 1.16
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220118080652-4eddfdbbc652
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module github.com/nspcc-dev/neo-go/examples/token-sale
|
||||
|
||||
go 1.15
|
||||
go 1.16
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220118080652-4eddfdbbc652
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
module github.com/nspcc-dev/neo-go/examples/token
|
||||
|
||||
go 1.15
|
||||
go 1.16
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220118080652-4eddfdbbc652
|
||||
|
|
|
@ -12,6 +12,7 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||
|
@ -157,7 +158,17 @@ func getBuildInfo(name string, src interface{}) (*buildInfo, error) {
|
|||
default:
|
||||
panic(fmt.Sprintf("unsupported src type: %T", s))
|
||||
}
|
||||
names = append(names, name)
|
||||
if strings.HasPrefix(runtime.Version(), "go1.15") {
|
||||
dir, err = ioutil.TempDir("", "*")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
name = filepath.Join(dir, filepath.Base(name))
|
||||
absName = name
|
||||
names = append(names, "file="+name)
|
||||
} else {
|
||||
names = append(names, name)
|
||||
}
|
||||
conf.Overlay[absName] = buf
|
||||
} else {
|
||||
if strings.HasSuffix(name, ".go") {
|
||||
|
|
|
@ -303,7 +303,8 @@ func TestSequencePoints(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
require.NotNil(t, d)
|
||||
|
||||
require.Equal(t, d.Documents, []string{"foo.go"})
|
||||
require.Equal(t, 1, len(d.Documents))
|
||||
require.True(t, strings.HasSuffix(d.Documents[0], "foo.go"))
|
||||
|
||||
// Main func has 2 return on 4-th and 6-th lines.
|
||||
ps := d.Methods[0].SeqPoints
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
module github.com/nspcc-dev/neo-go/pkg/interop
|
||||
|
||||
go 1.15
|
||||
go 1.16
|
|
@ -209,7 +209,7 @@ func TestLoad(t *testing.T) {
|
|||
require.NoError(t, ioutil.WriteFile(filenameErr, []byte(src+"invalid_token"), os.ModePerm))
|
||||
filenameErr = "'" + filenameErr + "'"
|
||||
goMod := []byte(`module test.example/vmcli
|
||||
go 1.15`)
|
||||
go 1.16`)
|
||||
require.NoError(t, ioutil.WriteFile(filepath.Join(tmpDir, "go.mod"), goMod, os.ModePerm))
|
||||
|
||||
e := newTestVMCLI(t)
|
||||
|
@ -242,7 +242,7 @@ require (
|
|||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0
|
||||
)
|
||||
replace github.com/nspcc-dev/neo-go/pkg/interop => ` + filepath.Join(wd, "../../interop") + `
|
||||
go 1.15`)
|
||||
go 1.16`)
|
||||
require.NoError(t, ioutil.WriteFile(filepath.Join(tmpDir, "go.mod"), goMod, os.ModePerm))
|
||||
|
||||
e := newTestVMCLI(t)
|
||||
|
|
Loading…
Reference in a new issue