diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f425992f..9274ca6bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,8 +8,15 @@ and this project adheres to [Semantic Versioning]. ## [7.3.0] — unreleased +### Added + +- Support for **Go modules**. + [#486](https://github.com/ethereum/evmc/pull/486) + ### Changed +- The minimum **Go version** supported bumped to **1.11** (Go modules are required). + [#486](https://github.com/ethereum/evmc/pull/486) - Removed dependency on go-ethereum in Go bindings by introducing own `Address` and `Hash` types. [#513](https://github.com/ethereum/evmc/pull/513) diff --git a/README.md b/README.md index 56bbfa0d9..2b9135f1f 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Please visit the [documentation]. | ----------------------------- | --------------------- | ------------------------------ | ------------------- | **C** | C99, C11 | GCC 6+, clang 3.8+, MSVC 2015+ | Host- and VM-side | **C++** | C++11, C++14, C++17 | GCC 6+, clang 3.8+, MSVC 2015+ | Host- and VM-side -| **Go** _(bindings)_ | 1.9 - 1.12 | | Host-side only +| **Go** _(bindings)_ | 1.11 - 1.14 (modules) | | Host-side only | **Rust** _(bindings)_[¹](#n1) | 2018 edition | 1.37.0 and newer | VM-side only | **Java** _(bindings)_ | 11 | | Host-side only diff --git a/appveyor.yml b/appveyor.yml index 8400e8cbc..3a44dfe9d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -39,11 +39,6 @@ build_script: gcc --version go env - copy include/evmc/evmc.h bindings/go/evmc - copy include/evmc/helpers.h bindings/go/evmc - copy include/evmc/loader.h bindings/go/evmc - copy lib/loader/loader.c bindings/go/evmc - go build ./bindings/go/evmc go generate ./bindings/go/evmc go test -v ./bindings/go/evmc diff --git a/bindings/go/evmc/evmc.go b/bindings/go/evmc/evmc.go index 1f3609033..da8713129 100644 --- a/bindings/go/evmc/evmc.go +++ b/bindings/go/evmc/evmc.go @@ -5,7 +5,7 @@ package evmc /* -#cgo CFLAGS: -I${SRCDIR}/.. -Wall -Wextra +#cgo CFLAGS: -I${SRCDIR}/../../../include -Wall -Wextra #cgo !windows LDFLAGS: -ldl #include diff --git a/bindings/go/evmc/evmc.h b/bindings/go/evmc/evmc.h deleted file mode 120000 index 68e4b5bee..000000000 --- a/bindings/go/evmc/evmc.h +++ /dev/null @@ -1 +0,0 @@ -../../../include/evmc/evmc.h \ No newline at end of file diff --git a/bindings/go/evmc/helpers.h b/bindings/go/evmc/helpers.h deleted file mode 120000 index 9effd04b4..000000000 --- a/bindings/go/evmc/helpers.h +++ /dev/null @@ -1 +0,0 @@ -../../../include/evmc/helpers.h \ No newline at end of file diff --git a/bindings/go/evmc/host.go b/bindings/go/evmc/host.go index 88460e638..c0d70c4fa 100644 --- a/bindings/go/evmc/host.go +++ b/bindings/go/evmc/host.go @@ -5,7 +5,7 @@ package evmc /* -#cgo CFLAGS: -I${SRCDIR}/.. -Wall -Wextra -Wno-unused-parameter +#cgo CFLAGS: -I${SRCDIR}/../../../include -Wall -Wextra -Wno-unused-parameter #include #include diff --git a/bindings/go/evmc/loader.c b/bindings/go/evmc/loader.c deleted file mode 120000 index 37b452e9c..000000000 --- a/bindings/go/evmc/loader.c +++ /dev/null @@ -1 +0,0 @@ -../../../lib/loader/loader.c \ No newline at end of file diff --git a/bindings/go/evmc/loader.c b/bindings/go/evmc/loader.c new file mode 100644 index 000000000..88f47a614 --- /dev/null +++ b/bindings/go/evmc/loader.c @@ -0,0 +1,4 @@ +/* Include evmc::loader in the Go package. + * The "go build" builds all additional C/C++ files in the Go package directory, + * but symbolic links are ignored so #include is used instead. */ +#include "../../../lib/loader/loader.c" diff --git a/bindings/go/evmc/loader.h b/bindings/go/evmc/loader.h deleted file mode 120000 index 8e4511962..000000000 --- a/bindings/go/evmc/loader.h +++ /dev/null @@ -1 +0,0 @@ -../../../include/evmc/loader.h \ No newline at end of file diff --git a/circle.yml b/circle.yml index 569c3bef6..15779e4a8 100644 --- a/circle.yml +++ b/circle.yml @@ -251,6 +251,12 @@ jobs: - image: circleci/golang steps: &bindings-go-steps - checkout + - run: + name: "Environment" + command: | + go version + go env + gcc --version - run: name: "Go Build" command: | @@ -258,10 +264,28 @@ jobs: go vet -v ./bindings/go/evmc go generate -v ./bindings/go/evmc go test -v ./bindings/go/evmc + - run: + name: "Go module integration test" + working_directory: test/gomod + command: | + V=$CIRCLE_TAG + if [ -z $V ]; then + V=$CIRCLE_SHA1 + fi + echo "version: $V" + + go mod init evmc.ethereum.org/evmc_use + go get -v github.com/ethereum/evmc/v7@$V + go mod tidy -v + go mod graph + gcc -shared -I../../include ../../examples/example_vm/example_vm.c -o example-vm.so + go test -v + go mod graph + bindings-go-min: docker: - - image: circleci/golang:1.9 + - image: circleci/golang:1.11 steps: *bindings-go-steps bindings-java: diff --git a/go.mod b/go.mod new file mode 100644 index 000000000..8292e1722 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/ethereum/evmc/v7 + +go 1.11 diff --git a/test/gomod/.gitignore b/test/gomod/.gitignore new file mode 100644 index 000000000..2ea830a7b --- /dev/null +++ b/test/gomod/.gitignore @@ -0,0 +1,3 @@ +/go.mod +/go.sum +/example-vm.so diff --git a/test/gomod/README b/test/gomod/README new file mode 100644 index 000000000..8d9d308b1 --- /dev/null +++ b/test/gomod/README @@ -0,0 +1,9 @@ +Integration test for EVMC Go module + +Usage: + + go mod init evmc.ethereum.org/evmc_use + go get github.com/ethereum/evmc/v7@ + go mod tidy + gcc -shared -I../../include ../../examples/example_vm/example_vm.c -o example-vm.so + go test diff --git a/test/gomod/use_evmc_test.go b/test/gomod/use_evmc_test.go new file mode 100644 index 000000000..441ce343b --- /dev/null +++ b/test/gomod/use_evmc_test.go @@ -0,0 +1,20 @@ +package evmc_use + +import ( + "github.com/ethereum/evmc/v7/bindings/go/evmc" + "testing" +) + +var exampleVmPath = "./example-vm.so" + +func TestGetVmName(t *testing.T) { + vm, err := evmc.Load(exampleVmPath) + if err != nil { + t.Fatalf("%v", err) + } + + expectedName := "example_vm" + if name := vm.Name(); name != expectedName { + t.Errorf("wrong VM name: %s, expected %s", name, expectedName) + } +}