Backed out 2 changesets (bug 903746) for causing non-unified build bustages on nsIPri...
[gecko.git] / third_party / sqlite3 / src / moz.build
blob18e306f76051d2257f1ffb846393779fc13183cb
1 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
2 # vim: set filetype=python:
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 NoVisibilityFlags()
8 EXPORTS += [
9     'sqlite3.h',
12 # We allow warnings for third-party code that can be updated from upstream.
13 AllowCompilerWarnings()
15 if CONFIG['MOZ_FOLD_LIBS']:
16     # When folding libraries, sqlite is actually in the nss library.
17     FINAL_LIBRARY = 'nss'
18 else:
19     # The final library is in config/external/sqlite
20     FINAL_LIBRARY = 'sqlite'
22 DIRS += [
23     '../ext'
26 SOURCES += [
27     'sqlite3.c',
30 # -DSQLITE_SECURE_DELETE=1 will cause SQLITE to 0-fill delete data so we
31 # don't have to vacuum to make sure the data is not visible in the file.
32 # -DSQLITE_DEFAULT_PAGE_SIZE=32768 and SQLITE_MAX_DEFAULT_PAGE_SIZE=32768
33 # increases the page size from 1k, see bug 416330.  It must be kept in sync with
34 # the value of PREF_TS_PAGESIZE_DEFAULT in mozStorageService.cpp.  The value can
35 # be overridden on a per-platform basis through the use of the PREF_TS_PAGESIZE
36 # hidden preference.  If that preference is missing or invalid then this value
37 # will be used.
38 # Note: Be sure to update the configure.in checks when these change!
39 for var in ('SQLITE_SECURE_DELETE', 'SQLITE_THREADSAFE',
40             'SQLITE_ENABLE_UNLOCK_NOTIFY', 'SQLITE_ENABLE_DBSTAT_VTAB'):
41     DEFINES[var] = 1
43 DEFINES['SQLITE_DEFAULT_PAGE_SIZE'] = 32768
44 DEFINES['SQLITE_MAX_DEFAULT_PAGE_SIZE'] = 32768
46 # -DSQLITE_WIN32_GETVERSIONEX=0 avoids using deprecated functions.
47 # SQLite will just assume we are running on NT kinds of Windows. That's fine
48 # because we don't support Win9x.
49 # -DSQLITE_ALLOW_URI_AUTHORITY=1 enables uri authorities. See bug 879133.
50 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
51     DEFINES['SQLITE_WIN32_GETVERSIONEX'] = 0
52     DEFINES['SQLITE_ALLOW_URI_AUTHORITY'] = 1
54 # -DSQLITE_ENABLE_LOCKING_STYLE=1 to help with AFP folders
55 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
56     DEFINES['SQLITE_ENABLE_LOCKING_STYLE'] = 1
58 # sqlite defaults this to on on __APPLE_ but it breaks on newer iOS SDKs
59 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'uikit':
60     DEFINES['SQLITE_ENABLE_LOCKING_STYLE'] = 0
62 # Turn on SQLite's assertions in debug builds.
63 if CONFIG['MOZ_DEBUG']:
64     DEFINES['SQLITE_DEBUG'] = 1
65     DEFINES['SQLITE_ENABLE_API_ARMOR'] = True
66 else:
67     DEFINES['SQLITE_OMIT_COMPILEOPTION_DIAGS'] = 1
69 if CONFIG['OS_TARGET'] == 'Android':
70     # default to user readable only to fit Android security model
71     DEFINES['SQLITE_DEFAULT_FILE_PERMISSIONS'] = '0600'
73 # Force using _msize on mingw, as sqlite3 only enables it with MSVC.
74 if CONFIG['OS_TARGET'] == 'WINNT' and CONFIG['CC_TYPE'] != 'clang-cl':
75     DEFINES['SQLITE_USE_MALLOC_H'] = True
76     DEFINES['SQLITE_USE_MSIZE'] = True
78 # Omit unused functions to save some library footprint.
79 DEFINES['SQLITE_OMIT_DEPRECATED'] = True
80 DEFINES['SQLITE_OMIT_BUILTIN_TEST'] = True
82 # Try to use a MEMORY temp store when possible. That allows for better
83 # performance and doesn't suffer from a full separate tmp partition.
84 # Exclude 32bit platforms due to address space fragmentation issues.
85 if CONFIG['OS_TARGET'] == 'Android':
86     # On Android there's no tmp partition, so always use a MEMORY temp store.
87     DEFINES['SQLITE_TEMP_STORE'] = 3
88 elif CONFIG['HAVE_64BIT_BUILD']:
89     # On 64bit platforms default to a MEMORY temp store for performance.
90     DEFINES['SQLITE_TEMP_STORE'] = 2
92 # Change the default temp files prefix, to easily distinguish files we created
93 # vs files created by other Sqlite instances in the system.
94 DEFINES['SQLITE_TEMP_FILE_PREFIX'] = '"mz_etilqs_"'
96 # Enabling sqlite math functions
97 DEFINES['SQLITE_ENABLE_MATH_FUNCTIONS'] = True
98 if CONFIG["OS_TARGET"] == "Linux" or CONFIG["OS_TARGET"] == "Android":
99     OS_LIBS += [
100         "m"
101     ]
103 # 32-bit Android doesn't have the log2() stdlib function
104 if CONFIG['OS_TARGET'] == 'Android' and not CONFIG['HAVE_64BIT_BUILD']:
105     DEFINES['HAVE_LOG2'] = 0
107 # Suppress warnings in third-party code.
108 if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
109     CFLAGS += [
110         '-Wno-sign-compare',
111         '-Wno-type-limits',
112     ]
114 # Set a default journal size limit. Note an hot journal can grow over this
115 # limit, but if it does Sqlite will truncate it once it returns being idle.
116 # Also note growing a journal has a cost, so a too strict limit may affect
117 # performance.
118 # Also note this is necessary for safely supporting SQLITE_FCNTL_PERSIST_WAL
119 # that our base VFS uses, indeed when a journal limit is set, the journal will
120 # be truncated to 0 on shutdown, reducing the likelihood of corruption if the
121 # user doesn't move auxiliary files along with the main database.
122 # This is in bytes.
123 DEFINES['SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT'] = 1572864
125 # Thunderbird/Mail uses the FTS3 extension, but it's not using enhanced query
126 # syntax (SQLITE_ENABLE_FTS3_PARENTHESIS) yet.
127 if CONFIG["MOZ_THUNDERBIRD"] or CONFIG["MOZ_SUITE"]:
128     DEFINES['SQLITE_ENABLE_FTS3'] = 1
130 # Bug 1878311 - Disable the SQLITE_DIRECT_OVERFLOW_READ optimization due to
131 # privatebrowsing test failures.
132 DEFINES['SQLITE_DIRECT_OVERFLOW_READ'] = 0