1pub fn download_url() -> Option<String> {
3 let base = "https://filehost.perforce.com/perforce/r25.2";
5 let path = platform_path()?;
6 Some(format!("{base}/{path}"))
7}
8
9fn platform_path() -> Option<&'static str> {
11 #[cfg(all(target_os = "windows", target_arch = "x86_64"))]
12 {
13 Some("bin.ntx64/p4.exe")
14 }
15 #[cfg(all(target_os = "macos", target_arch = "aarch64"))]
16 {
17 Some("bin.macosx12arm64/p4")
18 }
19 #[cfg(all(target_os = "macos", target_arch = "x86_64"))]
20 {
21 Some("bin.macosx1015x86_64/p4")
22 }
23 #[cfg(all(
24 target_os = "linux",
25 target_arch = "x86_64",
26 any(target_env = "gnu", target_env = "musl")
27 ))]
28 {
29 Some("bin.linux26x86_64/p4")
30 }
31 #[cfg(all(
32 target_os = "linux",
33 target_arch = "aarch64",
34 any(target_env = "gnu", target_env = "musl")
35 ))]
36 {
37 Some("bin.linux26aarch64/p4")
38 }
39 #[cfg(not(any(
40 all(target_os = "windows", target_arch = "x86_64"),
41 all(target_os = "macos", target_arch = "aarch64"),
42 all(target_os = "macos", target_arch = "x86_64"),
43 all(
44 target_os = "linux",
45 target_arch = "x86_64",
46 any(target_env = "gnu", target_env = "musl")
47 ),
48 all(
49 target_os = "linux",
50 target_arch = "aarch64",
51 any(target_env = "gnu", target_env = "musl")
52 ),
53 )))]
54 {
55 None
56 }
57}
58
59pub fn binary_name() -> &'static str {
61 #[cfg(windows)]
62 {
63 "p4.exe"
64 }
65 #[cfg(not(windows))]
66 {
67 "p4"
68 }
69}
70
71pub fn default_install_dirs() -> &'static [&'static str] {
73 #[cfg(windows)]
74 {
75 &[
76 r"C:\Program Files\Perforce\p4.exe",
77 r"C:\Program Files (x86)\Perforce\p4.exe",
78 ]
79 }
80 #[cfg(target_os = "macos")]
81 {
82 &["/Applications/Perforce/p4", "/usr/local/bin/p4"]
83 }
84 #[cfg(target_os = "linux")]
85 {
86 &["/usr/local/bin/p4", "/usr/bin/p4", "/opt/perforce/bin/p4"]
87 }
88 #[cfg(not(any(windows, target_os = "macos", target_os = "linux")))]
89 {
90 &[]
91 }
92}