closes#4682
The self-hosted compiler is still bit rotted and still not compiling
successfully yet. I have a more serious rework of the code in a
different branch.
This behaves the same as stdout and stderr behavior which also
default to .inherit. Also adds a field to RunStep to change the behavior.
Since this is a breaking change, previous behavior can be restored by doing:
`RunStep.stdin_behavior = .Ignore`.
When building an object file from only one source file, instead of
having a two-stage cache system, we special case it and use the cache
directory that the .o file is output to as the final cache directory for
all the build artifacts.
When there are more than 1 source file, the linker has to merge objects
into one, and so the two stage approach makes sens. But in the case of
only one source file, this prevents needlessly copying the object file.
This commit fixes an issue with the previous one, where zig with cache
enabled would print a directory that actually did not have any build
artifacts in it.
Previously the zig build system incorrectly assumed that the only build
artifact was a binary. Now, when you enable the cache, only the output
dir is printed to stdout, and the zig build system iterates over the
files in that directory, copying them to the output directory.
To support this change:
* Add `std.os.renameat`, `std.os.renameatZ`, and `std.os.renameatW`.
* Fix `std.os.linux.renameat` not compiling due to typos.
* Deprecate `std.fs.updateFile` and `std.fs.updateFileMode`.
* Add `std.fs.Dir.updateFile`, which supports using open directory
handles for both the source and destination paths, as well as an
options parameter which allows overriding the mode.
* Update `std.fs.AtomicFile` to support operating based on an open
directory handle. Instead of `std.fs.AtomicFile.init`, use
`std.fs.Dir.atomicFile`.
* `std.fs.AtomicFile` deinit() better handles the situation when the
rename fails but the temporary file still exists, by still
attempting to remove the temporary file.
* `std.fs.Dir.openFileWindows` is moved to `std.os.windows.OpenFileW`.
* `std.os.RenameError` gains the error codes `NoDevice`,
`SharingViolation`, and `PipeBusy` which have been observed from
Windows.
Closes#4733
* `std.Buffer.print` is removed; use `buffer.outStream().print`
* `std.fmt.count` returns a `u64`
* `std.Fifo.print` is removed; use `fifo.outStream().print`
* `std.fmt.bufPrint` error is renamed from `BufferTooSmall`
to `NoSpaceLeft` to match `std.os.write`.
* `std.io.FixedBufferStream.getWritten` returns mutable buffer
if the buffer is mutable.