BUCK 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. load("@fbsource//tools/build_defs/apple:flag_defs.bzl", "get_preprocessor_flags_for_build_mode")
  2. load(
  3. "//tools/build_defs/oss:rn_defs.bzl",
  4. "ANDROID",
  5. "APPLE",
  6. "CXX",
  7. "YOGA_CXX_TARGET",
  8. "fb_xplat_cxx_test",
  9. "get_apple_compiler_flags",
  10. "get_apple_inspector_flags",
  11. "react_native_target",
  12. "react_native_xplat_target",
  13. "rn_xplat_cxx_library",
  14. "subdir_glob",
  15. )
  16. APPLE_COMPILER_FLAGS = get_apple_compiler_flags()
  17. rn_xplat_cxx_library(
  18. name = "androidswitch",
  19. srcs = glob(
  20. ["**/*.cpp"],
  21. exclude = glob(["tests/**/*.cpp"]),
  22. ),
  23. headers = glob(
  24. ["**/*.h"],
  25. exclude = glob(["tests/**/*.h"]),
  26. ),
  27. header_namespace = "",
  28. exported_headers = subdir_glob(
  29. [
  30. ("", "*.h"),
  31. ("androidswitch", "*.h"),
  32. ],
  33. prefix = "react/components/androidswitch",
  34. ),
  35. compiler_flags = [
  36. "-fexceptions",
  37. "-frtti",
  38. "-std=c++14",
  39. "-Wall",
  40. ],
  41. cxx_tests = [":tests"],
  42. fbandroid_deps = [
  43. react_native_target("jni/react/jni:jni"),
  44. ],
  45. fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,
  46. fbobjc_labels = ["supermodule:ios/default/public.react_native.infra"],
  47. fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(),
  48. force_static = True,
  49. platforms = (ANDROID, APPLE, CXX),
  50. preprocessor_flags = [
  51. "-DLOG_TAG=\"ReactNative\"",
  52. "-DWITH_FBSYSTRACE=1",
  53. ],
  54. visibility = ["PUBLIC"],
  55. deps = [
  56. "//xplat/fbsystrace:fbsystrace",
  57. "//xplat/folly:headers_only",
  58. "//xplat/folly:memory",
  59. "//xplat/folly:molly",
  60. "//xplat/third-party/glog:glog",
  61. YOGA_CXX_TARGET,
  62. react_native_xplat_target("fabric/debug:debug"),
  63. react_native_xplat_target("fabric/core:core"),
  64. react_native_xplat_target("fabric/graphics:graphics"),
  65. react_native_xplat_target("fabric/components/view:view"),
  66. react_native_xplat_target("fabric/uimanager:uimanager"),
  67. "//xplat/js/react-native-github:generated_components-rncore",
  68. ],
  69. )
  70. fb_xplat_cxx_test(
  71. name = "tests",
  72. srcs = glob(["tests/**/*.cpp"]),
  73. headers = glob(["tests/**/*.h"]),
  74. compiler_flags = [
  75. "-fexceptions",
  76. "-frtti",
  77. "-std=c++14",
  78. "-Wall",
  79. ],
  80. contacts = ["oncall+react_native@xmail.facebook.com"],
  81. platforms = (
  82. # `Apple` and `Android` flavors are disabled because the module depends on `textlayoutmanager` which requires real an Emulator/Simulator to run.
  83. # At the same time, the code of tests does not rely on the simulator capabilities and it would be wasteful to add `fbandroid_use_instrumentation_test = True`.
  84. # (Beware of this option though.)
  85. # ANDROID,
  86. # APPLE,
  87. CXX
  88. ),
  89. deps = [
  90. ":androidswitch",
  91. "//xplat/folly:molly",
  92. "//xplat/third-party/gmock:gtest",
  93. ],
  94. )