Skip to content

Commit

Permalink
Add COMPONENT_BUILD global define.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
darin@chromium.org committed Jul 13, 2011
1 parent 8c01b7f commit 63e39a2
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 62 deletions.
2 changes: 1 addition & 1 deletion base/at_exit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
49 changes: 36 additions & 13 deletions base/base.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
},
}],
],
}],
Expand Down Expand Up @@ -605,7 +593,7 @@
'targets': [
{
'target_name': 'base_nacl_win64',
'type': 'static_library',
'type': '<(component)',
'variables': {
'base_target': 1,
},
Expand All @@ -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',
},
},
},
],
}],
Expand Down
4 changes: 2 additions & 2 deletions base/base_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -19,7 +19,7 @@
#define BASE_API __attribute__((visibility("default")))
#endif

#else // defined(BASE_DLL)
#else // defined(COMPONENT_BUILD)
#define BASE_API
#endif

Expand Down
4 changes: 2 additions & 2 deletions base/debug/debug_on_start_win.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion base/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, int>(
Expand Down
8 changes: 8 additions & 0 deletions build/common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,9 @@
}, { # else: branding!="Chrome"
'defines': ['CHROMIUM_BUILD'],
}],
['component=="shared_library"', {
'defines': ['COMPONENT_BUILD'],
}],
['toolkit_views==1', {
'defines': ['TOOLKIT_VIEWS=1'],
}],
Expand Down Expand Up @@ -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)$'] ]
}],
Expand Down
2 changes: 2 additions & 0 deletions chrome/chrome.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions chrome/chrome_dll.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@
'<@(nacl_win64_dependencies)',
'chrome_dll_version',
'nacl_win64',
'../base/base.gyp:base_i18n_nacl_win64',
],
'defines': [
'<@(nacl_win64_defines)',
Expand Down
1 change: 1 addition & 0 deletions chrome/chrome_exe.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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': [
Expand Down
6 changes: 0 additions & 6 deletions crypto/crypto.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions crypto/crypto_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -19,7 +19,7 @@
#define CRYPTO_API __attribute__((visibility("default")))
#endif

#else // defined(CRYPTO_DLL)
#else // defined(COMPONENT_BUILD)
#define CRYPTO_API
#endif

Expand Down
1 change: 1 addition & 0 deletions ipc/ipc.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions net/base/net_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions net/base/ssl_false_start_blacklist.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
19 changes: 0 additions & 19 deletions net/net.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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': [
Expand Down
1 change: 1 addition & 0 deletions sandbox/sandbox.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
'dependencies': [
'../testing/gtest.gyp:gtest',
'../base/base.gyp:base_nacl_win64',
'../base/base.gyp:base_static_win64',
],
'configurations': {
'Common_Base': {
Expand Down
17 changes: 5 additions & 12 deletions ui/base/resource/resource_bundle_dummy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,35 @@

#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";
g_shared_instance_ = new ResourceBundle();
return std::string();
}

/* static */
// static
void ResourceBundle::CleanupSharedInstance() {
if (g_shared_instance_) {
delete g_shared_instance_;
g_shared_instance_ = NULL;
}
}

/* static */
// static
ResourceBundle& ResourceBundle::GetSharedInstance() {
// Must call InitSharedInstance before this function.
CHECK(g_shared_instance_ != NULL);
Expand Down

0 comments on commit 63e39a2

Please sign in to comment.