1 # Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
6 # Controls whether the build should uses the version of sqlite3 library
7 # shipped with the system (currently only supported on iOS) or the one
8 # shipped with Chromium source.
9 use_system_sqlite = is_ios
12 if (!use_system_sqlite) {
13 config("sqlite_warnings") {
16 # sqlite contains a few functions that are unused, at least on
17 # Windows with Chromium's sqlite patches applied
18 # (interiorCursorEOF fts3EvalDeferredPhrase
19 # fts3EvalSelectDeferred sqlite3Fts3InitHashTable
20 # sqlite3Fts3InitTok).
21 cflags += [ "-Wno-unused-function" ]
25 # SQLite doesn"t believe in compiler warnings,
27 # http://www.sqlite.org/faq.html#q17
28 "-Wno-int-to-pointer-cast",
29 "-Wno-pointer-to-int-cast",
34 # "sqlite3" can cause conflicts with the system library.
35 component("chromium_sqlite3") {
39 "amalgamation/sqlite3.c",
40 "amalgamation/sqlite3.h",
47 # New unicode61 tokenizer with built-in tables.
48 "SQLITE_DISABLE_FTS3_UNICODE",
50 # Chromium currently does not enable fts4, disable extra code.
51 "SQLITE_DISABLE_FTS4_DEFERRED",
53 "SQLITE_ENABLE_MEMORY_MANAGEMENT",
54 "SQLITE_SECURE_DELETE",
56 # Custom flag to tweak pcache pools.
57 # TODO(shess): This shouldn't use faux-SQLite naming.
58 "SQLITE_SEPARATE_CACHE_POOLS",
60 # TODO(shess): SQLite adds mutexes to protect structures which cross
61 # threads. In theory Chromium should be able to turn this off for a
65 # SQLite can spawn threads to sort in parallel if configured
66 # appropriately. Chromium doesn't configure SQLite for that, and would
67 # prefer to control distribution to worker threads.
68 "SQLITE_MAX_WORKER_THREADS=0",
70 # Use a read-only memory map when mmap'ed I/O is enabled to prevent memory
71 # stompers from directly corrupting the database.
72 # TODO(shess): Upstream the ability to use this define.
73 "SQLITE_MMAP_READ_ONLY=1",
75 # NOTE(shess): Some defines can affect the amalgamation. Those should be
76 # added to google_generate_amalgamation.sh, and the amalgamation
77 # re-generated. Usually this involves disabling features which include
78 # keywords or syntax, for instance SQLITE_OMIT_VIRTUALTABLE omits the
79 # virtual table syntax entirely. Missing an item usually results in
80 # syntax working but execution failing. Review:
82 # src/tool/mkkeywordhash.c
84 if (is_component_build) {
86 defines += [ "SQLITE_API=__declspec(dllexport)" ]
88 defines += [ "SQLITE_API=__attribute__((visibility(\"default\")))" ]
93 # Despite obvious warnings about not using this flag in deployment, we
94 # are turning off sync in ChromeOS and relying on the underlying
95 # journaling filesystem to do error recovery properly. It's much faster.
101 # Allow xSleep() call on Unix to use usleep() rather than sleep(), so it
102 # will have microsecond precision. Should only affect contended
103 # databases via the busy callback. Browser profile databases are mostly
104 # exclusive, but renderer databases may allow for contention.
107 # Use pread/pwrite directly rather than emulating them.
111 if (is_linux || is_android) {
113 # Linux provides fdatasync(), a faster equivalent of fsync().
114 "fdatasync=fdatasync",
118 # SQLite wants to track malloc sizes. On OSX it uses malloc_size(), on
119 # Windows _msize(), elsewhere it handles it manually by enlarging the malloc
120 # and injecting a field. Enable malloc_usable_size() for Linux.
121 # NOTE(shess): Android does _not_ export malloc_usable_size().
125 "HAVE_MALLOC_USABLE_SIZE",
129 include_dirs = [ "amalgamation" ]
131 configs -= [ "//build/config/compiler:chromium_code" ]
133 "//build/config/compiler:no_chromium_code",
135 # Must be after no_chromium_code for warning flags to be ordered
142 } else if (is_mac || is_ios) {
144 "CoreFoundation.framework",
145 "CoreServices.framework",
147 } else if (is_android) {
149 "SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576",
150 "SQLITE_DEFAULT_AUTOVACUUM=1",
151 "SQLITE_TEMP_STORE=3",
152 "SQLITE_ENABLE_FTS3_BACKWARDS",
153 "DSQLITE_DEFAULT_FILE_FORMAT=4",
162 config("sqlite_export") {
163 if (is_component_build && is_win) {
164 defines = [ "SQLITE_API=__declspec(dllimport)" ]
168 # This is used to allow the SQLITE_API definition to be different when
169 # building sqlite3.c than it is when clients include sqlite3.h.
174 public_configs = [ ":sqlite_export" ]
178 executable("sqlite_shell") {
179 # So shell.c can find the correct sqlite3.h.
180 include_dirs = [ "amalgamation" ]
184 "src/src/shell_icu_linux.c",
186 # Include a dummy c++ file to force linking of libstdc++.
192 "//build/config/sanitizers:deps",
199 if (use_system_sqlite) {
200 # iOS uses the version of sqlite3 shipped with the system instead of the
201 # version shipped with Chromium. Export a "sqlite" target so the change
202 # can be localized to this file.
204 config("sqlite_config") {
205 defines = [ "USE_SYSTEM_SQLITE" ]
209 assert(false, "extra flags to use system sqlite3 library missing")
213 source_set("sqlite") {
214 public_configs = [ ":sqlite_config" ]
223 source_set("sqlite_regexp") {
225 # Necessary to statically compile the extension.
228 "SQLITE_ENABLE_MEMORY_MANAGEMENT",
237 # src/ext/icu/icu.c uses assert(!"string") which causes warnings about
238 # conversion from string literal to bool.
239 configs -= [ "//build/config/clang:extra_warnings" ]