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", "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        "pfh:ReactNative_CommonInfrastructurePlaceholder",
42        "supermodule:xplat/default/public.react_native.infra",
43    ],
44    link_whole = True,
45    platform_preprocessor_flags = [(
46        "linux",
47        ["-D PIC_MODIFIER=@PLT"],
48    )],
49    plugins =
50        react_module_plugin_providers(
51            name = "AccessibilityManager",
52            native_class_func = "RCTAccessibilityManagerCls",
53        ) + react_module_plugin_providers(
54            name = "Appearance",
55            native_class_func = "RCTAppearanceCls",
56        ) + react_module_plugin_providers(
57            name = "DeviceInfo",
58            native_class_func = "RCTDeviceInfoCls",
59        ) + react_module_plugin_providers(
60            name = "ExceptionsManager",
61            native_class_func = "RCTExceptionsManagerCls",
62        ) + react_module_plugin_providers(
63            name = "PlatformConstants",
64            native_class_func = "RCTPlatformCls",
65        ) + react_module_plugin_providers(
66            name = "Clipboard",
67            native_class_func = "RCTClipboardCls",
68        ) + react_module_plugin_providers(
69            name = "I18nManager",
70            native_class_func = "RCTI18nManagerCls",
71        ) + react_module_plugin_providers(
72            name = "SourceCode",
73            native_class_func = "RCTSourceCodeCls",
74        ) + react_module_plugin_providers(
75            name = "ActionSheetManager",
76            native_class_func = "RCTActionSheetManagerCls",
77        ) + react_module_plugin_providers(
78            name = "AlertManager",
79            native_class_func = "RCTAlertManagerCls",
80        ) + react_module_plugin_providers(
81            name = "AsyncLocalStorage",
82            native_class_func = "RCTAsyncLocalStorageCls",
83        ) + react_module_plugin_providers(
84            name = "Timing",
85            native_class_func = "RCTTimingCls",
86        ) + react_module_plugin_providers(
87            name = "StatusBarManager",
88            native_class_func = "RCTStatusBarManagerCls",
89        ) + react_module_plugin_providers(
90            name = "KeyboardObserver",
91            native_class_func = "RCTKeyboardObserverCls",
92        ) + react_module_plugin_providers(
93            name = "AppState",
94            native_class_func = "RCTAppStateCls",
95        ) + react_module_plugin_providers(
96            name = "PerfMonitor",
97            native_class_func = "RCTPerfMonitorCls",
98        ) + react_module_plugin_providers(
99            name = "DevMenu",
100            native_class_func = "RCTDevMenuCls",
101        ) + react_module_plugin_providers(
102            name = "DevSettings",
103            native_class_func = "RCTDevSettingsCls",
104        ) + react_module_plugin_providers(
105            name = "RedBox",
106            native_class_func = "RCTRedBoxCls",
107        ) + react_module_plugin_providers(
108            name = "LogBox",
109            native_class_func = "RCTLogBoxCls",
110        ) + react_module_plugin_providers(
111            name = "WebSocketExecutor",
112            native_class_func = "RCTWebSocketExecutorCls",
113        ) + react_module_plugin_providers(
114            name = "WebSocketModule",
115            native_class_func = "RCTWebSocketModuleCls",
116        ) + react_module_plugin_providers(
117            name = "DevLoadingView",
118            native_class_func = "RCTDevLoadingViewCls",
119        ) + react_module_plugin_providers(
120            name = "DevSplitBundleLoader",
121            native_class_func = "RCTDevSplitBundleLoaderCls",
122        ) + react_module_plugin_providers(
123            name = "EventDispatcher",
124            native_class_func = "RCTEventDispatcherCls",
125        ),
126    plugins_header = "FBCoreModulesPlugins.h",
127    preprocessor_flags = get_objc_arc_preprocessor_flags() + get_preprocessor_flags_for_build_mode() + rn_extra_build_flags() + [
128        "-DRN_DISABLE_OSS_PLUGIN_HEADER",
129    ],
130    reexport_all_header_dependencies = True,
131    visibility = ["PUBLIC"],
132    exported_deps = [
133        "//xplat/js/react-native-github:FBReactNativeSpecApple",
134        "//xplat/js/react-native-github:RCTLinkingApple",
135        "//xplat/js/react-native-github:RCTPushNotificationApple",
136        "//xplat/js/react-native-github:ReactInternalApple",
137    ],
138)
139