github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/gnovm/Makefile (about)

     1  .PHONY: help
     2  help:
     3  	@echo "Available make commands:"
     4  	@cat Makefile | grep '^[a-z][^:]*:' | cut -d: -f1 | sort | sed 's/^/  /'
     5  
     6  # command to run dependency utilities, like goimports.
     7  rundep=go run -modfile ../misc/devdeps/go.mod
     8  
     9  ########################################
    10  # Environment variables
    11  # You can overwrite any of the following by passing a different value on the
    12  # command line, ie. `CGO_ENABLED=1 make test`.
    13  
    14  # disable cgo by default. cgo requires some additional dependencies in some
    15  # cases, and is not strictly required by any tm2 code.
    16  CGO_ENABLED ?= 0
    17  export CGO_ENABLED
    18  # flags for `make fmt`. -w will write the result to the destination files.
    19  GOFMT_FLAGS ?= -w
    20  # flags for `make imports`.
    21  GOIMPORTS_FLAGS ?= $(GOFMT_FLAGS)
    22  # test suite flags.
    23  GOTEST_FLAGS ?= -v -p 1 -timeout=30m
    24  # used to set the default GNOROOT. This helps on local development, as it sets
    25  # up GNOROOT to the supposed path of the Gno repository clone.
    26  GNOROOT_DIR ?= $(abspath $(lastword $(MAKEFILE_LIST))/../../)
    27  # We can't use '-trimpath' yet as amino use absolute path from call stack
    28  # to find some directory: see #1236
    29  GOBUILD_FLAGS ?= -ldflags "-X github.com/gnolang/gno/gnovm/pkg/gnoenv._GNOROOT=$(GNOROOT_DIR)"
    30  
    31  ########################################
    32  # Dev tools
    33  .PHONY: build
    34  build:
    35  	go build $(GOBUILD_FLAGS) -o build/gno ./cmd/gno
    36  
    37  .PHONY: install
    38  install:
    39  	go install $(GOBUILD_FLAGS) ./cmd/gno
    40  
    41  .PHONY: clean
    42  clean:
    43  	rm -rf build
    44  
    45  ########################################
    46  # Dev tools
    47  .PHONY: lint
    48  lint:
    49  	$(rundep) github.com/golangci/golangci-lint/cmd/golangci-lint run --config ../.github/golangci.yml ./...
    50  
    51  .PHONY: fmt
    52  fmt:
    53  	$(rundep) mvdan.cc/gofumpt $(GOFMT_FLAGS) .
    54  	$(rundep) mvdan.cc/gofumpt $(GOFMT_FLAGS) `find stdlibs -name "*.gno"`
    55  
    56  .PHONY: imports
    57  imports:
    58  	$(rundep) golang.org/x/tools/cmd/goimports $(GOIMPORTS_FLAGS) .
    59  
    60  ########################################
    61  # Test suite
    62  .PHONY: test
    63  test: _test.cmd _test.pkg _test.gnolang
    64  
    65  .PHONY: _test.cmd
    66  _test.cmd:
    67  	go test ./cmd/... $(GOTEST_FLAGS)
    68  
    69  .PHONY: _test.pkg
    70  _test.pkg:
    71  	go test ./pkg/... $(GOTEST_FLAGS)
    72  
    73  .PHONY: _test.gnolang
    74  _test.gnolang: _test.gnolang.native _test.gnolang.stdlibs _test.gnolang.realm _test.gnolang.pkg0 _test.gnolang.pkg1 _test.gnolang.pkg2 _test.gnolang.other
    75  _test.gnolang.other:;        go test tests/*.go -run "(TestFileStr|TestSelectors)" $(GOTEST_FLAGS)
    76  _test.gnolang.realm:;        go test tests/*.go -run "TestFiles/^zrealm" $(GOTEST_FLAGS)
    77  _test.gnolang.pkg0:;         go test tests/*.go -run "TestPackages/(bufio|crypto|encoding|errors|internal|io|math|sort|std|stdshim|strconv|strings|testing|unicode)" $(GOTEST_FLAGS)
    78  _test.gnolang.pkg1:;         go test tests/*.go -run "TestPackages/regexp" $(GOTEST_FLAGS)
    79  _test.gnolang.pkg2:;         go test tests/*.go -run "TestPackages/bytes" $(GOTEST_FLAGS)
    80  _test.gnolang.native:;       go test tests/*.go -test.short -run "TestFilesNative/" $(GOTEST_FLAGS)
    81  _test.gnolang.stdlibs:;      go test tests/*.go -test.short -run 'TestFiles$$/' $(GOTEST_FLAGS)
    82  _test.gnolang.native.sync:;  go test tests/*.go -test.short -run "TestFilesNative/" --update-golden-tests $(GOTEST_FLAGS)
    83  _test.gnolang.stdlibs.sync:; go test tests/*.go -test.short -run 'TestFiles$$/' --update-golden-tests $(GOTEST_FLAGS)
    84  
    85  ########################################
    86  # Code gen
    87  # TODO: move _dev.stringer to go:generate instructions, simplify generate
    88  #       to just go generate.
    89  .PHONY: generate
    90  generate: _dev.stringer _dev.generate
    91  
    92  stringer_cmd=$(rundep) golang.org/x/tools/cmd/stringer
    93  .PHONY: _dev.stringer
    94  _dev.stringer:
    95  	$(stringer_cmd) -type=Kind       ./pkg/gnolang
    96  	$(stringer_cmd) -type=Op         ./pkg/gnolang
    97  	$(stringer_cmd) -type=TransCtrl  ./pkg/gnolang
    98  	$(stringer_cmd) -type=TransField ./pkg/gnolang
    99  	$(stringer_cmd) -type=VPType     ./pkg/gnolang
   100  	$(stringer_cmd) -type=Word       ./pkg/gnolang
   101  
   102  .PHONY: _dev.generate
   103  _dev.generate:
   104  	go generate -x ./...
   105  
   106  # genproto:
   107  # see top-level Makefile.