@@ -32,6 +32,8 @@ class Extra:
3232 "true if needing to link against sqlite3.c"
3333 lib_sqlite_stdio : bool = False
3434 "true if needing sqlite3_stdio"
35+ lib_zlib : bool = False
36+ "true if needing zlib - we statically link in"
3537 sources : list [str ] = dataclasses .field (default_factory = list [str ])
3638 "list of files making source for this extra relative to sqlite3 directory"
3739 type : Literal ["extension" ] | Literal ["executable" ] = "extension"
@@ -91,6 +93,11 @@ def __post_init__(self):
9193 description = "A virtual table that returns suggested completions for a partial SQL input" ,
9294 doc = "completion.html" ,
9395 ),
96+ Extra (
97+ name = "compress" ,
98+ description = "SQL compression functions" ,
99+ lib_zlib = True ,
100+ ),
94101 Extra (
95102 name = "csv" ,
96103 description = "A virtual table for reading CSV files" ,
@@ -199,6 +206,11 @@ def __post_init__(self):
199206 ),
200207 # vtshim: not useful
201208 # wholenumber: use generate_series
209+ Extra (
210+ name = "zipfile" ,
211+ doc = "zipfile.html" ,
212+ description = "Read/Write access to simple archives" ,
213+ ),
202214 # zipfile: requires libz
203215 Extra (
204216 name = "zorder" ,
@@ -302,7 +314,7 @@ def __post_init__(self):
302314 lib_sqlite = True ,
303315 # work around sqlite's mistaken handling of utf8 on windows. it should be
304316 # using manifest but instead only has a hacky main thing going on
305- defines = [("main" , "main" )]
317+ defines = [("main" , "main" )],
306318 ),
307319 Extra (
308320 name = "sqlite3_showdb" ,
@@ -348,6 +360,14 @@ def __post_init__(self):
348360 sources = ["tool/showwal.c" ],
349361 description = "Shows low level content of a WAL file" ,
350362 ),
363+ Extra (
364+ name = "sqlar" ,
365+ type = "executable" ,
366+ sources = ["sqlar/sqlar.c" ],
367+ doc = "sqlar/" ,
368+ description = "Command line SQL archive tool" ,
369+ lib_sqlite = True ,
370+ ),
351371]
352372
353373import os
@@ -436,7 +456,7 @@ def make_windows_resource(manifest_filename: str | None, **fields):
436456"""
437457
438458
439- def resource_file (build_dir , compiler , extra : Extra ):
459+ def resource_file (build_dir , compiler , extra : Extra ) -> str :
440460 if compiler .compiler_type == "msvc" :
441461 if extra .type == "executable" :
442462 with open (build_dir / "utf8_manifest" , "wt" ) as mf :
@@ -493,18 +513,21 @@ def exc_type(exc: Exception) -> str:
493513 raise
494514 return type (exc ).__name__
495515
516+
496517@dataclasses .dataclass
497518class CompilerImplementation :
498519 """What is the actual compiler
499520
500521 Sometimes call we know is it is cc so the implementation
501522 details are determined by compile_check"""
523+
502524 name : Literal ["gcc" ] | Literal ["clang" ] | Literal ["msvc" ] | Literal ["unknown" ]
503525 version : str
504526 "random text"
505527 misc : set [str ]
506528 "the various other things"
507529
530+
508531def do_build (what : set [str ], verbose : bool , fail_fast : bool = False ):
509532 get_version ()
510533 compiler = ccompiler .new_compiler (verbose = True )
@@ -539,7 +562,7 @@ def do_build(what: set[str], verbose: bool, fail_fast: bool = False):
539562 objs = compiler .compile ([compile_check_name ], output_dir = str (build_dir ))
540563 compiler .link_executable (objs , "compile_check" , output_dir = str (build_dir ))
541564 out_name = f"{ build_dir } /compile_check{ compiler .exe_extension if compiler .exe_extension else '' } "
542- p = subprocess .run ([out_name ], capture_output = True , encoding = "utf8" , text = True )
565+ p = subprocess .run ([out_name ], capture_output = True , encoding = "utf8" , text = True )
543566 p .check_returncode ()
544567 info = p .stdout .splitlines ()
545568 ci = CompilerImplementation (info [0 ], info [1 ], set (info [2 :]))
@@ -609,18 +632,33 @@ def do_build(what: set[str], verbose: bool, fail_fast: bool = False):
609632 lib_enables = "CARRAY COLUMN_METADATA DBPAGE_VTAB DBSTAT_VTAB FTS4 FTS5 GEOPOLY MATH_FUNCTIONS PERCENTILE PREUPDATE_HOOK RTREE SESSION STAT4" .split ()
610633
611634 macros = [(f"SQLITE_ENABLE_{ enable } " , 1 ) for enable in lib_enables ]
635+
636+ # add in others
637+ macros .extend (
638+ [
639+ ("SQLITE_CONFIG_URI" , 1 ),
640+ ("SQLITE_THREADSAFE" , 1 ),
641+ ]
642+ )
643+
612644 cfg = pathlib .Path ("sqlite3" ) / "sqlite_cfg.h"
613645 if cfg .exists ():
614646 macros .append (("_HAVE_SQLITE_CONFIG_H" , 1 ))
615- macros .append (("SQLITE_THREADSAFE" , 1 ))
647+
648+ # we need a subset of zlib source files
649+ zlib_sources = [
650+ str (pathlib .Path ("sqlite3/zlib" ) / f"{ name } .c" )
651+ for name in "adler32 crc32 deflate inflate inffast inftrees zutil trees compress uncompr" .split ()
652+ ]
653+
616654 if compiler .compiler_type == "msvc" :
617655 macros .append (("SQLITE_API" , "__declspec(dllexport)" ))
618656 try :
619657 lib_resource = resource_file (
620658 build_dir , compiler , Extra (name = "libsqlite3" , description = "SQLite 3 library" , doc = "" )
621659 )
622660 lib_objs = compiler .compile (
623- [str (pathlib .Path ("sqlite3" ) / "sqlite3.c" ), lib_resource ],
661+ [str (pathlib .Path ("sqlite3" ) / "sqlite3.c" ), lib_resource ] + zlib_sources ,
624662 output_dir = str (build_dir ),
625663 macros = macros ,
626664 extra_preargs = compile_extra_preargs ,
0 commit comments