Skip to content

Commit

Permalink
Convert from using env['PLATFORM'] directly to using the more flexible
Browse files Browse the repository at this point in the history
and better-thought-out Hammer env.Bits() idioms:
* env['PLATFORM'] == 'win32' => env.Bit('windows')
* env['PLATFORM'] == 'posix' => env.Bit('linux')
* env['PLATFORM'] == 'darwin' => env.Bit('mac')
New idioms:
* env.Bit('posix') => really does mean "any POSIX platform"
* env.AnyBits('mac', 'linux') => specifically mac or linux, excluding
  other POSIX platforms
Where we were using compound conditionals (e.g., "env['PLATFORM'] in
('posix', 'darwin')") I tried to take my best shot at translating
the intent (i.e., "env.Bits('posix')" for something POSIX, "not
env.Bits('mac')" for something not yet ported to Mac, etc.)
Review URL: http://codereview.chromium.org/15051

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7270 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
sgk@google.com committed Dec 18, 2008
1 parent db86350 commit b96fc5d
Show file tree
Hide file tree
Showing 87 changed files with 248 additions and 225 deletions.
16 changes: 8 additions & 8 deletions base/base_lib.scons
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env.ApplySConscript([
'$ICU38_DIR/using_icu38.scons',
])

if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
env.Prepend(
CCFLAGS = [
'/Wp64',
Expand Down Expand Up @@ -84,7 +84,7 @@ input_files = [
# Add object files David M Gay's dtoa and g_fmt third party lib. We
# compile these separately so we can disable warnings.
env_dmg_fp = env.Clone()
if env_dmg_fp['PLATFORM'] == 'win32':
if env_dmg_fp.Bit('windows'):
env_dmg_fp.Append(
CCFLAGS = [
'/wd4018',
Expand All @@ -93,7 +93,7 @@ if env_dmg_fp['PLATFORM'] == 'win32':
'/wd4554',
],
)
elif env_dmg_fp['PLATFORM'] in ('darwin', 'posix'):
elif env_dmg_fp.Bit('posix'):
for var in ['CCFLAGS', 'CXXFLAGS']:
if '-Wall' in env_dmg_fp[var]:
env_dmg_fp[var].remove('-Wall')
Expand All @@ -104,7 +104,7 @@ input_files.extend([
env_dmg_fp.Object('third_party/dmg_fp/g_fmt.cc'),
])

if env['PLATFORM'] in ('posix', 'darwin'):
if env.Bit('posix'):
# Remove files that still need to be ported from the input_files list.
# TODO(port): delete files from this list as they get ported.
to_be_ported_files = [
Expand All @@ -123,7 +123,7 @@ if env['PLATFORM'] in ('posix', 'darwin'):
for remove in to_be_ported_files:
input_files.remove(remove)

if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
input_files.extend([
'base_drag_source.cc',
'base_drop_target.cc',
Expand Down Expand Up @@ -162,7 +162,7 @@ if env['PLATFORM'] == 'win32':
'worker_pool.cc',
])

if env['PLATFORM'] in ('darwin', 'posix'):
if env.Bit('posix'):
input_files.extend([
'condition_variable_posix.cc',
'debug_util_posix.cc',
Expand All @@ -182,7 +182,7 @@ if env['PLATFORM'] in ('darwin', 'posix'):
'waitable_event_generic.cc',
])

if env['PLATFORM'] == 'darwin':
if env.Bit('mac'):
input_files.extend([
'base_paths_mac.mm',
'clipboard_mac.mm',
Expand All @@ -198,7 +198,7 @@ if env['PLATFORM'] == 'darwin':
'worker_pool_mac.mm',
])

if env['PLATFORM'] == 'posix':
if env.Bit('linux'):
input_files.extend([
'atomicops_internals_x86_gcc.cc',
'base_paths_linux.cc',
Expand Down
14 changes: 7 additions & 7 deletions base/base_unittests.scons
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ env.ApplySConscript([
'$ZLIB_DIR/using_zlib.scons',
])

if env['PLATFORM'] in ('posix', 'darwin'):
if env.Bit('posix'):
env.ApplySConscript([
'$LIBEVENT_DIR/using_libevent.scons',
])

if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
env.Prepend(
CCFLAGS = [
'/TP',
'/WX',
],
)

if env['PLATFORM'] == 'posix':
if env.Bit('linux'):
env.Append(
# We need 'Xss' (X Screen Saver) in LIBS if we want idletimer_unittest
LIBS = [
Expand Down Expand Up @@ -99,7 +99,7 @@ input_files = [
'gfx/rect_unittest.cc',
]

if env['PLATFORM'] in ('posix', 'darwin'):
if env.Bit('posix'):
# Remove files that still need to be ported from the input_files list.
# TODO(port): delete files from this list as they get ported.
to_be_ported_files = [
Expand All @@ -112,7 +112,7 @@ if env['PLATFORM'] in ('posix', 'darwin'):
for remove in to_be_ported_files:
input_files.remove(remove)

if env['PLATFORM'] == 'darwin':
if env.Bit('mac'):
# Remove files that still need to be ported from the input_files list.
# TODO(port): delete files from this list as they get ported.
to_be_ported_files = [
Expand All @@ -123,7 +123,7 @@ if env['PLATFORM'] == 'darwin':
input_files.remove(remove)


if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
# Windows-specific tests.
input_files.extend([
'directory_watcher_unittest.cc',
Expand All @@ -136,7 +136,7 @@ if env['PLATFORM'] == 'win32':
'wmi_util_unittest.cc',
])

if env['PLATFORM'] == 'darwin':
if env.Bit('mac'):
# Mac-specific tests.
input_files.extend([
'mac_util_unittest.cc',
Expand Down
8 changes: 4 additions & 4 deletions base/gfx/base_gfx.scons
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env.ApplySConscript([
'$ZLIB_DIR/using_zlib.scons',
])

if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
env.Prepend(
CCFLAGS = [
'/WX',
Expand All @@ -34,7 +34,7 @@ input_files = [
'size.cc',
]

if env['PLATFORM'] in ('posix', 'darwin'):
if env.Bit('posix'):
# Remove files that still need to be ported from the input_files list.
# TODO(port): delete files from this list as they get ported.
to_be_ported_files = [
Expand All @@ -44,10 +44,10 @@ if env['PLATFORM'] in ('posix', 'darwin'):
for remove in to_be_ported_files:
input_files.remove(remove)

if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
input_files.extend([
])
elif env['PLATFORM'] == 'posix':
elif env.Bit('linux'):
input_files.extend([
])

Expand Down
6 changes: 3 additions & 3 deletions breakpad/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ env.Prepend(
],
)

if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
env.Append(
CCFLAGS = [
'/TP',
Expand All @@ -29,7 +29,7 @@ if env['PLATFORM'] == 'win32':
env.ChromeStaticLibrary('breakpad_sender', sender_input_files)


if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
handler_input_files = [
'src/client/windows/crash_generation/client_info.cc',
'src/client/windows/crash_generation/minidump_generator.cc',
Expand All @@ -38,7 +38,7 @@ if env['PLATFORM'] == 'win32':
'src/client/windows/crash_generation/crash_generation_server.cc',
'src/client/windows/crash_generation/crash_generation_client.cc',
]
elif env['PLATFORM'] == 'posix':
elif env.Bit('linux'):
handler_input_files = [
'src/common/linux/guid_creator.cc',
'src/client/linux/handler/exception_handler.cc',
Expand Down
4 changes: 2 additions & 2 deletions build/SConscript.v8
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ v8_scons_targets_on = [
'$V8_MODE_DIR/snapshot${OBJSUFFIX}',
]

if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
v8_scons_targets_off.extend([
env.File('$V8_DIR/vc80.pdb')
])
Expand All @@ -79,7 +79,7 @@ env.Install('$LIBS_DIR', v8[1])
env.Install('$V8_DIR', '$V8_MODE_DIR/snapshot-empty${OBJSUFFIX}')

# To satisfy tests expecting the following .exe name.
if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
# TODO(evanm): this may be necessary on other platforms(?)
i = env.InstallAs('$TARGET_ROOT/v8_shell_sample${PROGSUFFIX}', v8[0])

Expand Down
2 changes: 1 addition & 1 deletion build/debug.scons
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env.Append(
],
)

if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
if env.get('INCREMENTAL') is None:
# INCREMENTAL was not specified on the command line or in the
# external environment; debug default is incremental link.
Expand Down
2 changes: 1 addition & 1 deletion build/external_code.scons
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ External code settings for Chromium builds.

Import("env")

if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
env.Append(
CPPDEFINES = [
'_CRT_SECURE_NO_DEPRECATE',
Expand Down
2 changes: 1 addition & 1 deletion build/googleurl_lib.scons
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ env.Prepend(
],
)

if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
env.Append(
CCFLAGS = [
'/TP',
Expand Down
2 changes: 1 addition & 1 deletion build/googleurl_unittests.scons
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env.Prepend(
],
)

if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
env.Append(
CCFLAGS = [
'/TP',
Expand Down
6 changes: 3 additions & 3 deletions build/internal/essential.scons
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ env.Append(
],
)

if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
incremental = env.get('INCREMENTAL')
if incremental is not None:
if incremental:
Expand Down Expand Up @@ -110,7 +110,7 @@ if env['PLATFORM'] == 'win32':
'/EH', # VCCLCompilerTool.ExceptionHandling="0"
],
)
elif env['PLATFORM'] == 'posix':
elif env.Bit('linux'):
pass
elif env['PLATFORM'] == 'mac':
elif env.Bit('mac'):
pass
2 changes: 1 addition & 1 deletion build/internal/release_impl_dom_stats.scons
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env.Append(
],
)

if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
env.Replace(
CHROMIUM_LINK_OPT_FLAGS = [
'/OPT:REF', # VCLinkerTool.OptimizeReferences="2"
Expand Down
18 changes: 9 additions & 9 deletions chrome/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ env.Prepend(


# TODO(port)
if env_res['PLATFORM'] == 'win32':
if env_res.Bit('windows'):
env_res.Append(
CPPPATH = [
'.',
Expand Down Expand Up @@ -139,7 +139,7 @@ env_dll.Append(
],
)

if env_dll['PLATFORM'] == 'win32':
if env_dll.Bit('windows'):
env_dll.Append(
LIBS = [
# TODO(sgk): to be ported to Mac and Linux
Expand Down Expand Up @@ -190,7 +190,7 @@ if env_dll['PLATFORM'] == 'win32':

input_files = []

if env_dll['PLATFORM'] == 'win32':
if env_dll.Bit('windows'):
input_files.extend([
'app/chrome_dll_main.cc',
'$V8_DIR/snapshot-empty$OBJSUFFIX',
Expand Down Expand Up @@ -226,7 +226,7 @@ grit_files.extend(google_chrome)


# TODO(port)
if env_dll['PLATFORM'] == 'win32':
if env_dll.Bit('windows'):
dll_targets = env_dll.ChromeSharedLibrary('chrome_dll/chrome',
dll_resources + input_files,
PDB='chrome_dll.pdb')
Expand Down Expand Up @@ -300,7 +300,7 @@ env_exe.Append(
)

# TODO(port)
if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
chrome_exe = env_exe.ChromeProgram(
'chrome_exe/chrome',
[
Expand Down Expand Up @@ -366,7 +366,7 @@ flats = [
]

# TODO(port)
if env_flat['PLATFORM'] == 'win32':
if env_flat.Bit('windows'):
flats_out = []
for i in flats:
flats_out.extend(env_flat.FlatHtml(i))
Expand All @@ -383,7 +383,7 @@ if not env.WantSystemLib('sqlite'):
sconscript_files.append('$THIRD_PARTY_DIR/sqlite/SConscript')

# TODO(port)
if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
sconscript_files.extend([
'app/resources/SConscript',
'app/theme/SConscript',
Expand All @@ -394,7 +394,7 @@ if env['PLATFORM'] == 'win32':
env.SConscript(sconscript_files, exports=['env', 'env_res', 'env_test'])

# TODO(port)
if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
env.InstallAs('$LIBS_DIR/${LIBPREFIX}jscre${LIBSUFFIX}',
'$WEBKIT_DIR/JavaScriptCore_pcre.lib')

Expand All @@ -408,7 +408,7 @@ gears_plugins = [
]

# TODO(port)
if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
env.Install('$DESTINATION_ROOT/plugins/gears', gears_plugins)

env.Command('$DESTINATION_ROOT/resources/inspector',
Expand Down
10 changes: 5 additions & 5 deletions chrome/browser/browser.scons
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ env.Prepend(
],
)

if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
env.Prepend(
CPPPATH = [
'$CHROME_DIR/tools/build/win',
Expand All @@ -39,7 +39,7 @@ if env['PLATFORM'] == 'win32':

input_files = []

if env['PLATFORM'] in ('posix', 'win32'):
if not env.Bit('mac'):
# TODO: Port to Mac.
input_files.extend([
'autocomplete/keyword_provider.cc',
Expand Down Expand Up @@ -117,7 +117,7 @@ if env['PLATFORM'] in ('posix', 'win32'):
'webdata/web_database.cc',
])

if env['PLATFORM'] == 'win32':
if env.Bit('windows'):
# TODO: Port these.
input_files.extend([
'autofill_manager.cc',
Expand Down Expand Up @@ -300,11 +300,11 @@ if env['PLATFORM'] == 'win32':
'web_contents_view_win.cc',
])

if env['PLATFORM'] in ('darwin', 'posix'):
if env.Bit('posix'):
input_files.extend([
'importer/firefox_profile_lock_posix.cc',
])

if env['PLATFORM'] in ('posix', 'win32'):
if not env.Bit('mac'):
# TODO: This should work for all platforms.
env.ChromeStaticLibrary('browser', input_files)
Loading

0 comments on commit b96fc5d

Please sign in to comment.