xref: /aosp_15_r20/external/cronet/third_party/cpu_features/BUILD.gn (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1# Copyright 2023 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5config("cpu_features_config") {
6  cflags = [ "-Wno-unused-function" ]
7  defines = [
8    "STACK_LINE_READER_BUFFER_SIZE=1024",
9    "HAVE_STRONG_GETAUXVAL",
10  ]
11  include_dirs = [ "src/include" ]
12}
13
14config("ndk_compat_headers") {
15  include_dirs = [ "src/ndk_compat" ]
16}
17
18source_set("cpuinfo") {
19  sources = [
20    "src/src/copy.inl",
21    "src/src/define_introspection.inl",
22    "src/src/define_introspection_and_hwcaps.inl",
23    "src/src/equals.inl",
24    "src/src/filesystem.c",
25    "src/src/hwcaps.c",
26    "src/src/stack_line_reader.c",
27    "src/src/string_view.c",
28  ]
29  if (current_cpu == "x86" || current_cpu == "x64") {
30    sources += [
31      "src/src/impl_x86__base_implementation.inl",
32      "src/src/impl_x86_freebsd.c",
33      "src/src/impl_x86_linux_or_android.c",
34      "src/src/impl_x86_macos.c",
35      "src/src/impl_x86_windows.c",
36    ]
37  } else if (current_cpu == "arm") {
38    sources += [ "src/src/impl_arm_linux_or_android.c" ]
39  } else if (current_cpu == "arm64") {
40    sources += [ "src/src/impl_aarch64_linux_or_android.c" ]
41  } else if (current_cpu == "mips") {
42    sources += [ "src/src/impl_mips_linux_or_android.c" ]
43  } else if (current_cpu == "ppc") {
44    sources += [ "src/src/impl_ppc_linux.c" ]
45  } else if (current_cpu == "riscv64") {
46    sources += [ "src/src/impl_riscv_linux.c" ]
47  } else {
48    error("Missing definition for architecture: $current_cpu")
49  }
50  configs += [ ":cpu_features_config" ]
51}
52
53source_set("ndk_compat") {
54  sources = [
55    "src/ndk_compat/cpu-features.c",
56    "src/ndk_compat/cpu-features.h",
57  ]
58  configs += [ ":cpu_features_config" ]
59  public_configs = [ ":ndk_compat_headers" ]
60  deps = [ ":cpuinfo" ]
61}
62