mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
17381f197f
Summary: add script which proves that new codegen gives a similar code as old one. How it works? While creating a rule, it generates file which is bash script returning 1 or 0 depending if result of new and old codegen are the same (it's done by redirecting output of buck's cmd). How js script works: 1. remove empty lines 2. remove comments 3. remove imports 4. sort lines (cause order of structs might be different so let's sort everything!) 5. remove namespaces (I grouped them in new codegen) Reviewed By: RSNara Differential Revision: D16827988 fbshipit-source-id: 0432144161e2dcf8ed4cbe2eeea712d062e3721d
181 lines
4.8 KiB
Python
181 lines
4.8 KiB
Python
load("@fbsource//tools/build_defs:default_platform_defs.bzl", "ANDROID", "APPLE", "IOS")
|
|
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_android_library", "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_components", "rn_codegen_modules")
|
|
load("//tools/build_defs/oss:rn_defs.bzl", "react_native_target")
|
|
|
|
fb_native.sh_binary(
|
|
name = "codegen_rn_modules_tests",
|
|
main = "src/cli/verify_with_old_codegen.sh",
|
|
visibility = ["PUBLIC"],
|
|
resources = [
|
|
"fbsource//xplat/js:setup_env",
|
|
"src/cli/verify_with_old_codegen.js",
|
|
"src/cli/verify_with_old_codegen.sh",
|
|
],
|
|
)
|
|
|
|
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.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"],
|
|
)
|
|
|
|
fb_native.genrule(
|
|
name = "codegen_tests_schema",
|
|
srcs = glob(
|
|
[
|
|
"**/e2e/__test_fixtures__/components/*NativeComponent.js",
|
|
"**/e2e/__test_fixtures__/modules/Native*.js",
|
|
],
|
|
),
|
|
cmd = "$(exe fbsource//xplat/js/react-native-github/packages/react-native-codegen:write_to_json) $OUT $SRCS",
|
|
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",
|
|
)
|
|
|
|
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-codegen_tests",
|
|
],
|
|
)
|
|
|
|
rn_android_library(
|
|
name = "rn_codegen_library_java",
|
|
srcs = glob(["**/*.java"]),
|
|
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"],
|
|
)
|