react-native-macos/ReactCommon/callinvoker/BUCK

28 строки
749 B
Python
Исходник Обычный вид История

load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "CXX", "rn_xplat_cxx_library", "subdir_glob")
Make async calls work Summary: JSCallInvoker requires a `std::weak_ptr<Instance>` to create. In our C++, `CatalystInstance` is responsible for creating this `Instance` object. This `CatalystInstance` C++ initialization is separate from the `TurboModuleManager` C++ initialization. Therefore, in this diff, I made `CatalystInstance` responsible for creating the `JSCallInvoker`. It then exposes the `JSCallInvoker` using a hybrid class called `JSCallInvokerHolder`, which contains a `std::shared_ptr<JSCallInvoker>` member variable. Using `CatalystInstance.getJSCallInvokerHolder()` in TurboModuleManager.java, we get a handle to this hybrid container. Then, we pass it this hybrid object to `TurboModuleManager::initHybrid`, which retrieves the `std::shared_ptr<JSCallInvoker>` from the `JavaJSCallInvokerHandler`. There were a few cyclic dependencies, so I had to break down the buck targets: - `CatalystInstanceImpl.java` depends on `JSCallInvokerHolderImpl.java`, and `TurboModuleManager.java` depends on classes that are packaged with `CatalystInstanceImpl.java`. So, I had to put `JSCallInvokerHolderImpl.java` in its own buck target. - `CatalystInstance.cpp` depends on `JavaJSCallInvokerHolder.cpp`, and `TurboModuleManager.cpp` depends on classes that are build with `CatalystInstance.cpp`. So, I had to put `JavaJSCallInvokerHolder.cpp` in its own buck target. To make things simpler, I also moved `JSCallInvoker.{cpp,h}` files into the same buck target as `JavaJSCallInvokerHolder.{cpp,h}`. I think these steps should be enough to create the TurboModuleManager without needing a bridge: 1. Make `JSCallInvoker` an abstract base class. 2. On Android, create another derived class of `JSCallInvoker` that doesn't depend on Instance. 3. Create `JavaJSCallInvokerHolder` using an instance of this new class somewhere in C++. 4. Pass this instance of `JavaJSCallInvokerHolder` to Java and use it to create/instatiate `TurboModuleManager`. Regarding steps 1 and 2, we can also make JSCallInvoker accept a lambda. Reviewed By: mdvacca Differential Revision: D15055511 fbshipit-source-id: 0ad72a86599819ec35d421dbee7e140959a26ab6
2019-05-03 23:25:56 +03:00
rn_xplat_cxx_library(
name = "callinvoker",
srcs = glob(["**/*.cpp"]),
Make async calls work Summary: JSCallInvoker requires a `std::weak_ptr<Instance>` to create. In our C++, `CatalystInstance` is responsible for creating this `Instance` object. This `CatalystInstance` C++ initialization is separate from the `TurboModuleManager` C++ initialization. Therefore, in this diff, I made `CatalystInstance` responsible for creating the `JSCallInvoker`. It then exposes the `JSCallInvoker` using a hybrid class called `JSCallInvokerHolder`, which contains a `std::shared_ptr<JSCallInvoker>` member variable. Using `CatalystInstance.getJSCallInvokerHolder()` in TurboModuleManager.java, we get a handle to this hybrid container. Then, we pass it this hybrid object to `TurboModuleManager::initHybrid`, which retrieves the `std::shared_ptr<JSCallInvoker>` from the `JavaJSCallInvokerHandler`. There were a few cyclic dependencies, so I had to break down the buck targets: - `CatalystInstanceImpl.java` depends on `JSCallInvokerHolderImpl.java`, and `TurboModuleManager.java` depends on classes that are packaged with `CatalystInstanceImpl.java`. So, I had to put `JSCallInvokerHolderImpl.java` in its own buck target. - `CatalystInstance.cpp` depends on `JavaJSCallInvokerHolder.cpp`, and `TurboModuleManager.cpp` depends on classes that are build with `CatalystInstance.cpp`. So, I had to put `JavaJSCallInvokerHolder.cpp` in its own buck target. To make things simpler, I also moved `JSCallInvoker.{cpp,h}` files into the same buck target as `JavaJSCallInvokerHolder.{cpp,h}`. I think these steps should be enough to create the TurboModuleManager without needing a bridge: 1. Make `JSCallInvoker` an abstract base class. 2. On Android, create another derived class of `JSCallInvoker` that doesn't depend on Instance. 3. Create `JavaJSCallInvokerHolder` using an instance of this new class somewhere in C++. 4. Pass this instance of `JavaJSCallInvokerHolder` to Java and use it to create/instatiate `TurboModuleManager`. Regarding steps 1 and 2, we can also make JSCallInvoker accept a lambda. Reviewed By: mdvacca Differential Revision: D15055511 fbshipit-source-id: 0ad72a86599819ec35d421dbee7e140959a26ab6
2019-05-03 23:25:56 +03:00
header_namespace = "",
exported_headers = subdir_glob(
[
("ReactCommon", "*.h"),
],
prefix = "ReactCommon",
),
compiler_flags_pedantic = True,
labels = [
"pfh:ReactNative_CommonInfrastructurePlaceholder",
"supermodule:xplat/default/public.react_native.infra",
],
platforms = (ANDROID, APPLE, CXX),
Make async calls work Summary: JSCallInvoker requires a `std::weak_ptr<Instance>` to create. In our C++, `CatalystInstance` is responsible for creating this `Instance` object. This `CatalystInstance` C++ initialization is separate from the `TurboModuleManager` C++ initialization. Therefore, in this diff, I made `CatalystInstance` responsible for creating the `JSCallInvoker`. It then exposes the `JSCallInvoker` using a hybrid class called `JSCallInvokerHolder`, which contains a `std::shared_ptr<JSCallInvoker>` member variable. Using `CatalystInstance.getJSCallInvokerHolder()` in TurboModuleManager.java, we get a handle to this hybrid container. Then, we pass it this hybrid object to `TurboModuleManager::initHybrid`, which retrieves the `std::shared_ptr<JSCallInvoker>` from the `JavaJSCallInvokerHandler`. There were a few cyclic dependencies, so I had to break down the buck targets: - `CatalystInstanceImpl.java` depends on `JSCallInvokerHolderImpl.java`, and `TurboModuleManager.java` depends on classes that are packaged with `CatalystInstanceImpl.java`. So, I had to put `JSCallInvokerHolderImpl.java` in its own buck target. - `CatalystInstance.cpp` depends on `JavaJSCallInvokerHolder.cpp`, and `TurboModuleManager.cpp` depends on classes that are build with `CatalystInstance.cpp`. So, I had to put `JavaJSCallInvokerHolder.cpp` in its own buck target. To make things simpler, I also moved `JSCallInvoker.{cpp,h}` files into the same buck target as `JavaJSCallInvokerHolder.{cpp,h}`. I think these steps should be enough to create the TurboModuleManager without needing a bridge: 1. Make `JSCallInvoker` an abstract base class. 2. On Android, create another derived class of `JSCallInvoker` that doesn't depend on Instance. 3. Create `JavaJSCallInvokerHolder` using an instance of this new class somewhere in C++. 4. Pass this instance of `JavaJSCallInvokerHolder` to Java and use it to create/instatiate `TurboModuleManager`. Regarding steps 1 and 2, we can also make JSCallInvoker accept a lambda. Reviewed By: mdvacca Differential Revision: D15055511 fbshipit-source-id: 0ad72a86599819ec35d421dbee7e140959a26ab6
2019-05-03 23:25:56 +03:00
preferred_linkage = "static",
preprocessor_flags = [
"-DLOG_TAG=\"ReactNative\"",
"-DWITH_FBSYSTRACE=1",
],
visibility = [
"PUBLIC",
],
)