mirror of
https://github.com/ziglang/zig.git
synced 2026-02-19 07:48:31 +00:00
stage2: proper file extension stripping
Previously it used mem.split on "." and took the first iterated item. Now it uses fs.path.extension and strips off that number of bytes. Closes #7404
This commit is contained in:
parent
52bc1442d6
commit
6ab5bebed1
@ -1762,7 +1762,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_comp_progress_node: *
|
||||
const o_basename_noext = if (direct_o)
|
||||
comp.bin_file.options.root_name
|
||||
else
|
||||
mem.split(c_source_basename, ".").next().?;
|
||||
c_source_basename[0 .. c_source_basename.len - std.fs.path.extension(c_source_basename).len];
|
||||
const o_basename = try std.fmt.allocPrint(arena, "{s}{s}", .{ o_basename_noext, comp.getTarget().oFileExt() });
|
||||
|
||||
const digest = if (!comp.disable_c_depfile and try man.hit()) man.final() else blk: {
|
||||
@ -2731,7 +2731,7 @@ fn buildOutputFromZig(
|
||||
},
|
||||
.root_src_path = src_basename,
|
||||
};
|
||||
const root_name = mem.split(src_basename, ".").next().?;
|
||||
const root_name = src_basename[0 .. src_basename.len - std.fs.path.extension(src_basename).len];
|
||||
const target = comp.getTarget();
|
||||
const fixed_output_mode = if (target.cpu.arch.isWasm()) .Obj else output_mode;
|
||||
const bin_basename = try std.zig.binNameAlloc(comp.gpa, .{
|
||||
|
||||
@ -1339,16 +1339,16 @@ fn buildOutputType(
|
||||
break :blk "test";
|
||||
} else if (root_src_file) |file| {
|
||||
const basename = fs.path.basename(file);
|
||||
break :blk mem.split(basename, ".").next().?;
|
||||
break :blk basename[0 .. basename.len - fs.path.extension(basename).len];
|
||||
} else if (c_source_files.items.len >= 1) {
|
||||
const basename = fs.path.basename(c_source_files.items[0].src_path);
|
||||
break :blk mem.split(basename, ".").next().?;
|
||||
break :blk basename[0 .. basename.len - fs.path.extension(basename).len];
|
||||
} else if (link_objects.items.len >= 1) {
|
||||
const basename = fs.path.basename(link_objects.items[0]);
|
||||
break :blk mem.split(basename, ".").next().?;
|
||||
break :blk basename[0 .. basename.len - fs.path.extension(basename).len];
|
||||
} else if (emit_bin == .yes) {
|
||||
const basename = fs.path.basename(emit_bin.yes);
|
||||
break :blk mem.split(basename, ".").next().?;
|
||||
break :blk basename[0 .. basename.len - fs.path.extension(basename).len];
|
||||
} else if (show_builtin) {
|
||||
break :blk "builtin";
|
||||
} else if (arg_mode == .run) {
|
||||
|
||||
@ -140,7 +140,7 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile) !void {
|
||||
|
||||
const dirname = path.dirname(src_file).?;
|
||||
const basename = path.basename(src_file);
|
||||
const noextbasename = mem.split(basename, ".").next().?;
|
||||
const noextbasename = basename[0 .. basename.len - std.fs.path.extension(basename).len];
|
||||
const before_arch_dir = path.dirname(dirname).?;
|
||||
const dirbasename = path.basename(dirname);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user