| ... | ... | @@ -44,7 +44,8 @@ pub const std_options: std.Options = .{ |
| 44 | 44 | |
| 45 | 45 | gpa: Allocator, |
| 46 | 46 | graph: *Graph, |
| 47 | | install_paths: InstallPaths, |
| 47 | install_paths: PrefixPaths, |
| 48 | deployed_paths: PrefixPaths, |
| 48 | 49 | scanned_config: *const ScannedConfig, |
| 49 | 50 | /// Includes an extra auto-generated placeholder Step at the end that indicates |
| 50 | 51 | /// configure must be rerun. It is done this way so that the hot path of file |
| ... | ... | @@ -95,7 +96,7 @@ const use_safe_allocator = switch (builtin.mode) { |
| 95 | 96 | .fast, .small => false, |
| 96 | 97 | }; |
| 97 | 98 | |
| 98 | | const InstallPaths = struct { |
| 99 | const PrefixPaths = struct { |
| 99 | 100 | prefix: Path, |
| 100 | 101 | lib: Path, |
| 101 | 102 | bin: Path, |
| ... | ... | @@ -692,42 +693,62 @@ pub fn main(init: process.Init.Minimal) !void { |
| 692 | 693 | }); |
| 693 | 694 | defer main_progress_node.end(); |
| 694 | 695 | |
| 695 | | const install_prefix_path: Path = if (graph.environ_map.get("DESTDIR")) |dest_dir| .{ |
| 696 | | .root_dir = .cwd(), |
| 697 | | .sub_path = try Dir.path.join(arena, &.{ dest_dir, override_install_prefix orelse "/usr" }), |
| 698 | | } else if (override_install_prefix) |cwd_relative| .{ |
| 699 | | .root_dir = .cwd(), |
| 700 | | .sub_path = cwd_relative, |
| 701 | | } else .{ |
| 702 | | .root_dir = graph.build_root_directory, |
| 703 | | .sub_path = "zig-out", |
| 696 | const deployed_paths: PrefixPaths = blk: { |
| 697 | const prefix: Path = if (override_install_prefix) |cwd_relative| .{ |
| 698 | .root_dir = .cwd(), |
| 699 | .sub_path = cwd_relative, |
| 700 | } else if (graph.environ_map.get("DESTDIR") != null) .{ |
| 701 | .root_dir = .cwd(), |
| 702 | .sub_path = "/usr", |
| 703 | } else .{ |
| 704 | .root_dir = graph.build_root_directory, |
| 705 | .sub_path = "zig-out", |
| 706 | }; |
| 707 | break :blk .{ |
| 708 | .prefix = prefix, |
| 709 | // The lib/bin/include overrides are interpreted relative to the |
| 710 | // install prefix unless absolute paths are used. |
| 711 | .lib = if (override_lib_dir) |lib_dir| |
| 712 | if (Dir.path.isAbsolute(lib_dir)) .{ |
| 713 | .root_dir = .cwd(), |
| 714 | .sub_path = lib_dir, |
| 715 | } else try prefix.join(arena, lib_dir) |
| 716 | else |
| 717 | try prefix.join(arena, "lib"), |
| 718 | .bin = if (override_bin_dir) |bin_dir| |
| 719 | if (Dir.path.isAbsolute(bin_dir)) .{ |
| 720 | .root_dir = .cwd(), |
| 721 | .sub_path = bin_dir, |
| 722 | } else try prefix.join(arena, bin_dir) |
| 723 | else |
| 724 | try prefix.join(arena, "bin"), |
| 725 | .include = if (override_include_dir) |include_dir| |
| 726 | if (Dir.path.isAbsolute(include_dir)) .{ |
| 727 | .root_dir = .cwd(), |
| 728 | .sub_path = include_dir, |
| 729 | } else try prefix.join(arena, include_dir) |
| 730 | else |
| 731 | try prefix.join(arena, "include"), |
| 732 | }; |
| 704 | 733 | }; |
| 705 | | |
| 706 | | // These three overrides are meant to be relative to the install prefix, |
| 707 | | // not current working directory, unless absolute paths are used. |
| 708 | | const install_lib_path: Path = if (override_lib_dir) |lib_dir| |
| 709 | | if (Dir.path.isAbsolute(lib_dir)) .{ |
| 734 | const install_paths: PrefixPaths = if (graph.environ_map.get("DESTDIR")) |destdir| .{ |
| 735 | .prefix = .{ |
| 710 | 736 | .root_dir = .cwd(), |
| 711 | | .sub_path = lib_dir, |
| 712 | | } else try install_prefix_path.join(arena, lib_dir) |
| 713 | | else |
| 714 | | try install_prefix_path.join(arena, "lib"); |
| 715 | | |
| 716 | | const install_bin_path: Path = if (override_bin_dir) |bin_dir| |
| 717 | | if (Dir.path.isAbsolute(bin_dir)) .{ |
| 737 | .sub_path = try Dir.path.join(arena, &.{ destdir, deployed_paths.prefix.sub_path }), |
| 738 | }, |
| 739 | .lib = .{ |
| 718 | 740 | .root_dir = .cwd(), |
| 719 | | .sub_path = bin_dir, |
| 720 | | } else try install_prefix_path.join(arena, bin_dir) |
| 721 | | else |
| 722 | | try install_prefix_path.join(arena, "bin"); |
| 723 | | |
| 724 | | const install_include_path: Path = if (override_include_dir) |include_dir| |
| 725 | | if (Dir.path.isAbsolute(include_dir)) .{ |
| 741 | .sub_path = try Dir.path.join(arena, &.{ destdir, deployed_paths.lib.sub_path }), |
| 742 | }, |
| 743 | .bin = .{ |
| 726 | 744 | .root_dir = .cwd(), |
| 727 | | .sub_path = include_dir, |
| 728 | | } else try install_prefix_path.join(arena, include_dir) |
| 729 | | else |
| 730 | | try install_prefix_path.join(arena, "include"); |
| 745 | .sub_path = try Dir.path.join(arena, &.{ destdir, deployed_paths.bin.sub_path }), |
| 746 | }, |
| 747 | .include = .{ |
| 748 | .root_dir = .cwd(), |
| 749 | .sub_path = try Dir.path.join(arena, &.{ destdir, deployed_paths.include.sub_path }), |
| 750 | }, |
| 751 | } else deployed_paths; |
| 731 | 752 | |
| 732 | 753 | const now = Io.Clock.Timestamp.now(io, .awake); |
| 733 | 754 | |
| ... | ... | @@ -830,12 +851,8 @@ pub fn main(init: process.Init.Minimal) !void { |
| 830 | 851 | .gpa = gpa, |
| 831 | 852 | .graph = &graph, |
| 832 | 853 | .scanned_config = &scanned_config, |
| 833 | | .install_paths = .{ |
| 834 | | .prefix = install_prefix_path, |
| 835 | | .lib = install_lib_path, |
| 836 | | .bin = install_bin_path, |
| 837 | | .include = install_include_path, |
| 838 | | }, |
| 854 | .install_paths = install_paths, |
| 855 | .deployed_paths = deployed_paths, |
| 839 | 856 | |
| 840 | 857 | .steps = &.{}, |
| 841 | 858 | .generated_files = &.{}, |
| ... | ... | @@ -4099,6 +4116,10 @@ pub fn relativePath( |
| 4099 | 4116 | .install_lib => try maker.install_paths.lib.join(arena, sub_path), |
| 4100 | 4117 | .install_bin => try maker.install_paths.bin.join(arena, sub_path), |
| 4101 | 4118 | .install_include => try maker.install_paths.include.join(arena, sub_path), |
| 4119 | .deployed_prefix => try maker.deployed_paths.prefix.join(arena, sub_path), |
| 4120 | .deployed_lib => try maker.deployed_paths.lib.join(arena, sub_path), |
| 4121 | .deployed_bin => try maker.deployed_paths.bin.join(arena, sub_path), |
| 4122 | .deployed_include => try maker.deployed_paths.include.join(arena, sub_path), |
| 4102 | 4123 | .libc_runtimes => if (maker.graph.libc_runtimes_dir) |libc_runtimes_dir| .{ |
| 4103 | 4124 | .root_dir = .cwd(), |
| 4104 | 4125 | .sub_path = try Dir.path.join(arena, &.{ libc_runtimes_dir, sub_path }), |
| ... | ... | @@ -4708,6 +4729,10 @@ fn confPathDepToCachePath( |
| 4708 | 4729 | .install_lib => @panic("TODO"), |
| 4709 | 4730 | .install_bin => @panic("TODO"), |
| 4710 | 4731 | .install_include => @panic("TODO"), |
| 4732 | .deployed_prefix => @panic("TODO"), |
| 4733 | .deployed_lib => @panic("TODO"), |
| 4734 | .deployed_bin => @panic("TODO"), |
| 4735 | .deployed_include => @panic("TODO"), |
| 4711 | 4736 | .libc_runtimes => @panic("TODO"), |
| 4712 | 4737 | }; |
| 4713 | 4738 | } |