Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions gengo/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,35 @@ func findPackages(pkgType string, rosPkgPaths []string) (map[string]string, erro
if err != nil {
continue
}
generateMsgs(p, pkgType, pkgs)
for _, f := range files {
if !f.IsDir() {
continue
}
pkgPath := filepath.Join(p, f.Name())
if isRosPackage(pkgPath) {
pkgName := filepath.Base(pkgPath)
msgPath := filepath.Join(pkgPath, pkgType)
msgPaths, err := filepath.Glob(msgPath + fmt.Sprintf("/*.%s", pkgType))
if err != nil {
continue
}
for _, m := range msgPaths {
basename := filepath.Base(m)
rootname := basename[:len(basename)-len(pkgType)-1]
fullname := pkgName + "/" + rootname
pkgs[fullname] = m
}
}
generateMsgs(pkgPath, pkgType, pkgs)
}
}
return pkgs, nil
}

func generateMsgs(pkgPath, pkgType string, pkgs map[string]string) {
if isRosPackage(pkgPath) {
pkgName := filepath.Base(pkgPath)
msgPath := filepath.Join(pkgPath, pkgType)
msgPaths, err := filepath.Glob(msgPath + fmt.Sprintf("/*.%s", pkgType))
if err != nil {
return
}
for _, m := range msgPaths {
basename := filepath.Base(m)
rootname := basename[:len(basename)-len(pkgType)-1]
fullname := pkgName + "/" + rootname
pkgs[fullname] = m
}
}
}

func findAllMessages(rosPkgPaths []string) (map[string]string, error) {
return findPackages("msg", rosPkgPaths)
}
Expand Down