1load("@fbsource//tools/build_defs/apple:flag_defs.bzl", "get_objc_arc_preprocessor_flags", "get_preprocessor_flags_for_build_mode")
2load("@fbsource//tools/build_defs/oss:rn_defs.bzl", "react_native_xplat_target", "rn_apple_library", "rn_extra_build_flags")
3load(
4    "@fbsource//xplat/configurations/buck/apple/plugins/sad_xplat_hosted_configurations:react_module_registration.bzl",
5    "react_module_plugin_providers",
6)
7
8rn_apple_library(
9    name = "CoreModulesApple",
10    srcs = glob(
11        [
12            "**/*.m",
13            "**/*.mm",
14        ],
15    ),
16    exported_headers = glob(["**/*.h"]),
17    autoglob = False,
18    compiler_flags = [
19        "-Wno-error=unguarded-availability-new",
20        "-Wno-unknown-warning-option",
21        "-Wno-unused-property-ivar",
22    ],
23    contacts = ["[email protected]"],
24    enable_exceptions = True,
25    exported_linker_flags = [
26        "-weak_framework",
27        "UserNotifications",
28        "-weak_framework",
29        "WebKit",
30    ],
31    exported_preprocessor_flags = rn_extra_build_flags(),
32    extension_api_only = True,
33    frameworks = [
34        "Foundation",
35        "UIKit",
36    ],
37    header_path_prefix = "React",
38    labels = [
39        "depslint_never_remove",  # Some old NativeModule still relies on +load unfortunately.
40        "disable_plugins_only_validation",
41        "fbios_link_group:xplat/default/public.react_native.infra",
42        "pfh:ReactNative_CommonInfrastructurePlaceholder",
43        "talkios_link_group:xplat/default/public.react_native.infra",
44    ],
45    link_whole = True,
46    platform_preprocessor_flags = [(
47        "linux",
48        ["-D PIC_MODIFIER=@PLT"],
49    )],
50    plugins =
51        react_module_plugin_providers(
52            name = "AccessibilityManager",
53            native_class_func = "RCTAccessibilityManagerCls",
54        ) + react_module_plugin_providers(
55            name = "Appearance",
56            native_class_func = "RCTAppearanceCls",
57        ) + react_module_plugin_providers(
58            name = "DeviceInfo",
59            native_class_func = "RCTDeviceInfoCls",
60        ) + react_module_plugin_providers(
61            name = "ExceptionsManager",
62            native_class_func = "RCTExceptionsManagerCls",
63        ) + react_module_plugin_providers(
64            name = "PlatformConstants",
65            native_class_func = "RCTPlatformCls",
66        ) + react_module_plugin_providers(
67            name = "Clipboard",
68            native_class_func = "RCTClipboardCls",
69        ) + react_module_plugin_providers(
70            name = "I18nManager",
71            native_class_func = "RCTI18nManagerCls",
72        ) + react_module_plugin_providers(
73            name = "SourceCode",
74            native_class_func = "RCTSourceCodeCls",
75        ) + react_module_plugin_providers(
76            name = "ActionSheetManager",
77            native_class_func = "RCTActionSheetManagerCls",
78        ) + react_module_plugin_providers(
79            name = "AlertManager",
80            native_class_func = "RCTAlertManagerCls",
81        ) + react_module_plugin_providers(
82            name = "Timing",
83            native_class_func = "RCTTimingCls",
84        ) + react_module_plugin_providers(
85            name = "StatusBarManager",
86            native_class_func = "RCTStatusBarManagerCls",
87        ) + react_module_plugin_providers(
88            name = "KeyboardObserver",
89            native_class_func = "RCTKeyboardObserverCls",
90        ) + react_module_plugin_providers(
91            name = "AppState",
92            native_class_func = "RCTAppStateCls",
93        ) + react_module_plugin_providers(
94            name = "PerfMonitor",
95            native_class_func = "RCTPerfMonitorCls",
96        ) + react_module_plugin_providers(
97            name = "DevMenu",
98            native_class_func = "RCTDevMenuCls",
99        ) + react_module_plugin_providers(
100            name = "DevSettings",
101            native_class_func = "RCTDevSettingsCls",
102        ) + react_module_plugin_providers(
103            name = "RedBox",
104            native_class_func = "RCTRedBoxCls",
105        ) + react_module_plugin_providers(
106            name = "LogBox",
107            native_class_func = "RCTLogBoxCls",
108        ) + react_module_plugin_providers(
109            name = "WebSocketExecutor",
110            native_class_func = "RCTWebSocketExecutorCls",
111        ) + react_module_plugin_providers(
112            name = "WebSocketModule",
113            native_class_func = "RCTWebSocketModuleCls",
114        ) + react_module_plugin_providers(
115            name = "DevLoadingView",
116            native_class_func = "RCTDevLoadingViewCls",
117        ) + react_module_plugin_providers(
118            name = "DevSplitBundleLoader",
119            native_class_func = "RCTDevSplitBundleLoaderCls",
120        ) + react_module_plugin_providers(
121            name = "EventDispatcher",
122            native_class_func = "RCTEventDispatcherCls",
123        ),
124    plugins_header = "FBCoreModulesPlugins.h",
125    preprocessor_flags = get_objc_arc_preprocessor_flags() + get_preprocessor_flags_for_build_mode() + rn_extra_build_flags() + [
126        "-DRN_DISABLE_OSS_PLUGIN_HEADER",
127    ],
128    reexport_all_header_dependencies = True,
129    visibility = ["PUBLIC"],
130    deps = [
131        react_native_xplat_target("react/renderer/mapbuffer:mapbufferApple"),
132    ],
133    exported_deps = [
134        "//xplat/js/react-native-github:FBReactNativeSpecApple",
135        "//xplat/js/react-native-github:RCTLinkingApple",
136        "//xplat/js/react-native-github:RCTPushNotificationApple",
137        "//xplat/js/react-native-github:ReactInternalApple",
138    ],
139)
140