Files
react-native/packages/react-native-codegen/BUCK
T
Kevin Gozali 16044b3c2a Codegen Buck: fork schema generator target for FB vs OSS via rn_codegen_cli()
Summary:
Introduced a helper macro `rn_codegen_cli()` that defines ":write_to_json" and ":rn_codegen" targets differently based on the environment. When run at FB, it uses FB-specific setup. When run in OSS as a standalone repo, we use `yarn install` and `yarn run build` directly, then use `node` to run the output CLI.

This way, the same target can be used in both environments on other Buck targets.

Motivation: we need this to define rn_codegen_modules() to use codegen to produce Java TurboModule specs, that can be built by CircleCI (we build ReactAndroid via Buck as well). That way we can finally removed the checked-in .java spec files.

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D24442468

fbshipit-source-id: b1e5fce275100cfe3a1b3ae6d61c1c6d4b25651b
2020-10-22 17:09:30 -07:00

138 lines
3.6 KiB
Python

load("//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "IOS", "IS_OSS_BUILD", "react_native_root_target", "react_native_target", "rn_android_library", "rn_xplat_cxx_library")
load("//tools/build_defs/third_party:yarn_defs.bzl", "yarn_workspace")
load(":DEFS.bzl", "rn_codegen_cli", "rn_codegen_components", "rn_codegen_modules")
rn_codegen_cli()
SETUP_ENV_DEPS = [] if IS_OSS_BUILD else [
"//xplat/js:setup_env",
]
fb_native.sh_binary(
name = "codegen_rn_modules_tests",
main = "src/cli/verify_with_old_codegen.sh",
visibility = ["PUBLIC"],
resources = [
"src/cli/verify_with_old_codegen.js",
"src/cli/verify_with_old_codegen.sh",
] + SETUP_ENV_DEPS,
)
fb_native.sh_test(
name = "verify_all_modules_with_old_codegen",
test = "src/cli/verify_all_modules_with_old_codegen.sh",
visibility = ["PUBLIC"],
)
fb_native.genrule(
name = "codegen_tests_schema",
srcs = glob(
[
"**/e2e/__test_fixtures__/components/*NativeComponent.js",
"**/e2e/__test_fixtures__/modules/Native*.js",
],
),
cmd = "$(exe {}) $OUT $SRCS".format(react_native_root_target("packages/react-native-codegen:write_to_json")),
out = "schema-codegen_tests.json",
)
rn_codegen_components(
name = "codegen_tests",
schema_target = ":codegen_tests_schema",
)
rn_codegen_modules(
name = "codegen_tests",
native_module_spec_name = "FBReactNativeTestSpec",
schema_target = ":codegen_tests_schema",
)
rn_android_library(
name = "rn_codegen_library_java",
srcs = glob(
["**/*.java"],
exclude = ["android/gradlePlugin-build/**/*"],
),
visibility = [
"PUBLIC",
],
deps = [
react_native_target("java/com/facebook/react/bridge:bridge"),
react_native_target("java/com/facebook/react/common:common"),
react_native_target("java/com/facebook/react/views/view:view"),
react_native_target("java/com/facebook/react/uimanager:uimanager"),
":generated_components_java-codegen_tests",
],
)
rn_xplat_cxx_library(
name = "rn_codegen_library",
srcs = ["buck_tests/emptyFile.cpp"],
headers = [],
compiler_flags = [
"-fexceptions",
"-frtti",
"-std=c++14",
"-Wall",
],
platforms = (ANDROID, APPLE),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",
],
visibility = [
"PUBLIC",
],
deps = [
":generated_components-codegen_tests",
],
)
rn_xplat_cxx_library(
name = "rn_codegen_library_mm",
srcs = ["buck_tests/emptyFile.mm"],
headers = [],
apple_sdks = (IOS,),
compiler_flags = [
"-fexceptions",
"-frtti",
"-std=c++14",
"-Wall",
],
platforms = (APPLE),
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",
],
visibility = [
"PUBLIC",
],
deps = [
":generated_components-codegen_tests",
":generated_objcpp_modules-codegen_tests",
],
)
yarn_workspace(
name = "yarn-workspace",
srcs = glob(
["**/*.js"],
exclude = [
"**/__fixtures__/**",
"**/__flowtests__/**",
"**/__mocks__/**",
"**/__server_snapshot_tests__/**",
"**/__tests__/**",
"**/node_modules/**",
"**/node_modules/.bin/**",
"**/.*",
"**/.*/**",
"**/.*/.*",
"**/*.xcodeproj/**",
"**/*.xcworkspace/**",
],
),
visibility = ["PUBLIC"],
)