Codegen: exclude NativeModules that are not for the specific platform

Summary:
If a native module schema has `excludedPlatforms` defined, honor it and skip the module that doesn't belong to the platform.

E.g. NativeImagePickerIOS shouldn't generate anything for Android codegen output.
Similarly, IntentAndroid shouldn't generate anything for iOS codegen output.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D24373092

fbshipit-source-id: cfeb455a18c92f60191d988af2e9ce7ea5021304
This commit is contained in:
Kevin Gozali
2020-10-17 02:43:02 -07:00
committed by Facebook GitHub Bot
parent ec094e75bd
commit 76098831fd
11 changed files with 54 additions and 935 deletions
@@ -282,8 +282,12 @@ module.exports = {
Object.keys(nativeModules).forEach(codegenModuleName => {
const {
aliases,
excludedPlatforms,
spec: {properties},
} = nativeModules[codegenModuleName];
if (excludedPlatforms != null && excludedPlatforms.includes('android')) {
return;
}
const resolveAlias = createAliasResolver(aliases);
const className = `${codegenModuleName}Spec`;