| ... | ... | @@ -103,7 +103,6 @@ link_objects: ArrayList(LinkObject), |
| 103 | 103 | include_dirs: ArrayList(IncludeDir), |
| 104 | 104 | c_macros: ArrayList([]const u8), |
| 105 | 105 | installed_headers: ArrayList(*Step), |
| 106 | | output_dir: ?[]const u8, |
| 107 | 106 | is_linking_libc: bool = false, |
| 108 | 107 | is_linking_libcpp: bool = false, |
| 109 | 108 | vcpkg_bin_path: ?[]const u8 = null, |
| ... | ... | @@ -386,7 +385,6 @@ pub fn create(owner: *std.Build, options: Options) *CompileStep { |
| 386 | 385 | .disable_sanitize_c = false, |
| 387 | 386 | .sanitize_thread = false, |
| 388 | 387 | .rdynamic = false, |
| 389 | | .output_dir = null, |
| 390 | 388 | .override_dest_dir = null, |
| 391 | 389 | .installed_path = null, |
| 392 | 390 | .force_undefined_symbols = StringHashMap(void).init(owner.allocator), |
| ... | ... | @@ -450,19 +448,9 @@ fn computeOutFileNames(self: *CompileStep) void { |
| 450 | 448 | self.out_lib_filename = self.out_filename; |
| 451 | 449 | } |
| 452 | 450 | } |
| 453 | | if (self.output_dir != null) { |
| 454 | | self.output_lib_path_source.path = b.pathJoin( |
| 455 | | &.{ self.output_dir.?, self.out_lib_filename }, |
| 456 | | ); |
| 457 | | } |
| 458 | 451 | } |
| 459 | 452 | } |
| 460 | 453 | |
| 461 | | pub fn setOutputDir(self: *CompileStep, dir: []const u8) void { |
| 462 | | const b = self.step.owner; |
| 463 | | self.output_dir = b.dupePath(dir); |
| 464 | | } |
| 465 | | |
| 466 | 454 | pub fn installHeader(cs: *CompileStep, src_path: []const u8, dest_rel_path: []const u8) void { |
| 467 | 455 | const b = cs.step.owner; |
| 468 | 456 | const install_file = b.addInstallHeaderFile(src_path, dest_rel_path); |
| ... | ... | @@ -1931,54 +1919,31 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 1931 | 1919 | }, |
| 1932 | 1920 | else => |e| return e, |
| 1933 | 1921 | }; |
| 1934 | | const build_output_dir = fs.path.dirname(output_bin_path).?; |
| 1935 | | |
| 1936 | | if (self.output_dir) |output_dir| { |
| 1937 | | var src_dir = try fs.cwd().openIterableDir(build_output_dir, .{}); |
| 1938 | | defer src_dir.close(); |
| 1939 | | |
| 1940 | | // Create the output directory if it doesn't exist. |
| 1941 | | try fs.cwd().makePath(output_dir); |
| 1942 | | |
| 1943 | | var dest_dir = try fs.cwd().openDir(output_dir, .{}); |
| 1944 | | defer dest_dir.close(); |
| 1945 | | |
| 1946 | | var it = src_dir.iterate(); |
| 1947 | | while (try it.next()) |entry| { |
| 1948 | | // The compiler can put these files into the same directory, but we don't |
| 1949 | | // want to copy them over. |
| 1950 | | if (mem.eql(u8, entry.name, "llvm-ar.id") or |
| 1951 | | mem.eql(u8, entry.name, "libs.txt") or |
| 1952 | | mem.eql(u8, entry.name, "builtin.zig") or |
| 1953 | | mem.eql(u8, entry.name, "zld.id") or |
| 1954 | | mem.eql(u8, entry.name, "lld.id")) continue; |
| 1955 | | |
| 1956 | | _ = try src_dir.dir.updateFile(entry.name, dest_dir, entry.name, .{}); |
| 1957 | | } |
| 1958 | | } else { |
| 1959 | | self.output_dir = build_output_dir; |
| 1960 | | } |
| 1961 | | |
| 1962 | | // This will ensure all output filenames will now have the output_dir available! |
| 1963 | | self.computeOutFileNames(); |
| 1922 | const output_dir = fs.path.dirname(output_bin_path).?; |
| 1964 | 1923 | |
| 1965 | 1924 | // Update generated files |
| 1966 | | if (self.output_dir != null) { |
| 1967 | | self.output_dirname_source.path = self.output_dir.?; |
| 1925 | { |
| 1926 | self.output_dirname_source.path = output_dir; |
| 1968 | 1927 | |
| 1969 | 1928 | self.output_path_source.path = b.pathJoin( |
| 1970 | | &.{ self.output_dir.?, self.out_filename }, |
| 1929 | &.{ output_dir, self.out_filename }, |
| 1971 | 1930 | ); |
| 1972 | 1931 | |
| 1932 | if (self.kind == .lib) { |
| 1933 | self.output_lib_path_source.path = b.pathJoin( |
| 1934 | &.{ output_dir, self.out_lib_filename }, |
| 1935 | ); |
| 1936 | } |
| 1937 | |
| 1973 | 1938 | if (self.emit_h) { |
| 1974 | 1939 | self.output_h_path_source.path = b.pathJoin( |
| 1975 | | &.{ self.output_dir.?, self.out_h_filename }, |
| 1940 | &.{ output_dir, self.out_h_filename }, |
| 1976 | 1941 | ); |
| 1977 | 1942 | } |
| 1978 | 1943 | |
| 1979 | 1944 | if (self.target.isWindows() or self.target.isUefi()) { |
| 1980 | 1945 | self.output_pdb_path_source.path = b.pathJoin( |
| 1981 | | &.{ self.output_dir.?, self.out_pdb_filename }, |
| 1946 | &.{ output_dir, self.out_pdb_filename }, |
| 1982 | 1947 | ); |
| 1983 | 1948 | } |
| 1984 | 1949 | } |