# Copyright (C) 2017 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//gn/perfetto_check_build_deps.gni")
import("//gn/standalone/android.gni")
import("//gn/standalone/sanitizers/sanitizers.gni")
import("//gn/standalone/wasm.gni")

# These warnings have been introduced with the newest version of clang (only in
# the hermetic build) and are enabled just with -Werror.
hermetic_clang_suppressions = [ "-Wno-c99-designator" ]

config("extra_warnings") {
  cflags = [
    "-Wall",
    "-Wextra",
    "-Wpedantic",
  ]

  # Disable variadic macro warning as we make extensive use of them in trace
  # processor and client API.
  if (is_clang) {
    cflags += [ "-Wno-gnu-zero-variadic-macro-arguments" ]
  }

  # Disable Weverything on fuzzers to avoid breakages when new versions of clang
  # are rolled into OSS-fuzz.
  if (is_clang && !is_fuzzer) {
    cflags += [
      "-Weverything",
      "-Wno-c++98-compat-pedantic",
      "-Wno-c++98-compat",
      "-Wno-disabled-macro-expansion",
      "-Wno-gnu-include-next",
      "-Wno-gnu-statement-expression",
      "-Wno-padded",
      "-Wno-reserved-id-macro",
      "-Wno-unknown-sanitizers",
      "-Wno-unknown-warning-option",
      "-Wno-poison-system-directories",
    ]
  }

  if (!is_clang) {
    # Use return std::move(...) for compatibility with old compilers.
    cflags += [ "-Wno-redundant-move" ]
  }
}

config("no_exceptions") {
  cflags_cc = [ "-fno-exceptions" ]
}

config("no_rtti") {
  cflags_cc = [ "-fno-rtti" ]
}

config("c++11") {
  cflags_cc = [ "-std=c++11" ]
}

# This is needed to compile libunwindstack.
config("c++17") {
  cflags_cc = [ "-std=c++17" ]
}

config("visibility_hidden") {
  cflags = [ "-fvisibility=hidden" ]
}

config("default") {
  asmflags = []
  cflags = []
  cflags_c = []
  cflags_cc = []
  defines = []
  ldflags = []
  libs = []

  if (is_android || is_linux) {
    ldflags += [ "-Wl,--build-id" ]
  }

  cflags += [
    "-fstrict-aliasing",
    "-fstack-protector-strong",
    "-fPIC",
    "-g",
    "-Wformat",
  ]

  if (!is_fuzzer) {
    cflags += [ "-Werror" ]
  }

  if (is_clang) {
    cflags += [
      # Color compiler output, see https://github.com/ninja-build/ninja/wiki/FAQ
      "-fcolor-diagnostics",
      "-fdiagnostics-show-template-tree",
    ]
  }

  if (is_hermetic_clang && is_linux && !is_wasm) {
    cflags += hermetic_clang_suppressions
  } else {
    not_needed([ "hermetic_clang_suppressions" ])
  }

  if (is_lto) {
    cflags += [ "-flto=full" ]
    ldflags += [ "-flto=full" ]
  }

  if (current_cpu == "arm") {
    cflags += [
      "-march=armv7-a",
      "-mfpu=neon",
      "-mthumb",
    ]
  } else if (current_cpu == "x86") {
    asmflags += [ "-m32" ]
    cflags += [
      "-m32",
      "-msse2",
      "-mfpmath=sse",
    ]
    ldflags += [
      "-m32",
      "-lgcc",
    ]
  } else if (current_cpu == "arm64") {
    cflags += [ "-fno-omit-frame-pointer" ]
  }

  if (is_linux) {
    libs += [
      "pthread",
      "rt",
    ]
  }

  if (is_debug) {
    libs += [ "dl" ]
  }

  if (is_android) {
    asmflags += [ "--target=$android_abi_target" ]
    cflags += [
      "--sysroot=$android_compile_sysroot",
      "-isystem$android_compile_sysroot/$android_compile_sysroot_subdir",
      "-isystem$android_compile_sysroot",
      "-DANDROID",
      "-D__ANDROID_API__=${android_api_level}",
      "--target=$android_abi_target",
    ]
    cflags_cc += [
      "-I$android_ndk_root/sources/cxx-stl/llvm-libc++/include",
      "-I$android_ndk_root/sources/android/support/include",
      "-I$android_ndk_root/sources/cxx-stl/llvm-libc++abi/include",

      # This is needed for NDK libc++. Using -isystem instead of -I above
      # results in build breakage related to cmath.h.
      "-Wno-format-nonliteral",
    ]
    ldflags += [
      "-Wl,-z,nocopyreloc",
      "-gcc-toolchain",
      "$android_toolchain_root",
      "--sysroot=$android_ndk_root/$android_link_sysroot_subdir",
      "--target=$android_abi_target",
      "-Wl,--exclude-libs,libunwind.a",
      "-Wl,--exclude-libs,libgcc.a",
      "-Wl,--exclude-libs,libc++_static.a",
      "-Wl,--no-undefined",
      "-Wl,-z,noexecstack",
      "-Wl,-z,relro",
      "-Wl,-z,now",
      "-Wl,--warn-shared-textrel",
      "-Wl,--fatal-warnings",
    ]
    lib_dirs = [
      "$android_ndk_root/sources/cxx-stl/llvm-libc++/libs/$android_app_abi",
    ]
    libs += [
      "gcc",
      "c++_static",
      "c++abi",
    ]

    if (current_cpu == "arm") {
      # New NDKs don't have libandroid_support for arm64.
      libs += [ "android_support" ]
    }
  }
}

