mirror of
https://github.com/ziglang/zig.git
synced 2025-12-30 01:53:16 +00:00
* implement --debug-cc and --debug-link
* implement C source files having extra flags
- TODO a way to pass them on the CLI
* introduce the Directory abstraction which contains both an open file
descriptor and a file path name. The former is preferred but the
latter is needed when communicating paths over a command line (e.g.
to Clang or LLD).
* use the cache hash to choose an artifact directory
- TODO: use separate cache hash instances for the zig module and
each C object
* Module: introduce the crt_files table for keeping track of built libc
artifacts for linking.
* Add the ability to build 4/6 of the glibc static CRT lib files.
* The zig-cache directory is now passed as a parameter to Module.
* Implement the CLI logic of -femit-bin and -femit-h
- TODO: respect -fno-emit-bin
- TODO: the emit .h feature
* Add the -fvalgrind, -fstack-check, and --single-threaded CLI options.
* Implement the logic for auto detecting whether to enable PIC,
sanitize-C, stack-check, valgrind, and single-threaded.
* Properly add PIC args (or not) to clang argv.
* Implement renaming clang-compiled object files into their proper
place within the cache artifact directory.
- TODO: std lib needs a proper higher level abstraction for
std.os.renameat.
* Package is cleaned up to use the "Unmanaged" StringHashMap and use the
new Directory abstraction.
* Clean up zig lib directory detection to make proper use of directory
handles.
* Linker code invokes LLD.
- TODO properly deal with the stdout and stderr that we get from it
and expose diagnostics from the Module API that match the expected
error message format.
* Delete the bitrotted LLVM C ABI bindings. We'll resurrect just the
functions we need as we introduce dependencies on them. So far it
only has ZigLLDLink in it.
* Remove dead timer code.
* `zig env` now prints the path to the zig executable as well.
60 lines
1.8 KiB
Zig
60 lines
1.8 KiB
Zig
pub const Table = std.StringHashMapUnmanaged(*Package);
|
|
|
|
root_src_directory: Module.Directory,
|
|
/// Relative to `root_src_directory`.
|
|
root_src_path: []u8,
|
|
table: Table,
|
|
|
|
/// No references to `root_src_dir` and `root_src_path` are kept.
|
|
pub fn create(
|
|
gpa: *Allocator,
|
|
base_dir: std.fs.Dir,
|
|
/// Relative to `base_dir`.
|
|
root_src_dir: []const u8,
|
|
/// Relative to `root_src_dir`.
|
|
root_src_path: []const u8,
|
|
) !*Package {
|
|
const ptr = try gpa.create(Package);
|
|
errdefer gpa.destroy(ptr);
|
|
const root_src_path_dupe = try mem.dupe(gpa, u8, root_src_path);
|
|
errdefer gpa.free(root_src_path_dupe);
|
|
const root_src_dir_path = try mem.dupe(gpa, u8, root_src_dir);
|
|
errdefer gpa.free(root_src_dir_path);
|
|
ptr.* = .{
|
|
.root_src_directory = .{
|
|
.path = root_src_dir_path,
|
|
.handle = try base_dir.openDir(root_src_dir, .{}),
|
|
},
|
|
.root_src_path = root_src_path_dupe,
|
|
.table = .{},
|
|
};
|
|
return ptr;
|
|
}
|
|
|
|
pub fn destroy(pkg: *Package, gpa: *Allocator) void {
|
|
pkg.root_src_directory.handle.close();
|
|
gpa.free(pkg.root_src_path);
|
|
if (pkg.root_src_directory.path) |p| gpa.free(p);
|
|
{
|
|
var it = pkg.table.iterator();
|
|
while (it.next()) |kv| {
|
|
gpa.free(kv.key);
|
|
}
|
|
}
|
|
pkg.table.deinit(gpa);
|
|
gpa.destroy(pkg);
|
|
}
|
|
|
|
pub fn add(pkg: *Package, gpa: *Allocator, name: []const u8, package: *Package) !void {
|
|
try pkg.table.ensureCapacity(gpa, pkg.table.items().len + 1);
|
|
const name_dupe = try mem.dupe(gpa, u8, name);
|
|
pkg.table.putAssumeCapacityNoClobber(name_dupe, package);
|
|
}
|
|
|
|
const std = @import("std");
|
|
const mem = std.mem;
|
|
const Allocator = std.mem.Allocator;
|
|
const assert = std.debug.assert;
|
|
const Package = @This();
|
|
const Module = @import("Module.zig");
|