Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / sqlite / sqlite.gyp
blob160a4b27db3c27b6dd63a8eeb92df610e26263b7
1 # Copyright (c) 2012 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   'variables': {
7     'use_system_sqlite%': 0,
8     'required_sqlite_version': '3.6.1',
9   },
10   'target_defaults': {
11     'defines': [
12       'SQLITE_ENABLE_FTS3',
13       # New unicode61 tokenizer with built-in tables.
14       'SQLITE_DISABLE_FTS3_UNICODE',
15       # Chromium currently does not enable fts4, disable extra code.
16       'SQLITE_DISABLE_FTS4_DEFERRED',
17       'SQLITE_ENABLE_ICU',
18       'SQLITE_ENABLE_MEMORY_MANAGEMENT',
19       'SQLITE_SECURE_DELETE',
20       # Custom flag to tweak pcache pools.
21       # TODO(shess): This shouldn't use faux-SQLite naming.
22       'SQLITE_SEPARATE_CACHE_POOLS',
23       # TODO(shess): SQLite adds mutexes to protect structures which cross
24       # threads.  In theory Chromium should be able to turn this off for a
25       # slight speed boost.
26       'THREADSAFE',
27       # SQLite can spawn threads to sort in parallel if configured
28       # appropriately.  Chromium doesn't configure SQLite for that, and would
29       # prefer to control distribution to worker threads.
30       'SQLITE_MAX_WORKER_THREADS=0',
31       # Use a read-only memory map when mmap'ed I/O is enabled to prevent memory
32       # stompers from directly corrupting the database.
33       # TODO(shess): Upstream the ability to use this define.
34       'SQLITE_MMAP_READ_ONLY=1',
35       # NOTE(shess): Some defines can affect the amalgamation.  Those should be
36       # added to google_generate_amalgamation.sh, and the amalgamation
37       # re-generated.  Usually this involves disabling features which include
38       # keywords or syntax, for instance SQLITE_OMIT_VIRTUALTABLE omits the
39       # virtual table syntax entirely.  Missing an item usually results in
40       # syntax working but execution failing.  Review:
41       #   src/src/parse.py
42       #   src/tool/mkkeywordhash.c
43     ],
44   },
45   'targets': [
46     {
47       'target_name': 'sqlite',
48       'conditions': [
49         [ 'chromeos==1' , {
50           'defines': [
51             # Despite obvious warnings about not using this flag in deployment,
52             # we are turning off sync in ChromeOS and relying on the underlying
53             # journaling filesystem to do error recovery properly.  It's much
54             # faster.
55             'SQLITE_NO_SYNC',
56           ],
57         }],
58         ['os_posix == 1', {
59           'defines': [
60             # Allow xSleep() call on Unix to use usleep() rather than sleep().
61             # Microsecond precision is better than second precision.  Should
62             # only affect contended databases via the busy callback.  Browser
63             # profile databases are mostly exclusive, but renderer databases may
64             # allow for contention.
65             'HAVE_USLEEP=1',
66             # Use pread/pwrite directly rather than emulating them.
67             'USE_PREAD=1',
68           ],
69         }],
70         ['OS == "linux" or OS == "android"', {
71           'defines': [
72             # Linux provides fdatasync(), a faster equivalent of fsync().
73             'fdatasync=fdatasync',
74           ],
75         }],
76         # SQLite wants to track malloc sizes.  On OSX it uses malloc_size(), on
77         # Windows _msize(), elsewhere it handles it manually by enlarging the
78         # malloc and injecting a field.  Enable malloc_usable_size() for Linux.
79         # NOTE(shess): Android does _not_ export malloc_usable_size().
80         ['OS == "linux"', {
81           'defines': [
82             'HAVE_MALLOC_H',
83             'HAVE_MALLOC_USABLE_SIZE',
84           ],
85         }],
86         ['use_system_sqlite', {
87           'type': 'none',
88           'direct_dependent_settings': {
89             'defines': [
90               'USE_SYSTEM_SQLITE',
91             ],
92           },
94           'conditions': [
95             ['OS == "ios"', {
96               'dependencies': [
97                 'sqlite_regexp',
98               ],
99               'link_settings': {
100                 'xcode_settings': {
101                   'OTHER_LDFLAGS': [
102                     '-lsqlite3',
103                   ],
104                 },
105               },
106             }],
107             ['os_posix == 1 and OS != "mac" and OS != "ios" and OS != "android"', {
108               'direct_dependent_settings': {
109                 'cflags': [
110                   # This next command produces no output but it it will fail
111                   # (and cause GYP to fail) if we don't have a recent enough
112                   # version of sqlite.
113                   '<!@(pkg-config --atleast-version=<(required_sqlite_version) sqlite3)',
115                   '<!@(pkg-config --cflags sqlite3)',
116                 ],
117               },
118               'link_settings': {
119                 'ldflags': [
120                   '<!@(pkg-config --libs-only-L --libs-only-other sqlite3)',
121                 ],
122                 'libraries': [
123                   '<!@(pkg-config --libs-only-l sqlite3)',
124                 ],
125               },
126             }],
127           ],
128         }, { # !use_system_sqlite
129           # "sqlite3" can cause conflicts with the system library.
130           'product_name': 'chromium_sqlite3',
131           'type': '<(component)',
132           'sources': [
133             'amalgamation/sqlite3.h',
134             'amalgamation/sqlite3.c',
135           ],
136           'variables': {
137             'clang_warning_flags': [
138               # sqlite contains a few functions that are unused, at least on
139               # Windows with Chromium's sqlite patches applied
140               # (interiorCursorEOF fts3EvalDeferredPhrase
141               # fts3EvalSelectDeferred sqlite3Fts3InitHashTable
142               # sqlite3Fts3InitTok).
143               '-Wno-unused-function',
144             ],
145           },
146           'include_dirs': [
147             'amalgamation',
148           ],
149           'dependencies': [
150             '../icu/icu.gyp:icui18n',
151             '../icu/icu.gyp:icuuc',
152           ],
153           'msvs_disabled_warnings': [
154             4244, 4267,
155           ],
156           'conditions': [
157             ['OS == "win" and component == "shared_library"', {
158               'defines': ['SQLITE_API=__declspec(dllexport)'],
159               'direct_dependent_settings': {
160                 'defines': ['SQLITE_API=__declspec(dllimport)'],
161               },
162             }],
163             ['OS != "win" and component == "shared_library"', {
164               'defines': ['SQLITE_API=__attribute__((visibility("default")))'],
165             }],
166             ['OS=="linux"', {
167               'link_settings': {
168                 'libraries': [
169                   '-ldl',
170                 ],
171               },
172             }],
173             ['OS == "mac" or OS == "ios"', {
174               'link_settings': {
175                 'libraries': [
176                   '$(SDKROOT)/System/Library/Frameworks/CoreFoundation.framework',
177                   '$(SDKROOT)/System/Library/Frameworks/CoreServices.framework',
178                 ],
179               },
180             }],
181             ['OS == "android"', {
182               'defines': [
183                 'SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576',
184                 'SQLITE_DEFAULT_AUTOVACUUM=1',
185                 'SQLITE_TEMP_STORE=3',
186                 'SQLITE_ENABLE_FTS3_BACKWARDS',
187                 'SQLITE_DEFAULT_FILE_FORMAT=4',
188               ],
189             }],
190             ['os_posix == 1 and OS != "mac" and OS != "android"', {
191               'cflags': [
192                 # SQLite doesn't believe in compiler warnings,
193                 # preferring testing.
194                 #   http://www.sqlite.org/faq.html#q17
195                 '-Wno-int-to-pointer-cast',
196                 '-Wno-pointer-to-int-cast',
197               ],
198             }],
199           ],
200         }],
201       ],
202       'includes': [
203         # Disable LTO due to ELF section name out of range
204         # crbug.com/422251
205         '../../build/android/disable_gcc_lto.gypi',
206       ],
207     },
208   ],
209   'conditions': [
210     ['os_posix == 1 and OS != "mac" and OS != "ios" and OS != "android" and not use_system_sqlite', {
211       'targets': [
212         {
213           'target_name': 'sqlite_shell',
214           'type': 'executable',
215           'dependencies': [
216             '../icu/icu.gyp:icuuc',
217             'sqlite',
218           ],
219           # So shell.c can find the correct sqlite3.h.
220           'include_dirs': [
221             'amalgamation',
222           ],
223           'sources': [
224             'src/src/shell.c',
225             'src/src/shell_icu_linux.c',
226             # Include a dummy c++ file to force linking of libstdc++.
227             'build_as_cpp.cc',
228           ],
229         },
230       ],
231     },],
232     ['OS == "ios"', {
233       'targets': [
234         {
235           'target_name': 'sqlite_regexp',
236           'type': 'static_library',
237           'dependencies': [
238             '../icu/icu.gyp:icui18n',
239             '../icu/icu.gyp:icuuc',
240           ],
241           'defines': [
242             # Necessary to statically compile the extension.
243             'SQLITE_CORE',
244           ],
245           'sources': [
246             'src/ext/icu/icu.c',
247           ],
248         },
249       ],
250     }],
251   ],