mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
efec97f2be
Summary: This diff adds a babel plugin for the generated view configs which will inline them in the file instead of needing to check the view configs in (fb only) The way it works is: - babel reads the code - looks for type alias `CodegenNativeComponent` in `*NativeComponet.js` files - run the flow parser on the file source to create a schema - run the schema into codegen to get the view config source code - inject the generated source code back into the NativeComponent.js file - remove the original export - profit After this diff we will remove the `js1 build viewconfigs` command and the checked-in NativeViewConfig.js files Note: since this plugin is not published to open source, for now OSS will continue using the `requireNativeComponent` function Reviewed By: cpojer Differential Revision: D15516062 fbshipit-source-id: a8efb077773e04fd9753a7036682eeaae9175e09
199 lines
5.0 KiB
Python
199 lines
5.0 KiB
Python
load("@fbsource//tools/build_defs:default_platform_defs.bzl", "ANDROID", "APPLE")
|
|
load("@fbsource//tools/build_defs:fb_native_wrapper.bzl", "fb_native")
|
|
load("@fbsource//tools/build_defs:fb_xplat_cxx_binary.bzl", "fb_xplat_cxx_binary")
|
|
load("@fbsource//tools/build_defs/oss:rn_defs.bzl", "rn_xplat_cxx_library")
|
|
load("@fbsource//tools/build_defs/third_party:yarn_defs.bzl", "yarn_workspace")
|
|
load("@fbsource//xplat/js/react-native-github/packages/react-native-codegen:DEFS.bzl", "rn_codegen_test")
|
|
|
|
fb_native.sh_binary(
|
|
name = "copy_fixture_schema",
|
|
main = "buck_tests/copy_fixture.sh",
|
|
resources = [
|
|
"buck_tests/copy-fixture.js",
|
|
"buck_tests/copy_fixture.sh",
|
|
"fbsource//xplat/js:setup_env",
|
|
"src/generators/__test_fixtures__/fixtures.js",
|
|
],
|
|
)
|
|
|
|
fb_native.sh_binary(
|
|
name = "write_to_json",
|
|
main = "src/cli/combine/combine_js_to_schema.sh",
|
|
resources = [
|
|
"fbsource//xplat/js:setup_env",
|
|
"src/cli/combine/combine-js-to-schema.js",
|
|
"src/cli/combine/combine_js_to_schema.sh",
|
|
],
|
|
visibility = ["PUBLIC"],
|
|
)
|
|
|
|
fb_native.sh_binary(
|
|
name = "rn_codegen",
|
|
main = "buck_tests/generate-tests.sh",
|
|
resources = glob(
|
|
[
|
|
"buck_tests/**/*.js",
|
|
"src/**/*.js",
|
|
],
|
|
) + [
|
|
"buck_tests/generate-tests.js",
|
|
"package.json",
|
|
"fbsource//xplat/js:setup_env",
|
|
"yarn.lock",
|
|
],
|
|
visibility = ["PUBLIC"],
|
|
)
|
|
|
|
rn_codegen_test(
|
|
fixture_name = "INTERFACE_ONLY",
|
|
)
|
|
|
|
rn_codegen_test(
|
|
fixture_name = "BOOLEAN_PROP",
|
|
)
|
|
|
|
rn_codegen_test(
|
|
fixture_name = "STRING_PROP",
|
|
)
|
|
|
|
rn_codegen_test(
|
|
fixture_name = "INTEGER_PROPS",
|
|
)
|
|
|
|
rn_codegen_test(
|
|
fixture_name = "FLOAT_PROPS",
|
|
)
|
|
|
|
rn_codegen_test(
|
|
fixture_name = "COLOR_PROP",
|
|
)
|
|
|
|
rn_codegen_test(
|
|
fixture_name = "IMAGE_PROP",
|
|
)
|
|
|
|
rn_codegen_test(
|
|
fixture_name = "POINT_PROP",
|
|
)
|
|
|
|
rn_codegen_test(
|
|
fixture_name = "ARRAY_PROPS",
|
|
)
|
|
|
|
rn_codegen_test(
|
|
fixture_name = "MULTI_NATIVE_PROP",
|
|
)
|
|
|
|
rn_codegen_test(
|
|
fixture_name = "ENUM_PROP",
|
|
)
|
|
|
|
rn_codegen_test(
|
|
fixture_name = "EVENT_PROPS",
|
|
)
|
|
|
|
rn_codegen_test(
|
|
fixture_name = "EVENT_NESTED_OBJECT_PROPS",
|
|
)
|
|
|
|
rn_codegen_test(
|
|
fixture_name = "TWO_COMPONENTS_SAME_FILE",
|
|
)
|
|
|
|
rn_codegen_test(
|
|
fixture_name = "TWO_COMPONENTS_DIFFERENT_FILES",
|
|
)
|
|
|
|
fb_xplat_cxx_binary(
|
|
name = "rn_codegen_binary",
|
|
srcs = ["buck_tests/emptyFile.cpp"],
|
|
compiler_flags = [
|
|
"-fexceptions",
|
|
"-frtti",
|
|
"-std=c++14",
|
|
"-Wall",
|
|
],
|
|
platforms = (ANDROID, APPLE),
|
|
preprocessor_flags = [
|
|
"-DLOG_TAG=\"ReactNative\"",
|
|
"-DWITH_FBSYSTRACE=1",
|
|
],
|
|
visibility = ["PUBLIC"],
|
|
deps = [
|
|
":generated_components-ARRAY_PROPS",
|
|
":generated_components-BOOLEAN_PROP",
|
|
":generated_components-COLOR_PROP",
|
|
":generated_components-ENUM_PROP",
|
|
":generated_components-EVENT_NESTED_OBJECT_PROPS",
|
|
":generated_components-EVENT_PROPS",
|
|
":generated_components-FLOAT_PROPS",
|
|
":generated_components-IMAGE_PROP",
|
|
":generated_components-INTEGER_PROPS",
|
|
":generated_components-INTERFACE_ONLY",
|
|
":generated_components-MULTI_NATIVE_PROP",
|
|
":generated_components-POINT_PROP",
|
|
":generated_components-STRING_PROP",
|
|
":generated_components-TWO_COMPONENTS_DIFFERENT_FILES",
|
|
":generated_components-TWO_COMPONENTS_SAME_FILE",
|
|
],
|
|
)
|
|
|
|
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-ARRAY_PROPS",
|
|
":generated_components-BOOLEAN_PROP",
|
|
":generated_components-COLOR_PROP",
|
|
":generated_components-ENUM_PROP",
|
|
":generated_components-EVENT_NESTED_OBJECT_PROPS",
|
|
":generated_components-EVENT_PROPS",
|
|
":generated_components-FLOAT_PROPS",
|
|
":generated_components-IMAGE_PROP",
|
|
":generated_components-INTEGER_PROPS",
|
|
":generated_components-INTERFACE_ONLY",
|
|
":generated_components-MULTI_NATIVE_PROP",
|
|
":generated_components-POINT_PROP",
|
|
":generated_components-STRING_PROP",
|
|
":generated_components-TWO_COMPONENTS_DIFFERENT_FILES",
|
|
":generated_components-TWO_COMPONENTS_SAME_FILE",
|
|
],
|
|
)
|
|
|
|
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"],
|
|
)
|