# 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()

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

      '/wd4244',
      '/wd4291',
      '/wd4345',
      '/wd4521',
      '/wd4800',
      ],)
elif env['PLATFORM'] == 'posix':
  env.Append(
    # For the image readers and decoders:
    CXXFLAGS = "-Wno-sign-compare",
    LIBS = 'png'
  )

input_files = [
    '$PORT_DIR/bridge/chromium/PluginsChromium.cpp',

    '$PORT_DIR/history/BackForwardList.cpp',
    '$PORT_DIR/history/CachedPage.cpp',

    '$PORT_DIR/loader/IconLoader.cpp',
    '$PORT_DIR/loader/IconDatabaseNone.cpp',

    '$PORT_DIR/page/Location.cpp',
    '$PORT_DIR/page/chromium/AccessibilityObjectChromium.cpp',
    '$PORT_DIR/page/chromium/AXObjectCacheChromium.cpp',
    '$PORT_DIR/page/chromium/DragControllerChromium.cpp',
    '$PORT_DIR/page/chromium/EventHandlerChromium.cpp',
    '$PORT_DIR/page/chromium/FrameChromium.cpp',

    '$PORT_DIR/platform/GKURL.cpp',

    '$PORT_DIR/platform/chromium/ChromiumDataObject.cpp',
    '$PORT_DIR/platform/chromium/ClipboardChromium.cpp',
    '$PORT_DIR/platform/chromium/ClipboardUtilitiesChromium.cpp',
    '$PORT_DIR/platform/chromium/ContextMenuChromium.cpp',
    '$PORT_DIR/platform/chromium/ContextMenuItemChromium.cpp',
    '$PORT_DIR/platform/chromium/CursorChromium.cpp',
    '$PORT_DIR/platform/chromium/DragDataChromium.cpp',
    '$PORT_DIR/platform/chromium/DragImageChromium.cpp',
    '$PORT_DIR/platform/chromium/EditorChromium.cpp',
    '$PORT_DIR/platform/chromium/FileChooserChromium.cpp',
    '$PORT_DIR/platform/chromium/FileSystemChromium.cpp',
    '$PORT_DIR/platform/chromium/FramelessScrollView.cpp',
    '$PORT_DIR/platform/chromium/Language.cpp',
    '$PORT_DIR/platform/chromium/MimeTypeRegistryChromium.cpp',
    '$PORT_DIR/platform/chromium/PasteboardChromium.cpp',
    '$PORT_DIR/platform/chromium/PlatformKeyboardEventChromium.cpp',
    '$PORT_DIR/platform/chromium/PlatformScreenChromium.cpp',
    '$PORT_DIR/platform/chromium/PopupMenuChromium.cpp',
    '$PORT_DIR/platform/chromium/SearchPopupMenuChromium.cpp',
    '$PORT_DIR/platform/chromium/SharedTimerChromium.cpp',
    '$PORT_DIR/platform/chromium/SSLKeyGeneratorChromium.cpp',
    '$PORT_DIR/platform/chromium/SystemTimeChromium.cpp',
    '$PORT_DIR/platform/chromium/TemporaryLinkStubs.cpp',
    '$PORT_DIR/platform/chromium/TextBoundariesChromium.cpp',
    '$PORT_DIR/platform/chromium/TextBreakIteratorInternalICUChromium.cpp',
    '$PORT_DIR/platform/chromium/WidgetChromium.cpp',
    '$PORT_DIR/platform/chromium/ScrollbarThemeChromium.cpp',

    '$PORT_DIR/platform/graphics/AffineTransformSkia.cpp',
    '$PORT_DIR/platform/graphics/ColorSkia.cpp',
    '$PORT_DIR/platform/graphics/FloatPointSkia.cpp',
    '$PORT_DIR/platform/graphics/FloatRectSkia.cpp',
    '$PORT_DIR/platform/graphics/FontCustomPlatformData.cpp',
    '$PORT_DIR/platform/graphics/GradientSkia.cpp',
    '$PORT_DIR/platform/graphics/GraphicsContextSkia.cpp',
    '$PORT_DIR/platform/graphics/ImageBufferSkia.cpp',
    '$PORT_DIR/platform/graphics/ImageSkia.cpp',
    '$PORT_DIR/platform/graphics/ImageSourceSkia.cpp',
    '$PORT_DIR/platform/graphics/IntPointSkia.cpp',
    '$PORT_DIR/platform/graphics/IntRectSkia.cpp',
    '$PORT_DIR/platform/graphics/NativeImageSkia.cpp',
    '$PORT_DIR/platform/graphics/PathSkia.cpp',
    '$PORT_DIR/platform/graphics/PatternSkia.cpp',
    '$PORT_DIR/platform/graphics/PlatformContextSkia.cpp',
    '$PORT_DIR/platform/graphics/SkiaUtils.cpp',

    '$PORT_DIR/platform/graphics/svg/RenderPathSkia.cpp',
    '$PORT_DIR/platform/graphics/svg/SkiaSupport.cpp',
    '$PORT_DIR/platform/graphics/svg/SVGPaintServerGradientSkia.cpp',
    '$PORT_DIR/platform/graphics/svg/SVGPaintServerPatternSkia.cpp',
    '$PORT_DIR/platform/graphics/svg/SVGPaintServerSkia.cpp',
    '$PORT_DIR/platform/graphics/svg/SVGResourceFilterSkia.cpp',
    '$PORT_DIR/platform/graphics/svg/SVGResourceMaskerSkia.cpp',

    '$PORT_DIR/platform/image-decoders/bmp/BMPImageDecoder.cpp',
    '$PORT_DIR/platform/image-decoders/bmp/BMPImageReader.cpp',
    '$PORT_DIR/platform/image-decoders/gif/GIFImageDecoder.cpp',
    '$PORT_DIR/platform/image-decoders/gif/GIFImageReader.cpp',
    '$PORT_DIR/platform/image-decoders/ico/ICOImageDecoder.cpp',
    '$PORT_DIR/platform/image-decoders/jpeg/JPEGImageDecoder.cpp',
    '$PORT_DIR/platform/image-decoders/png/PNGImageDecoder.cpp',
    '$PORT_DIR/platform/image-decoders/xbm/XBMImageDecoder.cpp',

    '$PORT_DIR/platform/network/chromium/AuthenticationChallengeChromium.cpp',
    '$PORT_DIR/platform/network/chromium/CookieJarChromium.cpp',
    '$PORT_DIR/platform/network/chromium/DNSChromium.cpp',
    '$PORT_DIR/platform/network/chromium/NetworkStateNotifierChromium.cpp',

    '$PORT_DIR/plugins/chromium/PluginDataChromium.cpp',
]

