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 # TODO(shess): This cannot possibly be the right thing to do. AFAICT it is
14 # only necessary so that WebDatabase can #include <sqlite3.h>.
15 config("sqlite_config") {
16 include_dirs = [ "." ]
19 config("sqlite_warnings") {
22 # sqlite contains a few functions that are unused, at least on
23 # Windows with Chromium's sqlite patches applied
24 # (interiorCursorEOF fts3EvalDeferredPhrase
25 # fts3EvalSelectDeferred sqlite3Fts3InitHashTable
26 # sqlite3Fts3InitTok).
27 cflags += [ "-Wno-unused-function" ]
31 # SQLite doesn"t believe in compiler warnings,
33 # http://www.sqlite.org/faq.html#q17
34 "-Wno-int-to-pointer-cast",
35 "-Wno-pointer-to-int-cast",
40 # "sqlite3" can cause conflicts with the system library.
41 component("chromium_sqlite3") {
45 "amalgamation/sqlite3.c",
46 "amalgamation/sqlite3.h",
53 # New unicode61 tokenizer with built-in tables.
54 "SQLITE_DISABLE_FTS3_UNICODE",
56 # Chromium currently does not enable fts4, disable extra code.
57 "SQLITE_DISABLE_FTS4_DEFERRED",
59 "SQLITE_ENABLE_MEMORY_MANAGEMENT",
60 "SQLITE_SECURE_DELETE",
62 # Custom flag to tweak pcache pools.
63 # TODO(shess): This shouldn't use faux-SQLite naming.
64 "SQLITE_SEPARATE_CACHE_POOLS",
66 # TODO(shess): SQLite adds mutexes to protect structures which cross
67 # threads. In theory Chromium should be able to turn this off for a
71 # SQLite can spawn threads to sort in parallel if configured
72 # appropriately. Chromium doesn't configure SQLite for that, and would
73 # prefer to control distribution to worker threads.
74 "SQLITE_MAX_WORKER_THREADS=0",
76 # Use a read-only memory map when mmap'ed I/O is enabled to prevent memory
77 # stompers from directly corrupting the database.
78 # TODO(shess): Upstream the ability to use this define.
79 "SQLITE_MMAP_READ_ONLY=1",
81 # NOTE(shess): Some defines can affect the amalgamation. Those should be
82 # added to google_generate_amalgamation.sh, and the amalgamation
83 # re-generated. Usually this involves disabling features which include
84 # keywords or syntax, for instance SQLITE_OMIT_VIRTUALTABLE omits the
85 # virtual table syntax entirely. Missing an item usually results in
86 # syntax working but execution failing. Review:
88 # src/tool/mkkeywordhash.c
90 if (is_component_build) {
92 defines += [ "SQLITE_API=__declspec(dllexport)" ]
94 defines += [ "SQLITE_API=__attribute__((visibility(\"default\")))" ]
99 # Despite obvious warnings about not using this flag in deployment, we
100 # are turning off sync in ChromeOS and relying on the underlying
101 # journaling filesystem to do error recovery properly. It's much faster.
107 # Allow xSleep() call on Unix to use usleep() rather than sleep(), so it
108 # will have microsecond precision. Should only affect contended
109 # databases via the busy callback. Browser profile databases are mostly
110 # exclusive, but renderer databases may allow for contention.
113 # Use pread/pwrite directly rather than emulating them.
117 if (is_linux || is_android) {
119 # Linux provides fdatasync(), a faster equivalent of fsync().
120 "fdatasync=fdatasync",
124 # SQLite wants to track malloc sizes. On OSX it uses malloc_size(), on
125 # Windows _msize(), elsewhere it handles it manually by enlarging the malloc
126 # and injecting a field. Enable malloc_usable_size() for Linux.
127 # NOTE(shess): Android does _not_ export malloc_usable_size().
131 "HAVE_MALLOC_USABLE_SIZE",
135 include_dirs = [ "amalgamation" ]
137 configs -= [ "//build/config/compiler:chromium_code" ]
139 "//build/config/compiler:no_chromium_code",
141 # Must be after no_chromium_code for warning flags to be ordered
148 } else if (is_mac || is_ios) {
150 "CoreFoundation.framework",
151 "CoreServices.framework",
153 } else if (is_android) {
155 "SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576",
156 "SQLITE_DEFAULT_AUTOVACUUM=1",
157 "SQLITE_TEMP_STORE=3",
158 "SQLITE_ENABLE_FTS3_BACKWARDS",
159 "DSQLITE_DEFAULT_FILE_FORMAT=4",
168 config("sqlite_export") {
169 if (is_component_build && is_win) {
170 defines = [ "SQLITE_API=__declspec(dllimport)" ]
174 # This is used to allow the SQLITE_API definition to be different when
175 # building sqlite3.c than it is when clients include sqlite3.h.
187 executable("sqlite_shell") {
190 "src/src/shell_icu_linux.c",
192 # Include a dummy c++ file to force linking of libstdc++.
198 "//build/config/sanitizers:deps",
205 if (use_system_sqlite) {
206 # iOS uses the version of sqlite3 shipped with the system instead of the
207 # version shipped with Chromium. Export a "sqlite" target so the change
208 # can be localized to this file.
210 config("sqlite_config") {
211 defines = [ "USE_SYSTEM_SQLITE" ]
215 assert(false, "extra flags to use system sqlite3 library missing")
219 source_set("sqlite") {
220 public_configs = [ ":sqlite_config" ]
229 source_set("sqlite_regexp") {
231 # Necessary to statically compile the extension.
234 "SQLITE_ENABLE_MEMORY_MANAGEMENT",
243 # src/ext/icu/icu.c uses assert(!"string") which causes warnings about
244 # conversion from string literal to bool.
245 configs -= [ "//build/config/clang:extra_warnings" ]