cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / third_party / sqlite / BUILD.gn
blobdaeda7254bf18b8d93c90ced87c9c11a7abbe3d2
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.
5 declare_args() {
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 = [ "." ]
17   }
19   config("sqlite_warnings") {
20     cflags = []
21     if (is_clang) {
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" ]
28     }
29     if (is_linux) {
30       cflags += [
31         # SQLite doesn"t believe in compiler warnings,
32         # preferring testing.
33         #   http://www.sqlite.org/faq.html#q17
34         "-Wno-int-to-pointer-cast",
35         "-Wno-pointer-to-int-cast",
36       ]
37     }
38   }
40   # "sqlite3" can cause conflicts with the system library.
41   component("chromium_sqlite3") {
42     visibility = [ ":*" ]
44     sources = [
45       "amalgamation/sqlite3.c",
46       "amalgamation/sqlite3.h",
47     ]
49     cflags = []
50     defines = [
51       "SQLITE_ENABLE_FTS3",
52       "SQLITE_DISABLE_FTS3_UNICODE",
53       "SQLITE_DISABLE_FTS4_DEFERRED",
54       "SQLITE_ENABLE_ICU",
55       "SQLITE_ENABLE_MEMORY_MANAGEMENT",
56       "SQLITE_SECURE_DELETE",
57       "SQLITE_SEPARATE_CACHE_POOLS",
58       "THREADSAFE",
59     ]
60     if (is_component_build) {
61       if (is_win) {
62         defines += [ "SQLITE_API=__declspec(dllexport)" ]
63       } else {
64         defines += [ "SQLITE_API=__attribute__((visibility(\"default\")))" ]
65       }
66     }
67     if (is_chromeos) {
68       defines += [
69         # Despite obvious warnings about not using this flag in deployment, we
70         # are turning off sync in ChromeOS and relying on the underlying
71         # journaling filesystem to do error recovery properly. It's much faster.
72         "SQLITE_NO_SYNC",
73       ]
74     }
75     if (is_posix) {
76       defines += [
77         # Allow xSleep() call on Unix to use usleep() rather than sleep(), so it
78         # will have microsecond precision.  Should only affect contended databases
79         # via the busy callback.  Browser profile databases are mostly exclusive,
80         # but renderer databases may allow for contention.
81         "HAVE_USLEEP=1",
82       ]
83     }
84     if (is_linux || is_android) {
85       defines += [
86         # Linux provides fdatasync(), a faster equivalent of fsync().
87         "fdatasync=fdatasync",
88       ]
89     }
91     include_dirs = [ "amalgamation" ]
93     configs -= [ "//build/config/compiler:chromium_code" ]
94     configs += [
95       "//build/config/compiler:no_chromium_code",
97       # Must be after no_chromium_code for warning flags to be ordered
98       # correctly.
99       ":sqlite_warnings",
100     ]
102     if (is_linux) {
103       libs = [ "dl" ]
104     } else if (is_mac || is_ios) {
105       libs = [
106         "CoreFoundation.framework",
107         "CoreServices.framework",
108       ]
109     } else if (is_android) {
110       defines += [
111         "SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576",
112         "SQLITE_DEFAULT_AUTOVACUUM=1",
113         "SQLITE_TEMP_STORE=3",
114         "SQLITE_ENABLE_FTS3_BACKWARDS",
115         "DSQLITE_DEFAULT_FILE_FORMAT=4",
116       ]
117     }
119     deps = [
120       "//third_party/icu",
121     ]
122   }
124   config("sqlite_export") {
125     if (is_component_build && is_win) {
126       defines = [ "SQLITE_API=__declspec(dllimport)" ]
127     }
128   }
130   # This is used to allow the SQLITE_API definition to be different when
131   # building sqlite3.c than it is when clients include sqlite3.h.
132   group("sqlite") {
133     public_deps = [ ":chromium_sqlite3" ]
134     public_configs = [ ":sqlite_export", ":sqlite_config" ]
135   }
137   if (is_linux) {
138     executable("sqlite_shell") {
139       sources = [
140         "src/src/shell.c",
141         "src/src/shell_icu_linux.c",
143         # Include a dummy c++ file to force linking of libstdc++.
144         "build_as_cpp.cc",
145       ]
147       deps = [
148         ":sqlite",
149         "//build/config/sanitizers:deps",
150         "//third_party/icu",
151       ]
152     }
153   }
156 if (use_system_sqlite) {
157   # iOS uses the version of sqlite3 shipped with the system instead of the
158   # version shipped with Chromium. Export a "sqlite" target so the change
159   # can be localized to this file.
161   config("sqlite_config") {
162     defines = [ "USE_SYSTEM_SQLITE" ]
163     if (is_ios) {
164       libs = [ "sqlite3" ]
165     } else {
166       assert(false, "extra flags to use system sqlite3 library missing")
167     }
168   }
170   source_set("sqlite") {
171     public_configs = [ ":sqlite_config" ]
172     if (is_ios) {
173       deps = [
174         ":sqlite_regexp",
175       ]
176     }
177   }
179   if (is_ios) {
180     source_set("sqlite_regexp") {
181       defines = [
182         # Necessary to statically compile the extension.
183         "SQLITE_CORE",
184         "SQLITE_DISABLE_FTS3_UNICODE",
185         "SQLITE_DISABLE_FTS4_DEFERRED",
186         "SQLITE_ENABLE_FTS3",
187         "SQLITE_ENABLE_ICU",
188         "SQLITE_ENABLE_MEMORY_MANAGEMENT",
189         "SQLITE_SECURE_DELETE",
190         "SQLITE_SEPARATE_CACHE_POOLS",
191         "THREADSAFE",
192       ]
193       sources = [
194         "src/ext/icu/icu.c",
195       ]
196       deps = [
197         "//third_party/icu",
198       ]
199       if (is_clang) {
200         # src/ext/icu/icu.c uses assert(!"string") which causes warnings about
201         # conversion from string literal to bool.
202         configs -= [ "//build/config/clang:extra_warnings" ]
203       }
204     }
205   }