[go: nahoru, domu]

Add is_chromecast to GN build.

There are several specific features needed for Chromecast builds. This
flag will be used to enable and disable these features. This flag is
the equivalent of 'embedded' and 'is_chromecast' in GYP, which mean the
same thing in practice.

BUG=516899
Bug:b/17615224

Review URL: https://codereview.chromium.org/1345013002

Cr-Commit-Position: refs/heads/master@{#349961}
diff --git a/build/config/chromecast_build.gni b/build/config/chromecast_build.gni
new file mode 100644
index 0000000..3fac609
--- /dev/null
+++ b/build/config/chromecast_build.gni
@@ -0,0 +1,15 @@
+# Copyright 2015 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.
+
+# This block should only contain Chromecast-specific build arguments used by
+# by components outside of //chromecast.
+declare_args() {
+  # Set this true for a Chromecast build. Chromecast builds are supported on
+  # Linux and Android.
+  is_chromecast = false
+}
+
+# Assert that Chromecast is being built for a supported platform.
+assert(is_linux || is_android || !is_chromecast,
+       "Chromecast builds are not supported on $target_os")
diff --git a/build/config/features.gni b/build/config/features.gni
index 83a80f1d..2b479f1 100644
--- a/build/config/features.gni
+++ b/build/config/features.gni
@@ -15,6 +15,7 @@
 # to set up feature flags.
 
 import("//build/config/chrome_build.gni")
+import("//build/config/chromecast_build.gni")
 if (is_android) {
   import("//build/config/android/config.gni")
 }
@@ -23,8 +24,8 @@
   # Multicast DNS.
   enable_mdns = is_win || is_linux
 
-  enable_plugins = !is_android && !is_ios
-  enable_pdf = !is_android && !is_ios
+  enable_plugins = (!is_android && !is_ios) || is_chromecast
+  enable_pdf = !is_android && !is_ios && !is_chromecast
 
   # Enables Native Client support.
   # TODO(GYP): Get NaCl linking on other platforms.
@@ -36,9 +37,9 @@
   # this will go away when Mac and Win are working and we can just use
   # the commented out logic.
   # Eventually we want this to be:
-  #   enable_nacl = !is_ios && !is_android
-  enable_nacl =
-      ((is_linux && !is_chromeos) || is_nacl) && current_cpu != "mipsel"
+  #   enable_nacl = !is_ios && !is_android && !is_chromecast
+  enable_nacl = ((is_linux && !is_chromeos) || is_nacl) &&
+                current_cpu != "mipsel" && !is_chromecast
   enable_nacl_untrusted = enable_nacl
   enable_pnacl = enable_nacl_untrusted
 
@@ -59,8 +60,7 @@
   # Android OS includes support for proprietary codecs regardless of building
   # Chromium or Google Chrome. We also ship Google Chrome and Chromecast with
   # proprietary codecs.
-  # TODO(GYP) The GYP build has || chromecast==1 for this:
-  proprietary_codecs = is_android || is_chrome_branded
+  proprietary_codecs = is_android || is_chrome_branded || is_chromecast
 
   # TODO(GYP) This should be enabled on ios as well.
   enable_configuration_policy = !is_ios
@@ -86,23 +86,19 @@
 
   enable_one_click_signin = is_win || is_mac || (is_linux && !is_chromeos)
 
-  enable_remoting = !is_ios && !is_android
+  enable_remoting = !is_ios && !is_android && !is_chromecast
 
   # Enable hole punching for the protected video.
-  enable_video_hole = is_android
+  enable_video_hole = is_android || is_chromecast
 
   # Enables browser side Content Decryption Modules. Required for embedders
   # (e.g. Android and ChromeCast) that use a browser side CDM.
-  enable_browser_cdms = is_android
+  enable_browser_cdms = is_android || is_chromecast
 
   # Hangout services is an extension that adds extra features to Hangouts.
   # For official GYP builds, this flag is set.
   enable_hangout_services_extension = false
 
-  # Enables the use of CDMs in pepper plugins. Chromecast requires that this
-  # can be explicitly disabled in gn args.
-  enable_pepper_cdms = enable_plugins && (is_linux || is_mac || is_win)
-
   # Variable safe_browsing is used to control the build time configuration
   # for safe browsing feature. Safe browsing can be compiled in 4 different
   # levels: 0 disables it, 1 enables it fully, and 2 enables only UI and
@@ -137,7 +133,7 @@
 }
 
 # libudev usage. This currently only affects the content layer.
