Commit Graph

8255 Commits (555a2c03286507ffe4bd3bea2154dbfb719ebef1)

Author SHA1 Message Date
Andrew Kelley 555a2c0328
(breaking) std.fs.copyFile now integrates with Dir
Removed:
 * `std.fs.updateFile`
 * `std.fs.updateFileMode`
 * `std.fs.copyFile`
 * `std.fs.copyFileMode`

Added:
 * `std.fs.Dir.copyFile`
 * `std.fs.copyFileAbsolute`
 * `std.fs.updateFileAbsolute`

Moved:
 * `std.fs.Dir.UpdateFileOptions` => `std.fs.CopyFileOptions`

Deprecated:
 * `std.fs.deleteDir`
 * `std.fs.deleteDirC`
 * `std.fs.deleteDirW`
 * `std.fs.readLink`
 * `std.fs.readLinkC`
2020-03-19 14:43:41 -04:00
LemonBoy e3c92d0532 ir: More changes to sentinel-terminated const arrays
* Don't add an extra slot for the sentinel. Most of the code keeps using
  the constant value from the type descriptor, let's harmonize all the
  code dealing with sentinels.

* Properly write out sentinel values when reinterpreting pointers at
  comptime.

* Allow the reading of the 0th element in a `[0:S]T` type.
2020-03-19 09:53:30 -04:00
Andrew Kelley 7a361751e5
Merge branch 'LemonBoy-travbug'
closes #4747
2020-03-18 16:42:58 -04:00
Andrew Kelley 46ffc798b6
fix swapped logic for Windows
Remove `std.fs.deleteTree`. Callers instead should use
`std.fs.cwd().deleteTree`.

Add `std.fs.deleteTreeAbsolute` for when the caller has an absolute
path.
2020-03-18 16:42:47 -04:00
Andrew Kelley 27affde592
(breaking) clarify openDir API
* remove deprecated `std.fs.Dir` APIs
 * `std.fs.Dir.openDir` now takes a options struct with bool fields for
   `access_sub_paths` and `iterate`. It's now much more clear how
   opening directories works.
 * fixed the std lib and various zig code calling the wrong openDir
   function.
 * the runtime safety check for dir flags is removed in favor of the
   cheaper option of putting a comment on the same line as handling
   EBADF / ACCESS_DENIED, since that will show up in stack traces.
2020-03-18 16:10:57 -04:00
LemonBoy c45fe2759f
build: Fix silly bug in directory traversal 2020-03-18 13:45:52 -04:00
LemonBoy e15605e1c1
std: Safety check for iterate()
Calling iterate() on a Dir object returned by openDirTraverse is always
an error.
2020-03-18 13:45:52 -04:00
LemonBoy 4843c3b4c3
std: Introduce fnctl wrapper 2020-03-18 13:45:52 -04:00
Andrew Kelley b1537b525f
Merge branch 'LemonBoy-fix-4749'
Closes #4750
Closes #4749
2020-03-18 11:16:25 -04:00
LemonBoy 11a4ce42c1
zig fmt: Respect trailing commas in error set declarations
The logic is not perfect as it doesn't take into account the presence of
doc comments, but it's an improvement over the status quo.
2020-03-18 11:15:22 -04:00
Andrew Kelley 63a4dbc30d
array sentinel does not count towards type_has_one_possible_value 2020-03-18 11:11:41 -04:00
LemonBoy 1479c28b49
ir: Correct ABI size calculation for arrays
Zero-length array with a sentinel may not have zero size.

