mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Codegen Android: allow generating Fabric Java component files during build time
Summary: This commit: * Generate Fabric component Java files along side Java NativeModule specs, when `USE_FABRIC=1` is set * Adjust the component codegen to place output files in a subdir based on package name * Adjust existing Buck targets to filter the right nativemodule vs component java files (this avoids duplicated symbols) * Compiles the Java output during build time on RNTester/ReactAndroid (Gradle) Not in this commit: * Fabric C++ files * Removing checked-in generated component files. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D25416614 fbshipit-source-id: fd670ead2198c9b5a65812c692b7aed9f3d7cd58
This commit is contained in:
committed by
Facebook GitHub Bot
parent
471f6ad358
commit
3af21381df
+9
-3
@@ -35,7 +35,7 @@ const template = `/**
|
||||
* ${'@'}generated by codegen project: GeneratePropsJavaInterface.js
|
||||
*/
|
||||
|
||||
package com.facebook.react.viewmanagers;
|
||||
package ::_PACKAGE_NAME_::;
|
||||
|
||||
::_IMPORTS_::
|
||||
|
||||
@@ -215,6 +215,12 @@ module.exports = {
|
||||
moduleSpecName: string,
|
||||
packageName?: string,
|
||||
): FilesOutput {
|
||||
// TODO: This doesn't support custom package name yet.
|
||||
// TODO: But it customizes the name here temporarily to prepare for Fabric RNTester support.
|
||||
const normalizedPackageName =
|
||||
packageName != null ? packageName : 'com.facebook.react.viewmanagers';
|
||||
const outputDir = `java/${normalizedPackageName.replace(/\./g, '/')}`;
|
||||
|
||||
const files = new Map();
|
||||
Object.keys(schema.modules).forEach(moduleName => {
|
||||
const module = schema.modules[moduleName];
|
||||
@@ -240,7 +246,6 @@ module.exports = {
|
||||
.forEach(componentName => {
|
||||
const component = components[componentName];
|
||||
const className = getInterfaceJavaClassName(componentName);
|
||||
const fileName = `${className}.java`;
|
||||
|
||||
const imports = getImports(component, 'interface');
|
||||
const propsString = generatePropsString(component, imports);
|
||||
@@ -257,6 +262,7 @@ module.exports = {
|
||||
.sort()
|
||||
.join('\n'),
|
||||
)
|
||||
.replace(/::_PACKAGE_NAME_::/g, normalizedPackageName)
|
||||
.replace(/::_CLASSNAME_::/g, className)
|
||||
.replace('::_EXTEND_CLASSES_::', extendString)
|
||||
.replace(
|
||||
@@ -265,7 +271,7 @@ module.exports = {
|
||||
)
|
||||
.replace('::_COMMAND_HANDLERS_::', commandsString);
|
||||
|
||||
files.set(fileName, replacedTemplate);
|
||||
files.set(`${outputDir}/${className}.java`, replacedTemplate);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user