From 63e39a28e492e8f9a10d05cd970da2a1d539c0f3 Mon Sep 17 00:00:00 2001 From: "darin@chromium.org" Date: Wed, 13 Jul 2011 20:41:28 +0000 Subject: [PATCH] Add COMPONENT_BUILD global define. This avoids the need to define FOO_DLL macros for each project that we wish to optionally build as a DLL (when component=="shared_library"). This in turn means that we do not need direct_dependent_settings to define FOO_DLL, and that means that we don't need to update projects to convert transitive dependencies into explicit dependencies. This makes the component build more consistent with the static build. An alternative would be to use all_dependent_settings, but I feel that the global approach is simpler as it creates less repetition in each target definition for components. A side-effect of this change is that I needed to make base_nacl_win64 be a shared_library in the component build. R=rvargas,bradnelson,evan Review URL: http://codereview.chromium.org/7344022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@92409 0039d316-1c4b-4281-b951-d872f2087c98 --- base/at_exit.cc | 2 +- base/base.gypi | 49 +++++++++++++++++------ base/base_api.h | 4 +- base/debug/debug_on_start_win.h | 4 +- base/logging.h | 2 +- build/common.gypi | 8 ++++ chrome/chrome.gyp | 2 + chrome/chrome_dll.gypi | 1 + chrome/chrome_exe.gypi | 1 + crypto/crypto.gyp | 6 --- crypto/crypto_api.h | 4 +- ipc/ipc.gypi | 1 + net/base/net_api.h | 4 +- net/base/ssl_false_start_blacklist.h | 4 +- net/net.gyp | 19 --------- sandbox/sandbox.gyp | 1 + ui/base/resource/resource_bundle_dummy.cc | 17 +++----- 17 files changed, 67 insertions(+), 62 deletions(-) diff --git a/base/at_exit.cc b/base/at_exit.cc index cafe75be7f4416..c7daad40f8e536 100644 --- a/base/at_exit.cc +++ b/base/at_exit.cc @@ -22,7 +22,7 @@ static AtExitManager* g_top_manager = NULL; AtExitManager::AtExitManager() : next_manager_(g_top_manager) { // If multiple modules instantiate AtExitManagers they'll end up living in this // module... they have to coexist. -#if !defined(BASE_DLL) +#if !defined(COMPONENT_BUILD) DCHECK(!g_top_manager); #endif g_top_manager = this; diff --git a/base/base.gypi b/base/base.gypi index 79bff9bc5c1a27..ea23a8ef29b833 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -535,25 +535,13 @@ },], [ 'component=="shared_library"', { 'defines': [ - 'BASE_DLL', 'BASE_IMPLEMENTATION', ], 'conditions': [ ['OS=="win"', { - 'msvs_disabled_warnings': [ - 4251, - ], 'sources!': [ 'debug/debug_on_start_win.cc', ], - 'direct_dependent_settings': { - 'defines': [ - 'BASE_DLL', - ], - 'msvs_disabled_warnings': [ - 4251, - ], - }, }], ], }], @@ -605,7 +593,7 @@ 'targets': [ { 'target_name': 'base_nacl_win64', - 'type': 'static_library', + 'type': '<(component)', 'variables': { 'base_target': 1, }, @@ -631,6 +619,41 @@ 'msvs_target_platform': 'x64', }, }, + 'conditions': [ + [ 'component == "shared_library"', { + 'defines': [ + 'BASE_IMPLEMENTATION', + ], + 'sources!': [ + 'debug/debug_on_start_win.cc', + ], + }], + ], + }, + { + 'target_name': 'base_i18n_nacl_win64', + 'type': 'static_library', + # TODO(gregoryd): direct_dependent_settings should be shared with the + # 32-bit target, but it doesn't work due to a bug in gyp + 'direct_dependent_settings': { + 'include_dirs': [ + '..', + ], + }, + 'defines': [ + '<@(nacl_win64_defines)', + ], + 'include_dirs': [ + '..', + ], + 'sources': [ + 'i18n/icu_util_nacl_win64.cc', + ], + 'configurations': { + 'Common_Base': { + 'msvs_target_platform': 'x64', + }, + }, }, ], }], diff --git a/base/base_api.h b/base/base_api.h index 2361659e19fea2..deeae078ea6b4d 100644 --- a/base/base_api.h +++ b/base/base_api.h @@ -6,7 +6,7 @@ #define BASE_BASE_API_H_ #pragma once -#if defined(BASE_DLL) +#if defined(COMPONENT_BUILD) #if defined(WIN32) #if defined(BASE_IMPLEMENTATION) @@ -19,7 +19,7 @@ #define BASE_API __attribute__((visibility("default"))) #endif -#else // defined(BASE_DLL) +#else // defined(COMPONENT_BUILD) #define BASE_API #endif diff --git a/base/debug/debug_on_start_win.h b/base/debug/debug_on_start_win.h index 4a5c1201b8cb26..86d4721c08b8c8 100644 --- a/base/debug/debug_on_start_win.h +++ b/base/debug/debug_on_start_win.h @@ -27,7 +27,7 @@ namespace debug { // There is no way for this code, as currently implemented, to work across DLLs. // TODO(rvargas): It looks like we really don't use this code, at least not for // Chrome. Figure out if it's really worth implementing something simpler. -#if !defined(BASE_DLL) +#if !defined(COMPONENT_BUILD) // Debug on start functions and data. class DebugOnStart { @@ -74,7 +74,7 @@ DECLSPEC_SELECTANY DebugOnStart::PIFV debug_on_start = &DebugOnStart::Init; #endif // _WIN64 -#endif // defined(BASE_DLL) +#endif // defined(COMPONENT_BUILD) } // namespace debug } // namespace base diff --git a/base/logging.h b/base/logging.h index 849de0e33292ff..0a3a6a3942cf2c 100644 --- a/base/logging.h +++ b/base/logging.h @@ -469,7 +469,7 @@ std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) { } // MSVC doesn't like complex extern templates and DLLs. -#if !defined(COMPILER_MSVC) && defined(BASE_DLL) +#if !defined(COMPILER_MSVC) && !defined(COMPONENT_BUILD) // Commonly used instantiations of MakeCheckOpString<>. Explicitly instantiated // in logging.cc. extern template std::string* MakeCheckOpString( diff --git a/build/common.gypi b/build/common.gypi index 4ed9fefe2b6225..9b67d7367c1a91 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -694,6 +694,9 @@ }, { # else: branding!="Chrome" 'defines': ['CHROMIUM_BUILD'], }], + ['component=="shared_library"', { + 'defines': ['COMPONENT_BUILD'], + }], ['toolkit_views==1', { 'defines': ['TOOLKIT_VIEWS=1'], }], @@ -922,6 +925,11 @@ }, }, }], + ['OS=="win" and component=="shared_library"', { + 'msvs_disabled_warnings': [ + 4251, # class 'std::xx' needs to have dll-interface. + ], + }], ['chromeos!=1', { 'sources/': [ ['exclude', '_chromeos\\.(h|cc)$'] ] }], diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 9edc4ef7cd58ff..83e8ea59dda893 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -39,6 +39,8 @@ 'common_nacl_win64', 'common_constants_win64', 'installer_util_nacl_win64', + '../base/base.gyp:base_static_win64', + '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations_win64', ], 'allocator_target': '../base/allocator/allocator.gyp:allocator', 'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/chrome', diff --git a/chrome/chrome_dll.gypi b/chrome/chrome_dll.gypi index 602e78cbe8d081..e8919b09ddf460 100644 --- a/chrome/chrome_dll.gypi +++ b/chrome/chrome_dll.gypi @@ -588,6 +588,7 @@ '<@(nacl_win64_dependencies)', 'chrome_dll_version', 'nacl_win64', + '../base/base.gyp:base_i18n_nacl_win64', ], 'defines': [ '<@(nacl_win64_defines)', diff --git a/chrome/chrome_exe.gypi b/chrome/chrome_exe.gypi index 6ab3910462fd74..84810ee38df182 100644 --- a/chrome/chrome_exe.gypi +++ b/chrome/chrome_exe.gypi @@ -505,6 +505,7 @@ '../breakpad/breakpad.gyp:breakpad_handler_win64', '../breakpad/breakpad.gyp:breakpad_sender_win64', '../base/base.gyp:base_nacl_win64', + '../base/base.gyp:base_static_win64', '../sandbox/sandbox.gyp:sandbox_win64', ], 'defines': [ diff --git a/crypto/crypto.gyp b/crypto/crypto.gyp index a6df806d6b7e2c..f660e4cd0eede1 100644 --- a/crypto/crypto.gyp +++ b/crypto/crypto.gyp @@ -76,14 +76,8 @@ }], [ 'component == "shared_library"', { 'defines': [ - 'CRYPTO_DLL', 'CRYPTO_IMPLEMENTATION', ], - 'direct_dependent_settings': { - 'defines': [ - 'CRYPTO_DLL', - ], - }, }], [ 'use_openssl==1', { # TODO(joth): Use a glob to match exclude patterns once the diff --git a/crypto/crypto_api.h b/crypto/crypto_api.h index b8af452def2e9c..2787af84974bdf 100644 --- a/crypto/crypto_api.h +++ b/crypto/crypto_api.h @@ -6,7 +6,7 @@ #define CRYPTO_CRYPTO_API_H_ #pragma once -#if defined(CRYPTO_DLL) +#if defined(COMPONENT_BUILD) #if defined(WIN32) #if defined(CRYPTO_IMPLEMENTATION) @@ -19,7 +19,7 @@ #define CRYPTO_API __attribute__((visibility("default"))) #endif -#else // defined(CRYPTO_DLL) +#else // defined(COMPONENT_BUILD) #define CRYPTO_API #endif diff --git a/ipc/ipc.gypi b/ipc/ipc.gypi index 65966af5fe49c5..38aead208e84ea 100644 --- a/ipc/ipc.gypi +++ b/ipc/ipc.gypi @@ -84,6 +84,7 @@ }, 'dependencies': [ '../base/base.gyp:base_nacl_win64', + '../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', ], # TODO(gregoryd): direct_dependent_settings should be shared with the # 32-bit target, but it doesn't work due to a bug in gyp diff --git a/net/base/net_api.h b/net/base/net_api.h index 610e974109ad4b..4b017fdfd8728f 100644 --- a/net/base/net_api.h +++ b/net/base/net_api.h @@ -10,7 +10,7 @@ // exported to consumers, and NET_TEST that allows unit tests to access features // not intended to be used directly by real consumers. -#if defined(NET_DLL) +#if defined(COMPONENT_BUILD) #if defined(WIN32) #if defined(NET_IMPLEMENTATION) @@ -26,7 +26,7 @@ #define NET_TEST __attribute__((visibility("default"))) #endif -#else /// defined(NET_DLL) +#else /// defined(COMPONENT_BUILD) #define NET_API #define NET_TEST #endif diff --git a/net/base/ssl_false_start_blacklist.h b/net/base/ssl_false_start_blacklist.h index 522282252bb7ec..17596308d99bd1 100644 --- a/net/base/ssl_false_start_blacklist.h +++ b/net/base/ssl_false_start_blacklist.h @@ -14,11 +14,11 @@ namespace net { // to TLS False Start. Because this set is several hundred long, it's // precompiled by the code in ssl_false_start_blacklist_process.cc into a hash // table for fast lookups. -class NET_TEST SSLFalseStartBlacklist { +class SSLFalseStartBlacklist { public: // IsMember returns true if the given host is in the blacklist. // host: a DNS name in dotted form (i.e. "www.example.com") - static bool IsMember(const char* host); + NET_TEST static bool IsMember(const char* host); // Hash returns the modified djb2 hash of the given string. static unsigned Hash(const char* str) { diff --git a/net/net.gyp b/net/net.gyp index 1eb0a8d24b6507..31afc1747f8095 100644 --- a/net/net.gyp +++ b/net/net.gyp @@ -822,27 +822,8 @@ ], [ 'component == "shared_library"', { 'defines': [ - 'NET_DLL', 'NET_IMPLEMENTATION', ], - 'direct_dependent_settings': { - 'defines': [ - 'NET_DLL', - ], - }, - 'conditions': [ - [ 'OS == "win"', { - 'msvs_disabled_warnings': [ - # class 'std::xx' needs to have dll-interface. - 4251, - ], - 'direct_dependent_settings': { - 'msvs_disabled_warnings': [ - 4251, - ], - }, - }], - ], }], [ 'OS == "mac"', { 'dependencies': [ diff --git a/sandbox/sandbox.gyp b/sandbox/sandbox.gyp index 26699caf358cbe..a9ea6f4854c13e 100644 --- a/sandbox/sandbox.gyp +++ b/sandbox/sandbox.gyp @@ -239,6 +239,7 @@ 'dependencies': [ '../testing/gtest.gyp:gtest', '../base/base.gyp:base_nacl_win64', + '../base/base.gyp:base_static_win64', ], 'configurations': { 'Common_Base': { diff --git a/ui/base/resource/resource_bundle_dummy.cc b/ui/base/resource/resource_bundle_dummy.cc index 82afaab806d17f..0dbf1f1f1678b3 100644 --- a/ui/base/resource/resource_bundle_dummy.cc +++ b/ui/base/resource/resource_bundle_dummy.cc @@ -8,26 +8,19 @@ #include "base/logging.h" #include "base/synchronization/lock.h" -#include "ui/gfx/font.h" -#include "ui/gfx/platform_font_win.h" // NOTE(gregoryd): This is a hack to avoid creating more nacl_win64-specific // files. The font members of ResourceBundle are never initialized in our code -// so this destructor is never called. +// so we can get away with an empty class definition. namespace gfx { -Font::~Font() { - NOTREACHED(); -} -PlatformFontWin::HFontRef::~HFontRef() { - NOTREACHED(); -} +class Font {}; } namespace ui { ResourceBundle* ResourceBundle::g_shared_instance_ = NULL; -/* static */ +// static std::string ResourceBundle::InitSharedInstance( const std::string& pref_locale) { DCHECK(g_shared_instance_ == NULL) << "ResourceBundle initialized twice"; @@ -35,7 +28,7 @@ std::string ResourceBundle::InitSharedInstance( return std::string(); } -/* static */ +// static void ResourceBundle::CleanupSharedInstance() { if (g_shared_instance_) { delete g_shared_instance_; @@ -43,7 +36,7 @@ void ResourceBundle::CleanupSharedInstance() { } } -/* static */ +// static ResourceBundle& ResourceBundle::GetSharedInstance() { // Must call InitSharedInstance before this function. CHECK(g_shared_instance_ != NULL);