From c7414be0645a03f050abf8f17a9b0ea3fc58b3d2 Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Tue, 21 Jan 2025 22:07:52 +0100 Subject: [PATCH 1/4] chore: fmt Signed-off-by: moul <94029+moul@users.noreply.github.com> --- .github/workflows/build_template.yml | 3 ++- gno.land/Makefile | 6 +++++- gnovm/Makefile | 2 +- gnovm/pkg/gnolang/internal/softfloat/copy.sh | 6 +++--- .../internal/softfloat/runtime_softfloat64_test.go | 5 +++-- tm2/Makefile | 5 +++++ tm2/pkg/overflow/overflow_impl.go | 12 ++++-------- 7 files changed, 23 insertions(+), 16 deletions(-) diff --git a/.github/workflows/build_template.yml b/.github/workflows/build_template.yml index a2c96f2d37e..454e76b84da 100644 --- a/.github/workflows/build_template.yml +++ b/.github/workflows/build_template.yml @@ -23,7 +23,8 @@ jobs: - name: Check generated files are up to date working-directory: ${{ inputs.modulepath }} run: | - go generate -x ./... + make generate + if [ "$(git status -s)" != "" ]; then echo "command 'go generate' creates file that differ from git tree, please run 'go generate' and commit:" git status -s diff --git a/gno.land/Makefile b/gno.land/Makefile index 075560f44a9..90ba7451c35 100644 --- a/gno.land/Makefile +++ b/gno.land/Makefile @@ -50,9 +50,13 @@ install.gnokey:; go install ./cmd/gnokey .PHONY: dev.gnoweb generate.gnoweb dev.gnoweb: make -C ./pkg/gnoweb dev -generate.gnoweb: + +.PHONY: generate +generate: + go generate -x ./... make -C ./pkg/gnoweb generate + .PHONY: fclean fclean: clean rm -rf gnoland-data genesis.json diff --git a/gnovm/Makefile b/gnovm/Makefile index babb7ad74ca..d02b99045c7 100644 --- a/gnovm/Makefile +++ b/gnovm/Makefile @@ -125,7 +125,7 @@ _test.filetest:; # TODO: move _dev.stringer to go:generate instructions, simplify generate # to just go generate. .PHONY: generate -generate: _dev.stringer _dev.generate +generate: _dev.stringer _dev.generate fmt imports stringer_cmd=$(rundep) golang.org/x/tools/cmd/stringer .PHONY: _dev.stringer diff --git a/gnovm/pkg/gnolang/internal/softfloat/copy.sh b/gnovm/pkg/gnolang/internal/softfloat/copy.sh index 6d2a8f80462..d46623117e8 100644 --- a/gnovm/pkg/gnolang/internal/softfloat/copy.sh +++ b/gnovm/pkg/gnolang/internal/softfloat/copy.sh @@ -10,7 +10,7 @@ cat > runtime_softfloat64.go << EOF EOF cat "$GOROOT/src/runtime/softfloat64.go" >> ./runtime_softfloat64.go -sed -i 's/^package runtime$/package softfloat/' runtime_softfloat64.go +sed -i '' 's/^package runtime$/package softfloat/' runtime_softfloat64.go # softfloat64_test.go: # - add header @@ -25,8 +25,8 @@ cat > runtime_softfloat64_test.go << EOF EOF cat "$GOROOT/src/runtime/softfloat64_test.go" >> ./runtime_softfloat64_test.go -sed -i 's/^package runtime_test$/package softfloat_test/ +sed -i '' 's/^package runtime_test$/package softfloat_test/ s#^\t\. "runtime"$#\t. "github.com/gnolang/gno/gnovm/pkg/gnolang/internal/softfloat"# s/GOARCH/runtime.GOARCH/g 16a\ - "runtime"' runtime_softfloat64_test.go \ No newline at end of file + "runtime"' runtime_softfloat64_test.go diff --git a/gnovm/pkg/gnolang/internal/softfloat/runtime_softfloat64_test.go b/gnovm/pkg/gnolang/internal/softfloat/runtime_softfloat64_test.go index c57fe08b0ef..7b3a40ab838 100644 --- a/gnovm/pkg/gnolang/internal/softfloat/runtime_softfloat64_test.go +++ b/gnovm/pkg/gnolang/internal/softfloat/runtime_softfloat64_test.go @@ -12,9 +12,10 @@ package softfloat_test import ( "math" "math/rand" - . "github.com/gnolang/gno/gnovm/pkg/gnolang/internal/softfloat" + "runtime" "testing" - "runtime" + + . "github.com/gnolang/gno/gnovm/pkg/gnolang/internal/softfloat" ) // turn uint64 op into float64 op diff --git a/tm2/Makefile b/tm2/Makefile index 0aaa63e5285..fd3aede0d4c 100644 --- a/tm2/Makefile +++ b/tm2/Makefile @@ -63,3 +63,8 @@ _test.pkg.others:; go test $(GOTEST_FLAGS) `go list ./pkg/... | grep -Ev 'pkg/( _test.pkg.amino:; go test $(GOTEST_FLAGS) ./pkg/amino/... _test.pkg.bft:; go test $(GOTEST_FLAGS) ./pkg/bft/... _test.pkg.db:; go test $(GOTEST_FLAGS) ./pkg/db/... ./pkg/iavl/benchmarks/... + +.PHONY: generate +generate: + go generate -x ./... + $(MAKE) fmt diff --git a/tm2/pkg/overflow/overflow_impl.go b/tm2/pkg/overflow/overflow_impl.go index 0f057f65387..ab9f13c163d 100644 --- a/tm2/pkg/overflow/overflow_impl.go +++ b/tm2/pkg/overflow/overflow_impl.go @@ -84,10 +84,9 @@ func Quotient8(a, b int8) (int8, int8, bool) { } c := a / b status := (c < 0) == ((a < 0) != (b < 0)) || (c == 0) // no sign check for 0 quotient - return c, a%b, status + return c, a % b, status } - // Add16 performs + operation on two int16 operands, returning a result and status. func Add16(a, b int16) (int16, bool) { c := a + b @@ -170,10 +169,9 @@ func Quotient16(a, b int16) (int16, int16, bool) { } c := a / b status := (c < 0) == ((a < 0) != (b < 0)) || (c == 0) // no sign check for 0 quotient - return c, a%b, status + return c, a % b, status } - // Add32 performs + operation on two int32 operands, returning a result and status. func Add32(a, b int32) (int32, bool) { c := a + b @@ -256,10 +254,9 @@ func Quotient32(a, b int32) (int32, int32, bool) { } c := a / b status := (c < 0) == ((a < 0) != (b < 0)) || (c == 0) // no sign check for 0 quotient - return c, a%b, status + return c, a % b, status } - // Add64 performs + operation on two int64 operands, returning a result and status. func Add64(a, b int64) (int64, bool) { c := a + b @@ -342,6 +339,5 @@ func Quotient64(a, b int64) (int64, int64, bool) { } c := a / b status := (c < 0) == ((a < 0) != (b < 0)) || (c == 0) // no sign check for 0 quotient - return c, a%b, status + return c, a % b, status } - From ca9c24610a1e4a6a8ae7d2513fe0fe018638dd0d Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Tue, 21 Jan 2025 22:19:36 +0100 Subject: [PATCH 2/4] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- gnovm/pkg/gnolang/internal/softfloat/copy.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gnovm/pkg/gnolang/internal/softfloat/copy.sh b/gnovm/pkg/gnolang/internal/softfloat/copy.sh index d46623117e8..db74757e9e7 100644 --- a/gnovm/pkg/gnolang/internal/softfloat/copy.sh +++ b/gnovm/pkg/gnolang/internal/softfloat/copy.sh @@ -10,7 +10,8 @@ cat > runtime_softfloat64.go << EOF EOF cat "$GOROOT/src/runtime/softfloat64.go" >> ./runtime_softfloat64.go -sed -i '' 's/^package runtime$/package softfloat/' runtime_softfloat64.go +sed 's/^package runtime$/package softfloat/' runtime_softfloat64.go > tmpfile +mv tmpfile runtime_softfloat64.go # softfloat64_test.go: # - add header @@ -25,8 +26,9 @@ cat > runtime_softfloat64_test.go << EOF EOF cat "$GOROOT/src/runtime/softfloat64_test.go" >> ./runtime_softfloat64_test.go -sed -i '' 's/^package runtime_test$/package softfloat_test/ +sed 's/^package runtime_test$/package softfloat_test/ s#^\t\. "runtime"$#\t. "github.com/gnolang/gno/gnovm/pkg/gnolang/internal/softfloat"# s/GOARCH/runtime.GOARCH/g 16a\ - "runtime"' runtime_softfloat64_test.go + "runtime"' runtime_softfloat64_test.go > tmpfile +mv tmpfile runtime_softfloat64_test.go From 08e023a2479b0f35e2d6f986ad23b86629b430c5 Mon Sep 17 00:00:00 2001 From: moul <94029+moul@users.noreply.github.com> Date: Fri, 24 Jan 2025 15:49:57 +0100 Subject: [PATCH 3/4] chore: fixup Signed-off-by: moul <94029+moul@users.noreply.github.com> --- gnovm/tests/stdlibs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnovm/tests/stdlibs/README.md b/gnovm/tests/stdlibs/README.md index 8742447e59a..d264cf35c45 100644 --- a/gnovm/tests/stdlibs/README.md +++ b/gnovm/tests/stdlibs/README.md @@ -5,4 +5,4 @@ available when testing gno code in `_test.gno` and `_filetest.gno` files. Re-declarations of functions already existing override the definitions of the normal stdlibs directory. -Adding imports that don't exist in the corresponding normal stdlib is undefined behavior \ No newline at end of file +Adding imports that don't exist in the corresponding normal stdlib is undefined behavior From 90dcbd85ffe33800f2f1956ab00a61c002d99b9a Mon Sep 17 00:00:00 2001 From: Manfred Touron <94029+moul@users.noreply.github.com> Date: Tue, 28 Jan 2025 13:26:47 +0100 Subject: [PATCH 4/4] Delete gnovm/pkg/gnolang/internal/softfloat/copy.sh --- gnovm/pkg/gnolang/internal/softfloat/copy.sh | 34 -------------------- 1 file changed, 34 deletions(-) delete mode 100644 gnovm/pkg/gnolang/internal/softfloat/copy.sh diff --git a/gnovm/pkg/gnolang/internal/softfloat/copy.sh b/gnovm/pkg/gnolang/internal/softfloat/copy.sh deleted file mode 100644 index db74757e9e7..00000000000 --- a/gnovm/pkg/gnolang/internal/softfloat/copy.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -# softfloat64.go: -# - add header -# - change package name -cat > runtime_softfloat64.go << EOF -// Code generated by copy.sh. DO NOT EDIT. -// This file is copied from \$GOROOT/src/runtime/softfloat64.go. -// It is the software floating point implementation used by the Go runtime. - -EOF -cat "$GOROOT/src/runtime/softfloat64.go" >> ./runtime_softfloat64.go -sed 's/^package runtime$/package softfloat/' runtime_softfloat64.go > tmpfile -mv tmpfile runtime_softfloat64.go - -# softfloat64_test.go: -# - add header -# - change package name -# - change import to right package -# - change GOARCH to runtime.GOARCH, and import the "runtime" package -cat > runtime_softfloat64_test.go << EOF -// Code generated by copy.sh. DO NOT EDIT. -// This file is copied from \$GOROOT/src/runtime/softfloat64_test.go. -// It is the tests for the software floating point implementation -// used by the Go runtime. - -EOF -cat "$GOROOT/src/runtime/softfloat64_test.go" >> ./runtime_softfloat64_test.go -sed 's/^package runtime_test$/package softfloat_test/ -s#^\t\. "runtime"$#\t. "github.com/gnolang/gno/gnovm/pkg/gnolang/internal/softfloat"# -s/GOARCH/runtime.GOARCH/g -16a\ - "runtime"' runtime_softfloat64_test.go > tmpfile -mv tmpfile runtime_softfloat64_test.go