Function addPathDir [src]

Prototype

pub fn addPathDir(run: *Run, search_path: []const u8) void

Parameters

run: *Runsearch_path: []const u8

Source

pub fn addPathDir(run: *Run, search_path: []const u8) void { const b = run.step.owner; const env_map = getEnvMapInternal(run); const use_wine = b.enable_wine and b.graph.host.result.os.tag != .windows and use_wine: switch (run.argv.items[0]) { .artifact => |p| p.artifact.rootModuleTarget().os.tag == .windows, .lazy_path => |p| { switch (p.lazy_path) { .generated => |g| if (g.file.step.cast(Step.Compile)) |cs| break :use_wine cs.rootModuleTarget().os.tag == .windows, else => {}, } break :use_wine std.mem.endsWith(u8, p.lazy_path.basename(b, &run.step), ".exe"); }, .decorated_directory => false, .bytes => |bytes| std.mem.endsWith(u8, bytes, ".exe"), .output_file, .output_directory => false, }; const key = if (use_wine) "WINEPATH" else "PATH"; const prev_path = env_map.get(key); if (prev_path) |pp| { const new_path = b.fmt("{s}{c}{s}", .{ pp, if (use_wine) fs.path.delimiter_windows else fs.path.delimiter, search_path, }); env_map.put(key, new_path) catch @panic("OOM"); } else { env_map.put(key, b.dupePath(search_path)) catch @panic("OOM"); } }