Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
711cc96
Refactor extensions into separate target
sbooth Jun 5, 2021
5048191
Merge branch 'main' into extension-refactor
sbooth May 24, 2024
3e49f1d
Rename class and add header
sbooth May 24, 2024
bd61218
Update header comment
sbooth May 24, 2024
e775e9a
Merge branch 'main' into extension-refactor
sbooth Jun 2, 2024
63e8a0a
Update module maps
sbooth Jun 2, 2024
1226517
Merge branch 'main' into extension-refactor
sbooth Oct 23, 2024
4bf0144
Merge branch 'main' into extension-refactor
sbooth Oct 24, 2024
9afebf0
Move percentile.c
sbooth Oct 24, 2024
1d12543
Move SQLITE_CORE define
sbooth Oct 24, 2024
caffceb
Merge branch 'main' into extension-refactor
sbooth Oct 25, 2024
4a758b4
Merge branch 'main' into extension-refactor
sbooth Jan 3, 2025
00c7d9e
Merge branch 'main' into extension-refactor
sbooth Feb 7, 2025
1af178c
Merge branch 'main' into extension-refactor
sbooth Feb 19, 2025
e5d3afe
Merge branch 'main' into extension-refactor
sbooth May 21, 2025
9509c21
Merge branch 'main' into extension-refactor
sbooth May 28, 2025
e7927b8
Update Swift 5.3 package
sbooth May 28, 2025
aa69faf
Reorder `header`
sbooth May 29, 2025
3feeaad
Reorganize extensions and add traits for each
sbooth May 30, 2025
1ce1669
Remove comment
sbooth May 30, 2025
47fc68b
Add extension targets
sbooth May 30, 2025
4f09404
Merge branch 'main' into extension-refactor
sbooth May 30, 2025
9620531
Fix copy/paste error
sbooth May 30, 2025
02fd6be
Remove -
sbooth May 30, 2025
5767432
Use plain C for CSQLiteExtensions module
sbooth May 30, 2025
9c8f913
Revert "Use plain C for CSQLiteExtensions module"
sbooth May 31, 2025
188d2aa
Merge branch 'main' into extension-refactor-2
sbooth Jun 1, 2025
9abbf31
Merge branch 'main' into extension-refactor-2
sbooth Jun 6, 2025
9c0839d
Merge branch 'main' into extension-refactor-2
sbooth Jun 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 130 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ let package = Package(
name: "CSQLite",
targets: [
"CSQLite",
"CSQLiteExtensions",
]),
],
traits: [
Expand Down Expand Up @@ -249,6 +250,35 @@ let package = Package(
name: "ENABLE_STAT4",
description: "Enables the sqlite_stat4 table"
),
// Statically linked extensions
.trait(
name: "CSQLITE_ENABLE_CARRAY_EXTENSION",
description: "Enables the statically linked carray extension"
),
.trait(
name: "CSQLITE_ENABLE_DECIMAL_EXTENSION",
description: "Enables the statically linked decimal extension"
),
.trait(
name: "CSQLITE_ENABLE_IEEE754_EXTENSION",
description: "Enables the statically linked ieee754 extension"
),
.trait(
name: "CSQLITE_ENABLE_PERCENTILE_EXTENSION",
description: "Enables the statically linked percentile extension"
),
.trait(
name: "CSQLITE_ENABLE_SERIES_EXTENSION",
description: "Enables the statically linked series extension"
),
.trait(
name: "CSQLITE_ENABLE_SHA3_EXTENSION",
description: "Enables the statically linked sha3 extension"
),
.trait(
name: "CSQLITE_ENABLE_UUID_EXTENSION",
description: "Enables the statically linked uuid extension"
),
// Default traits
.default(enabledTraits: [
"DQS_0",
Expand All @@ -270,26 +300,122 @@ let package = Package(
"ENABLE_SNAPSHOT",
"ENABLE_STMTVTAB",
"ENABLE_STAT4",
"CSQLITE_ENABLE_CARRAY_EXTENSION",
"CSQLITE_ENABLE_DECIMAL_EXTENSION",
"CSQLITE_ENABLE_IEEE754_EXTENSION",
"CSQLITE_ENABLE_PERCENTILE_EXTENSION",
"CSQLITE_ENABLE_SERIES_EXTENSION",
"CSQLITE_ENABLE_SHA3_EXTENSION",
"CSQLITE_ENABLE_UUID_EXTENSION",
]),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "CSQLite",
cSettings: compileTimeOptions + platformConfiguration + features + [
cSettings: compileTimeOptions + platformConfiguration + features,
linkerSettings: [
.linkedLibrary("m"),
]),
.target(
name: "CSQLiteExtensions",
dependencies: [
.targetItem(name: "CSQLiteCArrayExtension", condition: .when(traits: ["CSQLITE_ENABLE_CARRAY_EXTENSION"])),
.targetItem(name: "CSQLiteDecimalExtension", condition: .when(traits: ["CSQLITE_ENABLE_DECIMAL_EXTENSION"])),
.targetItem(name: "CSQLiteIEEE754Extension", condition: .when(traits: ["CSQLITE_ENABLE_IEEE754_EXTENSION"])),
.targetItem(name: "CSQLitePercentileExtension", condition: .when(traits: ["CSQLITE_ENABLE_PERCENTILE_EXTENSION"])),
.targetItem(name: "CSQLiteSeriesExtension", condition: .when(traits: ["CSQLITE_ENABLE_SERIES_EXTENSION"])),
.targetItem(name: "CSQLiteSHA3Extension", condition: .when(traits: ["CSQLITE_ENABLE_SHA3_EXTENSION"])),
.targetItem(name: "CSQLiteUUIDExtension", condition: .when(traits: ["CSQLITE_ENABLE_UUID_EXTENSION"])),
]),
.target(
name: "CSQLiteCArrayExtension",
dependencies: [
"CSQLite",
],
path: "Sources/extensions/carray",
cSettings: [
// For statically linking extensions
// https://sqlite.org/loadext.html#statically_linking_a_run_time_loadable_extension
.define("SQLITE_CORE", to: "1"),
]),
.target(
name: "CSQLiteDecimalExtension",
dependencies: [
"CSQLite",
],
linkerSettings: [
.linkedLibrary("m"),
path: "Sources/extensions/decimal",
cSettings: [
// For statically linking extensions
// https://sqlite.org/loadext.html#statically_linking_a_run_time_loadable_extension
.define("SQLITE_CORE", to: "1"),
]),
.target(
name: "CSQLiteIEEE754Extension",
dependencies: [
"CSQLite",
],
path: "Sources/extensions/ieee754",
cSettings: [
// For statically linking extensions
// https://sqlite.org/loadext.html#statically_linking_a_run_time_loadable_extension
.define("SQLITE_CORE", to: "1"),
]),
.target(
name: "CSQLitePercentileExtension",
dependencies: [
"CSQLite",
],
path: "Sources/extensions/percentile",
cSettings: [
// For statically linking extensions
// https://sqlite.org/loadext.html#statically_linking_a_run_time_loadable_extension
.define("SQLITE_CORE", to: "1"),
]),
.target(
name: "CSQLiteSeriesExtension",
dependencies: [
"CSQLite",
],
path: "Sources/extensions/series",
cSettings: [
// For statically linking extensions
// https://sqlite.org/loadext.html#statically_linking_a_run_time_loadable_extension
.define("SQLITE_CORE", to: "1"),
]),
.target(
name: "CSQLiteSHA3Extension",
dependencies: [
"CSQLite",
],
path: "Sources/extensions/sha3",
cSettings: [
// For statically linking extensions
// https://sqlite.org/loadext.html#statically_linking_a_run_time_loadable_extension
.define("SQLITE_CORE", to: "1"),
]),
.target(
name: "CSQLiteUUIDExtension",
dependencies: [
"CSQLite",
],
path: "Sources/extensions/uuid",
cSettings: [
// For statically linking extensions
// https://sqlite.org/loadext.html#statically_linking_a_run_time_loadable_extension
.define("SQLITE_CORE", to: "1"),
]),
.testTarget(
name: "CSQLiteTests",
dependencies: [
"CSQLite",
])
]),
.testTarget(
name: "CSQLiteExtensionsTests",
dependencies: [
"CSQLiteExtensions",
]),
],
cLanguageStandard: .gnu11
)
98 changes: 94 additions & 4 deletions Package@swift-5.3.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,26 +92,116 @@ let package = Package(
name: "CSQLite",
targets: [
"CSQLite",
"CSQLiteExtensions",
]),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "CSQLite",
cSettings: compileTimeOptions + platformConfiguration + features + [
cSettings: compileTimeOptions + platformConfiguration + features,
linkerSettings: [
.linkedLibrary("m"),
]),
.target(
name: "CSQLiteExtensions",
dependencies: [
"CSQLiteCArrayExtension",
"CSQLiteDecimalExtension",
"CSQLiteIEEE754Extension",
"CSQLitePercentileExtension",
"CSQLiteSeriesExtension",
"CSQLiteSHA3Extension",
"CSQLiteUUIDExtension",
]),
.target(
name: "CSQLiteCArrayExtension",
dependencies: [
"CSQLite",
],
path: "Sources/extensions/carray",
cSettings: [
// For statically linking extensions
// https://sqlite.org/loadext.html#statically_linking_a_run_time_loadable_extension
.define("SQLITE_CORE", to: "1"),
]),
.target(
name: "CSQLiteDecimalExtension",
dependencies: [
"CSQLite",
],
linkerSettings: [
.linkedLibrary("m"),
path: "Sources/extensions/decimal",
cSettings: [
// For statically linking extensions
// https://sqlite.org/loadext.html#statically_linking_a_run_time_loadable_extension
.define("SQLITE_CORE", to: "1"),
]),
.target(
name: "CSQLiteIEEE754Extension",
dependencies: [
"CSQLite",
],
path: "Sources/extensions/ieee754",
cSettings: [
// For statically linking extensions
// https://sqlite.org/loadext.html#statically_linking_a_run_time_loadable_extension
.define("SQLITE_CORE", to: "1"),
]),
.target(
name: "CSQLitePercentileExtension",
dependencies: [
"CSQLite",
],
path: "Sources/extensions/percentile",
cSettings: [
// For statically linking extensions
// https://sqlite.org/loadext.html#statically_linking_a_run_time_loadable_extension
.define("SQLITE_CORE", to: "1"),
]),
.target(
name: "CSQLiteSeriesExtension",
dependencies: [
"CSQLite",
],
path: "Sources/extensions/series",
cSettings: [
// For statically linking extensions
// https://sqlite.org/loadext.html#statically_linking_a_run_time_loadable_extension
.define("SQLITE_CORE", to: "1"),
]),
.target(
name: "CSQLiteSHA3Extension",
dependencies: [
"CSQLite",
],
path: "Sources/extensions/sha3",
cSettings: [
// For statically linking extensions
// https://sqlite.org/loadext.html#statically_linking_a_run_time_loadable_extension
.define("SQLITE_CORE", to: "1"),
]),
.target(
name: "CSQLiteUUIDExtension",
dependencies: [
"CSQLite",
],
path: "Sources/extensions/uuid",
cSettings: [
// For statically linking extensions
// https://sqlite.org/loadext.html#statically_linking_a_run_time_loadable_extension
.define("SQLITE_CORE", to: "1"),
]),
.testTarget(
name: "CSQLiteTests",
dependencies: [
"CSQLite",
])
]),
.testTarget(
name: "CSQLiteExtensionsTests",
dependencies: [
"CSQLiteExtensions",
]),
],
cLanguageStandard: .gnu11
)
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ The following traits enable commonly-used SQLite features:
> [!NOTE]
> The `ENABLE_SESSION` trait also sets the `ENABLE_PREUPDATE_HOOK` trait.

