# Copyright (c) 2006-2008 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.

Import('env')

env = env.Clone()

env.SConscript([
    '$BREAKPAD_DIR/using_breakpad.scons',
    '$CHROME_DIR/third_party/wtl/using_wtl.scons',
    '$GRIT_DIR/build/using_generated_resources.scons',
    '$ICU38_DIR/using_icu38.scons',
    '$LIBJPEG_DIR/using_libjpeg.scons',
    '$LIBPNG_DIR/using_libpng.scons',
    '$LIBXML_DIR/using_libxml.scons',
    '$NPAPI_DIR/using_npapi.scons',
    '$SKIA_DIR/using_skia.scons',
    '$ZLIB_DIR/using_zlib.scons',
], {'env':env})

env.Prepend(
    CPPPATH = [
        '$CHROME_DIR/app',
        '$CHROME_SRC_DIR',
    ],
)

env.Append(
    CPPPATH = [
        '$WEBKIT_DIR/build/localized_strings',
    ],
)

if env.Bit('windows'):
  env.Prepend(
      CPPPATH = [
          '$CHROME_DIR/tools/build/win',
      ],
  )

input_files = ChromeFileList([
  # TODO(sgk):  violate standard indentation so we don't have to
  # reindent too much when we remove the explicit MSVSFilter() calls
  # in favor of generating the hierarchy to reflect the file system.
  MSVSFilter('extensions', [
    'extensions/url_pattern.cc',
    'extensions/url_pattern.h',
    'extensions/user_script.cc',
    'extensions/user_script.h',
  ]),
  MSVSFilter('net', [
    'net/cookie_monster_sqlite.cc',
    'net/cookie_monster_sqlite.h',
    'net/dns.h',
    'net/url_request_intercept_job.cc',
    'net/url_request_intercept_job.h',
  ]),
  MSVSFilter('gfx', [
    'gfx/chrome_canvas.cc',
    'gfx/chrome_canvas.h',
    'gfx/chrome_canvas_skia.cc',
    'gfx/chrome_canvas_win.cc',
    'gfx/chrome_font.h',
    'gfx/chrome_font_gtk.cc',
    'gfx/chrome_font_skia.cc',
    'gfx/chrome_font_win.cc',
    'gfx/color_utils.cc',
    'gfx/color_utils.h',
    'gfx/emf.cc',
    'gfx/emf.h',
    'gfx/favicon_size.h',
    'gfx/icon_util.cc',
    'gfx/icon_util.h',
    'gfx/insets.h',
    'gfx/path_gtk.cc',
    'gfx/path_win.cc',
    'gfx/path.h',
    'gfx/text_elider.cc',
    'gfx/text_elider.h',
    'gfx/utils.h',
  ]),
  MSVSFilter('ipc', [
    'ipc_channel.h',
    'ipc_channel_posix.cc',
    'ipc_channel_proxy.cc',
    'ipc_channel_proxy.h',
    'ipc_channel_win.cc',
    'ipc_logging.cc',
    'ipc_logging.h',
    'ipc_message.cc',
    'ipc_message.h',
    'ipc_message_macros.h',
    'ipc_message_utils.cc',
    'ipc_message_utils.h',
    'ipc_sync_channel.cc',
    'ipc_sync_channel.h',
    'ipc_sync_message.cc',
    'ipc_sync_message.h',
    'plugin_messages.h',
    'plugin_messages_internal.h',
    'render_messages.h',
    'render_messages_internal.h',
    'worker_messages.h',
    'worker_messages_internal.h',
  ]),
    'accessibility.h',
    'animation.cc',
    'animation.h',
    'bindings_policy.h',
    'child_process.cc',
    'child_process.h',
    'child_process_host.cc',
    'child_process_host.h',
    'child_process_info.cc',
    'child_process_info.h',
    'child_thread.cc',
    'child_thread.h',
    'chrome_constants.cc',
    'chrome_constants.h',
    'chrome_counters.cc',
    'chrome_counters.h',
    'chrome_paths.cc',
    'chrome_paths.h',
    'chrome_paths_internal.h',
    'chrome_paths_linux.cc',
    'chrome_paths_mac.cc',
    'chrome_paths_win.cc',
    'chrome_plugin_api.h',
    'chrome_plugin_lib.cc',
    'chrome_plugin_lib.h',
    'chrome_plugin_util.cc',
    'chrome_plugin_util.h',
    'chrome_process_filter.cc',
    'chrome_process_filter.h',
    'chrome_switches.cc',
    'chrome_switches.h',
    'classfactory.cc',
    'classfactory.h',
    'clipboard_service.h',
    'common_glue.cc',
    'common_resources.h',
    'debug_flags.cc',
    'debug_flags.h',
    'drag_drop_types.cc',
    'drag_drop_types.h',
    'env_vars.cc',
    'env_vars.h',
    'filter_policy.h',
    'gears_api.h',
    'json_value_serializer.cc',
    'json_value_serializer.h',
    'jstemplate_builder.cc',
    'jstemplate_builder.h',
    'l10n_util.cc',
    'l10n_util.h',
    'libxml_utils.cc',
    'libxml_utils.h',
    'logging_chrome.cc',
    'logging_chrome.h',
    'main_function_params.h',
    'message_router.cc',
    'message_router.h',
    'mru_cache.h',
    'native_web_keyboard_event.h',
    'native_web_keyboard_event_linux.cc',
    'navigation_types.h',
    'notification_details.h',
    'notification_registrar.cc',
    'notification_registrar.h',
    'notification_service.cc',
    'notification_service.h',
    'notification_source.h',
    'notification_types.h',
    'os_exchange_data.cc',
    'os_exchange_data.h',
    'page_transition_types.h',
    'page_zoom.h',
    '$CHROME_DIR/tools/build/win/precompiled$OBJSUFFIX',
    '$CHROME_DIR/tools/build/win/precompiled.h',
    'pref_member.cc',
    'pref_member.h',
    'pref_names.cc',
    'pref_names.h',
    'pref_service.cc',
    'pref_service.h',
    'process_watcher.cc',
    'process_watcher.h',
    'property_bag.cc',
    'property_bag.h',
    'ref_counted_util.h',
    'resource_bundle.cc',
    'resource_bundle.h',
    'resource_bundle_linux.cc',
    'resource_bundle_win.cc',
    'resource_dispatcher.cc',
    'resource_dispatcher.h',
    'sandbox_init_wrapper.cc',
    'sandbox_init_wrapper.h',
    'scoped_vector.h',
    'security_filter_peer.cc',
    'security_filter_peer.h',
    'slide_animation.cc',
    'slide_animation.h',
    'sqlite_compiled_statement.cc',
    'sqlite_compiled_statement.h',
    'sqlite_utils.cc',
    'sqlite_utils.h',
    'stl_util-inl.h',
    'task_queue.cc',
    'task_queue.h',
    'throb_animation.cc',
    'throb_animation.h',
    'thumbnail_score.cc',
    'thumbnail_score.h',
    'time_format.cc',
    'time_format.h',
    'unzip.cc',
    'unzip.h',
    'url_constants.cc',
    'url_constants.h',
    'visitedlink_common.cc',
    'visitedlink_common.h',
    'win_safe_util.cc',
    'win_safe_util.h',
    'win_util.cc',
    'win_util.h',
    'worker_thread_ticker.cc',
    'worker_thread_ticker.h',
])

