# Copyright 2018 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/buildflag_header.gni")
import("//build/config/nacl/config.gni")
import("//services/service_manager/zygote/common/zygote_features.gni")

if (is_linux) {
  component("zygote") {
    if (is_nacl_nonsfi) {
      # When running the nacl toolchain is_linux is false so *_linux.cc files are
      # excluded. Reset the filter so they are included.
      set_sources_assignment_filter([])
    }

    sources = [
      "common/common_sandbox_support_linux.cc",
      "common/common_sandbox_support_linux.h",
      "common/zygote_fork_delegate_linux.h",
      "common/zygote_handle.h",
      "host/zygote_communication_linux.cc",
      "host/zygote_communication_linux.h",
      "host/zygote_host_impl_linux.cc",
      "host/zygote_host_impl_linux.h",
      "zygote_linux.cc",
      "zygote_linux.h",
      "zygote_main.h",
      "zygote_main_linux.cc",
    ]

    if (use_zygote_handle) {
      sources += [
        "common/zygote_handle.h",
        "host/zygote_handle_linux.cc",
      ]
    }

    public_deps = [
      ":zygote_buildflags",
      ":zygote_util",
    ]

    deps = [
      "//base",
      "//base:i18n",
      "//ipc",
      "//sandbox",
      "//services/service_manager/embedder",
      "//services/service_manager/sandbox",
      "//third_party/icu",
    ]

    defines = [ "IS_SERVICE_MANAGER_ZYGOTE_IMPL" ]
  }
}

source_set("zygote_util") {
  if (is_nacl_nonsfi) {
    # When running the nacl toolchain is_linux is false so *_linux.cc files are
    # excluded. Reset the filter so they are included.
    set_sources_assignment_filter([])
  }

  sources = [
    "common/send_zygote_child_ping_linux.cc",
    "common/send_zygote_child_ping_linux.h",
    "common/zygote_commands_linux.h",
  ]

  deps = [
    "//base",
    "//services/service_manager/sandbox:sanitizer_buildflags",
  ]

  defines = [ "IS_SERVICE_MANAGER_ZYGOTE_IMPL" ]
}

buildflag_header("zygote_buildflags") {
  header = "common/zygote_buildflags.h"
  flags = [ "USE_ZYGOTE_HANDLE=$use_zygote_handle" ]
}
