Commit 341857e5cd

David Rubin <daviru007@icloud.com>
2024-03-03 19:56:09
make `addCSourceFiles` assert `options.files` are relative
1 parent 055023e
Changed files (1)
lib
std
lib/std/Build/Module.zig
@@ -464,6 +464,16 @@ pub const AddCSourceFilesOptions = struct {
 pub fn addCSourceFiles(m: *Module, options: AddCSourceFilesOptions) void {
     const b = m.owner;
     const allocator = b.allocator;
+
+    for (options.files) |path| {
+        if (std.fs.path.isAbsolute(path)) {
+            std.debug.panic(
+                "file paths added with 'addCSourceFiles' must be relative, found absolute path '{s}'",
+                .{path},
+            );
+        }
+    }
+
     const c_source_files = allocator.create(CSourceFiles) catch @panic("OOM");
     c_source_files.* = .{
         .root = options.root,