@@ -36,6 +36,8 @@ fn download_duckdb_lib_archive() -> Result<PathBuf, Box<dyn std::error::Error>>
3636 "x86_64-apple-darwin" => ( "osx" , "universal" ) ,
3737 "x86_64-unknown-linux-gnu" => ( "linux" , "amd64" ) ,
3838 "aarch64-unknown-linux-gnu" => ( "linux" , "arm64" ) ,
39+ "x86_64-pc-windows-msvc" => ( "windows" , "amd64" ) ,
40+ "aarch64-pc-windows-msvc" => ( "windows" , "arm64" ) ,
3941 _ => return Err ( format ! ( "Unsupported target: {target}" ) . into ( ) ) ,
4042 } ;
4143
@@ -71,9 +73,11 @@ fn extract_duckdb_libraries(archive_path: PathBuf) -> Result<PathBuf, Box<dyn st
7173 . ok_or ( "Invalid archive path" ) ?
7274 . to_path_buf ( ) ;
7375
74- // Check if already extracted. The archive for Linux only contains a .so library, macOS only .dylib.
76+ // Check if already extracted. The archive for Linux contains
77+ // a .so library, macOS .dylib and Windows a .dll file.
7578 if duckdb_lib_dir. join ( "libduckdb.dylib" ) . exists ( )
7679 || duckdb_lib_dir. join ( "libduckdb.so" ) . exists ( )
80+ || duckdb_lib_dir. join ( "duckdb.dll" ) . exists ( )
7781 {
7882 println ! ( "DuckDB libraries already extracted, skipping extraction" ) ;
7983 return Ok ( duckdb_lib_dir) ;
@@ -204,7 +208,7 @@ fn build_duckdb(duckdb_source_root: &Path) -> Result<PathBuf, Box<dyn std::error
204208 }
205209 fs:: create_dir_all ( & duckdb_library_dir) ?;
206210
207- // Copy .dylib and .so files (macOS and Linux ).
211+ // Copy .dylib, .so, and .dll files (macOS, Linux, and Windows ).
208212 for entry in fs:: read_dir ( build_dir. join ( "src" ) ) ? {
209213 let entry = entry?;
210214 let path = entry. path ( ) ;
@@ -233,8 +237,13 @@ fn main() {
233237 let zip_source_path = download_duckdb_source_archive ( ) . unwrap ( ) ;
234238 let extracted_source_path = extract_duckdb_source ( zip_source_path) . unwrap ( ) ;
235239 drop ( fs:: remove_dir_all ( & duckdb_repo) ) ;
240+
241+ #[ cfg( unix) ]
236242 std:: os:: unix:: fs:: symlink ( & extracted_source_path, & duckdb_repo) . unwrap ( ) ;
237243
244+ #[ cfg( windows) ]
245+ std:: os:: windows:: fs:: symlink_dir ( & extracted_source_path, & duckdb_repo) . unwrap ( ) ;
246+
238247 let library_path =
239248 // DuckDB debug build is linked in case of `VX_DUCKDB_DEBUG=1`.
240249 if env:: var ( "VX_DUCKDB_DEBUG" ) . is_ok_and ( |v| matches ! ( v. as_str( ) , "1" | "true" ) ) {
@@ -293,6 +302,8 @@ fn main() {
293302 println ! ( "cargo:rerun-if-env-changed=VX_DUCKDB_SAN" ) ;
294303 println ! ( "cargo:rustc-link-search=native={}" , library_path. display( ) ) ;
295304 println ! ( "cargo:rustc-link-lib=dylib=duckdb" ) ;
305+
306+ #[ cfg( unix) ]
296307 println ! ( "cargo:rustc-link-arg=-Wl,-rpath,{}" , library_path. display( ) ) ;
297308
298309 // Compile our C++ code that exposes additional DuckDB functionality.
0 commit comments