if env['PLATFORM'] == 'win32':
  # Windows specific implementations.
  input_files.extend([
    '$PORT_DIR/platform/chromium/FileSystemChromiumWin.cpp',
    '$PORT_DIR/platform/chromium/ScrollBarThemeChromiumWin.cpp',
    '$PORT_DIR/platform/win/BString.cpp',
    '$PORT_DIR/platform/win/SoundWin.cpp',

    '$PORT_DIR/platform/graphics/FontCacheWin.cpp',
    '$PORT_DIR/platform/graphics/FontPlatformDataWin.cpp',
    '$PORT_DIR/platform/graphics/FontUtilsWin.cpp',
    '$PORT_DIR/platform/graphics/FontWin.cpp',
    '$PORT_DIR/platform/graphics/GlyphPageTreeNodeWin.cpp',
    '$PORT_DIR/platform/graphics/IconWin.cpp',
    '$PORT_DIR/platform/graphics/SimpleFontDataWin.cpp',
    '$PORT_DIR/platform/graphics/ThemeHelperWin.cpp',
    '$PORT_DIR/platform/graphics/UniscribeHelper.cpp',
    '$PORT_DIR/platform/graphics/UniscribeHelperTextRun.cpp',

    '$PORT_DIR/rendering/RenderThemeWin.cpp',
  ])

if env['PLATFORM'] == 'posix':
  # Linux specific implementations.
  input_files.extend([
    '$PORT_DIR/platform/chromium/FileSystemPosix.cpp',
    '$PORT_DIR/platform/chromium/gtk2drawing.c',
    '$PORT_DIR/platform/chromium/IconLinux.cpp',
    '$PORT_DIR/platform/chromium/KeyCodeConversionGtk.cpp',
    '$PORT_DIR/platform/chromium/RenderThemeGtk.cpp',
    '$PORT_DIR/platform/chromium/ScrollbarThemeChromiumLinux.cpp',
    '$PORT_DIR/platform/chromium/SoundPosix.cpp',

    '$PORT_DIR/platform/graphics/chromium/FontCacheLinux.cpp',
    '$PORT_DIR/platform/graphics/chromium/FontLinux.cpp',
    '$PORT_DIR/platform/graphics/chromium/FontPlatformDataLinux.cpp',
    '$PORT_DIR/platform/graphics/chromium/GlyphPageTreeNodeLinux.cpp',
    '$PORT_DIR/platform/graphics/chromium/SimpleFontDataLinux.cpp',

    '$PORT_DIR/platform/graphics/skia/GdkSkia.cc',
  ])

  # Remove from the list files that haven't yet been made portable to Linux.
  to_be_ported_files = [
    '$PORT_DIR/platform/graphics/FontCustomPlatformData.cpp',
  ]
  input_files = list(set(input_files) - set(to_be_ported_files))

if env['PLATFORM'] == 'darwin':
  # Mac specific implementations.
  input_files.extend([
    '$PORT_DIR/bridge/mac/FrameMac.mm',
    '$PORT_DIR/page/EventHandlerMac.mm',
    '$PORT_DIR/page/WebCoreFrameBridge.mm',
    '$PORT_DIR/platform/GKURLMac.mm',
    '$PORT_DIR/platform/PluginStubsMac.cpp',
    '$PORT_DIR/platform/mac/DragDataMac.mm',
    '$PORT_DIR/platform/mac/IntRectMac.mm',
    '$PORT_DIR/platform/graphics/mac/FontCacheMacPending.cpp',
    '$PORT_DIR/rendering/RenderThemeMac.mm',
  ])

  # Remove from the list files that haven't yet been made portable to Mac.
  to_be_ported_files = [
    '$PORT_DIR/page/chromium/AXObjectCacheChromium.cpp',
    '$PORT_DIR/page/chromium/EventHandlerChromium.cpp',
    '$PORT_DIR/platform/chromium/CursorChromium.cpp',
    '$PORT_DIR/platform/chromium/DragDataChromium.cpp',
    '$PORT_DIR/platform/chromium/PopupMenuChromium.cpp',
    '$PORT_DIR/platform/chromium/WidgetChromium.cpp',
    '$PORT_DIR/platform/chromium/ScrollbarThemeChromium.cpp',
    '$PORT_DIR/platform/graphics/FontCustomPlatformData.cpp',
    '$PORT_DIR/platform/graphics/ImageSkia.cpp',
  ]
  input_files = list(set(input_files) - set(to_be_ported_files))

if env.get('KJS'):
  input_files.extend([
    '$PORT_DIR/bridge/KJSBridge.cpp',
    '$PORT_DIR/bridge/ScriptControllerKJS.cpp',
  ])
else:
  input_files.extend([
    '$PORT_DIR/bindings/v8/ScriptController.cpp',
  ])

env.ChromeStaticLibrary("port", input_files)