mirror of
https://github.com/ziglang/zig.git
synced 2026-01-31 03:33:37 +00:00
CLI: fix detection of link inputs
This commit is contained in:
parent
861df93768
commit
7656903518
@ -1392,13 +1392,6 @@ pub const UnresolvedInput = union(enum) {
|
||||
/// Put exactly this string in the dynamic section, no rpath.
|
||||
dso_exact: Input.DsoExact,
|
||||
|
||||
///// Relocatable.
|
||||
//object: Input.Object,
|
||||
///// Static library.
|
||||
//archive: Input.Object,
|
||||
///// Windows resource file.
|
||||
//winres: Path,
|
||||
|
||||
pub const NameQuery = struct {
|
||||
name: []const u8,
|
||||
query: Query,
|
||||
|
||||
23
src/main.zig
23
src/main.zig
@ -2721,7 +2721,7 @@ fn buildOutputType(
|
||||
},
|
||||
}
|
||||
if (create_module.c_source_files.items.len == 0 and
|
||||
!link.anyObjectInputs(create_module.link_inputs.items) and
|
||||
!anyObjectLinkInputs(create_module.cli_link_inputs.items) and
|
||||
root_src_file == null)
|
||||
{
|
||||
// For example `zig cc` and no args should print the "no input files" message.
|
||||
@ -2763,9 +2763,13 @@ fn buildOutputType(
|
||||
if (create_module.c_source_files.items.len >= 1)
|
||||
break :b create_module.c_source_files.items[0].src_path;
|
||||
|
||||
for (create_module.link_inputs.items) |link_input| {
|
||||
if (link_input.path()) |path| break :b path.sub_path;
|
||||
}
|
||||
for (create_module.cli_link_inputs.items) |unresolved_link_input| switch (unresolved_link_input) {
|
||||
.path_query => |pq| switch (Compilation.classifyFileExt(pq.path.sub_path)) {
|
||||
.object, .static_library, .res => break :b pq.path.sub_path,
|
||||
else => continue,
|
||||
},
|
||||
else => continue,
|
||||
};
|
||||
|
||||
if (emit_bin == .yes)
|
||||
break :b emit_bin.yes;
|
||||
@ -7491,3 +7495,14 @@ fn handleModArg(
|
||||
c_source_files_owner_index.* = create_module.c_source_files.items.len;
|
||||
rc_source_files_owner_index.* = create_module.rc_source_files.items.len;
|
||||
}
|
||||
|
||||
fn anyObjectLinkInputs(link_inputs: []const link.UnresolvedInput) bool {
|
||||
for (link_inputs) |link_input| switch (link_input) {
|
||||
.path_query => |pq| switch (Compilation.classifyFileExt(pq.path.sub_path)) {
|
||||
.object, .static_library, .res => return true,
|
||||
else => continue,
|
||||
},
|
||||
else => continue,
|
||||
};
|
||||
return false;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user