mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add excludedPlatform option to CodeSchema
Summary: Currently we generate Java ViewManager interfaces and C++ classes for iOS regardless whether the component is supported on platform or it isn't. This adds an option to exclude either iOS to Android in order to avoid this. Changelog: In codegen it is now possible to exclude one or the other platform Reviewed By: rickhanlonii Differential Revision: D18217185 fbshipit-source-id: 1c569b92c92a5b991c96b0abdff6b8ed395e449f
This commit is contained in:
committed by
Facebook Github Bot
parent
03f5951b45
commit
b6a23d8793
+32
-24
@@ -208,33 +208,41 @@ module.exports = {
|
||||
return;
|
||||
}
|
||||
|
||||
return Object.keys(components).forEach(componentName => {
|
||||
const component = components[componentName];
|
||||
const className = getInterfaceJavaClassName(componentName);
|
||||
const fileName = `${className}.java`;
|
||||
return Object.keys(components)
|
||||
.filter(componentName => {
|
||||
const component = components[componentName];
|
||||
return component.excludedPlatform !== 'android';
|
||||
})
|
||||
.forEach(componentName => {
|
||||
const component = components[componentName];
|
||||
const className = getInterfaceJavaClassName(componentName);
|
||||
const fileName = `${className}.java`;
|
||||
|
||||
const imports = getImports(component);
|
||||
const propsString = generatePropsString(component, imports);
|
||||
const commandsString = generateCommandsString(component, componentName);
|
||||
const extendString = getClassExtendString(component);
|
||||
const imports = getImports(component);
|
||||
const propsString = generatePropsString(component, imports);
|
||||
const commandsString = generateCommandsString(
|
||||
component,
|
||||
componentName,
|
||||
);
|
||||
const extendString = getClassExtendString(component);
|
||||
|
||||
const replacedTemplate = template
|
||||
.replace(
|
||||
/::_IMPORTS_::/g,
|
||||
Array.from(imports)
|
||||
.sort()
|
||||
.join('\n'),
|
||||
)
|
||||
.replace(/::_CLASSNAME_::/g, className)
|
||||
.replace('::_EXTEND_CLASSES_::', extendString)
|
||||
.replace(
|
||||
'::_METHODS_::',
|
||||
[propsString, commandsString].join('\n' + ' ').trimRight(),
|
||||
)
|
||||
.replace('::_COMMAND_HANDLERS_::', commandsString);
|
||||
const replacedTemplate = template
|
||||
.replace(
|
||||
/::_IMPORTS_::/g,
|
||||
Array.from(imports)
|
||||
.sort()
|
||||
.join('\n'),
|
||||
)
|
||||
.replace(/::_CLASSNAME_::/g, className)
|
||||
.replace('::_EXTEND_CLASSES_::', extendString)
|
||||
.replace(
|
||||
'::_METHODS_::',
|
||||
[propsString, commandsString].join('\n' + ' ').trimRight(),
|
||||
)
|
||||
.replace('::_COMMAND_HANDLERS_::', commandsString);
|
||||
|
||||
files.set(fileName, replacedTemplate);
|
||||
});
|
||||
files.set(fileName, replacedTemplate);
|
||||
});
|
||||
});
|
||||
|
||||
return files;
|
||||
|
||||
Reference in New Issue
Block a user