From a9de97fa1e6c47c69a5da150682ab2f56d6aba47 Mon Sep 17 00:00:00 2001 From: ucwong Date: Thu, 14 Sep 2023 19:53:59 +0800 Subject: [PATCH] rlp/rlpgen: remove build tag --- core/types/block.go | 1 - core/types/gen_account_rlp.go | 3 --- core/types/gen_log_rlp.go | 3 --- core/types/log.go | 2 +- rlp/rlpgen/main.go | 15 +++++---------- 5 files changed, 6 insertions(+), 18 deletions(-) diff --git a/core/types/block.go b/core/types/block.go index dd1184b664..2af680bf2d 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -99,7 +99,6 @@ func (s *BlockSolution) UnmarshalJSON(input []byte) error { } //go:generate go run github.com/fjl/gencodec -type Header -field-override headerMarshaling -out gen_header_json.go -//go:generate go run ../../rlp/rlpgen -type Header -out gen_header_rlp.go // Header represents a block header in the Cortex blockchain. type Header struct { diff --git a/core/types/gen_account_rlp.go b/core/types/gen_account_rlp.go index e1e4cb6d6c..af7a77b671 100644 --- a/core/types/gen_account_rlp.go +++ b/core/types/gen_account_rlp.go @@ -1,8 +1,5 @@ // Code generated by rlpgen. DO NOT EDIT. -//go:build !norlpgen -// +build !norlpgen - package types import "github.com/CortexFoundation/CortexTheseus/rlp" diff --git a/core/types/gen_log_rlp.go b/core/types/gen_log_rlp.go index c0ec02aea4..d96ff0b895 100644 --- a/core/types/gen_log_rlp.go +++ b/core/types/gen_log_rlp.go @@ -1,8 +1,5 @@ // Code generated by rlpgen. DO NOT EDIT. -//go:build !norlpgen -// +build !norlpgen - package types import "github.com/CortexFoundation/CortexTheseus/rlp" diff --git a/core/types/log.go b/core/types/log.go index c0401008b5..c6d13eb43c 100644 --- a/core/types/log.go +++ b/core/types/log.go @@ -21,7 +21,7 @@ import ( "github.com/CortexFoundation/CortexTheseus/common/hexutil" ) -//go:generate go run ../../rlp/rlpgen -norlpgen=false -type Log -out gen_log_rlp.go +//go:generate go run ../../rlp/rlpgen -type Log -out gen_log_rlp.go //go:generate go run github.com/fjl/gencodec -type Log -field-override logMarshaling -out gen_log_json.go // Log represents a contract log event. These events are generated by the LOG opcode and diff --git a/rlp/rlpgen/main.go b/rlp/rlpgen/main.go index 678d438525..f85c06a0f1 100644 --- a/rlp/rlpgen/main.go +++ b/rlp/rlpgen/main.go @@ -35,7 +35,6 @@ func main() { output = flag.String("out", "-", "output file (default is stdout)") genEncoder = flag.Bool("encoder", true, "generate EncodeRLP?") genDecoder = flag.Bool("decoder", false, "generate DecodeRLP?") - norlpGen = flag.Bool("norlpgen", true, "apply norlpgen build tag") typename = flag.String("type", "", "type to generate methods for") ) flag.Parse() @@ -46,7 +45,7 @@ func main() { GenerateEncoder: *genEncoder, GenerateDecoder: *genDecoder, } - code, err := cfg.process(*norlpGen) + code, err := cfg.process() if err != nil { fatal(err) } @@ -71,17 +70,13 @@ type Config struct { } // process generates the Go code. -func (cfg *Config) process(norlpGen bool) (code []byte, err error) { +func (cfg *Config) process() (code []byte, err error) { // Load packages. pcfg := &packages.Config{ - Mode: packages.NeedName | packages.NeedTypes | packages.NeedImports | packages.NeedDeps, + Mode: packages.NeedName | packages.NeedTypes, Dir: cfg.Dir, } - if norlpGen { - pcfg.BuildFlags = []string{"-tags", "norlpgen"} - } - ps, err := packages.Load(pcfg, pathOfPackageRLP, ".") if err != nil { return nil, err @@ -122,8 +117,8 @@ func (cfg *Config) process(norlpGen bool) (code []byte, err error) { // This is done here to avoid processing these lines with gofmt. var header bytes.Buffer fmt.Fprint(&header, "// Code generated by rlpgen. DO NOT EDIT.\n\n") - fmt.Fprint(&header, "//go:build !norlpgen\n") - fmt.Fprint(&header, "// +build !norlpgen\n\n") + //fmt.Fprint(&header, "//go:build !norlpgen\n") + //fmt.Fprint(&header, "// +build !norlpgen\n\n") return append(header.Bytes(), code...), nil }