summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshess <shess@chromium.org>2015-08-31 17:30:54 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-01 00:31:26 +0000
commitf71db5c36625ff00feb8283028631303ae5caa7c (patch)
tree8fc79afa22c7619dfb4dc577cf1b69362b1e4e5f
parent7f8d24c802186fec1018a955a04a2b36152f3872 (diff)
downloadchromium_src-f71db5c36625ff00feb8283028631303ae5caa7c.zip
chromium_src-f71db5c36625ff00feb8283028631303ae5caa7c.tar.gz
chromium_src-f71db5c36625ff00feb8283028631303ae5caa7c.tar.bz2
[sqlite] Respect the gyp and gn component switch.
SQLITE_API is the existing mechanism SQLite provides, and is used in preference to inventing a new SQLITE_EXPORT symbol (like sql/sql_export.h and other examples). CoreServices.framework is necessary on OSX because of the Time Machine patch. Remove sql/proxy.{h,cc}, which was necessary to work around SQLite linking statically into both component shlibs and unit test executables. [Relanding https://codereview.chromium.org/1322463002/ ] BUG=489444 TBR=michaeln@chromium.org, thakis@chromium.org, brettw@chromium.org Review URL: https://codereview.chromium.org/1306863006 Cr-Commit-Position: refs/heads/master@{#346536}
-rw-r--r--sql/BUILD.gn2
-rw-r--r--sql/connection_unittest.cc13
-rw-r--r--sql/proxy.cc28
-rw-r--r--sql/proxy.h39
-rw-r--r--sql/sql.gyp2
-rw-r--r--third_party/sqlite/BUILD.gn31
-rw-r--r--third_party/sqlite/sqlite.gyp12
7 files changed, 45 insertions, 82 deletions
diff --git a/sql/BUILD.gn b/sql/BUILD.gn
index 38f85b4..57f1b38 100644
--- a/sql/BUILD.gn
+++ b/sql/BUILD.gn
@@ -13,8 +13,6 @@ component("sql") {
"init_status.h",
"meta_table.cc",
"meta_table.h",
- "proxy.cc",
- "proxy.h",
"recovery.cc",
"recovery.h",
"statement.cc",
diff --git a/sql/connection_unittest.cc b/sql/connection_unittest.cc
index df35dd1..aa9dbeb 100644
--- a/sql/connection_unittest.cc
+++ b/sql/connection_unittest.cc
@@ -12,7 +12,6 @@
#include "sql/connection.h"
#include "sql/correct_sql_test_base.h"
#include "sql/meta_table.h"
-#include "sql/proxy.h"
#include "sql/statement.h"
#include "sql/test/error_callback_support.h"
#include "sql/test/scoped_error_ignorer.h"
@@ -86,12 +85,12 @@ class ScopedScalarFunction {
int args,
base::Callback<void(sqlite3_context*,int,sqlite3_value**)> cb)
: db_(db.db_), function_name_(function_name), cb_(cb) {
- sql::sqlite3_create_function_v2(db_, function_name, args, SQLITE_UTF8,
- this, &Run, NULL, NULL, NULL);
+ ::sqlite3_create_function_v2(db_, function_name, args, SQLITE_UTF8,
+ this, &Run, NULL, NULL, NULL);
}
~ScopedScalarFunction() {
- sql::sqlite3_create_function_v2(db_, function_name_, 0, SQLITE_UTF8,
- NULL, NULL, NULL, NULL, NULL);
+ ::sqlite3_create_function_v2(db_, function_name_, 0, SQLITE_UTF8,
+ NULL, NULL, NULL, NULL, NULL);
}
private:
@@ -115,10 +114,10 @@ class ScopedCommitHook {
base::Callback<int(void)> cb)
: db_(db.db_),
cb_(cb) {
- sql::sqlite3_commit_hook(db_, &Run, this);
+ ::sqlite3_commit_hook(db_, &Run, this);
}
~ScopedCommitHook() {
- sql::sqlite3_commit_hook(db_, NULL, NULL);
+ ::sqlite3_commit_hook(db_, NULL, NULL);
}
private:
diff --git a/sql/proxy.cc b/sql/proxy.cc
deleted file mode 100644
index 5104812..0000000
--- a/sql/proxy.cc
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2015 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.
-
-#include "sql/proxy.h"
-
-namespace sql {
-
-int sqlite3_create_function_v2(
- sqlite3 *db,
- const char *zFunctionName,
- int nArg,
- int eTextRep,
- void *pApp,
- void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
- void (*xStep)(sqlite3_context*,int,sqlite3_value**),
- void (*xFinal)(sqlite3_context*),
- void (*xDestroy)(void*)) {
- return ::sqlite3_create_function_v2(
- db, zFunctionName, nArg, eTextRep, pApp,
- xFunc, xStep, xFinal, xDestroy);
-}
-
-void *sqlite3_commit_hook(sqlite3* db, int(*func)(void*), void* arg) {
- return ::sqlite3_commit_hook(db, func, arg);
-}
-
-} // namespace sql
diff --git a/sql/proxy.h b/sql/proxy.h
deleted file mode 100644
index 7a2863b..0000000
--- a/sql/proxy.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright 2015 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.
-
-#ifndef SQL_PROXY_H_
-#define SQL_PROXY_H_
-
-#include "sql/sql_export.h"
-#include "third_party/sqlite/sqlite3.h"
-
-// TODO(shess): third_party/sqlite does not track component build correctly, so
-// each shared library gets a private copy of everything, so sqlite3_* calls
-// outside of the main sql/ component don't work right. Hack around this by
-// adding pass-through functions while I land a separate fix for the component
-// issue.
-
-// This is only required for tests - if these abilities are desired for
-// production code, they should probably do obvious things like live in
-// sql::Connection and use C++ wrappers.
-
-// http://crbug.com/489444
-
-namespace sql {
-
-SQL_EXPORT int sqlite3_create_function_v2(
- sqlite3 *db,
- const char *zFunctionName,
- int nArg,
- int eTextRep,
- void *pApp,
- void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
- void (*xStep)(sqlite3_context*,int,sqlite3_value**),
- void (*xFinal)(sqlite3_context*),
- void (*xDestroy)(void*));
-SQL_EXPORT void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
-
-} // namespace sql
-
-#endif // SQL_PROXY_H_
diff --git a/sql/sql.gyp b/sql/sql.gyp
index d983a45..018b287 100644
--- a/sql/sql.gyp
+++ b/sql/sql.gyp
@@ -27,8 +27,6 @@
'init_status.h',
'meta_table.cc',
'meta_table.h',
- 'proxy.cc',
- 'proxy.h',
'recovery.cc',
'recovery.h',
'statement.cc',
diff --git a/third_party/sqlite/BUILD.gn b/third_party/sqlite/BUILD.gn
index ac14a2c..d9fef6e 100644
--- a/third_party/sqlite/BUILD.gn
+++ b/third_party/sqlite/BUILD.gn
@@ -10,6 +10,8 @@ declare_args() {
}
if (!use_system_sqlite) {
+ # TODO(shess): This cannot possibly be the right thing to do. AFAICT it is
+ # only necessary so that WebDatabase can #include <sqlite3.h>.
config("sqlite_config") {
include_dirs = [ "." ]
}
@@ -35,7 +37,9 @@ if (!use_system_sqlite) {
}
}
- source_set("sqlite") {
+ component("sqlite_build") {
+ visibility = [ ":*" ]
+
sources = [
"amalgamation/sqlite3.c",
"amalgamation/sqlite3.h",
@@ -52,6 +56,13 @@ if (!use_system_sqlite) {
"SQLITE_SEPARATE_CACHE_POOLS",
"THREADSAFE",
]
+ if (is_component_build) {
+ if (is_win) {
+ defines += [ "SQLITE_API=__declspec(dllexport)" ]
+ } else {
+ defines += [ "SQLITE_API=__attribute__((visibility(\"default\")))" ]
+ }
+ }
if (is_chromeos) {
defines += [
# Despite obvious warnings about not using this flag in deployment, we
@@ -85,7 +96,10 @@ if (!use_system_sqlite) {
if (is_linux) {
libs = [ "dl" ]
} else if (is_mac || is_ios) {
- libs = [ "CoreFoundation.framework" ]
+ libs = [
+ "CoreFoundation.framework",
+ "CoreServices.framework",
+ ]
} else if (is_android) {
defines += [
"SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT=1048576",
@@ -99,8 +113,19 @@ if (!use_system_sqlite) {
deps = [
"//third_party/icu",
]
+ }
- public_configs = [ ":sqlite_config" ]
+ config("sqlite_export") {
+ if (is_component_build && is_win) {
+ defines = [ "SQLITE_API=__declspec(dllimport)" ]
+ }
+ }
+
+ # This is used to allow the SQLITE_API definition to be different when
+ # building sqlite3.c than it is when clients include sqlite3.h.
+ group("sqlite") {
+ public_deps = [ ":sqlite_build" ]
+ public_configs = [ ":sqlite_export", ":sqlite_config" ]
}
if (is_linux) {
diff --git a/third_party/sqlite/sqlite.gyp b/third_party/sqlite/sqlite.gyp
index 61bfd9d..f4b3175 100644
--- a/third_party/sqlite/sqlite.gyp
+++ b/third_party/sqlite/sqlite.gyp
@@ -116,7 +116,7 @@
],
}, { # !use_system_sqlite
'product_name': 'sqlite3',
- 'type': 'static_library',
+ 'type': '<(component)',
'sources': [
'amalgamation/sqlite3.h',
'amalgamation/sqlite3.c',
@@ -148,6 +148,15 @@
4244, 4267,
],
'conditions': [
+ ['OS == "win" and component == "shared_library"', {
+ 'defines': ['SQLITE_API=__declspec(dllexport)'],
+ 'direct_dependent_settings': {
+ 'defines': ['SQLITE_API=__declspec(dllimport)'],
+ },
+ }],
+ ['OS != "win" and component == "shared_library"', {
+ 'defines': ['SQLITE_API=__attribute__((visibility("default")))'],
+ }],
['OS=="linux"', {
'link_settings': {
'libraries': [
@@ -159,6 +168,7 @@
'link_settings': {
'libraries': [
'$(SDKROOT)/System/Library/Frameworks/CoreFoundation.framework',
+ '$(SDKROOT)/System/Library/Frameworks/CoreServices.framework',
],
},
}],