@@ -927,6 +927,7 @@ fn buildOutputType(
927
927
var symbol_wrap_set : std .StringArrayHashMapUnmanaged (void ) = .{};
928
928
var c_source_files = std .ArrayList (Compilation .CSourceFile ).init (arena );
929
929
var rc_source_files = std .ArrayList (Compilation .RcSourceFile ).init (arena );
930
+ var res_files = std .ArrayList (Compilation .LinkObject ).init (arena );
930
931
var link_objects = std .ArrayList (Compilation .LinkObject ).init (arena );
931
932
var framework_dirs = std .ArrayList ([]const u8 ).init (arena );
932
933
var frameworks : std .StringArrayHashMapUnmanaged (Framework ) = .{};
@@ -1602,7 +1603,8 @@ fn buildOutputType(
1602
1603
}
1603
1604
} else switch (file_ext orelse
1604
1605
Compilation .classifyFileExt (arg )) {
1605
- .object , .static_library , .shared_library , .res = > try link_objects .append (.{ .path = arg }),
1606
+ .object , .static_library , .shared_library = > try link_objects .append (.{ .path = arg }),
1607
+ .res = > try res_files .append (.{ .path = arg }),
1606
1608
.assembly , .assembly_with_cpp , .c , .cpp , .h , .ll , .bc , .m , .mm , .cu = > {
1607
1609
try c_source_files .append (.{
1608
1610
.src_path = arg ,
@@ -1702,7 +1704,11 @@ fn buildOutputType(
1702
1704
.ext = file_ext , // duped while parsing the args.
1703
1705
});
1704
1706
},
1705
- .unknown , .shared_library , .object , .static_library , .res = > try link_objects .append (.{
1707
+ .unknown , .shared_library , .object , .static_library = > try link_objects .append (.{
1708
+ .path = it .only_arg ,
1709
+ .must_link = must_link ,
1710
+ }),
1711
+ .res = > try res_files .append (.{
1706
1712
.path = it .only_arg ,
1707
1713
.must_link = must_link ,
1708
1714
}),
@@ -2473,6 +2479,12 @@ fn buildOutputType(
2473
2479
} else if (emit_bin == .yes ) {
2474
2480
const basename = fs .path .basename (emit_bin .yes );
2475
2481
break :blk basename [0 .. basename .len - fs .path .extension (basename ).len ];
2482
+ } else if (rc_source_files .items .len >= 1 ) {
2483
+ const basename = fs .path .basename (rc_source_files .items [0 ].src_path );
2484
+ break :blk basename [0 .. basename .len - fs .path .extension (basename ).len ];
2485
+ } else if (res_files .items .len >= 1 ) {
2486
+ const basename = fs .path .basename (res_files .items [0 ].path );
2487
+ break :blk basename [0 .. basename .len - fs .path .extension (basename ).len ];
2476
2488
} else if (show_builtin ) {
2477
2489
break :blk "builtin" ;
2478
2490
} else if (arg_mode == .run ) {
@@ -2551,6 +2563,21 @@ fn buildOutputType(
2551
2563
link_libcpp = true ;
2552
2564
}
2553
2565
2566
+ if (target_info .target .ofmt == .coff ) {
2567
+ // Now that we know the target supports resources,
2568
+ // we can add the res files as link objects.
2569
+ for (res_files .items ) | res_file | {
2570
+ try link_objects .append (res_file );
2571
+ }
2572
+ } else {
2573
+ if (rc_source_files .items .len != 0 ) {
2574
+ fatal ("rc files are not allowed unless the target object format is coff (Windows/UEFI)" , .{});
2575
+ }
2576
+ if (res_files .items .len != 0 ) {
2577
+ fatal ("res files are not allowed unless the target object format is coff (Windows/UEFI)" , .{});
2578
+ }
2579
+ }
2580
+
2554
2581
if (target_info .target .cpu .arch .isWasm ()) blk : {
2555
2582
if (single_threaded == null ) {
2556
2583
single_threaded = true ;
0 commit comments