BUILD.gn 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. # Copyright 2014 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. import("//build/config/chromecast_build.gni")
  5. import("//build/config/chromeos/ui_mode.gni")
  6. import("//build/config/features.gni")
  7. import("//build/config/linux/pkg_config.gni")
  8. import("//build/config/ui.gni")
  9. import("//components/os_crypt/features.gni")
  10. if (use_gnome_keyring) {
  11. # Gnome-keyring is normally dynamically loaded. The gnome_keyring config
  12. # will set this up.
  13. pkg_config("gnome_keyring") {
  14. packages = [ "gnome-keyring-1" ]
  15. defines = [ "USE_GNOME_KEYRING" ]
  16. ignore_libs = true
  17. }
  18. # If you want to link gnome-keyring directly (use only for unit tests)
  19. # ADDITIONALLY add this config on top of ":gnome_keyring". pkg-config is a
  20. # bit slow, so prefer not to run it again. In practice, gnome-keyring's libs
  21. # are just itself and common gnome ones we link already, so we can get away
  22. # with additionally just coding the library name here.
  23. # TODO(cfroussios): This is only used by
  24. # chrome/browser/password_manager/native_backend_gnome_x_unittest.cc
  25. # We should deprecate both.
  26. config("gnome_keyring_direct") {
  27. libs = [ "gnome-keyring" ]
  28. }
  29. }
  30. component("os_crypt") {
  31. sources = [
  32. "os_crypt.h",
  33. "os_crypt_switches.cc",
  34. "os_crypt_switches.h",
  35. ]
  36. deps = [
  37. "//base",
  38. "//build:branding_buildflags",
  39. "//build:chromecast_buildflags",
  40. "//build:chromeos_buildflags",
  41. "//components/prefs",
  42. "//crypto",
  43. ]
  44. configs += [ "//build/config/compiler:wexit_time_destructors" ]
  45. defines = [ "IS_OS_CRYPT_IMPL" ]
  46. if (allow_runtime_configurable_key_storage) {
  47. defines += [ "ALLOW_RUNTIME_CONFIGURABLE_KEY_STORAGE" ]
  48. }
  49. # TODO(crbug.com/1339022): Provide a Fuchsia-specific implementation.
  50. if ((is_posix && !is_apple && !(is_linux && !is_castos)) || is_fuchsia) {
  51. sources += [ "os_crypt_posix.cc" ]
  52. }
  53. if (is_apple) {
  54. sources += [
  55. "keychain_password_mac.h",
  56. "keychain_password_mac.mm",
  57. "os_crypt_mac.mm",
  58. ]
  59. }
  60. if (is_win) {
  61. sources += [ "os_crypt_win.cc" ]
  62. libs = [ "crypt32.lib" ]
  63. }
  64. if (is_linux && !is_castos) {
  65. sources += [
  66. "key_storage_config_linux.cc",
  67. "key_storage_config_linux.h",
  68. "key_storage_linux.cc",
  69. "key_storage_linux.h",
  70. "key_storage_util_linux.cc",
  71. "key_storage_util_linux.h",
  72. "os_crypt_linux.cc",
  73. ]
  74. if (use_gnome_keyring) {
  75. sources += [
  76. "key_storage_keyring.cc",
  77. "key_storage_keyring.h",
  78. "keyring_util_linux.cc",
  79. "keyring_util_linux.h",
  80. ]
  81. configs += [ ":gnome_keyring" ]
  82. defines += [ "USE_KEYRING" ]
  83. }
  84. if (use_glib) {
  85. sources += [
  86. "key_storage_libsecret.cc",
  87. "key_storage_libsecret.h",
  88. "libsecret_util_linux.cc",
  89. "libsecret_util_linux.h",
  90. ]
  91. configs += [ "//build/config/linux:glib" ]
  92. deps += [ "//third_party/libsecret" ]
  93. defines += [ "USE_LIBSECRET" ]
  94. }
  95. if (use_dbus) {
  96. sources += [
  97. "key_storage_kwallet.cc",
  98. "key_storage_kwallet.h",
  99. "kwallet_dbus.cc",
  100. "kwallet_dbus.h",
  101. ]
  102. deps += [ "//dbus" ]
  103. defines += [ "USE_KWALLET" ]
  104. }
  105. }
  106. }
  107. static_library("test_support") {
  108. testonly = true
  109. sources = [
  110. "os_crypt_mocker.cc",
  111. "os_crypt_mocker.h",
  112. ]
  113. deps = [
  114. ":os_crypt",
  115. "//base",
  116. "//testing/gtest",
  117. ]
  118. if (is_linux && !is_castos) {
  119. sources += [
  120. "os_crypt_mocker_linux.cc",
  121. "os_crypt_mocker_linux.h",
  122. ]
  123. defines = []
  124. if (use_gnome_keyring) {
  125. defines += [ "USE_KEYRING" ]
  126. }
  127. if (use_glib) {
  128. defines += [ "USE_LIBSECRET" ]
  129. }
  130. if (use_dbus) {
  131. defines += [ "USE_KWALLET" ]
  132. }
  133. }
  134. }
  135. source_set("unit_tests") {
  136. testonly = true
  137. sources = [ "os_crypt_unittest.cc" ]
  138. deps = [
  139. ":os_crypt",
  140. ":test_support",
  141. "//base",
  142. "//base/test:test_support",
  143. "//build:branding_buildflags",
  144. "//build:chromeos_buildflags",
  145. "//components/prefs:test_support",
  146. "//crypto",
  147. "//testing/gmock",
  148. "//testing/gtest",
  149. ]
  150. if (is_apple) {
  151. sources += [ "keychain_password_mac_unittest.mm" ]
  152. }
  153. if (is_linux && !is_castos) {
  154. sources += [
  155. "key_storage_linux_unittest.cc",
  156. "key_storage_util_linux_unittest.cc",
  157. "os_crypt_linux_unittest.cc",
  158. ]
  159. defines = []
  160. if (use_gnome_keyring) {
  161. sources += [ "key_storage_keyring_unittest.cc" ]
  162. configs += [ ":gnome_keyring" ]
  163. deps += [ "//base/test:test_support" ]
  164. defines += [ "USE_KEYRING" ]
  165. }
  166. if (use_glib) {
  167. sources += [ "key_storage_libsecret_unittest.cc" ]
  168. deps += [ "//third_party/libsecret" ]
  169. defines += [ "USE_LIBSECRET" ]
  170. }
  171. if (use_dbus) {
  172. sources += [
  173. "key_storage_kwallet_unittest.cc",
  174. "kwallet_dbus_unittest.cc",
  175. ]
  176. deps += [ "//dbus:test_support" ]
  177. defines += [ "USE_KWALLET" ]
  178. }
  179. }
  180. }