@@ -53,40 +53,46 @@ impl TargetTriple {
53
53
}
54
54
55
55
pub fn from_component ( component : & str ) -> Result < Self > {
56
- match Component :: from_name ( component) . map ( |c| c. name ) ?. as_str ( ) {
57
- component:: FORC => {
58
- let os = match std:: env:: consts:: OS {
59
- "macos" => "darwin" ,
60
- "linux" => "linux" ,
61
- unsupported_os => bail ! ( "Unsupported os: {}" , unsupported_os) ,
62
- } ;
63
- let architecture = match std:: env:: consts:: ARCH {
64
- "aarch64" => "arm64" ,
65
- "x86_64" => "amd64" ,
66
- unsupported_arch => bail ! ( "Unsupported architecture: {}" , unsupported_arch) ,
67
- } ;
56
+ let is_bundled_with_forc = Component :: from_name ( component)
57
+ . map ( |comp| {
58
+ comp. name == component:: FORC
59
+ || Component :: from_name ( component:: FORC )
60
+ . map ( |forc| comp. tarball_prefix == forc. tarball_prefix )
61
+ . unwrap_or ( false )
62
+ } )
63
+ . unwrap_or ( false ) ;
68
64
69
- Ok ( Self ( format ! ( "{os}_{architecture}" ) ) )
70
- }
71
- _ => {
72
- let architecture = match std:: env:: consts:: ARCH {
73
- "aarch64" | "x86_64" => std:: env:: consts:: ARCH ,
74
- unsupported_arch => bail ! ( "Unsupported architecture: {}" , unsupported_arch) ,
75
- } ;
65
+ if is_bundled_with_forc {
66
+ let os = match std:: env:: consts:: OS {
67
+ "macos" => "darwin" ,
68
+ "linux" => "linux" ,
69
+ unsupported_os => bail ! ( "Unsupported os: {}" , unsupported_os) ,
70
+ } ;
71
+ let architecture = match std:: env:: consts:: ARCH {
72
+ "aarch64" => "arm64" ,
73
+ "x86_64" => "amd64" ,
74
+ unsupported_arch => bail ! ( "Unsupported architecture: {}" , unsupported_arch) ,
75
+ } ;
76
76
77
- let vendor = match std:: env:: consts:: OS {
78
- "macos" => "apple" ,
79
- _ => "unknown" ,
80
- } ;
77
+ Ok ( Self ( format ! ( "{os}_{architecture}" ) ) )
78
+ } else {
79
+ let architecture = match std:: env:: consts:: ARCH {
80
+ "aarch64" | "x86_64" => std:: env:: consts:: ARCH ,
81
+ unsupported_arch => bail ! ( "Unsupported architecture: {}" , unsupported_arch) ,
82
+ } ;
81
83
82
- let os = match std:: env:: consts:: OS {
83
- "macos" => "darwin" ,
84
- "linux" => "linux-gnu" ,
85
- unsupported_os => bail ! ( "Unsupported os: {}" , unsupported_os) ,
86
- } ;
84
+ let vendor = match std:: env:: consts:: OS {
85
+ "macos" => "apple" ,
86
+ _ => "unknown" ,
87
+ } ;
87
88
88
- Ok ( Self ( format ! ( "{architecture}-{vendor}-{os}" ) ) )
89
- }
89
+ let os = match std:: env:: consts:: OS {
90
+ "macos" => "darwin" ,
91
+ "linux" => "linux-gnu" ,
92
+ unsupported_os => bail ! ( "Unsupported os: {}" , unsupported_os) ,
93
+ } ;
94
+
95
+ Ok ( Self ( format ! ( "{architecture}-{vendor}-{os}" ) ) )
90
96
}
91
97
}
92
98
}
0 commit comments