Skip to content

Commit

Permalink
re-generated by skipping targets with sanity check errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gen2thomas committed Jan 7, 2024
1 parent 0cbcfde commit 111e5db
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions doc-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,21 @@ func main() {
continue
}
fmt.Println("Generating documentation for:", target)
updateDocumentation(target, path, docPath)
if err := updateDocumentation(target, path, docPath); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}
}

func updateDocumentation(target, path, docPath string) {
func updateDocumentation(target, path, docPath string) error {
// Get the important information from the compiler.
cmd := exec.Command("tinygo", "info", target)
outBytes, err := cmd.Output()
if err != nil {
fmt.Fprintln(os.Stderr, "could not run tinygo:", err)
os.Exit(1)
return fmt.Errorf("could not run tinygo: %v", err)
}

var buildTags []string
var goos, goarch, goroot string
for _, line := range strings.Split(string(outBytes), "\n") {
Expand All @@ -138,8 +141,7 @@ func updateDocumentation(target, path, docPath string) {
}
}
if len(buildTags) == 0 || goos == "" || goarch == "" || goroot == "" {
fmt.Fprintln(os.Stderr, "could not find all needed properties (build tags, GOOS, GOARCH, GOROOT)")
os.Exit(1)
return fmt.Errorf("could not find all needed properties (build tags, GOOS, GOARCH, GOROOT)")
}

// Get the list of files that would be compiled for this package.
Expand All @@ -154,24 +156,26 @@ func updateDocumentation(target, path, docPath string) {

// Do some sanity checking.
if len(pkgs[0].Errors) != 0 {
fmt.Fprintf(os.Stderr, " sanity check failed with %d error(s)\n", len(pkgs[0].Errors))
for _, err := range pkgs[0].Errors {
fmt.Fprintln(os.Stderr, err)
fmt.Fprintf(os.Stderr, " * %v\n", err)
}
os.Exit(1)
return nil
//os.Exit(1)
}
pkg := pkgs[0]

err = writeMachinePackageDoc(path, target, pkg)
if err != nil {
fmt.Fprintln(os.Stderr, "error:", err)
os.Exit(1)
return fmt.Errorf("error on write machine package doc: %v", err)
}

err = updateBoardDocumentation(docPath, pkg, buildTags)
if err != nil {
fmt.Fprintln(os.Stderr, "error:", err)
os.Exit(1)
return fmt.Errorf("error on update board documentation: %v", err)
}

return nil
}

func writeMachinePackageDoc(path, target string, pkg *packages.Package) error {
Expand Down

0 comments on commit 111e5db

Please sign in to comment.