config("debug_symbols") {
  cflags = [ "-O0" ]
  if (is_android || is_linux) {
    cflags += [ "-funwind-tables" ]
  }
}

config("release") {
  cflags = [
    "-fdata-sections",
    "-ffunction-sections",
  ]
  if (is_android) {
    cflags += [ "-O2" ]
  } else if (is_fuzzer) {
    cflags += [ "-O1" ]
  } else {
    cflags += [ "-O3" ]
  }
  if (is_mac) {
    ldflags = [ "-dead_strip" ]
  } else {
    ldflags = [
      "-Wl,--gc-sections",
      "-Wl,--icf=all",
      "-Wl,-O1",
    ]
  }
  defines = [ "NDEBUG" ]
}

config("shared_library") {
  if (is_android || is_linux) {
    ldflags = [ "-fPIC" ]
  }
}

config("executable") {
  ldflags = []

  # Android will refuse to run executables if they aren't position independent.
  # Instead on Linux there isn't any need and they break ASan (goo.gl/paFR6K).
  if (is_android || is_linux) {
    asmflags = [ "-fPIE" ]
    cflags = [ "-fPIE" ]
    ldflags += [ "-pie" ]
  }

  # -rpath stores the path to the linked shared libraries into the binary, so
  # that they can be launched without passing any LD_LIBRARY_PATH. It's
  # supported only by Linux, not Android. But concretely we need this only when
  # use_custom_libcxx=true && custom_libcxx_is_static=false, which happens only
  # on Linux right now.
  if (is_linux) {
    ldflags += [
      "-Wl,-rpath=\$ORIGIN/.",
      "-Wl,-rpath-link=.",
    ]
  }
}

# This config is only added to certain leaf target types (see BUILDCONFIG.gn).
# This allows us to remove the config (and thus the dependency) on a per-target
# basis. If the config was applied to source_sets, then they would unavoidably
# carry the dependency onto liblog to the final target.
config("android_liblog") {
  if (is_android) {
    libs = [ "log" ]
  }
}

# Checks that tools/install-build-deps has been run since it last changed.
perfetto_check_build_deps("check_build_deps") {
  args = []
}

perfetto_check_build_deps("check_build_deps_android") {
  args = [ "--android" ]
}
