mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Codegen: Add JNI C++ generator for TurboModule subclasses
Summary: This adds the C++ classes for Android, just like checked in here: https://github.com/facebook/react-native/tree/master/ReactAndroid/src/main/java/com/facebook/fbreact/specs/jni The whitespace/formatting is slightly different but the functionality should be preserved. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D23489368 fbshipit-source-id: 60c112a48b6de2d2eb19f7d1bcc894048334610f
This commit is contained in:
committed by
Facebook GitHub Bot
parent
fc2b1cac82
commit
02fed06340
@@ -38,7 +38,7 @@ function generateSpec(platform, schemaPath, outputDirectory) {
|
||||
RNCodegen.generate(
|
||||
{libraryName, schema, outputDirectory: tempOutputDirectory, moduleSpecName},
|
||||
{
|
||||
generators: ['modules'],
|
||||
generators: platform === 'android' ? ['modulesAndroid'] : ['modules'],
|
||||
},
|
||||
);
|
||||
|
||||
@@ -73,6 +73,22 @@ function generateSpec(platform, schemaPath, outputDirectory) {
|
||||
`${outputDirectory}/${f}`,
|
||||
);
|
||||
});
|
||||
|
||||
// And all C++ files for JNI.
|
||||
const jniOutputDirectory = `${outputDirectory}/jni`;
|
||||
mkdirp.sync(jniOutputDirectory);
|
||||
files
|
||||
.filter(
|
||||
f =>
|
||||
f.startsWith(moduleSpecName) &&
|
||||
(f.endsWith('.h') || f.endsWith('.cpp')),
|
||||
)
|
||||
.forEach(f => {
|
||||
fs.copyFileSync(
|
||||
`${tempOutputDirectory}/${f}`,
|
||||
`${jniOutputDirectory}/${f}`,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user