-use_udev = is_linux
+use_udev = is_linux && !is_chromecast
 
 # Enable the spell checker.
 enable_spellcheck = !is_ios
@@ -146,11 +142,15 @@
 use_browser_spellchecker = is_android || is_mac
 
 # Enable basic printing support and UI.
-enable_basic_printing = !is_chromeos
+enable_basic_printing = !is_chromeos && !is_chromecast
 
 # Enable printing with print preview. It does not imply
 # enable_basic_printing. It's possible to build Chrome with preview only.
-enable_print_preview = !is_android
+enable_print_preview = !is_android && !is_chromecast
+
+# Enables the use of CDMs in pepper plugins.
+enable_pepper_cdms =
+    enable_plugins && (is_linux || is_mac || is_win) && !is_chromecast
 
 # The seccomp-bpf sandbox is only supported on three architectures
 # currently.
@@ -168,13 +168,13 @@
 
 enable_web_speech = !is_android && !is_ios
 
-use_dbus = is_linux
+use_dbus = is_linux && !is_chromecast
 
 enable_extensions = !is_android && !is_ios
 
 enable_task_manager = !is_ios && !is_android
 
-use_cups = is_desktop_linux || is_mac
+use_cups = (is_desktop_linux || is_mac) && !is_chromecast
 
 enable_themes = !is_android && !is_ios
 
@@ -204,8 +204,7 @@
 
 # Option controlling the use of GConf (the classic GNOME configuration
 # system).
-# TODO(GYP) also require !embedded to enable.
-use_gconf = is_linux && !is_chromeos
+use_gconf = is_linux && !is_chromeos && !is_chromecast
 
 # Whether to back up data before sync.
 enable_pre_sync_backup = is_win || is_mac || (is_linux && !is_chromeos)
diff --git a/build/config/ui.gni b/build/config/ui.gni
index bf62c4d..35e8144 100644
--- a/build/config/ui.gni
+++ b/build/config/ui.gni
@@ -14,21 +14,25 @@
 # required. See the declare_args block of BUILDCONFIG.gn for advice on how
 # to set up feature flags.
 
+import("//build/config/chromecast_build.gni")
+
 declare_args() {
   # Indicates if Ash is enabled. Ash is the Aura Shell which provides a
   # desktop-like environment for Aura. Requires use_aura = true
-  use_ash = is_win || is_linux
+  use_ash = (is_win || is_linux) && !is_chromecast
 
   # Indicates if Ozone is enabled. Ozone is a low-level library layer for Linux
-  # that does not require X11.
-  use_ozone = false
+  # that does not require X11. Enabling this feature disables use of glib, x11,
+  # Pango, and Cairo. Default to false on non-Chromecast builds.
+  use_ozone = is_chromecast
 
   # Indicates if Aura is enabled. Aura is a low-level windowing library, sort
   # of a replacement for GDI or GTK.
-  use_aura = is_win || is_linux
+  use_aura = is_win || is_linux || is_chromecast
 
   # True means the UI is built using the "views" framework.
-  toolkit_views = is_mac || is_win || is_chromeos || use_aura
+  toolkit_views =
+      (is_mac || is_win || is_chromeos || use_aura) && !is_chromecast
 
   # Whether the entire browser uses toolkit-views on Mac instead of Cocoa.
   mac_views_browser = false
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index d213de75..f3f3757 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -2525,11 +2525,6 @@
             'browser/media/router/media_router.gyp:media_router_test_support',
             'test/media_router/media_router_tests.gypi:media_router_integration_test_files'
           ],
