Skip to content

Commit

Permalink
Rename rn_codegen_modules(native_module_spec_name => name)
Browse files Browse the repository at this point in the history
Summary: Changelog: [Internal]

Reviewed By: PeteTheHeat

Differential Revision: D25963929

fbshipit-source-id: 4c82562404a21b5a1789d11ae2d228411329fee5
  • Loading branch information
RSNara authored and facebook-github-bot committed Jan 22, 2021
1 parent 93e4170 commit 5a2099f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 25 deletions.
1 change: 0 additions & 1 deletion Libraries/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ rn_codegen_modules(
name = "FBReactNativeSpec",
android_package_name = "com.facebook.fbreact.specs",
library_labels = ["supermodule:xplat/default/public.react_native.infra"],
native_module_spec_name = "FBReactNativeSpec",
schema_target = ":FBReactNativeSpec-codegen-modules-schema",
)

Expand Down
3 changes: 1 addition & 2 deletions packages/react-native-codegen/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ rn_codegen_components(
)

rn_codegen_modules(
name = "codegen_tests",
name = "FBReactNativeTestSpec",
android_package_name = "com.facebook.fbreact.specs",
native_module_spec_name = "FBReactNativeTestSpec",
schema_target = ":codegen_tests_schema",
)

Expand Down
43 changes: 21 additions & 22 deletions packages/react-native-codegen/DEFS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -104,25 +104,24 @@ def rn_codegen_cli():

def rn_codegen_modules(
name,
native_module_spec_name,
android_package_name,
library_labels = [],
schema_target = ""):
generate_fixtures_rule_name = "{}-codegen-modules".format(native_module_spec_name)
generate_module_hobjcpp_name = "{}-codegen-modules-hobjcpp".format(native_module_spec_name)
generate_module_mm_name = "{}-codegen-modules-mm".format(native_module_spec_name)
generate_module_java_name = "{}-codegen-modules-java".format(native_module_spec_name)
generate_module_java_zip_name = "{}-codegen-modules-java_zip".format(native_module_spec_name)
generate_module_jni_h_name = "{}-codegen-modules-jni_h".format(native_module_spec_name)
generate_module_jni_cpp_name = "{}-codegen-modules-jni_cpp".format(native_module_spec_name)
generate_fixtures_rule_name = "{}-codegen-modules".format(name)
generate_module_hobjcpp_name = "{}-codegen-modules-hobjcpp".format(name)
generate_module_mm_name = "{}-codegen-modules-mm".format(name)
generate_module_java_name = "{}-codegen-modules-java".format(name)
generate_module_java_zip_name = "{}-codegen-modules-java_zip".format(name)
generate_module_jni_h_name = "{}-codegen-modules-jni_h".format(name)
generate_module_jni_cpp_name = "{}-codegen-modules-jni_cpp".format(name)

fb_native.genrule(
name = generate_fixtures_rule_name,
srcs = native.glob(["src/generators/**/*.js"]),
cmd = "$(exe {generator_script}) $(location {schema_target}) {library_name} $OUT {android_package_name}".format(
generator_script = react_native_root_target("packages/react-native-codegen:generate_all_from_schema"),
schema_target = schema_target,
library_name = native_module_spec_name,
library_name = name,
android_package_name = android_package_name,
),
out = "codegenfiles-{}".format(name),
Expand Down Expand Up @@ -151,20 +150,20 @@ def rn_codegen_modules(

fb_native.genrule(
name = generate_module_jni_h_name,
cmd = "cp $(location :{})/jni/{}.h $OUT".format(generate_fixtures_rule_name, native_module_spec_name),
out = "{}.h".format(native_module_spec_name),
cmd = "cp $(location :{})/jni/{}.h $OUT".format(generate_fixtures_rule_name, name),
out = "{}.h".format(name),
labels = ["codegen_rule"],
)

fb_native.genrule(
name = generate_module_jni_cpp_name,
cmd = "cp $(location :{})/jni/{}-generated.cpp $OUT".format(generate_fixtures_rule_name, native_module_spec_name),
out = "{}-generated.cpp".format(native_module_spec_name),
cmd = "cp $(location :{})/jni/{}-generated.cpp $OUT".format(generate_fixtures_rule_name, name),
out = "{}-generated.cpp".format(name),
labels = ["codegen_rule"],
)

rn_android_library(
name = "{}".format(native_module_spec_name),
name = "{}".format(name),
srcs = [
":{}".format(generate_module_java_zip_name),
],
Expand All @@ -183,7 +182,7 @@ def rn_codegen_modules(
)

rn_xplat_cxx_library(
name = "{}-jni".format(native_module_spec_name),
name = "{}-jni".format(name),
srcs = [
":{}".format(generate_module_jni_cpp_name),
],
Expand All @@ -192,7 +191,7 @@ def rn_codegen_modules(
":{}".format(generate_module_jni_h_name),
],
exported_headers = {
"{}/{}.h".format(native_module_spec_name, native_module_spec_name): ":{}".format(generate_module_jni_h_name),
"{}/{}.h".format(name, name): ":{}".format(generate_module_jni_h_name),
},
compiler_flags = [
"-fexceptions",
Expand Down Expand Up @@ -224,28 +223,28 @@ def rn_codegen_modules(
# iOS Buck build isn't fully working in OSS, so let's skip it for OSS for now.
fb_native.genrule(
name = generate_module_hobjcpp_name,
cmd = "cp $(location :{})/{}.h $OUT".format(generate_fixtures_rule_name, native_module_spec_name),
out = "{}.h".format(native_module_spec_name),
cmd = "cp $(location :{})/{}.h $OUT".format(generate_fixtures_rule_name, name),
out = "{}.h".format(name),
labels = ["codegen_rule"],
)

fb_native.genrule(
name = generate_module_mm_name,
cmd = "cp $(location :{})/{}-generated.mm $OUT".format(generate_fixtures_rule_name, native_module_spec_name),
out = "{}-generated.mm".format(native_module_spec_name),
cmd = "cp $(location :{})/{}-generated.mm $OUT".format(generate_fixtures_rule_name, name),
out = "{}-generated.mm".format(name),
labels = ["codegen_rule"],
)

rn_apple_library(
name = "{}Apple".format(native_module_spec_name),
name = "{}Apple".format(name),
extension_api_only = True,
header_namespace = "",
sdks = (IOS),
compiler_flags = [
"-Wno-unused-private-field",
],
exported_headers = {
"{}/{}.h".format(native_module_spec_name, native_module_spec_name): ":{}".format(generate_module_hobjcpp_name),
"{}/{}.h".format(name, name): ":{}".format(generate_module_hobjcpp_name),
},
headers = [
":{}".format(generate_module_hobjcpp_name),
Expand Down

0 comments on commit 5a2099f

Please sign in to comment.