Re-subimission of https://codereview.chromium.org/1041213003/
[chromium-blink-merge.git] / third_party / sqlite / BUILD.gn
blob526d16b195a5c903c88f575c43b33d81d3603c04
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 config("sqlite_config") {
6   include_dirs = [ "." ]
9 source_set("sqlite") {
10   sources = [
11     "amalgamation/sqlite3.c",
12     "amalgamation/sqlite3.h",
13   ]
15   cflags = []
16   defines = [
17     "SQLITE_CORE",
18     "SQLITE_ENABLE_FTS3",
19     "SQLITE_DISABLE_FTS3_UNICODE",
20     "SQLITE_DISABLE_FTS4_DEFERRED",
21     "SQLITE_ENABLE_ICU",
22     "SQLITE_ENABLE_MEMORY_MANAGEMENT",
23     "SQLITE_SECURE_DELETE",
24     "SQLITE_SEPARATE_CACHE_POOLS",
25     "THREADSAFE",
26     "_HAS_EXCEPTIONS=0",
27   ]
28   if (is_chromeos) {
29     defines += [
30       # Despite obvious warnings about not using this flag in deployment, we
31       # are turning off sync in ChromeOS and relying on the underlying
32       # journaling filesystem to do error recovery properly. It's much faster.
33       "SQLITE_NO_SYNC",
34     ]
35   }
36   if (is_posix) {
37     defines += [
38       # Allow xSleep() call on Unix to use usleep() rather than sleep(), so it
39       # will have microsecond precision.  Should only affect contended databases
40       # via the busy callback.  Browser profile databases are mostly exclusive,
41       # but renderer databases may allow for contention.
42       "HAVE_USLEEP=1",
43     ]
44   }
45   if (is_linux || is_android) {
46     defines += [
47       # Linux provides fdatasync(), a faster equivalent of fsync().
48       "fdatasync=fdatasync",
49     ]
50   }
52   include_dirs = [ "amalgamation" ]
54   configs -= [ "//build/config/compiler:chromium_code" ]
55   configs += [ "//build/config/compiler:no_chromium_code" ]
57   if (is_linux) {
58     cflags += [
59       # SQLite doesn"t believe in compiler warnings,
60       # preferring testing.
61       #   http://www.sqlite.org/faq.html#q17
62       "-Wno-int-to-pointer-cast",
63       "-Wno-pointer-to-int-cast",
64     ]
65     libs = [ "dl" ]
66   } else if (is_mac || is_ios) {
67     libs = [ "CoreFoundation.framework" ]
68   } else if (is_android) {
69     defines += [
70       "SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576",
71       "SQLITE_DEFAULT_AUTOVACUUM=1",
72       "SQLITE_TEMP_STORE=3",
73       "SQLITE_ENABLE_FTS3_BACKWARDS",
74       "DSQLITE_DEFAULT_FILE_FORMAT=4",
75     ]
76   }
78   public_configs = [ ":sqlite_config" ]
80   deps = [
81     "//third_party/icu",
82   ]
85 if (is_linux) {
86   executable("sqlite_shell") {
87     sources = [
88       "src/src/shell.c",
89       "src/src/shell_icu_linux.c",
91       # Include a dummy c++ file to force linking of libstdc++.
92       "build_as_cpp.cc",
93     ]
95     deps = [
96       ":sqlite",
97       "//third_party/icu",
98     ]
99   }
102 if (is_ios) {
103   source_set("sqlite_regexp") {
104     sources = [
105       "src/ext/icu/icu.c",
106     ]
107     deps = [
108       "//third_party/icu",
109     ]
110   }