-          'conditions': [
-            ['toolkit_views==0', {
-              'sources!': [ 'browser/ui/views/media_router/media_router_ui_browsertest.cc' ],
-            }],
-          ],
         }],
         ['enable_mdns==1', {
           'sources' : [
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
index 95df486..0f5d4e4 100644
--- a/chrome/test/BUILD.gn
+++ b/chrome/test/BUILD.gn
@@ -339,6 +339,16 @@
         # TODO(gbillock): aura linux does not support the automation for
         # SendMouseMoveNotifyWhenDone
         sources -= [ "../browser/ui/views/toolbar/toolbar_button_test.cc" ]
+
+        if (!is_chromeos) {
+          # Desktop linux.
+          sources -= [
+            # TODO(port): This times out. Attempts have been made to fix the
+            # individual failures, but each time I disable a test from these
+            # suites, it seems like one or another starts timing out too.
+            "../browser/ui/views/keyboard_access_browsertest.cc",
+          ]
+        }
       }
       if (is_chromeos || !use_x11) {
         sources -= [
@@ -351,15 +361,7 @@
       }
     }
 
-    if (is_linux && !is_chromeos) {
-      # Desktop linux.
-      sources -= [
-        # TODO(port): This times out. Attempts have been made to fix the
-        # individual failures, but each time I disable a test from these
-        # suites, it seems like one or another starts timing out too.
-        "../browser/ui/views/keyboard_access_browsertest.cc",
-      ]
-    } else {
+    if (!is_desktop_linux) {
       # Everything but desktop Linux.
       sources += rebase_path(
               chrome_tests_gypi_values.chrome_interactive_ui_test_non_desktop_linux_sources,
@@ -998,8 +1000,11 @@
         "../browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc",
         "../browser/ui/ash/launcher/launcher_favicon_loader_browsertest.cc",
         "../browser/ui/ash/shelf_browsertest.cc",
-        "../browser/ui/views/frame/browser_non_client_frame_view_ash_browsertest.cc",
       ]
+
+      if (toolkit_views) {
+        sources -= [ "../browser/ui/views/frame/browser_non_client_frame_view_ash_browsertest.cc" ]
+      }
     }
     if (is_mac) {
       # TODO(mark): We really want this for all non-static library
@@ -1715,9 +1720,6 @@
                 ".",
                 "//chrome")
       }
-      if (!toolkit_views) {
-        sources -= [ "../browser/ui/views/media_router/media_router_ui_browsertest.cc" ]
-      }
     }
     if (enable_webrtc) {
       sources += rebase_path(
diff --git a/chromecast/build/args.gn b/chromecast/build/args.gn
deleted file mode 100644
index a768a59..0000000
--- a/chromecast/build/args.gn
+++ /dev/null
@@ -1,36 +0,0 @@
-# Build arguments for Chromecast.
-# Copy the contents of this file to gn args.
-
-root_extra_deps = [ "//chromecast" ]
-
-# Enable the use of browser-side CDM.
-enable_browser_cdms = true
-
-# Enable plugins, but explicitly disable use of Pepper CDMs.
-enable_plugins = true
-enable_pepper_cdms = false
-
-# Flags set from build/common.gypi
-
-# Compile with MSE support for MPEG2 TS. See //media/media_options.gni for more
-# detail.
-enable_mpeg2ts_stream_parser = true
-
-# Instead of maintaining a separate "Chromecast" ffmpeg branding, "ChromeOS" is
-# used, as it sufficiently covers all the required codecs.
-ffmpeg_branding = "ChromeOS"
-
-# Setting this to true generates libeglplatform_shim.so.1 from
-# //ui/ozone/platform/egltest:egl_platform_x11.
-ozone_platform_ozonex = true
-
-# Chromecast must use proprietary codecs. Setting this to true defines the
-# USE_PROPRIETARY_CODECS macro and the proper EME_CODEC macros.
-proprietary_codecs = true
-
-# See //build/config/ui.gni. Notice that use_x11 = is_linux && !use_ozone.
-use_ozone = true
-# TODO(halliwell): look into supporting Cast Ozone with GN.
-# ozone_platform_cast = 1
-# TODO(gyp): Add support for blink_logging_always_on and enable it.
-# blink_logging_always_on = 1
diff --git a/chromecast/chromecast.gni b/chromecast/chromecast.gni
index 610b179..5fe8adb 100644
--- a/chromecast/chromecast.gni
+++ b/chromecast/chromecast.gni
@@ -2,10 +2,35 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+# This args block should contain arguments used within the //chromecast
+# directory. Arguments which are used in other Chrome components should
+# be instead declared in //build/config/chromecast_build.gni.
 declare_args() {
-  # chromecast_branding is used to indicate build version. Set it to
-  # "public" for Chromium build.
+  # chromecast_branding is used to include or exclude Google-branded components.
+  # Set it to "public" for a Chromium build.
   chromecast_branding = "public"
 
+  # True if Chromecast build is targetted for linux desktop.
+  is_chromecast_desktop_build = is_linux && target_cpu != "arm"
+
+  # Use the stub graphics lib in //chromecast/graphics. If this is true, the
+  # value of |libcast_graphics_path| is ignored.
+  use_default_cast_graphics =
+      chromecast_branding == "public" || is_chromecast_desktop_build
+
+  # The path to the cast_graphics shared library. Any target pointed to must
+  # be named "libcast_graphics_1.0".
+  libcast_graphics_path = ""
+
+  # Use the stub media library in //chromecast/media. If this is true, the
+  # value of |libcast_media_path| is ignored.
+  use_default_cast_media =
+      chromecast_branding == "public" || is_chromecast_desktop_build
+
+  # The path to the cast_media shared library. Any target pointed to must be
+  # named "libcast_media_1.0".
+  libcast_media_path = ""
+
+  # Use Playready CDMs.
   use_playready = false
 }
diff --git a/chromecast/graphics/BUILD.gn b/chromecast/graphics/BUILD.gn
index f07a87154..7ba48c8 100644
--- a/chromecast/graphics/BUILD.gn
+++ b/chromecast/graphics/BUILD.gn
@@ -2,6 +2,8 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("//chromecast/chromecast.gni")
+
 source_set("graphics") {
   sources = [
     "cast_screen.cc",
@@ -14,3 +16,35 @@
     "//ui/gfx/geometry",
   ]
 }
+
+group("libcast_graphics") {
+  if (use_default_cast_graphics) {
+    public_deps = [
+      ":libcast_graphics_default",
+    ]
+  } else {
+    public_deps = [
+      "$libcast_graphics_path:libcast_graphics_1.0",
+    ]
+  }
+}
+
+if (use_default_cast_graphics) {
+  shared_library("libcast_graphics_default") {
+    output_name = "libcast_graphics_1.0"
+
+    sources = [
+      "cast_egl_platform_default.cc",
+      "graphics_properties_default.cc",
+      "osd_plane_default.cc",
+    ]
+
+    public_deps = [
+      "//chromecast/public",
+    ]
+
+    deps = [
+      "//base",
+    ]
+  }
+}
diff --git a/chromecast/media/BUILD.gn b/chromecast/media/BUILD.gn
index cd72d9d..a5471ebb 100644
--- a/chromecast/media/BUILD.gn
+++ b/chromecast/media/BUILD.gn
@@ -2,6 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("//chromecast/chromecast.gni")
 import("//testing/test.gni")
 
 group("media") {
@@ -59,6 +60,18 @@
   ]
 }
 
+group("libcast_media") {
+  if (use_default_cast_media) {
+    public_deps = [
+      "//chromecast/media/base:libcast_media_default",
+    ]
+  } else {
+    public_deps = [
+      "$libcast_media_path:libcast_media_1.0",
+    ]
+  }
+}
+
 # TODO(slan): delete this target once Chromecast M44/earlier is obsolete.
 # See: b/21639416
 shared_library("libffmpegsumo") {
diff --git a/chromecast/media/base/BUILD.gn b/chromecast/media/base/BUILD.gn
index b82d938..aa8e7d23 100644
--- a/chromecast/media/base/BUILD.gn
+++ b/chromecast/media/base/BUILD.gn
@@ -9,6 +9,7 @@
   libcast_media_target = ""
 }
 
+# TODO(slan): See if the dependency on //media can be broken.
 source_set("base") {
   sources = [
     "decrypt_context_impl.cc",
@@ -58,10 +59,13 @@
 
   configs += [ "//chromecast:config" ]
 
+  public_deps = [
+    "//chromecast/public",
+    "//chromecast/public/media",
+  ]
+
   deps = [
     "//build/config/sanitizers:deps",
     "//chromecast/media/cma/backend",
-    "//chromecast/public",
-    "//chromecast/public/media",
   ]
 }
diff --git a/chromecast/media/cma/backend/BUILD.gn b/chromecast/media/cma/backend/BUILD.gn
index c186404..7507b7d6 100644
--- a/chromecast/media/cma/backend/BUILD.gn
+++ b/chromecast/media/cma/backend/BUILD.gn
@@ -16,6 +16,12 @@
     "video_pipeline_device_default.h",
   ]
 
+  # This target cannot depend on //media. Include these headers directly.
+  sources += [
+    "//media/base/media_export.h",
+    "//media/base/timestamp_constants.h",
+  ]
+
   public_deps = [
     "//chromecast/public",
     "//chromecast/public/media",
@@ -23,8 +29,6 @@
 
   deps = [
     "//base",
-    "//chromecast/media/cma/base",
-    "//media",
   ]
 
   configs += [ "//chromecast:config" ]
diff --git a/content/shell/BUILD.gn b/content/shell/BUILD.gn
index 1ee13ab..a6c9654 100644
--- a/content/shell/BUILD.gn
+++ b/content/shell/BUILD.gn
@@ -314,7 +314,7 @@
     ]
   }
 
-  if (is_linux) {
+  if (is_linux && !is_chromecast) {
     deps += [ "//third_party/freetype2" ]
   }
 
diff --git a/media/BUILD.gn b/media/BUILD.gn
index eafcc1e..68c1e5f 100644
--- a/media/BUILD.gn
+++ b/media/BUILD.gn
@@ -207,8 +207,6 @@
     "filters/ivf_parser.h",
     "filters/jpeg_parser.cc",
     "filters/jpeg_parser.h",
-    "filters/source_buffer_platform.cc",
-    "filters/source_buffer_platform.h",
     "filters/source_buffer_range.cc",
     "filters/source_buffer_range.h",
     "filters/source_buffer_stream.cc",
@@ -505,6 +503,18 @@
     ]
   }
 
