@@ -51,8 +51,8 @@ pub const LinkObject = union(enum) {
51
51
other_step : * Step.Compile ,
52
52
system_lib : SystemLib ,
53
53
assembly_file : LazyPath ,
54
- foreign_source_file : * ForeignSourceFile ,
55
- foreign_source_files : * ForeignSourceFiles ,
54
+ c_source_file : * CSourceFile ,
55
+ c_source_files : * CSourceFiles ,
56
56
win32_resource_file : * RcSourceFile ,
57
57
};
58
58
@@ -89,7 +89,7 @@ pub const ForeignSourceLanguage = enum {
89
89
find_by_file_extension ,
90
90
};
91
91
92
- pub const ForeignSourceFiles = struct {
92
+ pub const CSourceFiles = struct {
93
93
root : LazyPath ,
94
94
/// `files` is relative to `root`, which is
95
95
/// the build root by default
@@ -98,19 +98,6 @@ pub const ForeignSourceFiles = struct {
98
98
language : ForeignSourceLanguage ,
99
99
};
100
100
101
- pub const ForeignSourceFile = struct {
102
- file : LazyPath ,
103
- flags : []const []const u8 = &.{},
104
- language : ForeignSourceLanguage ,
105
-
106
- pub fn dupe (file : ForeignSourceFile , b : * std.Build ) ForeignSourceFile {
107
- return .{
108
- .file = file .file .dupe (b ),
109
- .flags = b .dupeStrings (file .flags ),
110
- .language = file .language ,
111
- };
112
- }
113
- };
114
101
pub const CSourceFile = struct {
115
102
file : LazyPath ,
116
103
flags : []const []const u8 = &.{},
@@ -317,10 +304,10 @@ fn addShallowDependencies(m: *Module, dependee: *Module) void {
317
304
.assembly_file ,
318
305
= > | lp | addLazyPathDependencies (m , dependee , lp ),
319
306
320
- .foreign_source_file = > | x | addLazyPathDependencies (m , dependee , x .file ),
307
+ .c_source_file = > | x | addLazyPathDependencies (m , dependee , x .file ),
321
308
.win32_resource_file = > | x | addLazyPathDependencies (m , dependee , x .file ),
322
309
323
- .foreign_source_files ,
310
+ .c_source_files ,
324
311
.system_lib ,
325
312
= > {},
326
313
};
@@ -507,14 +494,6 @@ pub fn linkFramework(m: *Module, name: []const u8, options: LinkFrameworkOptions
507
494
m .frameworks .put (b .allocator , b .dupe (name ), options ) catch @panic ("OOM" );
508
495
}
509
496
510
- pub const AddForeignSourceFilesOptions = struct {
511
- /// When provided, `files` are relative to `root` rather than the
512
- /// package that owns the `Compile` step.
513
- root : ? LazyPath = null ,
514
- files : []const []const u8 ,
515
- flags : []const []const u8 = &.{},
516
- language : ForeignSourceLanguage ,
517
- };
518
497
pub const AddCSourceFilesOptions = struct {
519
498
/// When provided, `files` are relative to `root` rather than the
520
499
/// package that owns the `Compile` step.
@@ -525,57 +504,39 @@ pub const AddCSourceFilesOptions = struct {
525
504
};
526
505
527
506
/// Handy when you have many non-Zig source files and want them all to have the same flags.
528
- pub fn addForeignSourceFiles (m : * Module , options : AddForeignSourceFilesOptions ) void {
507
+ pub fn addCSourceFiles (m : * Module , options : AddCSourceFilesOptions ) void {
529
508
const b = m .owner ;
530
509
const allocator = b .allocator ;
531
510
532
511
for (options .files ) | path | {
533
512
if (std .fs .path .isAbsolute (path )) {
534
513
std .debug .panic (
535
- "file paths added with 'addForeignSourceFiles ' must be relative, found absolute path '{s}'" ,
514
+ "file paths added with 'addCSourceFiles ' must be relative, found absolute path '{s}'" ,
536
515
.{path },
537
516
);
538
517
}
539
518
}
540
519
541
- const source_files = allocator .create (ForeignSourceFiles ) catch @panic ("OOM" );
542
- source_files .* = .{
520
+ const c_source_files = allocator .create (CSourceFiles ) catch @panic ("OOM" );
521
+ c_source_files .* = .{
543
522
.root = options .root orelse b .path ("" ),
544
523
.files = b .dupeStrings (options .files ),
545
524
.flags = b .dupeStrings (options .flags ),
546
525
.language = options .language ,
547
526
};
548
- m .link_objects .append (allocator , .{ .foreign_source_files = source_files }) catch @panic ("OOM" );
549
- addLazyPathDependenciesOnly (m , source_files .root );
527
+ m .link_objects .append (allocator , .{ .c_source_files = c_source_files }) catch @panic ("OOM" );
528
+ addLazyPathDependenciesOnly (m , c_source_files .root );
550
529
}
551
530
552
- /// Handy when you have many C/C++ source files and want them all to have the same flags.
553
- pub fn addCSourceFiles (m : * Module , options : AddCSourceFilesOptions ) void {
554
- addForeignSourceFiles (m , .{
555
- .root = options .root ,
556
- .files = options .files ,
557
- .flags = options .flags ,
558
- .language = options .language ,
559
- });
560
- }
561
-
562
- pub fn addForeignSourceFile (m : * Module , source : ForeignSourceFile ) void {
531
+ pub fn addCSourceFile (m : * Module , source : CSourceFile ) void {
563
532
const b = m .owner ;
564
533
const allocator = b .allocator ;
565
- const source_file = allocator .create (ForeignSourceFile ) catch @panic ("OOM" );
566
- source_file .* = source .dupe (b );
567
- m .link_objects .append (allocator , .{ .foreign_source_file = source_file }) catch @panic ("OOM" );
534
+ const c_source_file = allocator .create (CSourceFile ) catch @panic ("OOM" );
535
+ c_source_file .* = source .dupe (b );
536
+ m .link_objects .append (allocator , .{ .c_source_file = c_source_file }) catch @panic ("OOM" );
568
537
addLazyPathDependenciesOnly (m , source .file );
569
538
}
570
539
571
- pub fn addCSourceFile (m : * Module , source : CSourceFile ) void {
572
- addForeignSourceFile (m , .{
573
- .file = source .file ,
574
- .flags = source .flags ,
575
- .language = source .language ,
576
- });
577
- }
578
-
579
540
/// Resource files must have the extension `.rc`.
580
541
/// Can be called regardless of target. The .rc file will be ignored
581
542
/// if the target object format does not support embedded resources.
0 commit comments