if not env.Bit('windows'):
  # TODO(port): This is temporary so we can link.
  input_files.Append(
      'temp_scaffolding_stubs.cc',
      'file_descriptor_set_posix.cc',
  )

  # TODO(port): Port these.
  input_files.Remove(
      'chrome_process_filter.cc',
      'drag_drop_types.cc',
      'gfx/emf.cc',
      'gfx/icon_util.cc',
      'os_exchange_data.cc',
      'process_watcher.cc',
  )

if not env.Bit('windows'):
  # Windows specific files
  input_files.Remove(
      'chrome_paths_win.cc',
      'classfactory.cc',
      'gfx/chrome_canvas_win.cc',
      'gfx/chrome_font_win.cc',
      'gfx/path_win.cc',
      'ipc_channel_win.cc',
      'resource_bundle_win.cc',
      'win_safe_util.cc',
      'win_util.cc',
      '$CHROME_DIR/tools/build/win/precompiled$OBJSUFFIX',
  )

if not env.Bit('linux'):
  # Linux specific files
  input_files.Remove(
      'chrome_paths_linux.cc',
      'resource_bundle_linux.cc',
      'gfx/chrome_canvas_skia.cc',
      'gfx/chrome_font_gtk.cc',
      'gfx/chrome_font_skia.cc',
      'gfx/path_gtk.cc',
  )

if not env.Bit('mac'):
  # Mac specific files
  input_files.Remove(
      'chrome_paths_mac.cc',
  )

if not env.Bit('posix'):
  input_files.Remove(
      'ipc_channel_posix.cc',
  )

if env.Bit('windows'):
  input_files.Append(
      'transport_dib_win.cc'
  )

if env.Bit('linux'):
  input_files.Append(
      '$CHROME_DIR/third_party/xdg_user_dirs/xdg_user_dir_lookup.cc',
      'transport_dib_linux.cc',
      'x11_util.cc'
  )

if env.Bit('mac'):
  input_files.Append(
      'transport_dib_mac.cc'
  )

if not env.Bit('mac'):
  # TODO(port): This should be enabled for all platforms.
  env.ChromeLibrary('common', input_files)

p = env.ChromeMSVSProject('common.vcproj',
                          dest='$CHROME_SRC_DIR/chrome/common/common.vcproj',
                          guid='{899F1280-3441-4D1F-BA04-CCD6208D9146}',
                          keyword='Win32Proj',
                          dependencies = [
                              '$LIBXML_DIR/build/libxml_config.vcproj',
                              '$CHROME_DIR/app/generated_resources.vcproj',
                          ],
                          # TODO(sgk):  when we can intuit the hierarchy
                          # from the built targets.
                          #buildtargets=TODO,
                          files=input_files,
                          relative_path_prefix='./',
                          tools=[
                              'VCPreBuildEventTool',
                              'VCCustomBuildTool',
                              'VCXMLDataGeneratorTool',
                              'VCWebServiceProxyGeneratorTool',
                              'VCMIDLTool',
                              'VCCLCompilerTool',
                              'VCManagedResourceCompilerTool',
                              'VCResourceCompilerTool',
                              'VCPreLinkEventTool',
                              'VCLibrarianTool',
                              'VCALinkTool',
                              'VCXDCMakeTool',
                              'VCBscMakeTool',
                              'VCFxCopTool',
                              'VCPostBuildEventTool',
                          ],
                          ConfigurationType='4')


p.AddConfig('Debug|Win32',
            InheritedPropertySheets=[
                './common.vsprops',
                '$(SolutionDir)../build/debug.vsprops',
                '../tools/build/win/precompiled.vsprops',
            ])

p.AddConfig('Release|Win32',
            InheritedPropertySheets=[
                './common.vsprops',
                '$(SolutionDir)../build/release.vsprops',
            ])

p.AddFileConfig('../tools/build/win/precompiled.cc',
                'Debug|Win32',
                tools=[
                    MSVSTool('VCCLCompilerTool',
                             UsePrecompiledHeader='1'),
                ])