+  if (use_low_memory_buffer) {
+    sources += [
+      "filters/source_buffer_platform.h",
+      "filters/source_buffer_platform_lowmem.cc",
+    ]
+  } else {
+    sources += [
+      "filters/source_buffer_platform.cc",
+      "filters/source_buffer_platform.h",
+    ]
+  }
+
   public_deps = [
     "//media/base",
     "//media/audio",
diff --git a/media/media_options.gni b/media/media_options.gni
index 746d96d6..1f3f6443 100644
--- a/media/media_options.gni
+++ b/media/media_options.gni
@@ -2,6 +2,8 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("//build/config/chromecast_build.gni")
+
 declare_args() {
   # Allows distributions to link pulseaudio directly (DT_NEEDED) instead of
   # using dlopen. This helps with automated detection of ABI mismatches and
@@ -36,22 +38,27 @@
   # Enables runtime selection of ALSA library for audio.
   use_alsa = false
 
-  # TODO(GYP): How to handled the "embedded" use case?
-  # Original conditional: (OS=="linux" or OS=="freebsd" or OS=="solaris") and embedded!=1
-  if (is_posix && !is_android && !is_mac) {
+  # Alsa should be used on non-Android, non-Mac POSIX systems, and Chromecast
+  # builds for desktop Linux.
+  if ((is_posix && !is_android && !is_mac) ||
+      (is_chromecast && target_cpu != "arm" && is_linux)) {
     use_alsa = true
     if (!use_cras) {
       use_pulseaudio = true
     }
   }
 
+  # Use low-memory buffers on non-Android builds of Chromecast.
+  use_low_memory_buffer = is_chromecast && !is_android
+
   # Enables the MPEG2-TS stream parser for use with Media Source. Disabled by
-  # default since it's not available on the normal Web Platform and costs money.
-  enable_mpeg2ts_stream_parser = false
+  # default (except on Chromecast) since it's not available on the normal Web
+  # Platform and costs money.
+  enable_mpeg2ts_stream_parser = is_chromecast
 
   # Enable HEVC/H265 demuxing. Actual decoding must be provided by the
-  # platform.
-  enable_hevc_demuxing = false
+  # platform. Enable by default for Chromecast.
+  enable_hevc_demuxing = is_chromecast
 
   # Experiment to enable mojo media application: http://crbug.com/431776
   # Valid options are:
diff --git a/media/midi/BUILD.gn b/media/midi/BUILD.gn
index f056aed..bbf0a14 100644
--- a/media/midi/BUILD.gn
+++ b/media/midi/BUILD.gn
@@ -15,7 +15,7 @@
 
 # Common configuration for targets in the media/midi directory.
 config("midi_config") {
-  if (use_alsa) {
+  if (use_alsa && use_udev) {
     defines = [
       "USE_ALSA",
       "USE_UDEV",
diff --git a/net/BUILD.gn b/net/BUILD.gn
index 0add477..c21196b 100644
--- a/net/BUILD.gn
+++ b/net/BUILD.gn
@@ -2,6 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("//build/config/chromecast_build.gni")
 import("//build/config/compiler/compiler.gni")
 import("//build/config/crypto.gni")
 import("//build/config/features.gni")
@@ -31,9 +32,9 @@
                           "scope",
                           [ "net.gypi" ])
 
-# Disable Kerberos on ChromeOS, Android and iOS, at least for now. It needs
-# configuration (krb5.conf and so on).
-use_kerberos = !is_chromeos && !is_android && !is_ios
+# Disable Kerberos on ChromeOS, Android, iOS, and Chromecast, at least for now.
+# It needs configuration (krb5.conf and so on).
+use_kerberos = !is_chromeos && !is_android && !is_ios && !is_chromecast
 
 # The way the cache uses mmap() is inefficient on some Android devices. If
 # this flag is set, we hackily avoid using mmap() in the disk cache. We are
@@ -990,7 +991,7 @@
         "//build/config/sanitizers:deps",
       ]
 
-      if (is_desktop_linux) {
+      if (is_desktop_linux && use_gconf) {
         configs += [
           "//build/config/linux:gconf",
           "//build/config/linux:glib",
diff --git a/ui/ozone/BUILD.gn b/ui/ozone/BUILD.gn
index a11bb7f..030e0f3 100644
--- a/ui/ozone/BUILD.gn
+++ b/ui/ozone/BUILD.gn
@@ -35,6 +35,11 @@
   ozone_platform_test_deps += [ "platform/drm:gbm_unittests" ]
 }
 
+if (ozone_platform_cast) {
+  ozone_platforms += [ "cast" ]
+  ozone_platform_deps += [ "platform/cast" ]
+}
+
 platform_list_cc_file = "$target_gen_dir/platform_list.cc"
 platform_list_h_file = "$target_gen_dir/platform_list.h"
 platform_list_txt_file = "$target_gen_dir/platform_list.txt"
diff --git a/ui/ozone/ozone.gni b/ui/ozone/ozone.gni
index e0da9196..74d7aa23 100644
--- a/ui/ozone/ozone.gni
+++ b/ui/ozone/ozone.gni
@@ -2,6 +2,8 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
+import("//build/config/chromecast_build.gni")
+
 declare_args() {
   # Select platforms automatically. Turn this off for manual control.
   ozone_auto_platforms = true
@@ -13,19 +15,32 @@
 
   # Enable individual platforms.
   ozone_platform_caca = false
+  ozone_platform_cast = false
   ozone_platform_egltest = false
   ozone_platform_gbm = false
   ozone_platform_ozonex = false
   ozone_platform_test = false
 
   if (ozone_auto_platforms) {
-    # Use test as the default platform.
-    ozone_platform = "test"
+    if (is_chromecast) {
+      # The default platform used at runtime is "cast".
+      ozone_platform = "cast"
 
-    # Build all platforms whose deps are in install-build-deps.sh.
-    # Only these platforms will be compile tested by buildbots.
-    ozone_platform_gbm = true
-    ozone_platform_test = true
-    ozone_platform_egltest = true
+      # For desktop Chromecast builds, override the default "cast" platform with
+      # --ozone_platform=egltest
+      ozone_platform_cast = true
+      ozone_platform_egltest = true
+      ozone_platform_ozonex = true
+      ozone_platform_test = true
+    } else {
+      # Use test as the default platform.
+      ozone_platform = "test"
+
+      # Build all platforms whose deps are in install-build-deps.sh.
+      # Only these platforms will be compile tested by buildbots.
+      ozone_platform_gbm = true
+      ozone_platform_test = true
+      ozone_platform_egltest = true
+    }
   }
 }
diff --git a/ui/ozone/platform/cast/BUILD.gn b/ui/ozone/platform/cast/BUILD.gn
new file mode 100644
index 0000000..98b3d52f
--- /dev/null
+++ b/ui/ozone/platform/cast/BUILD.gn
@@ -0,0 +1,37 @@
+# Copyright 2015 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("//build/config/chromecast_build.gni")
+import("//ui/ozone/ozone.gni")
+
+# GYP version: cast.gypi:ozone_platform_cast
+# TODO(slan): gn check needs deps on ozone and media to pass. Correct this.
+source_set("cast") {
+  sources = [
+    "client_native_pixmap_factory_cast.cc",
+    "client_native_pixmap_factory_cast.h",
+    "gpu_platform_support_cast.cc",
+    "gpu_platform_support_cast.h",
+    "overlay_manager_cast.cc",
+    "overlay_manager_cast.h",
+    "ozone_platform_cast.cc",
+    "ozone_platform_cast.h",
+    "platform_window_cast.cc",
+    "platform_window_cast.h",
+    "surface_factory_cast.cc",
+    "surface_factory_cast.h",
+    "surface_ozone_egl_cast.cc",
+    "surface_ozone_egl_cast.h",
+  ]
+
+  deps = [
+    "//base",
+    "//chromecast/graphics:libcast_graphics",
+    "//chromecast/media:libcast_media",
+    "//ui/gfx",
+    "//ui/gfx/geometry",
+    "//ui/ozone:ozone_base",
+    "//ui/platform_window",
+  ]
+}
diff --git a/ui/ozone/platform/cast/cast.gypi b/ui/ozone/platform/cast/cast.gypi
index 694f6d85..025e11e4 100644
--- a/ui/ozone/platform/cast/cast.gypi
+++ b/ui/ozone/platform/cast/cast.gypi
@@ -15,6 +15,7 @@
     ],
   },
   'targets': [
+    # GN target: //ui/ozone/platform/cast:cast
     {
       'target_name': 'ozone_platform_cast',
       'type': 'static_library',
@@ -28,9 +29,7 @@
         '../../chromecast/chromecast.gyp:cast_public_api',
         '../../chromecast/media/media.gyp:media_base',
       ],
-      'defines': [
-        'OZONE_IMPLEMENTATION',
-      ],
+
       'sources': [
         'client_native_pixmap_factory_cast.cc',
         'client_native_pixmap_factory_cast.h',