@@ -29,7 +29,7 @@ static DUCKDB_VERSION: Lazy<DuckDBVersion> = Lazy::new(|| {
2929 parse_version ( & version)
3030 } else {
3131 // The default DuckDB version to use when DUCKDB_VERSION env var is not set.
32- DuckDBVersion :: Release ( "1.4.2 " . to_owned ( ) )
32+ DuckDBVersion :: Release ( "1.5.0 " . to_owned ( ) )
3333 }
3434} ) ;
3535
@@ -275,7 +275,15 @@ fn extract_duckdb_source(source_dir: &Path) -> Result<PathBuf, Box<dyn std::erro
275275}
276276
277277/// Build DuckDB from source. Used for commit hashes or when VX_DUCKDB_DEBUG is set.
278- fn build_duckdb ( duckdb_source_dir : & Path ) -> Result < PathBuf , Box < dyn std:: error:: Error > > {
278+ fn build_duckdb (
279+ duckdb_source_dir : & Path ,
280+ version : & DuckDBVersion ,
281+ debug : bool ,
282+ ) -> Result < PathBuf , Box < dyn std:: error:: Error > > {
283+ let build_type = match debug {
284+ true => "debug" ,
285+ false => "release" ,
286+ } ;
279287 // Check for ninja
280288 if Command :: new ( "ninja" ) . arg ( "--version" ) . output ( ) . is_err ( ) {
281289 return Err (
@@ -285,10 +293,12 @@ fn build_duckdb(duckdb_source_dir: &Path) -> Result<PathBuf, Box<dyn std::error:
285293
286294 let inner_dir_name = DUCKDB_VERSION . archive_inner_dir_name ( ) ;
287295 let duckdb_repo_dir = duckdb_source_dir. join ( & inner_dir_name) ;
288- let build_dir = duckdb_repo_dir. join ( "build" ) . join ( "debug" ) ;
296+ let build_dir = duckdb_repo_dir. join ( "build" ) . join ( build_type ) ;
289297
290- // Check if already built
291298 let lib_dir = build_dir. join ( "src" ) ;
299+ let lib_dir_str = lib_dir. display ( ) ;
300+ println ! ( "cargo:info=Checking if DuckDB is already built in {lib_dir_str}" , ) ;
301+
292302 let already_built = lib_dir. join ( "libduckdb.dylib" ) . exists ( )
293303 || lib_dir. join ( "libduckdb.so" ) . exists ( )
294304 || lib_dir
@@ -309,12 +319,26 @@ fn build_duckdb(duckdb_source_dir: &Path) -> Result<PathBuf, Box<dyn std::error:
309319 ( "1" , "0" )
310320 } ;
311321
322+ let mut envs = vec ! [
323+ ( "GEN" , "ninja" ) ,
324+ ( "DISABLE_SANITIZER" , asan_option) ,
325+ ( "THREADSAN" , tsan_option) ,
326+ ( "BUILD_SHELL" , "false" ) ,
327+ ( "BUILD_UNITTESTS" , "false" ) ,
328+ ( "ENABLE_UNITTEST_CPP_TESTS" , "false" ) ,
329+ ] ;
330+
331+ // If we're building from a commit (likely a pre-release), we need to
332+ // build extensions statically. Otherwise DuckDB tries to load them
333+ // from an http endpoint with version 0.0.1 (all non-tagged builds)
334+ // which doesn't exists. httpfs also requires CURL dev headers
335+ if matches ! ( version, DuckDBVersion :: Commit ( _) ) {
336+ envs. push ( ( "BUILD_EXTENSIONS" , "httpfs;parquet;tpch;tpcds;jemalloc" ) ) ;
337+ } ;
338+
312339 let output = Command :: new ( "make" )
313340 . current_dir ( & duckdb_repo_dir)
314- . env ( "GEN" , "ninja" )
315- . env ( "DISABLE_SANITIZER" , asan_option)
316- . env ( "THREADSAN" , tsan_option)
317- . arg ( "debug" )
341+ . envs ( envs)
318342 . output ( ) ?;
319343
320344 if !output. status . success ( ) {
@@ -398,15 +422,21 @@ fn main() {
398422 drop ( fs:: remove_dir_all ( & duckdb_symlink) ) ;
399423 std:: os:: unix:: fs:: symlink ( & extracted_source_path, & duckdb_symlink) . unwrap ( ) ;
400424
401- // Determine whether to build from source or use prebuilt libraries
402425 let use_debug_build =
403426 env:: var ( "VX_DUCKDB_DEBUG" ) . is_ok_and ( |v| matches ! ( v. as_str( ) , "1" | "true" ) ) ;
427+ println ! ( "cargo:info=DuckDB debug build: {use_debug_build}" ) ;
404428
405429 let library_path = if use_debug_build || !DUCKDB_VERSION . is_release ( ) {
406430 // Build from source for:
407431 // - Commit hashes (no prebuilt available)
408432 // - When VX_DUCKDB_DEBUG=1 (user wants debug build)
409- build_duckdb ( & extracted_source_path) . unwrap ( )
433+ match build_duckdb ( & extracted_source_path, & DUCKDB_VERSION , use_debug_build) {
434+ Ok ( path) => path,
435+ Err ( err) => {
436+ println ! ( "cargo:error={err}" ) ;
437+ panic ! ( "duckdb build failed" ) ;
438+ }
439+ }
410440 } else {
411441 // Download prebuilt libraries for release versions
412442 let archive_path = download_duckdb_lib_archive ( ) . unwrap ( ) ;
@@ -494,6 +524,7 @@ fn main() {
494524 . file ( "cpp/file_system.cpp" )
495525 . file ( "cpp/logical_type.cpp" )
496526 . file ( "cpp/object_cache.cpp" )
527+ . file ( "cpp/reusable_dict.cpp" )
497528 . file ( "cpp/replacement_scan.cpp" )
498529 . file ( "cpp/scalar_function.cpp" )
499530 . file ( "cpp/table_filter.cpp" )
0 commit comments