Skip to content

Commit

Permalink
Update OSS Buck definitions (#31948)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #31948

Changelog: [Internal]

Adds necessary shims to bring our BUCK files closer to parsing/building correctly in open source. This is part of fixing the Buck-based tests on CircleCI which were broken by d4ee734.

Reviewed By: sammy-SC

Differential Revision: D30072866

fbshipit-source-id: be3b50f4fe99233d3777412161038f13fecd4da5
  • Loading branch information
motiz88 authored and facebook-github-bot committed Aug 4, 2021
1 parent dc15c48 commit 2abbf94
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 37 deletions.
3 changes: 3 additions & 0 deletions .buckconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@

[alias]
rntester = //packages/rn-tester/android/app:app

[project]
package_boundary_exceptions = .
60 changes: 34 additions & 26 deletions BUCK
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
load("@fbsource//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load("@fbsource//tools/build_defs:glob_defs.bzl", "subdir_glob")
load("@fbsource//tools/build_defs:platform_defs.bzl", "APPLETVOS", "IOS")
load("@fbsource//tools/build_defs/apple:config_utils_defs.bzl", "STATIC_LIBRARY_APPLETVOS_CONFIG", "fbobjc_configs")
load("@fbsource//tools/build_defs/apple:fb_apple_test.bzl", "fb_apple_test")
load("@fbsource//tools/build_defs/apple:flag_defs.bzl", "get_base_appletvos_flags", "get_objc_arc_preprocessor_flags", "get_preprocessor_flags_for_build_mode", "get_static_library_ios_flags")
load("@fbsource//tools/build_defs/oss:metro_defs.bzl", "rn_library")
load("@fbsource//tools/build_defs/oss:rn_defs.bzl", "YOGA_CXX_TARGET", "react_native_xplat_dep", "react_native_xplat_target", "rn_apple_library")
load("@fbsource//tools/build_defs/third_party:yarn_defs.bzl", "yarn_workspace")
load(
"@fbsource//xplat/configurations/buck/apple/plugins/sad_xplat_hosted_configurations:react_components_registration.bzl",
"react_fabric_component_plugin_provider",
)
load("@fbsource//xplat/hermes/defs:hermes.bzl", "HERMES_BYTECODE_VERSION")
load("@fbsource//xplat/js:rn_xplat_defs.bzl", "rn_extra_build_flags", "rn_xplat_cxx_library")
load("@fbsource//xplat/js/react-native-github/packages/react-native-codegen:DEFS.bzl", "rn_codegen_components")
load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load("//tools/build_defs/apple:config_utils_defs.bzl", "STATIC_LIBRARY_APPLETVOS_CONFIG", "fbobjc_configs")
load("//tools/build_defs/apple:fb_apple_test.bzl", "fb_apple_test")
load("//tools/build_defs/apple:flag_defs.bzl", "get_base_appletvos_flags", "get_objc_arc_preprocessor_flags", "get_preprocessor_flags_for_build_mode", "get_static_library_ios_flags")
load("//tools/build_defs/oss:metro_defs.bzl", "rn_library")
load(
"//tools/build_defs/oss:rn_codegen_defs.bzl",
"rn_codegen",
"rn_codegen_components",
)
load(
"//tools/build_defs/oss:rn_defs.bzl",
"APPLETVOS",
"HERMES_BYTECODE_VERSION",
"IOS",
"YOGA_CXX_TARGET",
"react_fabric_component_plugin_provider",
"react_native_root_target",
"react_native_xplat_dep",
"react_native_xplat_target",
"rn_apple_library",
"rn_extra_build_flags",
"rn_xplat_cxx_library2",
"subdir_glob",
)
load("//tools/build_defs/third_party:yarn_defs.bzl", "yarn_workspace")

RCTCXXBRIDGE_PUBLIC_HEADERS = {
"React/" + x: "React/CxxBridge/" + x
Expand All @@ -33,7 +39,9 @@ fb_native.genrule(
name = "codegen_rn_components_schema_rncore",
srcs = glob(
[
"**/*NativeComponent.js",
"Libraries/**/*NativeComponent.js",
"jest/**/*NativeComponent.js",
"packages/**/*NativeComponent.js",
],
exclude = [
"**/__*__/**",
Expand All @@ -42,9 +50,9 @@ fb_native.genrule(
"packages/rn-tester/**",
],
) + [
"//xplat/js/react-native-github/packages/rn-tester:nativecomponent-srcs",
react_native_root_target("packages/rn-tester:nativecomponent-srcs"),
],
cmd = "$(exe //xplat/js/react-native-github/packages/react-native-codegen:write_to_json) $OUT $SRCS",
cmd = "$(exe {}) $OUT $SRCS".format(react_native_root_target("packages/react-native-codegen:write_to_json")),
out = "schema-rncore.json",
)

Expand All @@ -53,7 +61,7 @@ rn_codegen_components(
schema_target = ":codegen_rn_components_schema_rncore",
)

rn_xplat_cxx_library(
rn_xplat_cxx_library2(
name = "RCTCxxBridge",
srcs = glob([
"React/CxxBridge/*.mm",
Expand Down Expand Up @@ -96,7 +104,7 @@ rn_xplat_cxx_library(
":ReactInternal",
"//fbobjc/Libraries/FBReactKit:RCTFBSystrace",
"//xplat/folly:molly",
"//xplat/js/react-native-github/React/CoreModules:CoreModules",
react_native_root_target("React/CoreModules:CoreModules"),
react_native_xplat_target("cxxreact:bridge"),
react_native_xplat_target("cxxreact:jsbigstring"),
react_native_xplat_target("jsi:JSCRuntime"),
Expand All @@ -114,7 +122,7 @@ RCTCXXMODULE_PUBLIC_HEADERS = {
]
}

rn_xplat_cxx_library(
rn_xplat_cxx_library2(
name = "RCTCxxModule",
srcs = glob([
"React/CxxModule/*.mm",
Expand Down Expand Up @@ -154,7 +162,7 @@ rn_xplat_cxx_library(
],
)

rn_xplat_cxx_library(
rn_xplat_cxx_library2(
name = "RCTCxxUtils",
srcs = glob([
"React/CxxUtils/*.mm",
Expand Down Expand Up @@ -310,7 +318,7 @@ REACT_COMPONENTVIEWS_BASE_FILES = [
"React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm",
]

rn_xplat_cxx_library(
rn_xplat_cxx_library2(
name = "ReactInternal",
srcs = glob(
[
Expand Down Expand Up @@ -406,7 +414,7 @@ rn_xplat_cxx_library(
],
)

rn_xplat_cxx_library(
rn_xplat_cxx_library2(
name = "RCTFabric",
srcs = glob(
[
Expand Down Expand Up @@ -628,7 +636,7 @@ rn_apple_library(
# Ideally, each component view gets its own target, and each target uses react_fabric_component_plugin_provider.
# For each component, an app can import the base component view, or an app-specific subclass.
# i.e. Apps depend on "ImageView" target for RCTImageComponentView.h, and "FBReactImageView" target for FBReactImageComponentView.h
rn_xplat_cxx_library(
rn_xplat_cxx_library2(
name = "RCTFabricComponentViewsBase",
srcs = glob(REACT_COMPONENTVIEWS_BASE_FILES),
header_namespace = "",
Expand Down
6 changes: 3 additions & 3 deletions packages/rn-tester/BUCK
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@fbsource//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load("@fbsource//tools/build_defs/oss:metro_defs.bzl", "rn_library")
load("@fbsource//tools/build_defs/third_party:yarn_defs.bzl", "yarn_workspace")
load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load("//tools/build_defs/oss:metro_defs.bzl", "rn_library")
load("//tools/build_defs/third_party:yarn_defs.bzl", "yarn_workspace")

yarn_workspace(
name = "yarn-workspace",
Expand Down
7 changes: 7 additions & 0 deletions tools/build_defs/apple/config_utils_defs.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
STATIC_LIBRARY_APPLETVOS_CONFIG = {}

def fbobjc_configs(
common_settings = {},
config_specific_settings = {},
extra_target_config = {}):
return {}
2 changes: 2 additions & 0 deletions tools/build_defs/apple/fb_apple_test.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def fb_apple_test(**kwargs):
pass
11 changes: 11 additions & 0 deletions tools/build_defs/apple/flag_defs.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def get_base_appletvos_flags():
return []

def get_objc_arc_preprocessor_flags():
return []

def get_preprocessor_flags_for_build_mode():
return []

def get_static_library_ios_flags():
return []
28 changes: 20 additions & 8 deletions tools/build_defs/oss/rn_defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ IOS = "ios"

MACOSX = "macosx"

APPLETVOS = "appletvos"

YOGA_TARGET = "//ReactAndroid/src/main/java/com/facebook:yoga"

YOGA_CXX_TARGET = "//ReactCommon/yoga:yoga"
Expand Down Expand Up @@ -86,6 +88,8 @@ def rn_xplat_cxx_library(name, **kwargs):
**new_kwargs
)

rn_xplat_cxx_library2 = rn_xplat_cxx_library

# Example: react_native_target('java/com/facebook/react/common:common')
def react_native_target(path):
return "//ReactAndroid/src/main/" + path
Expand Down Expand Up @@ -174,14 +178,7 @@ def rn_apple_library(*args, **kwargs):
kwargs.setdefault("enable_exceptions", True)
kwargs.setdefault("target_sdk_version", "11.0")

# Unsupported kwargs
_ = kwargs.pop("autoglob", False)
_ = kwargs.pop("plugins_only", False)
_ = kwargs.pop("enable_exceptions", False)
_ = kwargs.pop("extension_api_only", False)
_ = kwargs.pop("sdks", [])

native.apple_library(*args, **kwargs)
fb_apple_library(*args, **kwargs)

def rn_java_library(*args, **kwargs):
_ = kwargs.pop("is_androidx", False)
Expand Down Expand Up @@ -334,6 +331,16 @@ def _single_subdir_glob(dirpath, glob_pattern, exclude = None, prefix = None):
return results

def fb_apple_library(*args, **kwargs):
# Unsupported kwargs
_ = kwargs.pop("autoglob", False)
_ = kwargs.pop("plugins_only", False)
_ = kwargs.pop("enable_exceptions", False)
_ = kwargs.pop("extension_api_only", False)
_ = kwargs.pop("sdks", [])
_ = kwargs.pop("inherited_buck_flags", [])
_ = kwargs.pop("plugins", [])
_ = kwargs.pop("complete_nullability", False)

native.apple_library(*args, **kwargs)

def oss_cxx_library(**kwargs):
Expand All @@ -351,3 +358,8 @@ def fb_xplat_cxx_test(**_kwargs):
def react_module_plugin_providers():
# Noop for now
return []

def react_fabric_component_plugin_provider(name, native_class_func):
return None

HERMES_BYTECODE_VERSION = -1

0 comments on commit 2abbf94

Please sign in to comment.