blob: 95b9cb978b2c3bc08fddbe7bd5e8298423e8a568 [file] [log] [blame]
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
declare_args() {
# Controls whether the build should uses the version of sqlite3 library
# shipped with the system (currently only supported on iOS) or the one
# shipped with Chromium source.
use_system_sqlite = is_ios
}
if (!use_system_sqlite) {
config("sqlite_config") {
include_dirs = [ "." ]
}
source_set("sqlite") {
sources = [
"amalgamation/sqlite3.c",
"amalgamation/sqlite3.h",
]
cflags = []
defines = [
"SQLITE_ENABLE_FTS3",
"SQLITE_DISABLE_FTS3_UNICODE",
"SQLITE_DISABLE_FTS4_DEFERRED",
"SQLITE_ENABLE_ICU",
"SQLITE_ENABLE_MEMORY_MANAGEMENT",
"SQLITE_SECURE_DELETE",
"SQLITE_SEPARATE_CACHE_POOLS",
"THREADSAFE",
]
if (is_chromeos) {
defines += [
# Despite obvious warnings about not using this flag in deployment, we
# are turning off sync in ChromeOS and relying on the underlying
# journaling filesystem to do error recovery properly. It's much faster.
"SQLITE_NO_SYNC",
]
}
if (is_posix) {
defines += [
# Allow xSleep() call on Unix to use usleep() rather than sleep(), so it
# will have microsecond precision. Should only affect contended databases
# via the busy callback. Browser profile databases are mostly exclusive,
# but renderer databases may allow for contention.
"HAVE_USLEEP=1",
]
}
if (is_linux || is_android) {
defines += [
# Linux provides fdatasync(), a faster equivalent of fsync().
"fdatasync=fdatasync",
]
}
include_dirs = [ "amalgamation" ]
configs -= [ "//build/config/compiler:chromium_code" ]
configs += [ "//build/config/compiler:no_chromium_code" ]
if (is_linux) {
cflags += [
# SQLite doesn"t believe in compiler warnings,
# preferring testing.
# http://www.sqlite.org/faq.html#q17
"-Wno-int-to-pointer-cast",
"-Wno-pointer-to-int-cast",
]
libs = [ "dl" ]
} else if (is_mac || is_ios) {
libs = [ "CoreFoundation.framework" ]
} else if (is_android) {
defines += [
"SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576",
"SQLITE_DEFAULT_AUTOVACUUM=1",
"SQLITE_TEMP_STORE=3",
"SQLITE_ENABLE_FTS3_BACKWARDS",
"DSQLITE_DEFAULT_FILE_FORMAT=4",
]
}
deps = [
"//third_party/icu",
]
public_configs = [ ":sqlite_config" ]
}
if (is_linux) {
executable("sqlite_shell") {
sources = [
"src/src/shell.c",
"src/src/shell_icu_linux.c",
# Include a dummy c++ file to force linking of libstdc++.
"build_as_cpp.cc",
]
deps = [
":sqlite",
"//third_party/icu",
]
}
}
}
if (use_system_sqlite) {
# iOS uses the version of sqlite3 shipped with the system instead of the
# version shipped with Chromium. Export a "sqlite" target so the change
# can be localized to this file.
config("sqlite_config") {
defines = [ "USE_SYSTEM_SQLITE" ]
if (is_ios) {
libs = [ "sqlite3" ]
} else {
assert(false, "extra flags to use system sqlite3 library missing")
}
}
source_set("sqlite") {
public_configs = [ ":sqlite_config" ]
if (is_ios) {
deps = [
":sqlite_regexp",
]
}
}
if (is_ios) {
source_set("sqlite_regexp") {
defines = [
# Necessary to statically compile the extension.
"SQLITE_CORE",
"SQLITE_DISABLE_FTS3_UNICODE",
"SQLITE_DISABLE_FTS4_DEFERRED",
"SQLITE_ENABLE_FTS3",
"SQLITE_ENABLE_ICU",
"SQLITE_ENABLE_MEMORY_MANAGEMENT",
"SQLITE_SECURE_DELETE",
"SQLITE_SEPARATE_CACHE_POOLS",
"THREADSAFE",
]
sources = [
"src/ext/icu/icu.c",
]
deps = [
"//third_party/icu",
]
if (is_clang) {
# src/ext/icu/icu.c uses assert(!"string") which causes warnings about
# conversion from string literal to bool.
configs -= [ "//build/config/clang:extra_warnings" ]
}
}
}
}