| ... | ... | @@ -137,16 +137,9 @@ pub fn make( |
| 137 | 137 | const producer_index = arg.producer.value.?; |
| 138 | 138 | const producer_step = producer_index.ptr(conf); |
| 139 | 139 | const producer = producer_step.extended.get(conf.extra).compile; |
| 140 | | const root_module = producer.root_module.get(conf); |
| 141 | | const root_module_target = root_module.resolved_target.get(conf).?.result.get(conf); |
| 142 | | const os_tag = root_module_target.flags.os_tag.unwrap().?; |
| 143 | 140 | const producer_make_comp_step = maker.stepByIndex(producer_index); |
| 144 | 141 | const producer_make_comp = &producer_make_comp_step.extended.compile; |
| 145 | 142 | |
| 146 | | if (os_tag == .windows) { |
| 147 | | // On Windows we don't have rpaths so we have to add .dll search paths to PATH |
| 148 | | addPathForDynLibs(producer_index); |
| 149 | | } |
| 150 | 143 | const file_path = producer_make_comp.installed_path orelse maker.generatedPath(producer.generated_bin.value.?).*; |
| 151 | 144 | |
| 152 | 145 | argv_list.appendAssumeCapacity(try mem.concat(arena, u8, &.{ |
| ... | ... | @@ -953,7 +946,7 @@ const FuzzTestRunner = struct { |
| 953 | 946 | if (i == std.math.maxInt(u32)) return; |
| 954 | 947 | i += 1; |
| 955 | 948 | }) { |
| 956 | | const name_prefix = "f" ++ Io.Dir.path.sep_str ++ "in"; |
| 949 | const name_prefix = "f" ++ Dir.path.sep_str ++ "in"; |
| 957 | 950 | in_name = std.fmt.bufPrint(&in_name_buf, name_prefix ++ "{x}", .{i}) catch unreachable; |
| 958 | 951 | in_f = cache_root.handle.openFile(io, in_name, .{ |
| 959 | 952 | .lock = .exclusive, |
| ... | ... | @@ -990,7 +983,7 @@ const FuzzTestRunner = struct { |
| 990 | 983 | defer in_f.close(io); |
| 991 | 984 | |
| 992 | 985 | // Save it to a seperate file |
| 993 | | const crash_name = "f" ++ Io.Dir.path.sep_str ++ "crash"; |
| 986 | const crash_name = "f" ++ Dir.path.sep_str ++ "crash"; |
| 994 | 987 | const out = cache_root.handle.createFile(io, crash_name, .{ |
| 995 | 988 | .lock = .exclusive, // Multiple run steps could have found a crash at the same time |
| 996 | 989 | }) catch |e| return step.fail(maker, "failed to create file '{f}{s}': {t}", .{ |
| ... | ... | @@ -1922,7 +1915,7 @@ fn runCommand( |
| 1922 | 1915 | |
| 1923 | 1916 | if (root_target.os.tag == .windows) { |
| 1924 | 1917 | // On Windows we don't have rpaths so we have to add .dll search paths to PATH |
| 1925 | | addPathForDynLibs(producer_index); |
| 1918 | try addPathForDynLibs(maker, producer_index, environ_map, argv[0]); |
| 1926 | 1919 | } |
| 1927 | 1920 | |
| 1928 | 1921 | gpa.free(step.result_failed_command.?); |
| ... | ... | @@ -2298,14 +2291,39 @@ fn convertPathArg(run_index: Configuration.Step.Index, maker: *Maker, path: Path |
| 2298 | 2291 | return Dir.path.join(arena, &.{ ".", child_cwd_rel }); |
| 2299 | 2292 | } |
| 2300 | 2293 | |
| 2301 | | fn addPathForDynLibs(artifact: Configuration.Step.Index) void { |
| 2302 | | if (true) @panic("TODO addPathForDynLibs"); |
| 2303 | | for (artifact.getCompileDependencies(true)) |compile| { |
| 2304 | | if (compile.root_module.resolved_target.?.result.os.tag == .windows and |
| 2305 | | compile.isDynamicLibrary()) |
| 2306 | | { |
| 2307 | | @panic("TODO addPathForDynLibs"); |
| 2308 | | //addPathDir(run, Dir.path.dirname(compile.getEmittedBin().getPath2(b, step)).?); |
| 2294 | fn addPathForDynLibs( |
| 2295 | maker: *Maker, |
| 2296 | artifact: Configuration.Step.Index, |
| 2297 | environ_map: *process.Environ.Map, |
| 2298 | argv0: []const u8, |
| 2299 | ) !void { |
| 2300 | const conf = &maker.scanned_config.configuration; |
| 2301 | const graph = maker.graph; |
| 2302 | const arena = graph.arena; // TODO don't leak into process arena |
| 2303 | const use_wine = graph.enable_wine and builtin.os.tag != .windows and std.ascii.endsWithIgnoreCase(argv0, ".exe"); |
| 2304 | const path_key = if (use_wine) "WINEPATH" else "PATH"; |
| 2305 | const path_delimiter: u8 = if (builtin.os.tag == .windows or use_wine) |
| 2306 | Dir.path.delimiter_windows |
| 2307 | else |
| 2308 | Dir.path.delimiter; |
| 2309 | |
| 2310 | var module_graph: Step.Compile.ModuleGraph = .empty; |
| 2311 | const compile_deps = try Step.Compile.getCompileDependencies(arena, &module_graph, conf, artifact, true); |
| 2312 | |
| 2313 | for (compile_deps) |dep_index| { |
| 2314 | const conf_comp_step = dep_index.ptr(conf); |
| 2315 | const conf_comp = conf_comp_step.extended.get(conf.extra).compile; |
| 2316 | const root_module = conf_comp.root_module.get(conf); |
| 2317 | const target = root_module.resolved_target.get(conf).?.result.get(conf); |
| 2318 | if (target.flags.os_tag == .windows and conf_comp.isDynamicLibrary()) { |
| 2319 | const dll_path = try maker.generatedPath(conf_comp.generated_bin.value.?).toString(arena); |
| 2320 | const search_path = Dir.path.dirname(dll_path).?; |
| 2321 | if (environ_map.get(path_key)) |prev_path| { |
| 2322 | const new_path = try allocPrint(arena, "{s}{c}{s}", .{ prev_path, path_delimiter, search_path }); |
| 2323 | try environ_map.put(path_key, new_path); |
| 2324 | } else { |
| 2325 | try environ_map.put(path_key, search_path); |
| 2326 | } |
| 2309 | 2327 | } |
| 2310 | 2328 | } |
| 2311 | 2329 | } |