@@ -25,7 +25,7 @@ fn main() {
2525 let out_path = Path :: new ( & out_dir) . join ( "bindgen.rs" ) ;
2626 #[ cfg( feature = "bundled" ) ]
2727 {
28- build_bundled:: main ( & out_dir , & out_path) ;
28+ build_bundled:: main ( & out_path) ;
2929 }
3030 #[ cfg( not( feature = "bundled" ) ) ]
3131 {
@@ -35,56 +35,9 @@ fn main() {
3535
3636#[ cfg( feature = "bundled" ) ]
3737mod build_bundled {
38- use std:: {
39- collections:: { HashMap , HashSet } ,
40- path:: Path ,
41- } ;
38+ use std:: path:: Path ;
4239
43- use crate :: win_target;
44-
45- #[ derive( serde:: Deserialize ) ]
46- struct Sources {
47- cpp_files : HashSet < String > ,
48- include_dirs : HashSet < String > ,
49- }
50-
51- #[ derive( serde:: Deserialize ) ]
52- struct Manifest {
53- base : Sources ,
54-
55- #[ allow( unused) ]
56- extensions : HashMap < String , Sources > ,
57- }
58-
59- #[ allow( unused) ]
60- fn add_extension (
61- cfg : & mut cc:: Build ,
62- manifest : & Manifest ,
63- extension : & str ,
64- cpp_files : & mut HashSet < String > ,
65- include_dirs : & mut HashSet < String > ,
66- ) {
67- cpp_files. extend ( manifest. extensions . get ( extension) . unwrap ( ) . cpp_files . clone ( ) ) ;
68- include_dirs. extend ( manifest. extensions . get ( extension) . unwrap ( ) . include_dirs . clone ( ) ) ;
69- cfg. define (
70- & format ! ( "DUCKDB_EXTENSION_{}_LINKED" , extension. to_uppercase( ) ) ,
71- Some ( "1" ) ,
72- ) ;
73- }
74-
75- fn untar_archive ( out_dir : & str ) {
76- let path = "duckdb.tar.gz" ;
77-
78- let tar_gz = std:: fs:: File :: open ( path) . expect ( "archive file" ) ;
79- let tar = flate2:: read:: GzDecoder :: new ( tar_gz) ;
80- let mut archive = tar:: Archive :: new ( tar) ;
81- archive. unpack ( out_dir) . expect ( "archive" ) ;
82- }
83-
84- pub fn main ( out_dir : & str , out_path : & Path ) {
85- let lib_name = super :: lib_name ( ) ;
86-
87- untar_archive ( out_dir) ;
40+ pub fn main ( out_path : & Path ) {
8841
8942 if !cfg ! ( feature = "bundled" ) {
9043 // This is just a sanity check, the top level `main` should ensure this.
@@ -94,7 +47,7 @@ mod build_bundled {
9447 #[ cfg( feature = "buildtime_bindgen" ) ]
9548 {
9649 use super :: { bindings, HeaderLocation } ;
97- let header = HeaderLocation :: FromPath ( format ! ( "{out_dir}/{lib_name} /src/include/duckdb.h" ) ) ;
50+ let header = HeaderLocation :: FromPath ( format ! ( "duckdb /src/include/duckdb.h" ) ) ;
9851 bindings:: write_to_out_dir ( header, out_path) ;
9952 }
10053 #[ cfg( not( feature = "buildtime_bindgen" ) ) ]
@@ -103,64 +56,48 @@ mod build_bundled {
10356 fs:: copy ( "src/bindgen_bundled_version.rs" , out_path) . expect ( "Could not copy bindings to output directory" ) ;
10457 }
10558
106- let manifest_file = std:: fs:: File :: open ( format ! ( "{out_dir}/{lib_name}/manifest.json" ) ) . expect ( "manifest file" ) ;
107- let manifest: Manifest = serde_json:: from_reader ( manifest_file) . expect ( "reading manifest file" ) ;
108-
109- let mut cpp_files = HashSet :: new ( ) ;
110- let mut include_dirs = HashSet :: new ( ) ;
111-
112- cpp_files. extend ( manifest. base . cpp_files . clone ( ) ) ;
113- // otherwise clippy will remove the clone here...
114- // https://github.com/rust-lang/rust-clippy/issues/9011
115- #[ allow( clippy:: all) ]
116- include_dirs. extend ( manifest. base . include_dirs . clone ( ) ) ;
117-
118- let mut cfg = cc:: Build :: new ( ) ;
119-
120- #[ cfg( feature = "parquet" ) ]
121- add_extension ( & mut cfg, & manifest, "parquet" , & mut cpp_files, & mut include_dirs) ;
122-
123- #[ cfg( feature = "json" ) ]
124- add_extension ( & mut cfg, & manifest, "json" , & mut cpp_files, & mut include_dirs) ;
125-
126- // duckdb/tools/pythonpkg/setup.py
127- cfg. define ( "DUCKDB_EXTENSION_AUTOINSTALL_DEFAULT" , "1" ) ;
128- cfg. define ( "DUCKDB_EXTENSION_AUTOLOAD_DEFAULT" , "1" ) ;
129-
130- // Since the manifest controls the set of files, we require it to be changed to know whether
131- // to rebuild the project
132- println ! ( "cargo:rerun-if-changed={out_dir}/{lib_name}/manifest.json" ) ;
133- // Make sure to rebuild the project if tar file changed
134- println ! ( "cargo:rerun-if-changed=duckdb.tar.gz" ) ;
135-
136- cfg. include ( lib_name) ;
137- cfg. includes ( include_dirs. iter ( ) . map ( |dir| format ! ( "{out_dir}/{lib_name}/{dir}" ) ) ) ;
138-
139- for f in cpp_files. into_iter ( ) . map ( |file| format ! ( "{out_dir}/{file}" ) ) {
140- cfg. file ( f) ;
141- }
142-
143- cfg. cpp ( true )
144- . flag_if_supported ( "-std=c++11" )
145- . flag_if_supported ( "-stdlib=libc++" )
146- . flag_if_supported ( "-stdlib=libstdc++" )
147- . flag_if_supported ( "/bigobj" )
148- . warnings ( false )
149- . flag_if_supported ( "-w" ) ;
150-
151- if win_target ( ) {
152- cfg. define ( "DUCKDB_BUILD_LIBRARY" , None ) ;
153- }
154- cfg. compile ( lib_name) ;
155-
156- println ! ( "cargo:lib_dir={out_dir}" ) ;
59+ // jemalloc is not built; use the rust jemallocator crate
60+ #[ allow( unused_mut) ]
61+ let mut extensions = "parquet" . to_string ( ) ;
62+ #[ cfg( feature="autocomplete" ) ] { extensions += ";autocomplete" ; }
63+ #[ cfg( feature="httpfs" ) ] { println ! ( "cargo:rustc-link-lib=static=httpfs_extension" ) ; extensions += ";httpfs" ; }
64+ #[ cfg( feature="tpcds" ) ] { println ! ( "cargo:rustc-link-lib=static=tpcds_extension" ) ; extensions += ";tpcds" ; }
65+ #[ cfg( feature="fts" ) ] { println ! ( "cargo:rustc-link-lib=static=fts_extension" ) ; extensions += ";fts" ; }
66+ #[ cfg( feature="icu" ) ] { println ! ( "cargo:rustc-link-lib=static=icu_extension" ) ; extensions += ";icu" ; }
67+ #[ cfg( feature="json" ) ] { println ! ( "cargo:rustc-link-lib=static=json_extension" ) ; extensions += ";json" ; }
68+
69+ let dst = cmake:: Config :: new ( "duckdb" )
70+ . define ( "ENABLE_EXTENSION_AUTOLOADING" , "1" )
71+ . define ( "ENABLE_EXTENSION_AUTOINSTALL" , "1" )
72+ . define ( "BUILD_JEMALLOC" , "0" )
73+ . define ( "BUILD_EXTENSIONS" , & extensions)
74+ . define ( "BUILD_UNITTESTS" , "0" )
75+ . profile ( "Release" )
76+ . build ( ) ;
77+ println ! ( "cargo:rustc-link-search=native={}/lib" , dst. display( ) ) ;
78+ println ! ( "cargo:rustc-link-lib=static=duckdb_fastpforlib" ) ;
79+ println ! ( "cargo:rustc-link-lib=static=duckdb_fmt" ) ;
80+ println ! ( "cargo:rustc-link-lib=static=duckdb_fsst" ) ;
81+ println ! ( "cargo:rustc-link-lib=static=duckdb_hyperloglog" ) ;
82+ println ! ( "cargo:rustc-link-lib=static=duckdb_mbedtls" ) ;
83+ println ! ( "cargo:rustc-link-lib=static=duckdb_miniz" ) ;
84+ println ! ( "cargo:rustc-link-lib=static=duckdb_pg_query" ) ;
85+ println ! ( "cargo:rustc-link-lib=static=duckdb_re2" ) ;
86+ println ! ( "cargo:rustc-link-lib=static=duckdb_skiplistlib" ) ;
87+ println ! ( "cargo:rustc-link-lib=static=duckdb_static" ) ;
88+ println ! ( "cargo:rustc-link-lib=static=duckdb_utf8proc" ) ;
89+ println ! ( "cargo:rustc-link-lib=static=duckdb_yyjson" ) ;
90+ println ! ( "cargo:rustc-link-lib=static=parquet_extension" ) ;
91+
92+ println ! ( "cargo:rustc-link-lib=stdc++" ) ;
15793 }
15894}
15995
16096fn env_prefix ( ) -> & ' static str {
16197 "DUCKDB"
16298}
16399
100+ #[ allow( dead_code) ]
164101fn lib_name ( ) -> & ' static str {
165102 "duckdb"
166103}
0 commit comments