@@ -38,11 +38,11 @@ impl flags::Dist {
38
38
// A hack to make VS Code prefer nightly over stable.
39
39
format ! ( "{VERSION_NIGHTLY}.{patch_version}" )
40
40
} ;
41
- dist_server ( sh, & format ! ( "{version}-standalone" ) , & target, allocator) ?;
41
+ dist_server ( sh, & format ! ( "{version}-standalone" ) , & target, allocator, self . zig ) ?;
42
42
let release_tag = if stable { date_iso ( sh) ? } else { "nightly" . to_owned ( ) } ;
43
43
dist_client ( sh, & version, & release_tag, & target) ?;
44
44
} else {
45
- dist_server ( sh, "0.0.0-standalone" , & target, allocator) ?;
45
+ dist_server ( sh, "0.0.0-standalone" , & target, allocator, self . zig ) ?;
46
46
}
47
47
Ok ( ( ) )
48
48
}
@@ -83,6 +83,7 @@ fn dist_server(
83
83
release : & str ,
84
84
target : & Target ,
85
85
allocator : Malloc ,
86
+ zig : bool ,
86
87
) -> anyhow:: Result < ( ) > {
87
88
let _e = sh. push_env ( "CFG_RELEASE" , release) ;
88
89
let _e = sh. push_env ( "CARGO_PROFILE_RELEASE_LTO" , "thin" ) ;
@@ -92,13 +93,14 @@ fn dist_server(
92
93
// * on Linux, this blows up the binary size from 8MB to 43MB, which is unreasonable.
93
94
// let _e = sh.push_env("CARGO_PROFILE_RELEASE_DEBUG", "1");
94
95
95
- if target. name . contains ( "-linux-" ) {
96
- env :: set_var ( "CC" , "clang" ) ;
97
- }
98
-
99
- let target_name = & target . name ;
96
+ let linux_target = target. is_linux ( ) ;
97
+ let target_name = match & target . libc_suffix {
98
+ Some ( libc_suffix ) if zig => format ! ( "{}.{libc_suffix}" , target . name ) ,
99
+ _ => target . name . to_owned ( ) ,
100
+ } ;
100
101
let features = allocator. to_features ( ) ;
101
- cmd ! ( sh, "cargo build --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --target {target_name} {features...} --release" ) . run ( ) ?;
102
+ let command = if linux_target && zig { "zigbuild" } else { "build" } ;
103
+ cmd ! ( sh, "cargo {command} --manifest-path ./crates/rust-analyzer/Cargo.toml --bin rust-analyzer --target {target_name} {features...} --release" ) . run ( ) ?;
102
104
103
105
let dst = Path :: new ( "dist" ) . join ( & target. artifact_name ) ;
104
106
if target_name. contains ( "-windows-" ) {
@@ -156,6 +158,7 @@ fn zip(src_path: &Path, symbols_path: Option<&PathBuf>, dest_path: &Path) -> any
156
158
157
159
struct Target {
158
160
name : String ,
161
+ libc_suffix : Option < String > ,
159
162
server_path : PathBuf ,
160
163
symbols_path : Option < PathBuf > ,
161
164
artifact_name : String ,
@@ -177,6 +180,10 @@ impl Target {
177
180
}
178
181
}
179
182
} ;
183
+ let ( name, libc_suffix) = match name. split_once ( '.' ) {
184
+ Some ( ( l, r) ) => ( l. to_owned ( ) , Some ( r. to_owned ( ) ) ) ,
185
+ None => ( name, None ) ,
186
+ } ;
180
187
let out_path = project_root. join ( "target" ) . join ( & name) . join ( "release" ) ;
181
188
let ( exe_suffix, symbols_path) = if name. contains ( "-windows-" ) {
182
189
( ".exe" . into ( ) , Some ( out_path. join ( "rust_analyzer.pdb" ) ) )
@@ -185,7 +192,11 @@ impl Target {
185
192
} ;
186
193
let server_path = out_path. join ( format ! ( "rust-analyzer{exe_suffix}" ) ) ;
187
194
let artifact_name = format ! ( "rust-analyzer-{name}{exe_suffix}" ) ;
188
- Self { name, server_path, symbols_path, artifact_name }
195
+ Self { name, libc_suffix, server_path, symbols_path, artifact_name }
196
+ }
197
+
198
+ fn is_linux ( & self ) -> bool {
199
+ self . name . contains ( "-linux-" )
189
200
}
190
201
}
191
202
0 commit comments