### Statically Linked Extensions

The following traits enable statically linked SQLite extensions and helper functions for automatic extension registration:

| Package Trait | Default | SQLite Extension |
| --- | :---: | --- |
| CSQLITE_ENABLE_CARRAY_EXTENSION | Y | [carray](https://sqlite.org/carray.html) |
| CSQLITE_ENABLE_DECIMAL_EXTENSION | Y | [decimal](https://sqlite.org/floatingpoint.html#the_decimal_c_extension) |
| CSQLITE_ENABLE_IEEE754_EXTENSION | Y | [ieee754](https://sqlite.org/floatingpoint.html#the_ieee754_c_extension) |
| CSQLITE_ENABLE_PERCENTILE_EXTENSION | Y | [percentile](https://www.sqlite.org/src/file/ext/misc/percentile.c) |
| CSQLITE_ENABLE_SERIES_EXTENSION | Y | [series](https://www.sqlite.org/src/file/ext/misc/series.c) |
| CSQLITE_ENABLE_SHA3_EXTENSION | Y | [sha3](https://www.sqlite.org/src/file/ext/misc/shathree.c) |
| CSQLITE_ENABLE_UUID_EXTENSION | Y | [uuid](https://www.sqlite.org/src/file/ext/misc/uuid.c) |

## License

SQLite is in the [public domain](https://sqlite.org/copyright.html).
79 changes: 0 additions & 79 deletions Sources/CSQLite/csqlite_shims.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,82 +290,3 @@ int csqlite_sqlite3_vtab_uses_all_schemas(sqlite3 *db)
{
return sqlite3_vtab_config(db, SQLITE_VTAB_USES_ALL_SCHEMAS);
}

// MARK: - Database extensions

void sqlite3_carray_init(void);
int csqlite_sqlite3_auto_extension_carray()
{
return sqlite3_auto_extension(sqlite3_carray_init);
}

int csqlite_sqlite3_cancel_auto_extension_carray()
{
return sqlite3_cancel_auto_extension(sqlite3_carray_init);
}

void sqlite3_decimal_init(void);
int csqlite_sqlite3_auto_extension_decimal()
{
return sqlite3_auto_extension(sqlite3_decimal_init);
}

int csqlite_sqlite3_cancel_auto_extension_decimal()
{
return sqlite3_cancel_auto_extension(sqlite3_decimal_init);
}

void sqlite3_ieee_init(void);
int csqlite_sqlite3_auto_extension_ieee754()
{
return sqlite3_auto_extension(sqlite3_ieee_init);
}

int csqlite_sqlite3_cancel_auto_extension_ieee754()
{
return sqlite3_cancel_auto_extension(sqlite3_ieee_init);
}

void sqlite3_percentile_init(void);
int csqlite_sqlite3_auto_extension_percentile()
{
return sqlite3_auto_extension(sqlite3_percentile_init);
}

int csqlite_sqlite3_cancel_auto_extension_percentile()
{
return sqlite3_cancel_auto_extension(sqlite3_percentile_init);
}

void sqlite3_series_init(void);
int csqlite_sqlite3_auto_extension_series()
{
return sqlite3_auto_extension(sqlite3_series_init);
}

int csqlite_sqlite3_cancel_auto_extension_series()
{
return sqlite3_cancel_auto_extension(sqlite3_series_init);
}

void sqlite3_shathree_init(void);
int csqlite_sqlite3_auto_extension_sha3()
{
return sqlite3_auto_extension(sqlite3_shathree_init);
}

int csqlite_sqlite3_cancel_auto_extension_sha3()
{
return sqlite3_cancel_auto_extension(sqlite3_shathree_init);
}

void sqlite3_uuid_init(void);
int csqlite_sqlite3_auto_extension_uuid()
{
return sqlite3_auto_extension(sqlite3_uuid_init);
}

int csqlite_sqlite3_cancel_auto_extension_uuid()
{
return sqlite3_cancel_auto_extension(sqlite3_uuid_init);
}
Loading