Skip to content

Commit f5428ba

Browse files
xihalejinzhongjia
authored andcommitted
fix: trimRight .zig for output files
1 parent 21ed859 commit f5428ba

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

build/0.11.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@ pub fn build(b: *Build) void {
3333
while (iterate.next()) |val| {
3434
if (val) |entry| {
3535
// get the entry name, entry can be file or directory
36-
const name = entry.name;
36+
const output_name = std.mem.trimRight(u8, entry.name, ".zig");
3737
if (entry.kind == .file) {
3838
// connect path
39-
const path = std.fs.path.join(b.allocator, &[_][]const u8{ relative_path, name }) catch |err| {
39+
const path = std.fs.path.join(b.allocator, &[_][]const u8{ relative_path, entry.name }) catch |err| {
4040
log.err("fmt path for examples failed, err is {}", .{err});
4141
std.os.exit(1);
4242
};
4343

4444
// build exe
4545
const exe = b.addExecutable(.{
46-
.name = name,
46+
.name = output_name,
4747
.root_source_file = .{ .path = path },
4848
.target = target,
4949
.optimize = optimize,
@@ -68,7 +68,7 @@ pub fn build(b: *Build) void {
6868
var child = ChildProcess.init(&args, b.allocator);
6969

7070
// build cwd
71-
const cwd = std.fs.path.join(b.allocator, &[_][]const u8{ full_path, name }) catch |err| {
71+
const cwd = std.fs.path.join(b.allocator, &[_][]const u8{ full_path, entry.name }) catch |err| {
7272
log.err("fmt path for examples failed, err is {}", .{err});
7373
std.os.exit(1);
7474
};

build/0.12.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ pub fn build(b: *Build) void {
3232
while (iterate.next()) |val| {
3333
if (val) |entry| {
3434
// get the entry name, entry can be file or directory
35-
const name = entry.name;
35+
const output_name = std.mem.trimRight(u8, entry.name, ".zig");
3636
if (entry.kind == .file) {
3737

3838
// connect path
39-
const path = std.fs.path.join(b.allocator, &[_][]const u8{ relative_path, name }) catch |err| {
39+
const path = std.fs.path.join(b.allocator, &[_][]const u8{ relative_path, entry.name }) catch |err| {
4040
log.err("fmt path for examples failed, err is {}", .{err});
4141
std.process.exit(1);
4242
};
4343

4444
// build exe
4545
const exe = b.addExecutable(.{
46-
.name = name,
46+
.name = output_name,
4747
.root_source_file = b.path(path),
4848
.target = target,
4949
.optimize = optimize,
@@ -70,7 +70,7 @@ pub fn build(b: *Build) void {
7070
// build cwd
7171
const cwd = std.fs.path.join(b.allocator, &[_][]const u8{
7272
full_path,
73-
name,
73+
entry.name,
7474
}) catch |err| {
7575
log.err("fmt path for examples failed, err is {}", .{err});
7676
std.process.exit(1);

build/0.13.zig

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ pub fn build(b: *Build) void {
3232
while (iterate.next()) |val| {
3333
if (val) |entry| {
3434
// get the entry name, entry can be file or directory
35-
const name = entry.name;
35+
const output_name = std.mem.trimRight(u8, entry.name, ".zig");
3636
if (entry.kind == .file) {
3737

3838
// connect path
39-
const path = std.fs.path.join(b.allocator, &[_][]const u8{ relative_path, name }) catch |err| {
39+
const path = std.fs.path.join(b.allocator, &[_][]const u8{ relative_path, entry.name }) catch |err| {
4040
log.err("fmt path for examples failed, err is {}", .{err});
4141
std.process.exit(1);
4242
};
4343

4444
// build exe
4545
const exe = b.addExecutable(.{
46-
.name = name,
46+
.name = output_name,
4747
.root_source_file = b.path(path),
4848
.target = target,
4949
.optimize = optimize,
@@ -68,10 +68,7 @@ pub fn build(b: *Build) void {
6868
var child = ChildProcess.init(&args, b.allocator);
6969

7070
// build cwd
71-
const cwd = std.fs.path.join(b.allocator, &[_][]const u8{
72-
full_path,
73-
name,
74-
}) catch |err| {
71+
const cwd = std.fs.path.join(b.allocator, &[_][]const u8{ full_path, entry.name }) catch |err| {
7572
log.err("fmt path for examples failed, err is {}", .{err});
7673
std.process.exit(1);
7774
};

build/0.14.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ pub fn build(b: *Build) void {
3232
while (iterate.next()) |val| {
3333
if (val) |entry| {
3434
// get the entry name, entry can be file or directory
35-
const name = entry.name;
35+
const output_name = std.mem.trimRight(u8, entry.name, ".zig");
3636
if (entry.kind == .file) {
3737

3838
// connect path
39-
const path = std.fs.path.join(b.allocator, &[_][]const u8{ relative_path, name }) catch |err| {
39+
const path = std.fs.path.join(b.allocator, &[_][]const u8{ relative_path, entry.name }) catch |err| {
4040
log.err("fmt path for examples failed, err is {}", .{err});
4141
std.process.exit(1);
4242
};
4343

4444
// build exe
4545
const exe = b.addExecutable(.{
46-
.name = name,
46+
.name = output_name,
4747
.root_source_file = b.path(path),
4848
.target = target,
4949
.optimize = optimize,
@@ -70,7 +70,7 @@ pub fn build(b: *Build) void {
7070
// build cwd
7171
const cwd = std.fs.path.join(b.allocator, &[_][]const u8{
7272
full_path,
73-
name,
73+
entry.name,
7474
}) catch |err| {
7575
log.err("fmt path for examples failed, err is {}", .{err});
7676
std.process.exit(1);

0 commit comments

Comments
 (0)