| ... | ... | @@ -42,7 +42,8 @@ pub const std_options: std.Options = .{ |
| 42 | 42 | |
| 43 | 43 | gpa: Allocator, |
| 44 | 44 | graph: *Graph, |
| 45 | | install_paths: InstallPaths, |
| 45 | install_paths: PrefixPaths, |
| 46 | deployed_paths: PrefixPaths, |
| 46 | 47 | scanned_config: *const ScannedConfig, |
| 47 | 48 | /// Includes an extra auto-generated placeholder Step at the end that indicates |
| 48 | 49 | /// configure must be rerun. It is done this way so that the hot path of file |
| ... | ... | @@ -93,7 +94,7 @@ const use_safe_allocator = switch (builtin.mode) { |
| 93 | 94 | .fast, .small => false, |
| 94 | 95 | }; |
| 95 | 96 | |
| 96 | | const InstallPaths = struct { |
| 97 | const PrefixPaths = struct { |
| 97 | 98 | prefix: Path, |
| 98 | 99 | lib: Path, |
| 99 | 100 | bin: Path, |
| ... | ... | @@ -663,42 +664,62 @@ pub fn main(init: process.Init.Minimal) !void { |
| 663 | 664 | }); |
| 664 | 665 | defer main_progress_node.end(); |
| 665 | 666 | |
| 666 | | const install_prefix_path: Path = if (graph.environ_map.get("DESTDIR")) |dest_dir| .{ |
| 667 | | .root_dir = .cwd(), |
| 668 | | .sub_path = try Dir.path.join(arena, &.{ dest_dir, override_install_prefix orelse "/usr" }), |
| 669 | | } else if (override_install_prefix) |cwd_relative| .{ |
| 670 | | .root_dir = .cwd(), |
| 671 | | .sub_path = cwd_relative, |
| 672 | | } else .{ |
| 673 | | .root_dir = graph.build_root_directory, |
| 674 | | .sub_path = "zig-out", |
| 667 | const deployed_paths: PrefixPaths = blk: { |
| 668 | const prefix: Path = if (override_install_prefix) |cwd_relative| .{ |
| 669 | .root_dir = .cwd(), |
| 670 | .sub_path = cwd_relative, |
| 671 | } else if (graph.environ_map.get("DESTDIR") != null) .{ |
| 672 | .root_dir = .cwd(), |
| 673 | .sub_path = "/usr", |
| 674 | } else .{ |
| 675 | .root_dir = graph.build_root_directory, |
| 676 | .sub_path = "zig-out", |
| 677 | }; |
| 678 | break :blk .{ |
| 679 | .prefix = prefix, |
| 680 | // The lib/bin/include overrides are interpreted relative to the |
| 681 | // install prefix unless absolute paths are used. |
| 682 | .lib = if (override_lib_dir) |lib_dir| |
| 683 | if (Dir.path.isAbsolute(lib_dir)) .{ |
| 684 | .root_dir = .cwd(), |
| 685 | .sub_path = lib_dir, |
| 686 | } else try prefix.join(arena, lib_dir) |
| 687 | else |
| 688 | try prefix.join(arena, "lib"), |
| 689 | .bin = if (override_bin_dir) |bin_dir| |
| 690 | if (Dir.path.isAbsolute(bin_dir)) .{ |
| 691 | .root_dir = .cwd(), |
| 692 | .sub_path = bin_dir, |
| 693 | } else try prefix.join(arena, bin_dir) |
| 694 | else |
| 695 | try prefix.join(arena, "bin"), |
| 696 | .include = if (override_include_dir) |include_dir| |
| 697 | if (Dir.path.isAbsolute(include_dir)) .{ |
| 698 | .root_dir = .cwd(), |
| 699 | .sub_path = include_dir, |
| 700 | } else try prefix.join(arena, include_dir) |
| 701 | else |
| 702 | try prefix.join(arena, "include"), |
| 703 | }; |
| 675 | 704 | }; |
| 676 | | |
| 677 | | // These three overrides are meant to be relative to the install prefix, |
| 678 | | // not current working directory, unless absolute paths are used. |
| 679 | | const install_lib_path: Path = if (override_lib_dir) |lib_dir| |
| 680 | | if (Dir.path.isAbsolute(lib_dir)) .{ |
| 705 | const install_paths: PrefixPaths = if (graph.environ_map.get("DESTDIR")) |destdir| .{ |
| 706 | .prefix = .{ |
| 681 | 707 | .root_dir = .cwd(), |
| 682 | | .sub_path = lib_dir, |
| 683 | | } else try install_prefix_path.join(arena, lib_dir) |
| 684 | | else |
| 685 | | try install_prefix_path.join(arena, "lib"); |
| 686 | | |
| 687 | | const install_bin_path: Path = if (override_bin_dir) |bin_dir| |
| 688 | | if (Dir.path.isAbsolute(bin_dir)) .{ |
| 708 | .sub_path = try Dir.path.join(arena, &.{ destdir, deployed_paths.prefix.sub_path }), |
| 709 | }, |
| 710 | .lib = .{ |
| 689 | 711 | .root_dir = .cwd(), |
| 690 | | .sub_path = bin_dir, |
| 691 | | } else try install_prefix_path.join(arena, bin_dir) |
| 692 | | else |
| 693 | | try install_prefix_path.join(arena, "bin"); |
| 694 | | |
| 695 | | const install_include_path: Path = if (override_include_dir) |include_dir| |
| 696 | | if (Dir.path.isAbsolute(include_dir)) .{ |
| 712 | .sub_path = try Dir.path.join(arena, &.{ destdir, deployed_paths.lib.sub_path }), |
| 713 | }, |
| 714 | .bin = .{ |
| 697 | 715 | .root_dir = .cwd(), |
| 698 | | .sub_path = include_dir, |
| 699 | | } else try install_prefix_path.join(arena, include_dir) |
| 700 | | else |
| 701 | | try install_prefix_path.join(arena, "include"); |
| 716 | .sub_path = try Dir.path.join(arena, &.{ destdir, deployed_paths.bin.sub_path }), |
| 717 | }, |
| 718 | .include = .{ |
| 719 | .root_dir = .cwd(), |
| 720 | .sub_path = try Dir.path.join(arena, &.{ destdir, deployed_paths.include.sub_path }), |
| 721 | }, |
| 722 | } else deployed_paths; |
| 702 | 723 | |
| 703 | 724 | const now = Io.Clock.Timestamp.now(io, .awake); |
| 704 | 725 | |
| ... | ... | @@ -795,12 +816,8 @@ pub fn main(init: process.Init.Minimal) !void { |
| 795 | 816 | .gpa = gpa, |
| 796 | 817 | .graph = &graph, |
| 797 | 818 | .scanned_config = &scanned_config, |
| 798 | | .install_paths = .{ |
| 799 | | .prefix = install_prefix_path, |
| 800 | | .lib = install_lib_path, |
| 801 | | .bin = install_bin_path, |
| 802 | | .include = install_include_path, |
| 803 | | }, |
| 819 | .install_paths = install_paths, |
| 820 | .deployed_paths = deployed_paths, |
| 804 | 821 | |
| 805 | 822 | .steps = &.{}, |
| 806 | 823 | .generated_files = &.{}, |
| ... | ... | @@ -3829,6 +3846,10 @@ pub fn relativePath( |
| 3829 | 3846 | .install_lib => try maker.install_paths.lib.join(arena, sub_path), |
| 3830 | 3847 | .install_bin => try maker.install_paths.bin.join(arena, sub_path), |
| 3831 | 3848 | .install_include => try maker.install_paths.include.join(arena, sub_path), |
| 3849 | .deployed_prefix => try maker.deployed_paths.prefix.join(arena, sub_path), |
| 3850 | .deployed_lib => try maker.deployed_paths.lib.join(arena, sub_path), |
| 3851 | .deployed_bin => try maker.deployed_paths.bin.join(arena, sub_path), |
| 3852 | .deployed_include => try maker.deployed_paths.include.join(arena, sub_path), |
| 3832 | 3853 | .libc_runtimes => if (maker.graph.libc_runtimes_dir) |libc_runtimes_dir| .{ |
| 3833 | 3854 | .root_dir = .cwd(), |
| 3834 | 3855 | .sub_path = try Dir.path.join(arena, &.{ libc_runtimes_dir, sub_path }), |
| ... | ... | @@ -4435,6 +4456,10 @@ fn confPathDepToCachePath( |
| 4435 | 4456 | .install_lib => @panic("TODO"), |
| 4436 | 4457 | .install_bin => @panic("TODO"), |
| 4437 | 4458 | .install_include => @panic("TODO"), |
| 4459 | .deployed_prefix => @panic("TODO"), |
| 4460 | .deployed_lib => @panic("TODO"), |
| 4461 | .deployed_bin => @panic("TODO"), |
| 4462 | .deployed_include => @panic("TODO"), |
| 4438 | 4463 | .libc_runtimes => @panic("TODO"), |
| 4439 | 4464 | }; |
| 4440 | 4465 | } |