Skip to content

Commit

Permalink
fix: gnodev, gnogensis
Browse files Browse the repository at this point in the history
Signed-off-by: Norman <[email protected]>
  • Loading branch information
n0izn0iz committed Jan 10, 2025
1 parent 7523824 commit 9380f1c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 29 deletions.
5 changes: 0 additions & 5 deletions contribs/gnodev/pkg/dev/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/gnolang/gno/gno.land/pkg/gnoland"
"github.com/gnolang/gno/gno.land/pkg/gnoland/ugnot"
"github.com/gnolang/gno/gno.land/pkg/integration"
"github.com/gnolang/gno/gnovm/pkg/gnolang"
"github.com/gnolang/gno/gnovm/pkg/packages"
"github.com/gnolang/gno/tm2/pkg/amino"
tmcfg "github.com/gnolang/gno/tm2/pkg/bft/config"
Expand Down Expand Up @@ -250,10 +249,6 @@ func (n *Node) updatePackages(paths ...string) error {

// Update or add package in the current known list.
for _, pkg := range pkgslist {
if pkg.ImportPath != "" && gnolang.IsStdlib(pkg.ImportPath) {
continue
}

n.pkgs[pkg.Dir] = Package{
Package: pkg,
Creator: deployer,
Expand Down
8 changes: 4 additions & 4 deletions contribs/gnodev/pkg/dev/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,6 @@ func NewPackagesMap(cfg *packages.LoadConfig, ppaths []PackagePath) (PackagesMap
continue
}

if pkg.ImportPath != "" && gnolang.IsStdlib(pkg.ImportPath) {
continue
}

if _, ok := pkgs[pkg.Dir]; ok {
continue // skip
}
Expand Down Expand Up @@ -136,6 +132,10 @@ func (pm PackagesMap) Load(fee std.Fee, start time.Time) ([]gnoland.TxWithMetada

metatxs := make([]gnoland.TxWithMetadata, 0, len(nonDraft))
for _, modPkg := range nonDraft {
if modPkg.ImportPath == "" || gnolang.IsStdlib(modPkg.ImportPath) {
continue
}

pkg := pm[modPkg.Dir]
if pkg.Creator.IsZero() {
return nil, fmt.Errorf("no creator set for %q", pkg.Dir)
Expand Down
2 changes: 1 addition & 1 deletion contribs/gnogenesis/internal/txs/txs_add_packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func execTxsAddPackages(
parsedTxs := make([]gnoland.TxWithMetadata, 0)
for _, path := range args {
// Generate transactions from the packages (recursively)
loadCfg := &packages.LoadConfig{IO: io, SelfContained: true}
loadCfg := &packages.LoadConfig{IO: io, Deps: true}
txs, err := gnoland.LoadPackagesFromDir(loadCfg, path, creator, genesisDeployFee)
if err != nil {
return fmt.Errorf("unable to load txs from directory, %w", err)
Expand Down
16 changes: 9 additions & 7 deletions gnovm/pkg/packages/analyze_packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,16 @@ func readPkgDir(pkgDir string, importPath string, fset *token.FileSet) *Package
ImportPath: importPath,
}

stdlibsPath := filepath.Join(gnoenv.RootDir(), "gnovm", "stdlibs")
if strings.HasPrefix(filepath.Clean(pkg.Dir), stdlibsPath) {
libPath, err := filepath.Rel(stdlibsPath, pkg.Dir)
if err != nil {
pkg.Errors = append(pkg.Errors, err)
return pkg
if pkg.ImportPath == "" {
stdlibsPath := filepath.Join(gnoenv.RootDir(), "gnovm", "stdlibs")
if strings.HasPrefix(filepath.Clean(pkg.Dir), stdlibsPath) {
libPath, err := filepath.Rel(stdlibsPath, pkg.Dir)
if err != nil {
pkg.Errors = append(pkg.Errors, err)
return pkg
}
pkg.ImportPath = libPath
}

Check warning on line 85 in gnovm/pkg/packages/analyze_packages.go

View check run for this annotation

Codecov / codecov/patch

gnovm/pkg/packages/analyze_packages.go#L85

Added line #L85 was not covered by tests
pkg.ImportPath = libPath
}

files := []string{}
Expand Down
13 changes: 1 addition & 12 deletions gnovm/pkg/packages/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,7 @@ func Load(conf *LoadConfig, patterns ...string) (PkgList, error) {

// check if this is a stdlib and queue it
if gnolang.IsStdlib(imp) {
dir := filepath.Join(gnoroot, "gnovm", "stdlibs", filepath.FromSlash(imp))
dirInfo, err := os.Stat(dir)
if err == nil && !dirInfo.IsDir() {
err = fmt.Errorf("%q is not a directory", dir)
}
if err != nil {
pkg.Errors = append(pkg.Errors, err)
delete(queuedByPkgPath, imp) // stop trying to get this lib, we can't
continue
}

pkg := readPkgDir(dir, imp, fset)
pkg := readPkgDir(filepath.Join(gnoroot, "gnovm", "stdlibs", filepath.FromSlash(imp)), imp, fset)
markForVisit(pkg)
continue
}
Expand Down

0 comments on commit 9380f1c

Please sign in to comment.