Codegen: separate Android/Cxx/iOS modules codegen outputs

Summary:
For now, separate the definition of `modules` generator per platform to avoid file output collision. Additionally:
* For Android, produce files under java/ (plus nested subdirs based on packageName) and jni/ (for C++ files) - JavaPoet version already does it
* Allow configuring packageName for Android - JavaPoet version has this
* Avoid tmp directory dance in the CLI script, given the proper modules separation

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D24410864

fbshipit-source-id: 9bd6bc1d65bec037bfca32ec478f3af50d72e927
This commit is contained in:
Kevin Gozali
2020-10-20 14:11:45 -07:00
committed by Facebook GitHub Bot
parent d03c0f965e
commit 13d9927a48
23 changed files with 109 additions and 114 deletions
@@ -284,10 +284,12 @@ module.exports = {
libraryName: string,
schema: SchemaType,
moduleSpecName: string,
packageName?: string,
): FilesOutput {
const files = new Map();
// TODO: Allow package configuration.
const packageName = 'com.facebook.fbreact.specs.beta';
const normalizedPackageName =
packageName != null ? packageName : 'com.facebook.fbreact.specs';
const outputDir = `java/${normalizedPackageName.replace(/\./g, '/')}`;
const nativeModules = getModules(schema);
Object.keys(nativeModules).forEach(hasteModuleName => {
@@ -365,9 +367,9 @@ module.exports = {
});
files.set(
`${className}.java`,
`${outputDir}/${className}.java`,
FileTemplate({
packageName,
packageName: normalizedPackageName,
className,
methods: methods.filter(Boolean).join('\n\n'),
imports: Array.from(imports)