116 Commits

Author SHA1 Message Date
Andrew Kelley
4a69b11e74 add license header to all std lib files
add SPDX license identifier
copyright ownership is zig contributors
2020-08-20 16:07:04 -04:00
Vincent Rischmann
b0846b6ecb builder: implement integer options 2020-08-19 17:41:43 -04:00
Andrew Kelley
f23fb3087b zig build: fix addBuildOption for []const u8 and ?[]const u8 2020-08-04 22:55:45 -07:00
Andrew Kelley
c594f8dc26 stage2 tests: support the -Denable-qemu options and friends 2020-08-04 15:32:16 -07:00
Andrew Kelley
edfede575c self-hosted: add build option for log scopes
Now you can enable a set of log scopes by passing -Dlog=<scope>
2020-08-03 21:56:21 -07:00
S0urc3C0de
5ae88e919b Add rdynamic option to build.zig 2020-08-02 17:50:06 +00:00
Sam Tebbs
0d31877444
Print } as format argument in enum build option (#5953)
Co-authored-by: Veikka Tuominen <git@vexu.eu>
Co-authored-by: Joachim Schmidt <joachim.schmidt557@outlook.com>
2020-07-31 11:37:40 +03:00
Vexu
e85fe13e44
run zig fmt on std lib and self hosted 2020-07-11 20:41:19 +03:00
Andrew Kelley
289eab9177
Merge pull request #5786 from ziglang/std-hash-map
reimplement std.HashMap
2020-07-05 21:12:20 +00:00
Andrew Kelley
632acffcbd update std lib to new hash map API 2020-07-05 21:11:42 +00:00
joachimschmidt557
0ae1157e45 std.mem.dupe is deprecated, move all references in std
Replaced all occurences of std.mem.dupe in stdlib with
Allocator.dupe/std.mem.dupeZ -> Allocator.dupeZ
2020-07-04 21:40:06 +03:00
heidezomp
672b4d5c24 zig build --help: Consistent capitalization/punctuation 2020-07-04 13:00:53 +00:00
Andrew Kelley
6938245fcc Merge remote-tracking branch 'origin/master' into zig-ast-to-zir 2020-06-22 23:22:17 -04:00
Andrew Kelley
c9a0ec25e0 self-hosted: add Tracy integration
This tool helps give an intuitive picture of performance. This will help
us understand where to improve the code.
2020-06-18 21:55:37 -04:00
Vexu
caaa26c9f0 reference emit_raw in std lib tests 2020-06-18 20:17:53 -04:00
Alexandros Naskos
65d827183b Added custom build step id, made tests.zig steps use it 2020-05-25 11:36:12 +03:00
Alexandros Naskos
d268e0cf2e Added and id and a cast function to build steps 2020-05-25 11:20:31 +03:00
Jakub Konka
3d267bab71 Re-enable refAllDecls gen and check in std.zig 2020-05-18 21:05:29 +02:00
Jakub Konka
d43c08a3e5 Add/fix missing WASI functionality to pass libstd tests
This rather large commit adds/fixes missing WASI functionality
in `libstd` needed to pass the `libstd` tests. As such, now by
default tests targeting `wasm32-wasi` target are enabled in
`test/tests.zig` module. However, they can be disabled by passing
the `-Dskip-wasi=true` flag when invoking the `zig build test`
command. When the flag is set to `false`, i.e., when WASI tests are
included, `wasmtime` with `--dir=.` is used as the default testing
command.

Since the majority of `libstd` tests were relying on `fs.cwd()`
call to get current working directory handle wrapped in `Dir`
struct, in order to make the tests WASI-friendly, `fs.cwd()`
call was replaced with `testing.getTestDir()` function which
resolved to either `fs.cwd()` for non-WASI targets, or tries to
fetch the preopen list from the WASI runtime and extract a
preopen for '.' path.

The summary of changes introduced by this commit:
* implement `Dir.makeDir` and `Dir.openDir` targeting WASI
* implement `Dir.deleteFile` and `Dir.deleteDir` targeting WASI
* fix `os.close` and map errors in `unlinkat`
* move WASI-specific `mkdirat` and `unlinkat` from `std.fs.wasi`
  to `std.os` module
* implement `lseek_{SET, CUR, END}` targeting WASI
* implement `futimens` targeting WASI
* implement `ftruncate` targeting WASI
* implement `readv`, `writev`, `pread{v}`, `pwrite{v}` targeting WASI
* make sure ANSI escape codes are _not_ used in stderr or stdout
  in WASI, as WASI always sanitizes stderr, and sanitizes stdout if
  fd is a TTY
* fix specifying WASI rights when opening/creating files/dirs
* tweak `AtomicFile` to be WASI-compatible
* implement `os.renameatWasi` for WASI-compliant `os.renameat` function
* implement sleep() targeting WASI
* fix `process.getEnvMap` targeting WASI
2020-05-18 16:09:49 +02:00
Andrew Kelley
f2ceb023f4
Merge pull request #5217 from wozeparrot/master
build.zig recursive dep support
2020-05-16 14:24:51 -04:00
DrDeano
72b72faa0b
Add Enum Option 2020-05-16 15:36:18 +01:00
DrDeano
b2cb8beed9
Add enum to addBuildOptions 2020-05-16 15:35:42 +01:00
Vexu
d4d509090b
make std.build.getInstallPath public
Closes  #5299
2020-05-09 00:31:11 +03:00
Josh Junon
b6dc7fc9ff
publicize member functions affected by #4909 2020-05-08 14:26:28 +03:00
Andrew Kelley
6f3d76f61e simplify test-evented-io build setting 2020-05-05 15:18:04 -04:00
Haze Booth
a39cb034ea Add setUseTestEventedIO for test steps in build.zig 2020-05-05 15:16:54 -04:00
wozeparrot
9d79f39844 switch anyerror to OutOfMemory 2020-04-30 12:14:17 -04:00
wozeparrot
bfb40972a9 build.zig recursive dep support 2020-04-29 12:54:06 -04:00
wozeparrot
01605a7742 add missing const to pkg dependencies 2020-04-27 18:29:55 -04:00
LemonBoy
a4b1242f0a build: Create the output directory if it doesn't exist
Fixes #5054
2020-04-17 05:12:42 -04:00
xackus
7a28c644aa new ArrayList API: fix everything else 2020-04-02 16:12:08 +02:00
Andrew Kelley
553f0e0546
fixups and revert a few things 2020-04-01 11:56:39 -04:00
daurnimator
ecbc235403
std: use std.ArrayList(u8) instead of std.Buffer in std/build.zig 2020-04-01 10:36:38 -04:00
Andrew Kelley
9e7ae06249
std lib API deprecations for the upcoming 0.6.0 release
See #3811
2020-03-30 14:23:22 -04:00
dbandstra
a8fa1ecd89 fix build.zig addBuildOption function for stream refactor 2020-03-21 23:18:09 -04:00
Andrew Kelley
3a2c490889 "generate .h files" feature is no longer supported in stage1 2020-03-20 18:33:36 -04:00
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
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
582991a5a8 build: Expose function-sections switch 2020-03-16 13:06:50 -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
Andrew Kelley
2bff0dda79
fix regressions found by test suite 2020-03-10 20:22:30 -04:00
daurnimator
8f627593eb
Use in_stream.readAllAlloc where sensible 2020-03-06 18:49:12 -05:00
daurnimator
1ca5f06762
Update callers of fs.makePath 2020-03-03 13:25:43 -05:00
xackus
00be934569 short std.builtin enum literals in std lib 2020-03-01 13:57:41 -05:00
Andrew Kelley
500dde32d5
dynamic_linker becomes a field of std.zig.CrossTarget 2020-02-28 14:51:56 -05:00
Andrew Kelley
6226726571
fix builder.findProgram test 2020-02-28 14:51:55 -05:00
Andrew Kelley
0912484c4f
improve the "external executor" detection logic 2020-02-28 14:51:54 -05:00
Andrew Kelley
cebcacd872
fix standardTargetOptions and improve init-exe to use it 2020-02-28 14:51:54 -05:00