# Copyright 2016 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/cast.gni")
import("//build/config/chrome_build.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/cronet/config.gni")
import("//build/config/dcheck_always_on.gni")
import("//build/config/features.gni")
import("//build/config/coverage/coverage.gni")

if (is_ios) {
  import("//build/config/apple/mobile_config.gni")
}

declare_args() {
  # Specify the current PGO phase.
  # Here's the different values that can be used:
  #     0 : Means that PGO is turned off.
  #     1 : Used during the PGI (instrumentation) phase.
  #     2 : Used during the PGO (optimization) phase.
  # PGO profiles are generated from `dcheck_always_on = false` builds. Mixing
  # those profiles with `dcheck_always_on = true` builds can cause the compiler
  # to think some code is hotter than it actually is, potentially causing very
  # bad compile times.
  chrome_pgo_phase = 0
  if (is_ohos || (!is_cronet_build && !dcheck_always_on && is_official_build &&
      # TODO(crbug.com/1336055): Update this now-outdated condition with regard
      # to chromecast and determine whether chromeos_is_browser_only is
      # obsolete.
      (is_high_end_android || is_win || is_mac || is_fuchsia ||
       (is_linux && !is_castos) ||
       (is_ios && use_blink && target_environment == "device")))) {
    if (!use_clang_coverage) {
    chrome_pgo_phase = 2
   }
  }

  # When using chrome_pgo_phase = 2, read profile data from this path.
  pgo_data_path = ""

  if (is_ohos) {
    pgo_data_path = "//build/pgo/ohos/arkweb.profdata"
  }

  # Whether to enable temporal pgo or not (experimental).
  temporal_pgo_profile = false

  # Flags to override the pgo profile with a freshly created one (newer than
  # the sha1 in the repo).
  pgo_override_filename = ""
  pgo_gs_bucket = ""
  pgo_gs_bucket_path = ""
}

# TODO(crbug.com/409738601): Remove assert once clang no
# longer crashes with PGO enabled for a debug build.
assert(!is_debug || chrome_pgo_phase == 0,
       "Cannot have a debug build optimized with PGO")