first pass at zig build system

* `zig build --export [obj|lib|exe]` changed to `zig build_obj`,
   `zig build_lib` and `zig build_exe` respectively.
 * `--name` parameter is optional when it can be inferred from the
   root source filename. closes #207
 * `zig build` now looks for `build.zig` which interacts with
   `std.build.Builder` to describe the targets, and then the zig
   build system prints TODO: build these targets. See #204
 * add `@bitcast` which is mainly used for pointer reinterpret
   casting and make explicit casting not do pointer reinterpretation.
   Closes #290
 * fix debug info for byval parameters
 * sort command line help options
 * `std.debug.panic` supports format string printing
 * add `std.mem.IncrementingAllocator`
 * fix const ptr to a variable with data changing at runtime.
   closes #289
This commit is contained in:
Andrew Kelley
2017-03-31 05:48:15 -04:00
parent 536c35136a
commit 3ca027ca82
27 changed files with 477 additions and 190 deletions

View File

@@ -139,6 +139,32 @@ void os_path_split(Buf *full_path, Buf *out_dirname, Buf *out_basename) {
if (out_basename) buf_init_from_buf(out_basename, full_path);
}
void os_path_extname(Buf *full_path, Buf *out_basename, Buf *out_extname) {
if (buf_len(full_path) == 0) {
buf_init_from_str(out_basename, "");
buf_init_from_str(out_extname, "");
return;
}
size_t i = buf_len(full_path) - 1;
while (true) {
if (buf_ptr(full_path)[i] == '.') {
buf_resize(out_basename, 0);
buf_append_mem(out_basename, buf_ptr(full_path), i);
buf_resize(out_extname, 0);
buf_append_mem(out_extname, buf_ptr(full_path) + i, buf_len(full_path) - i);
return;
}
if (i == 0) {
buf_init_from_buf(out_basename, full_path);
buf_init_from_str(out_extname, "");
return;
}
i -= 1;
}
}
void os_path_join(Buf *dirname, Buf *basename, Buf *out_full_path) {
buf_init_from_buf(out_full_path, dirname);
uint8_t c = *(buf_ptr(out_full_path) + buf_len(out_full_path) - 1);