Closes #4749
2020-03-18 11:10:45 -04:00
LemonBoy 013ada1b59 std: More type checks for Thread startFn return type
Closes #4756
2020-03-18 10:37:35 -04:00
Andrew Kelley dbde5df568
clean up some self-hosted bitrot + don't assume libstdc++
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.
2020-03-17 23:03:45 -04:00
Jonathan Marler 7251eb1681 fix a couple sockfds to be fd_t rather than i32
Using i32 causes compile errors on Windows because it uses *c_void rather than i32 for it's fd_t type.
2020-03-17 12:46:07 -04:00
Timon Kruiper 6a15d668ee Change the default stdin behavior of RunStep to .Inherit
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`.
2020-03-16 17:23:53 -04:00
LemonBoy 582991a5a8 build: Expose function-sections switch 2020-03-16 13:06:50 -04:00
Andrew Kelley a2432b6755
Merge pull request #4735 from ziglang/renameat
zig build system: correctly handle multiple output artifacts
2020-03-15 17:28:12 -04:00
Andrew Kelley a27a8561e9
adjust renameatW to always supply dest root dir
this fixes tests for wine
2020-03-15 17:26:29 -04:00
Andrew Kelley 7e45a3ef6a fix typo in new mem.len test 2020-03-15 15:57:51 -04:00
Andrew Kelley e369789062 fix std.os.renameatW
Ask for DELETE access when opening the source file.

Additionally, when the source and dest dir are the same, pass null
for RootDirectory.
2020-03-15 15:47:42 -04:00
Andrew Kelley 6c2b23593b fix std.mem.span handling of sentinel-terminated arrays
previously this function would use the array length, but now it scans
the array looking for the first sentinel that occurs.
2020-03-15 15:46:56 -04:00
Andrew Kelley 701aaf0ddf
renameatW: handle more windows nt status codes 2020-03-15 14:46:09 -04:00
Andrew Kelley 0a69a10f2a
Merge pull request #4740 from Vexu/cleanup
Cleanup and a fix in self-hosted parser
2020-03-15 14:18:33 -04:00
momumi 880d8fc380 fix Serializer to work with new OutStream API 2020-03-15 14:17:16 -04:00
Vexu 57f9f07558
use anon literals in ast.zig and parse.zig 2020-03-15 01:11:58 +02:00
Vexu 5e5dee829d
remove .Cancel correct merge err set parsing 2020-03-15 01:02:33 +02:00
Andrew Kelley a77386eb98
for build-obj with only 1 C file, name .o file after root_out_name 2020-03-14 17:11:51 -04:00
Andrew Kelley 4a8e766ef5
fix mismatch between expected and actual output name 2020-03-14 01:26:49 -04:00
Andrew Kelley faa3c40b54
fix docgen, which relied on stdout being path to binary 2020-03-14 00:46:40 -04:00
Andrew Kelley 66d7370fac
special case when doing build-obj with just one source file
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.
2020-03-13 23:59:36 -04:00
Andrew Kelley 66e76a0209
zig build system: correctly handle multiple output artifacts
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
2020-03-13 21:22:08 -04:00
Noam Preil eb4d313dbc Fix compilation with `--no-emit-bin` 2020-03-13 15:40:29 -04:00
Andrew Kelley 3eff77bfb5
Merge branch 'fengb-format-stream' 2020-03-13 12:07:06 -04:00
Andrew Kelley 4905102901
fix all the TODOs from the pull request
* `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.
2020-03-13 12:02:58 -04:00
Andrew Kelley 2dd920ee39
Merge branch 'format-stream' of https://github.com/fengb/zig into fengb-format-stream 2020-03-13 11:31:11 -04:00
Andrew Kelley a9297f2267
Merge pull request #4716 from LemonBoy/sys-misc
Introduce std.fs.file.setEndPos
2020-03-13 11:18:08 -04:00
LemonBoy de53537f10 Add NtDll-based ftruncate implementation 2020-03-13 08:45:37 +01:00
Andrew Kelley 5dd3c8eed6
Merge pull request #4727 from nrdmn/uefi3
std/os/uefi: various improvements and some refactoring
2020-03-12 20:58:29 -04:00
Andrew Kelley 2f06971a7e
Merge pull request #4725 from ziglang/update-musl
Upgrade musl libc to 1.2.0
2020-03-12 19:56:38 -04:00
Andrew Kelley f51bec321b
Merge pull request #4707 from Vexu/small-atomics
Support atomic operations with bools and non power of two integers
2020-03-12 18:55:16 -04:00
Nick Erdmann f44530302e std/os/uefi: file protocol improvements 2020-03-12 23:23:21 +01:00
Nick Erdmann 92beb13914 std/os/uefi: status reform 2020-03-12 23:23:12 +01:00
Nick Erdmann 6c368b9e73 std/os/uefi: device path protocol improvements 2020-03-12 23:23:02 +01:00
Nick Erdmann 9f475dae14 std/os/uefi: Add shell parameters protocol 2020-03-12 23:22:49 +01:00
Nick Erdmann 52eb4129de std/os/uefi: loaded image protocol improvements 2020-03-12 23:22:08 +01:00
Nick Erdmann e617e8a798 std/os/uefi: require guid output function be comptime 2020-03-12 23:22:08 +01:00
Nick Erdmann 7c12f93734 std/os/uefi: boot services and runtime services improvements
- Several function signatures added
- Add getNextVariableName sentinel termination annotation
2020-03-12 23:22:08 +01:00
Andrew Kelley 6e25ac2a2b
stage1: update musl libc building code for v1.2.0 2020-03-12 17:45:55 -04:00
Andrew Kelley edd6643a26
update musl src files to v1.2.0 2020-03-12 17:17:57 -04:00