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