-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add SQLite port (sqlite3) #17297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add SQLite port (sqlite3) #17297
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6a11389
Add SQLite port (sqlite3)
tiran e47669d
Address review
tiran dbe4506
update to 3.39, address review
tiran f51d380
Use sqlite3 port in test_sqlite
tiran 04b9bf8
register port variant
tiran 27d7337
simplify test case even further
tiran 926b15a
drop suffix for single thread test case
tiran f1f330a
build sqlite3 for CI
tiran File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# Copyright 2022 The Emscripten Authors. All rights reserved. | ||
# Emscripten is available under two separate licenses, the MIT license and the | ||
# University of Illinois/NCSA Open Source License. Both these licenses can be | ||
# found in the LICENSE file. | ||
|
||
import os | ||
import shutil | ||
import logging | ||
|
||
# sqlite amalgamation download URL uses relase year and tag | ||
# 2022 and (3, 38, 5) -> '/2022/sqlite-amalgamation-3380500.zip' | ||
VERSION = (3, 39, 0) | ||
VERSION_YEAR = 2022 | ||
HASH = 'cbaf4adb3e404d9aa403b34f133c5beca5f641ae1e23f84dbb021da1fb9efdc7c56b5922eb533ae5cb6d26410ac60cb3f026085591bc83ebc1c225aed0cf37ca' | ||
|
||
deps = [] | ||
|
||
|
||
def needed(settings): | ||
return settings.USE_SQLITE3 | ||
|
||
|
||
def get_lib_name(settings): | ||
return 'libsqlite3' + ('-mt' if settings.USE_PTHREADS else '') + '.a' | ||
|
||
|
||
def get(ports, settings, shared): | ||
release = f'sqlite-amalgamation-{VERSION[0]}{VERSION[1]:02}{VERSION[2]:02}00' | ||
# TODO: Fetch the file from an emscripten-hosted mirror. | ||
ports.fetch_project('sqlite3', f'https://www.sqlite.org/{VERSION_YEAR}/{release}.zip', release, sha512hash=HASH) | ||
|
||
def create(final): | ||
logging.info('building port: libsqlite3') | ||
|
||
source_path = os.path.join(ports.get_dir(), 'sqlite3', release) | ||
dest_path = os.path.join(ports.get_build_dir(), 'sqlite3') | ||
|
||
shutil.rmtree(dest_path, ignore_errors=True) | ||
shutil.copytree(source_path, dest_path) | ||
|
||
ports.install_headers(dest_path) | ||
|
||
# flags are based on sqlite-autoconf output. | ||
# SQLITE_HAVE_ZLIB is only used by shell.c | ||
flags = [ | ||
'-DSTDC_HEADERS=1', | ||
'-DHAVE_SYS_TYPES_H=1', | ||
'-DHAVE_SYS_STAT_H=1', | ||
'-DHAVE_STDLIB_H=1', | ||
'-DHAVE_STRING_H=1', | ||
'-DHAVE_MEMORY_H=1', | ||
'-DHAVE_STRINGS_H=1', | ||
'-DHAVE_INTTYPES_H=1', | ||
'-DHAVE_STDINT_H=1', | ||
'-DHAVE_UNISTD_H=1', | ||
'-DHAVE_FDATASYNC=1', | ||
'-DHAVE_USLEEP=1', | ||
'-DHAVE_LOCALTIME_R=1', | ||
'-DHAVE_GMTIME_R=1', | ||
'-DHAVE_DECL_STRERROR_R=1', | ||
'-DHAVE_STRERROR_R=1', | ||
'-DHAVE_POSIX_FALLOCATE=1', | ||
'-DSQLITE_OMIT_LOAD_EXTENSION=1', | ||
'-DSQLITE_ENABLE_MATH_FUNCTIONS=1', | ||
'-DSQLITE_ENABLE_FTS4=1', | ||
'-DSQLITE_ENABLE_FTS5=1', | ||
'-DSQLITE_ENABLE_RTREE=1', | ||
'-DSQLITE_ENABLE_GEOPOLY=1', | ||
'-DSQLITE_OMIT_POPEN=1', | ||
] | ||
if settings.USE_PTHREADS: | ||
flags += [ | ||
'-sUSE_PTHREADS', | ||
'-DSQLITE_THREADSAFE=1', | ||
] | ||
else: | ||
flags += ['-DSQLITE_THREADSAFE=0'] | ||
|
||
ports.build_port(dest_path, final, flags=flags, exclude_files=['shell.c']) | ||
|
||
return [shared.Cache.get_lib(get_lib_name(settings), create, what='port')] | ||
|
||
|
||
def clear(ports, settings, shared): | ||
shared.Cache.erase_lib(get_lib_name(settings)) | ||
|
||
|
||
def process_args(ports): | ||
return [] | ||
|
||
|
||
def show(): | ||
return 'sqlite (USE_SQLITE3=1); public domain)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we can completely remove the
tests/third_party/sqlite/
directory now?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still used by test_benchmark test_zzz_sqlite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case we could move it under
tests/benchmark/
.(Perhaps we could also make the benchmark code us the port.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it belongs in
tests/third_party
where it is, since it is third party test code.