Skip to content

Commit

Permalink
Include autolinkin.h in OnLoad.cpp only if it exists (#47875)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #47875

The old architecture looks broken because in the OnLoad.cpp file we try to include the autolinking.h header which is only generated when the New Architecture is enabled.

This fix guards the include and the usage of the function provided by the autolinking so that the old architecture should work as well.

## Changelog
[Internal] - Include autolinkin.h in OnLoad.cpp only if it exists

Reviewed By: blakef

Differential Revision: D66295318

fbshipit-source-id: 18461e6b70ac92af57b805bef51c0df49db02283
  • Loading branch information
cipolleschi authored and facebook-github-bot committed Nov 21, 2024
1 parent 3de9892 commit b8419b2
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@

#include <DefaultComponentsRegistry.h>
#include <DefaultTurboModuleManagerDelegate.h>
#if __has_include("<autolinking.h>")
#define AUTOLINKING_AVAILABLE 1
#include <autolinking.h>
#else
#define AUTOLINKING_AVAILABLE 0
#endif
#include <fbjni/fbjni.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
#include <rncore.h>
Expand All @@ -56,8 +61,10 @@ void registerComponents(
REACT_NATIVE_APP_COMPONENT_REGISTRATION(registry);
#endif

#if AUTOLINKING_AVAILABLE
// And we fallback to the components autolinked
autolinking_registerProviders(registry);
#endif
}

std::shared_ptr<TurboModule> cxxModuleProvider(
Expand All @@ -71,8 +78,12 @@ std::shared_ptr<TurboModule> cxxModuleProvider(
// return std::make_shared<NativeCxxModuleExample>(jsInvoker);
// }

#if AUTOLINKING_AVAILABLE
// And we fallback to the CXX module providers autolinked
return autolinking_cxxModuleProvider(name, jsInvoker);
#endif

return nullptr;
}

std::shared_ptr<TurboModule> javaModuleProvider(
Expand Down Expand Up @@ -101,10 +112,12 @@ std::shared_ptr<TurboModule> javaModuleProvider(
return module;
}

#if AUTOLINKING_AVAILABLE
// And we fallback to the module providers autolinked
if (auto module = autolinking_ModuleProvider(name, params)) {
return module;
}
#endif

return nullptr;
}
Expand Down

0 comments on commit b8419b2

Please sign in to comment.