Skip to content

Commit

Permalink
Ensure build output directory is created
Browse files Browse the repository at this point in the history
`tinygo build -o /path/to/out .` expected `/path/to/out` to already exist, which is different behaviour to `go build`. This change ensures tinygo creates any directories needed to be able to build to the specified output dir.
  • Loading branch information
jphastings committed Jan 18, 2025
1 parent 127557d commit b7044ab
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions builder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,11 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
},
}

// Create the output directory, if needed
if err := os.MkdirAll(filepath.Dir(outpath), 0755); err != nil {
return result, err
}

// Check whether we only need to create an object file.
// If so, we don't need to link anything and will be finished quickly.
outext := filepath.Ext(outpath)
Expand Down

0 comments on commit b7044ab

Please sign in to comment.