Revert "Fix broken channel icon in chrome://help on CrOS" and try again
[chromium-blink-merge.git] / third_party / sqlite / BUILD.gn
blob866c2449101283f3c98644074a7f009372f102b1
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   config("sqlite_config") {
14     include_dirs = [ "." ]
15   }
17   source_set("sqlite") {
18     sources = [
19       "amalgamation/sqlite3.c",
20       "amalgamation/sqlite3.h",
21     ]
23     cflags = []
24     defines = [
25       "SQLITE_ENABLE_FTS3",
26       "SQLITE_DISABLE_FTS3_UNICODE",
27       "SQLITE_DISABLE_FTS4_DEFERRED",
28       "SQLITE_ENABLE_ICU",
29       "SQLITE_ENABLE_MEMORY_MANAGEMENT",
30       "SQLITE_SECURE_DELETE",
31       "SQLITE_SEPARATE_CACHE_POOLS",
32       "THREADSAFE",
33     ]
34     if (is_chromeos) {
35       defines += [
36         # Despite obvious warnings about not using this flag in deployment, we
37         # are turning off sync in ChromeOS and relying on the underlying
38         # journaling filesystem to do error recovery properly. It's much faster.
39         "SQLITE_NO_SYNC",
40       ]
41     }
42     if (is_posix) {
43       defines += [
44         # Allow xSleep() call on Unix to use usleep() rather than sleep(), so it
45         # will have microsecond precision.  Should only affect contended databases
46         # via the busy callback.  Browser profile databases are mostly exclusive,
47         # but renderer databases may allow for contention.
48         "HAVE_USLEEP=1",
49       ]
50     }
51     if (is_linux || is_android) {
52       defines += [
53         # Linux provides fdatasync(), a faster equivalent of fsync().
54         "fdatasync=fdatasync",
55       ]
56     }
58     include_dirs = [ "amalgamation" ]
60     config("sqlite_warnings") {
61       cflags = []
62       if (is_clang) {
63         # sqlite contains a few functions that are unused, at least on
64         # Windows with Chromium's sqlite patches applied
65         # (interiorCursorEOF fts3EvalDeferredPhrase
66         # fts3EvalSelectDeferred sqlite3Fts3InitHashTable
67         # sqlite3Fts3InitTok).
68         cflags += [ "-Wno-unused-function" ]
69       }
70       if (is_linux) {
71         cflags += [
72           # SQLite doesn"t believe in compiler warnings,
73           # preferring testing.
74           #   http://www.sqlite.org/faq.html#q17
75           "-Wno-int-to-pointer-cast",
76           "-Wno-pointer-to-int-cast",
77         ]
78       }
79     }
80     configs -= [ "//build/config/compiler:chromium_code" ]
81     configs += [ "//build/config/compiler:no_chromium_code" ]
82     configs += [ ":sqlite_warnings" ]
84     if (is_linux) {
85       libs = [ "dl" ]
86     } else if (is_mac || is_ios) {
87       libs = [ "CoreFoundation.framework" ]
88     } else if (is_android) {
89       defines += [
90         "SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576",
91         "SQLITE_DEFAULT_AUTOVACUUM=1",
92         "SQLITE_TEMP_STORE=3",
93         "SQLITE_ENABLE_FTS3_BACKWARDS",
94         "DSQLITE_DEFAULT_FILE_FORMAT=4",
95       ]
96     }
98     deps = [
99       "//third_party/icu",
100     ]
102     public_configs = [ ":sqlite_config" ]
103   }
105   if (is_linux) {
106     executable("sqlite_shell") {
107       sources = [
108         "src/src/shell.c",
109         "src/src/shell_icu_linux.c",
111         # Include a dummy c++ file to force linking of libstdc++.
112         "build_as_cpp.cc",
113       ]
115       deps = [
116         ":sqlite",
117         "//third_party/icu",
118       ]
119     }
120   }
123 if (use_system_sqlite) {
124   # iOS uses the version of sqlite3 shipped with the system instead of the
125   # version shipped with Chromium. Export a "sqlite" target so the change
126   # can be localized to this file.
128   config("sqlite_config") {
129     defines = [ "USE_SYSTEM_SQLITE" ]
130     if (is_ios) {
131       libs = [ "sqlite3" ]
132     } else {
133       assert(false, "extra flags to use system sqlite3 library missing")
134     }
135   }
137   source_set("sqlite") {
138     public_configs = [ ":sqlite_config" ]
139     if (is_ios) {
140       deps = [
141         ":sqlite_regexp",
142       ]
143     }
144   }
146   if (is_ios) {
147     source_set("sqlite_regexp") {
148       defines = [
149         # Necessary to statically compile the extension.
150         "SQLITE_CORE",
151         "SQLITE_DISABLE_FTS3_UNICODE",
152         "SQLITE_DISABLE_FTS4_DEFERRED",
153         "SQLITE_ENABLE_FTS3",
154         "SQLITE_ENABLE_ICU",
155         "SQLITE_ENABLE_MEMORY_MANAGEMENT",
156         "SQLITE_SECURE_DELETE",
157         "SQLITE_SEPARATE_CACHE_POOLS",
158         "THREADSAFE",
159       ]
160       sources = [
161         "src/ext/icu/icu.c",
162       ]
163       deps = [
164         "//third_party/icu",
165       ]
166       if (is_clang) {
167         # src/ext/icu/icu.c uses assert(!"string") which causes warnings about
168         # conversion from string literal to bool.
169         configs -= [ "//build/config/clang:extra_warnings" ]
170       }
171     }
172   }