# Copyright 2014 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("//mojo/public/tools/bindings/mojom.gni")
import("//build/config/ui.gni")

executable("mojo_shell") {
  deps = [
    ":lib",
    "//base",
    "//mojo/common",
    "//mojo/environment:chromium",
    "//ui/gfx",
  ]

  if (is_component_build) {
    deps += ["//ui/gl"]
  }

  sources = [
    "desktop/mojo_main.cc"
  ]
}

# GYP version: mojo/mojo.gyp:mojo_shell_lib
source_set("lib") {
  deps = [
    ":app_child_process_bindings",
    ":external_service_bindings",
    "//base",
    "//base/third_party/dynamic_annotations",
    "//base:base_static",
    "//mojo/application",
    "//mojo/application_manager",
    "//mojo/common",
    "//mojo/gles2",
    "//mojo/public/interfaces/application",
    "//mojo/services/public/interfaces/network",
    "//mojo/spy",
    "//mojo/system",
  ]

  sources = [
    "app_child_process.cc",
    "app_child_process.h",
    "app_child_process_host.cc",
    "app_child_process_host.h",
    "child_process.cc",
    "child_process.h",
    "child_process_host.cc",
    "child_process_host.h",
    "context.cc",
    "context.h",
    "dbus_application_loader_linux.cc",
    "dbus_application_loader_linux.h",
    "dynamic_application_loader.cc",
    "dynamic_application_loader.h",
    "dynamic_service_runner.h",
    "init.cc",
    "init.h",
    "in_process_dynamic_service_runner.cc",
    "in_process_dynamic_service_runner.h",
    "mojo_url_resolver.cc",
    "mojo_url_resolver.h",
    "out_of_process_dynamic_service_runner.cc",
    "out_of_process_dynamic_service_runner.h",
    "switches.cc",
    "switches.h",
    "task_runners.cc",
    "task_runners.h",
    "test_child_process.cc",
    "test_child_process.h",
    "ui_application_loader_android.cc",
    "ui_application_loader_android.h",
  ]

  if (is_linux) {
    deps += ["//dbus"]
  } else if (is_android) {
    deps += [
      "//mojo/services/native_viewport:lib",
      "//mojo/services/network:lib",
    ]
    sources += [
      "network_application_loader.cc",
      "network_application_loader.h",
    ]
  }
}

mojom("app_child_process_bindings") {
  sources = [
    "app_child_process.mojom"
  ]
}

mojom("external_service_bindings") {
  sources = [
    "external_service.mojom"
  ]
}

test("mojo_shell_tests") {
  deps = [
    ":lib",
    "//base",
    "//base:i18n",
    "//base/test:test_support",
    "//testing/gtest",
    "//net:test_support",
    "//url",
    "//mojo/application_manager",
    "//mojo/services/test_service:bindings",
    "//mojo/common",
    "//mojo/environment:chromium",
    "//mojo/system",
  ]

  datadeps = [
    "//mojo/services/test_service:mojo_test_app",
    "//mojo/services/test_service:mojo_test_request_tracker_app",
  ]

  sources = [
    "child_process_host_unittest.cc",
    "dynamic_application_loader_unittest.cc",
    "in_process_dynamic_service_runner_unittest.cc",
    "shell_test_base.cc",
    "shell_test_base.h",
    "shell_test_base_unittest.cc",
    "shell_test_main.cc",
  ]

  if (is_android) {
    deps += [
      # TODO(GYP):
      #'../testing/android/native_test.gyp:native_test_native_code',
    ]
  }
}

# GYP version: mojo/mojo.gyp:mojo_shell_test_support
source_set("test_support") {
  sources = [
    "shell_test_helper.cc",
    "shell_test_helper.h",
  ]

  deps = [
    ":lib",
    "//base:base_static",
    "//mojo/system",
  ]
}