diff --git a/React/CoreModules/BUCK b/React/CoreModules/BUCK index 5658870246..22ead8b155 100644 --- a/React/CoreModules/BUCK +++ b/React/CoreModules/BUCK @@ -1,5 +1,9 @@ load("@fbsource//tools/build_defs/apple:flag_defs.bzl", "OBJC_ARC_PREPROCESSOR_FLAGS", "get_debug_preprocessor_flags", "get_fbobjc_enable_exception_lang_compiler_flags_DEPRECATED") -load("//tools/build_defs/oss:rn_defs.bzl", "rn_debug_flags", "rn_apple_library", "subdir_glob") +load("@fbsource//tools/build_defs/oss:rn_defs.bzl", "rn_apple_library", "rn_debug_flags", "subdir_glob") +load( + "@fbsource//xplat/configurations/buck/apple/plugins/sad_xplat_hosted_configurations:react_module_registration.bzl", + "react_module_plugin_providers", +) rn_apple_library( name = "CoreModulesApple", @@ -9,11 +13,49 @@ rn_apple_library( "**/*.mm", ], ), - headers = glob( - [ - "**/*.h", - ], + headers = ["CoreModulesPlugins.h"], + compiler_flags = [ + "-Wno-error=unguarded-availability-new", + "-Wno-unknown-warning-option", + ], + contacts = ["oncall+react_native@xmail.facebook.com"], + exported_linker_flags = [ + "-weak_framework", + "UserNotifications", + "-weak_framework", + "WebKit", + ], + exported_preprocessor_flags = rn_debug_flags(), + frameworks = [ + "Foundation", + "UIKit", + ], + lang_compiler_flags = get_fbobjc_enable_exception_lang_compiler_flags_DEPRECATED(), + link_whole = True, + platform_preprocessor_flags = [( + "linux", + ["-D PIC_MODIFIER=@PLT"], + )], + plugins = react_module_plugin_providers( + name = "PlatformConstants", + native_class_func = "RCTPlatformCls", ), + preprocessor_flags = OBJC_ARC_PREPROCESSOR_FLAGS + get_debug_preprocessor_flags() + rn_debug_flags() + [ + "-DRN_DISABLE_OSS_PLUGIN_HEADER", + ], + visibility = ["PUBLIC"], + exported_deps = [ + "fbsource//xplat/js/react-native-github:ReactInternalApple", + "fbsource//xplat/js/react-native-github/Libraries/FBReactNativeSpec:FBReactNativeSpecApple", + ":CoreModulesAppleHeader", + ], +) + +# Workaround: define exported headers target separately so that the header +# namespace can be specified correctly. +rn_apple_library( + name = "CoreModulesAppleHeader", + srcs = [], header_namespace = "", exported_headers = subdir_glob( [ @@ -22,6 +64,7 @@ rn_apple_library( "*.h", ), ], + exclude = ["CoreModulesPlugins.h"], prefix = "React", ), compiler_flags = [ @@ -40,17 +83,17 @@ rn_apple_library( "Foundation", "UIKit", ], - labels = ["depslint_never_add"], lang_compiler_flags = get_fbobjc_enable_exception_lang_compiler_flags_DEPRECATED(), link_whole = True, platform_preprocessor_flags = [( "linux", ["-D PIC_MODIFIER=@PLT"], )], - preprocessor_flags = OBJC_ARC_PREPROCESSOR_FLAGS + get_debug_preprocessor_flags() + rn_debug_flags(), + preprocessor_flags = OBJC_ARC_PREPROCESSOR_FLAGS + get_debug_preprocessor_flags() + rn_debug_flags() + [ + "-DRN_DISABLE_OSS_PLUGIN_HEADER", + ], visibility = ["PUBLIC"], exported_deps = [ "fbsource//xplat/js/react-native-github:ReactInternalApple", - "fbsource//xplat/js/react-native-github/Libraries/FBReactNativeSpec:FBReactNativeSpecApple", ], ) diff --git a/React/CoreModules/CoreModulesPlugins.h b/React/CoreModules/CoreModulesPlugins.h new file mode 100644 index 0000000000..29f2ecd51c --- /dev/null +++ b/React/CoreModules/CoreModulesPlugins.h @@ -0,0 +1,36 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +#ifdef RN_DISABLE_OSS_PLUGIN_HEADER + +// FB Internal: Plugins.h is autogenerated by the build system. +#import "Plugins.h" + +#else + +//OSS-compatibility layer: manually define these for github. + +#import + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wreturn-type-c-linkage" + +#ifdef __cplusplus +extern "C" { +#endif + +// NOTE: Sync these with FB internal version. + +Class RCTPlatformCls(void); + +#ifdef __cplusplus +} +#endif + +#pragma GCC diagnostic pop + +#endif // RN_DISABLE_OSS_PLUGIN_HEADER diff --git a/React/CoreModules/RCTPlatform.mm b/React/CoreModules/RCTPlatform.mm index 34a78484bf..b28d70248c 100644 --- a/React/CoreModules/RCTPlatform.mm +++ b/React/CoreModules/RCTPlatform.mm @@ -5,14 +5,15 @@ * LICENSE file in the root directory of this source tree. */ -#import "RCTPlatform.h" - #import #import +#import #import #import +#import "CoreModulesPlugins.h" + using namespace facebook::react; static NSString *interfaceIdiom(UIUserInterfaceIdiom idiom) { @@ -68,3 +69,7 @@ RCT_EXPORT_MODULE(PlatformConstants) } @end + +Class RCTPlatformCls(void) { + return RCTPlatform.class; +} diff --git a/tools/build_defs/oss/rn_defs.bzl b/tools/build_defs/oss/rn_defs.bzl index 0257c93b36..bf22dd5a24 100644 --- a/tools/build_defs/oss/rn_defs.bzl +++ b/tools/build_defs/oss/rn_defs.bzl @@ -331,3 +331,8 @@ def jni_instrumentation_test_lib(**_kwargs): def fb_xplat_cxx_test(**_kwargs): """A noop stub for OSS build.""" pass + +# iOS Plugin support. +def react_module_plugin_providers(): + # Noop for now + return []