# Copyright 2022 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Cronet can be built within:
# 1) Chromium. By setting `is_cronet_build` to true and using GN directly.
# 2) Android. By bypassing GN and instead running
# //components/cronet/gn2bp/run_gn2bp.py.
#
# Note: in both cases Cronet is always built *for* Android. What is changing is
# the underlying repository and build infrastructure.
declare_args() {
# Signals that Cronet is being built within Android.
#
# Note: attempting to build directly with GN, while this arg is set to true,
# is wrong and will not work. Instead, this arg is used internally by the
# scripts within //components/cronet/android/gn2bp to generate Soong build
# rules to build within the Android repository.
is_cronet_for_aosp_build = false
}
# Rely on a second declare_args block. This forces `is_cronet_for_aosp_build` to
# be computed first, including overrides (see
# https://gn.googlesource.com/gn/+/main/docs/reference.md#func_declare_args).
# Allowing `is_cronet_build` to depend on the overridden value of
# `is_cronet_for_aosp_build`.
declare_args() {
# Signals that Cronet is being built. Building within Android always implies
# that Cronet is being built.
is_cronet_build = is_cronet_for_aosp_build
}
# This should only ever happen if one decides to override, at the same time,
# is_cronet_build = false and is_cronet_for_aosp_build = true.
# This is always wrong, so surface it via an assert instead of a broken build.
assert(
!is_cronet_for_aosp_build || is_cronet_build,
"`is_cronet_build` cannot be disabled when `is_cronet_for_aosp_build` is enabled.")
assert(!is_cronet_for_aosp_build || target_os == "android")