@@ -78,21 +78,66 @@ pub const SystemLib = struct {
78
78
pub const SearchStrategy = enum { paths_first , mode_first , no_fallback };
79
79
};
80
80
81
+ /// Supported languages for "zig clang -x <lang>".
82
+ pub const CSourceLang = enum {
83
+ /// "c"
84
+ c ,
85
+ /// "c-header"
86
+ h ,
87
+ /// "c++"
88
+ cpp ,
89
+ /// "c++-header"
90
+ hpp ,
91
+ /// "objective-c"
92
+ m ,
93
+ /// "objective-c-header"
94
+ hm ,
95
+ /// "objective-c++"
96
+ mm ,
97
+ /// "objective-c++-header"
98
+ hmm ,
99
+ /// "assembler"
100
+ assembly ,
101
+ /// "assembler-with-cpp"
102
+ assembly_with_cpp ,
103
+ /// "cuda"
104
+ cu ,
105
+
106
+ pub fn getLangName (lang : @This ()) []const u8 {
107
+ return switch (lang ) {
108
+ .assembly = > "assembler" ,
109
+ .assembly_with_cpp = > "assembler-with-cpp" ,
110
+ .c = > "c" ,
111
+ .cpp = > "c++" ,
112
+ .h = > "c-header" ,
113
+ .hpp = > "c++-header" ,
114
+ .hm = > "objective-c-header" ,
115
+ .hmm = > "objective-c++-header" ,
116
+ .cu = > "cuda" ,
117
+ .m = > "objective-c" ,
118
+ .mm = > "objective-c++" ,
119
+ };
120
+ }
121
+ };
122
+
81
123
pub const CSourceFiles = struct {
82
124
dependency : ? * std.Build.Dependency ,
83
125
/// If `dependency` is not null relative to it,
84
126
/// else relative to the build root.
85
127
files : []const []const u8 ,
128
+ lang : ? CSourceLang = null ,
86
129
flags : []const []const u8 ,
87
130
};
88
131
89
132
pub const CSourceFile = struct {
90
133
file : LazyPath ,
134
+ lang : ? CSourceLang = null ,
91
135
flags : []const []const u8 = &.{},
92
136
93
137
pub fn dupe (self : CSourceFile , b : * std.Build ) CSourceFile {
94
138
return .{
95
139
.file = self .file .dupe (b ),
140
+ .lang = self .lang ,
96
141
.flags = b .dupeStrings (self .flags ),
97
142
};
98
143
}
@@ -457,6 +502,7 @@ pub const AddCSourceFilesOptions = struct {
457
502
/// package that owns the `Compile` step.
458
503
dependency : ? * std.Build.Dependency = null ,
459
504
files : []const []const u8 ,
505
+ lang : ? CSourceLang = null ,
460
506
flags : []const []const u8 = &.{},
461
507
};
462
508
@@ -468,6 +514,7 @@ pub fn addCSourceFiles(m: *Module, options: AddCSourceFilesOptions) void {
468
514
c_source_files .* = .{
469
515
.dependency = options .dependency ,
470
516
.files = b .dupeStrings (options .files ),
517
+ .lang = options .lang ,
471
518
.flags = b .dupeStrings (options .flags ),
472
519
};
473
520
m .link_objects .append (allocator , .{ .c_source_files = c_source_files }) catch @panic ("OOM" );
0 commit comments