@@ -153,18 +153,21 @@ pub const CSourceFiles = struct {
153153 files : []const []const u8 ,
154154 lang : ? CSourceLang = null ,
155155 flags : []const []const u8 ,
156+ precompiled_header : ? LazyPath = null ,
156157};
157158
158159pub const CSourceFile = struct {
159160 file : LazyPath ,
160161 lang : ? CSourceLang = null ,
161162 flags : []const []const u8 = &.{},
163+ precompiled_header : ? LazyPath = null ,
162164
163165 pub fn dupe (file : CSourceFile , b : * std.Build ) CSourceFile {
164166 return .{
165167 .file = file .file .dupe (b ),
166168 .lang = file .lang ,
167169 .flags = b .dupeStrings (file .flags ),
170+ .precompiled_header = file .precompiled_header ,
168171 };
169172 }
170173};
@@ -557,6 +560,7 @@ pub const AddCSourceFilesOptions = struct {
557560 files : []const []const u8 ,
558561 lang : ? CSourceLang = null ,
559562 flags : []const []const u8 = &.{},
563+ precompiled_header : ? LazyPath = null ,
560564};
561565
562566/// Handy when you have many C/C++ source files and want them all to have the same flags.
@@ -579,9 +583,14 @@ pub fn addCSourceFiles(m: *Module, options: AddCSourceFilesOptions) void {
579583 .files = b .dupeStrings (options .files ),
580584 .lang = options .lang ,
581585 .flags = b .dupeStrings (options .flags ),
586+ .precompiled_header = options .precompiled_header ,
582587 };
583588 m .link_objects .append (allocator , .{ .c_source_files = c_source_files }) catch @panic ("OOM" );
584589 addLazyPathDependenciesOnly (m , c_source_files .root );
590+
591+ if (options .precompiled_header ) | pch | {
592+ addLazyPathDependenciesOnly (m , pch );
593+ }
585594}
586595
587596pub fn addCSourceFile (m : * Module , source : CSourceFile ) void {
@@ -591,6 +600,10 @@ pub fn addCSourceFile(m: *Module, source: CSourceFile) void {
591600 c_source_file .* = source .dupe (b );
592601 m .link_objects .append (allocator , .{ .c_source_file = c_source_file }) catch @panic ("OOM" );
593602 addLazyPathDependenciesOnly (m , source .file );
603+
604+ if (source .precompiled_header ) | pch | {
605+ addLazyPathDependenciesOnly (m , pch );
606+ }
594607}
595608
596609/// Resource files must have the extension `.rc`.
0 commit comments