Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure build output directory is created #4707

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

jphastings
Copy link

@jphastings jphastings commented Jan 18, 2025

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.

I wasn't certain how to effectively test this change within this repo (this is my first TinyGo contribution), any advice would be welcome!

fixes #4687

`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.
@jphastings jphastings force-pushed the 4687-create-output-dir branch from b7044ab to 70387ac Compare January 18, 2025 18:56
@@ -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), 0777); err != nil {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I picked 777 to match the files' 666 permissions later in this code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant