• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4
5{
6  'variables': {
7    'use_system_sqlite%': 0,
8    'required_sqlite_version': '3.6.1',
9  },
10  'target_defaults': {
11    'defines': [
12      'SQLITE_CORE',
13      'SQLITE_ENABLE_BROKEN_FTS2',
14      'SQLITE_ENABLE_FTS2',
15      'SQLITE_ENABLE_FTS3',
16      'SQLITE_ENABLE_ICU',
17      'SQLITE_ENABLE_MEMORY_MANAGEMENT',
18      'SQLITE_SECURE_DELETE',
19      'SQLITE_SEPARATE_CACHE_POOLS',
20      'THREADSAFE',
21      '_HAS_EXCEPTIONS=0',
22    ],
23  },
24  'targets': [
25    {
26      'target_name': 'sqlite',
27      'conditions': [
28        [ 'chromeos==1' , {
29            'defines': [
30                # Despite obvious warnings about not using this flag
31                # in deployment, we are turning off sync in ChromeOS
32                # and relying on the underlying journaling filesystem
33                # to do error recovery properly.  It's much faster.
34                'SQLITE_NO_SYNC',
35                ],
36          },
37        ],
38        ['use_system_sqlite', {
39          'type': 'none',
40          'direct_dependent_settings': {
41            'defines': [
42              'USE_SYSTEM_SQLITE',
43            ],
44          },
45
46          'conditions': [
47            ['OS == "ios"', {
48              'dependencies': [
49                'sqlite_regexp',
50              ],
51              'link_settings': {
52                'libraries': [
53                  '$(SDKROOT)/usr/lib/libsqlite3.dylib',
54                ],
55              },
56            }],
57            ['os_posix == 1 and OS != "mac" and OS != "ios" and OS != "android"', {
58              'direct_dependent_settings': {
59                'cflags': [
60                  # This next command produces no output but it it will fail
61                  # (and cause GYP to fail) if we don't have a recent enough
62                  # version of sqlite.
63                  '<!@(pkg-config --atleast-version=<(required_sqlite_version) sqlite3)',
64
65                  '<!@(pkg-config --cflags sqlite3)',
66                ],
67              },
68              'link_settings': {
69                'ldflags': [
70                  '<!@(pkg-config --libs-only-L --libs-only-other sqlite3)',
71                ],
72                'libraries': [
73                  '<!@(pkg-config --libs-only-l sqlite3)',
74                ],
75              },
76            }],
77          ],
78        }, { # !use_system_sqlite
79          'product_name': 'sqlite3',
80          'type': 'static_library',
81          'sources': [
82            'amalgamation/sqlite3.h',
83            'amalgamation/sqlite3.c',
84            # fts2.c currently has a lot of conflicts when added to
85            # the amalgamation.  It is probably not worth fixing that.
86            'src/ext/fts2/fts2.c',
87            'src/ext/fts2/fts2.h',
88            'src/ext/fts2/fts2_hash.c',
89            'src/ext/fts2/fts2_hash.h',
90            'src/ext/fts2/fts2_icu.c',
91            'src/ext/fts2/fts2_porter.c',
92            'src/ext/fts2/fts2_tokenizer.c',
93            'src/ext/fts2/fts2_tokenizer.h',
94            'src/ext/fts2/fts2_tokenizer1.c',
95          ],
96
97          # TODO(shess): Previously fts1 and rtree files were
98          # explicitly excluded from the build.  Make sure they are
99          # logically still excluded.
100
101          # TODO(shess): Should all of the sources be listed and then
102          # excluded?  For editing purposes?
103
104          'include_dirs': [
105            'amalgamation',
106            # Needed for fts2 to build.
107            'src/src',
108          ],
109          'dependencies': [
110            '../icu/icu.gyp:icui18n',
111            '../icu/icu.gyp:icuuc',
112          ],
113          'direct_dependent_settings': {
114            'include_dirs': [
115              '.',
116              '../..',
117            ],
118          },
119          'msvs_disabled_warnings': [
120            4018, 4244, 4267,
121          ],
122          'conditions': [
123            ['OS=="linux"', {
124              'link_settings': {
125                'libraries': [
126                  '-ldl',
127                ],
128              },
129            }],
130            ['OS == "mac" or OS == "ios"', {
131              'link_settings': {
132                'libraries': [
133                  '$(SDKROOT)/System/Library/Frameworks/CoreFoundation.framework',
134                ],
135              },
136            }],
137            ['OS == "android"', {
138              'defines': [
139                'HAVE_USLEEP=1',
140                'SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576',
141                'SQLITE_DEFAULT_AUTOVACUUM=1',
142                'SQLITE_TEMP_STORE=3',
143                'SQLITE_ENABLE_FTS3_BACKWARDS',
144                'DSQLITE_DEFAULT_FILE_FORMAT=4',
145              ],
146              'android_enable_fdo': 1,
147            }],
148            ['os_posix == 1 and OS != "mac" and OS != "android"', {
149              'cflags': [
150                # SQLite doesn't believe in compiler warnings,
151                # preferring testing.
152                #   http://www.sqlite.org/faq.html#q17
153                '-Wno-int-to-pointer-cast',
154                '-Wno-pointer-to-int-cast',
155              ],
156            }],
157            ['clang==1', {
158              'xcode_settings': {
159                'WARNING_CFLAGS': [
160                  # sqlite does `if (*a++ && *b++);` in a non-buggy way.
161                  '-Wno-empty-body',
162                  # sqlite has some `unsigned < 0` checks.
163                  '-Wno-tautological-compare',
164                ],
165              },
166              'cflags': [
167                '-Wno-empty-body',
168                '-Wno-tautological-compare',
169              ],
170            }],
171          ],
172        }],
173      ],
174    },
175  ],
176  'conditions': [
177    ['os_posix == 1 and OS != "mac" and OS != "ios" and OS != "android" and not use_system_sqlite', {
178      'targets': [
179        {
180          'target_name': 'sqlite_shell',
181          'type': 'executable',
182          'dependencies': [
183            '../icu/icu.gyp:icuuc',
184            'sqlite',
185          ],
186          'sources': [
187            'src/src/shell.c',
188            'src/src/shell_icu_linux.c',
189            # Include a dummy c++ file to force linking of libstdc++.
190            'build_as_cpp.cc',
191          ],
192        },
193      ],
194    },],
195    ['OS == "ios"', {
196      'targets': [
197        {
198          'target_name': 'sqlite_regexp',
199          'type': 'static_library',
200          'dependencies': [
201            '../icu/icu.gyp:icui18n',
202            '../icu/icu.gyp:icuuc',
203          ],
204          'sources': [
205            'src/ext/icu/icu.c',
206          ],
207        },
208      ],
209    }],
210  ],
211}
212