Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create genrule to generate appmodules.so #41466

Closed
wants to merge 1 commit into from

Commits on Nov 22, 2023

  1. Create genrule to generate appmodules.so (facebook#41466)

    Summary:
    
    ## Context
    In open source, all apps use the same turbomodulemanager delegate (i.e: the default delegate).
    
    This diff introduces the buck infra that makes the oss default delegate work for meta apps.
    
    Concretely, we are going to make React Native use the same  delegate for **all** Meta apps.
    
    Each Meta app will:
    1. At build time, generate a unique TMProvider map
    2. At app init time, initialize the default delegate with the TMProvider map.
    
    ## Implementation
    **Step facebook#1:** At build time, generate a unique TMProvider map
    
    **Insight:** Buck genrules can accept, as input, the output of a buck query.
    
    So, here's how we get this done:
    1. Buck query (i.e: input to Genrule): Given the app's deps, query all the schemas in the app.
    2. Genrule: Read the schemas to generate the TMProvider map. The TMProvider map will also contain **all** the app's C++ module codegen.
    
    Concretely:
    1. This diff introduces a macro: rn_codegen_appmodules(deps).
    2. rn_codegen_appmodules(deps) generates appmodules.so, which contains the TMProvider map.
    
    **Step facebook#2:** At app init time, initialize the default delegate with the TMProvider map.
    
    This is how we'll initialize the DefaultTurboModuleManagerDelegate:
    1. DefaultTurboModuleManagerDelegate will load appmodules.so during init.
    2. When loaded, appmodules.so will assign the code-generated TMProvider map to DefaultTurboModuleManagerDelegate.
    
    ## Impact
    This should allow us to:
    1. Get one step closer to getting rid of the `js1 build turbomodule-manager-delegates --target <app>` script
    3. Remove the TurboModuleManagerDelegate from React Native's public API. (Because we use one delegate for all React Native apps in Meta and OSS)
    
    Changelog: [Internal]
    
    Reviewed By: mdvacca
    
    Differential Revision: D50988397
    RSNara authored and facebook-github-bot committed Nov 22, 2023
    Configuration menu
    Copy the full SHA
    8a827b8 View commit details
    Browse the repository at this point in the history