Skip to content

Commit

Permalink
Do not .lowerCase the library name when codegenerating TurboModule Specs
Browse files Browse the repository at this point in the history
Summary:
The Codegen is generating a broken output if using the default library name: `Packages<GradleModuleName>Spec`.
This diff is fixing the codegenerator to don't call the `.lowerCase` on the library name when generating the Makefile.

Changelog:
[Android] [Fixed] - Do not .lowerCase the library name when codegenerating TurboModule Specs

Reviewed By: ShikaSD

Differential Revision: D32597578

fbshipit-source-id: dee729a44134d7b3878074507191bb2a1c200608
  • Loading branch information
cortinico authored and facebook-github-bot committed Nov 24, 2021
1 parent a5469f9 commit 28aeb7b
Show file tree
Hide file tree
Showing 9 changed files with 398 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ module.exports = {
[
'jni/Android.mk',
AndroidMkTemplate({
libraryName: `${libraryName.toLowerCase()}`,
libraryName: libraryName,
}),
],
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1459,11 +1459,25 @@ const REAL_MODULE_EXAMPLE: SchemaType = {
},
};

const SAMPLE_WITH_UPPERCASE_NAME: SchemaType = {
modules: {
NativeSampleTurboModule: {
type: 'NativeModule',
aliases: {},
spec: {
properties: [],
},
moduleNames: ['SampleTurboModule'],
},
},
};

module.exports = {
COMPLEX_OBJECTS,
TWO_MODULES_DIFFERENT_FILES,
EMPTY_NATIVE_MODULES,
SIMPLE_NATIVE_MODULES,
NATIVE_MODULES_WITH_TYPE_ALIASES,
REAL_MODULE_EXAMPLE,
complex_objects: COMPLEX_OBJECTS,
two_modules_different_files: TWO_MODULES_DIFFERENT_FILES,
empty_native_modules: EMPTY_NATIVE_MODULES,
simple_native_modules: SIMPLE_NATIVE_MODULES,
native_modules_with_type_aliases: NATIVE_MODULES_WITH_TYPE_ALIASES,
real_module_example: REAL_MODULE_EXAMPLE,
SampleWithUppercaseName: SAMPLE_WITH_UPPERCASE_NAME,
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`GenerateModuleCpp can generate fixture COMPLEX_OBJECTS 1`] = `
exports[`GenerateModuleCpp can generate fixture SampleWithUppercaseName 1`] = `
Map {
"NativeModules.cpp" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
Expand All @@ -11,7 +11,37 @@ Map {
* @generated by codegen project: GenerateModuleH.js
*/
#include <react/modules/COMPLEX_OBJECTS/NativeModules.h>
#include <react/modules/SampleWithUppercaseName/NativeModules.h>
namespace facebook {
namespace react {
NativeSampleTurboModuleCxxSpecJSI::NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
: TurboModule(\\"SampleTurboModule\\", jsInvoker) {
}
} // namespace react
} // namespace facebook
",
}
`;
exports[`GenerateModuleCpp can generate fixture complex_objects 1`] = `
Map {
"NativeModules.cpp" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated by codegen project: GenerateModuleH.js
*/
#include <react/modules/complex_objects/NativeModules.h>
namespace facebook {
namespace react {
Expand Down Expand Up @@ -47,7 +77,7 @@ NativeSampleTurboModuleCxxSpecJSI::NativeSampleTurboModuleCxxSpecJSI(std::shared
}
`;
exports[`GenerateModuleCpp can generate fixture EMPTY_NATIVE_MODULES 1`] = `
exports[`GenerateModuleCpp can generate fixture empty_native_modules 1`] = `
Map {
"NativeModules.cpp" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
Expand All @@ -58,7 +88,7 @@ Map {
* @generated by codegen project: GenerateModuleH.js
*/
#include <react/modules/EMPTY_NATIVE_MODULES/NativeModules.h>
#include <react/modules/empty_native_modules/NativeModules.h>
namespace facebook {
namespace react {
Expand All @@ -77,7 +107,7 @@ NativeSampleTurboModuleCxxSpecJSI::NativeSampleTurboModuleCxxSpecJSI(std::shared
}
`;
exports[`GenerateModuleCpp can generate fixture NATIVE_MODULES_WITH_TYPE_ALIASES 1`] = `
exports[`GenerateModuleCpp can generate fixture native_modules_with_type_aliases 1`] = `
Map {
"NativeModules.cpp" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
Expand All @@ -88,7 +118,7 @@ Map {
* @generated by codegen project: GenerateModuleH.js
*/
#include <react/modules/NATIVE_MODULES_WITH_TYPE_ALIASES/NativeModules.h>
#include <react/modules/native_modules_with_type_aliases/NativeModules.h>
namespace facebook {
namespace react {
Expand All @@ -114,7 +144,7 @@ AliasTurboModuleCxxSpecJSI::AliasTurboModuleCxxSpecJSI(std::shared_ptr<CallInvok
}
`;
exports[`GenerateModuleCpp can generate fixture REAL_MODULE_EXAMPLE 1`] = `
exports[`GenerateModuleCpp can generate fixture real_module_example 1`] = `
Map {
"NativeModules.cpp" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
Expand All @@ -125,7 +155,7 @@ Map {
* @generated by codegen project: GenerateModuleH.js
*/
#include <react/modules/REAL_MODULE_EXAMPLE/NativeModules.h>
#include <react/modules/real_module_example/NativeModules.h>
namespace facebook {
namespace react {
Expand Down Expand Up @@ -196,7 +226,7 @@ NativeExceptionsManagerCxxSpecJSI::NativeExceptionsManagerCxxSpecJSI(std::shared
}
`;
exports[`GenerateModuleCpp can generate fixture SIMPLE_NATIVE_MODULES 1`] = `
exports[`GenerateModuleCpp can generate fixture simple_native_modules 1`] = `
Map {
"NativeModules.cpp" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
Expand All @@ -207,7 +237,7 @@ Map {
* @generated by codegen project: GenerateModuleH.js
*/
#include <react/modules/SIMPLE_NATIVE_MODULES/NativeModules.h>
#include <react/modules/simple_native_modules/NativeModules.h>
namespace facebook {
namespace react {
Expand Down Expand Up @@ -270,7 +300,7 @@ NativeSampleTurboModuleCxxSpecJSI::NativeSampleTurboModuleCxxSpecJSI(std::shared
}
`;
exports[`GenerateModuleCpp can generate fixture TWO_MODULES_DIFFERENT_FILES 1`] = `
exports[`GenerateModuleCpp can generate fixture two_modules_different_files 1`] = `
Map {
"NativeModules.cpp" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
Expand All @@ -281,7 +311,7 @@ Map {
* @generated by codegen project: GenerateModuleH.js
*/
#include <react/modules/TWO_MODULES_DIFFERENT_FILES/NativeModules.h>
#include <react/modules/two_modules_different_files/NativeModules.h>
namespace facebook {
namespace react {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,38 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`GenerateModuleH can generate fixture COMPLEX_OBJECTS 1`] = `
exports[`GenerateModuleH can generate fixture SampleWithUppercaseName 1`] = `
Map {
"NativeModules.h" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated by codegen project: GenerateModuleH.js
*/
#pragma once
#include <ReactCommon/TurboModule.h>
namespace facebook {
namespace react {
class JSI_EXPORT NativeSampleTurboModuleCxxSpecJSI : public TurboModule {
protected:
NativeSampleTurboModuleCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
public:
};
} // namespace react
} // namespace facebook
",
}
`;
exports[`GenerateModuleH can generate fixture complex_objects 1`] = `
Map {
"NativeModules.h" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
Expand Down Expand Up @@ -35,7 +67,7 @@ virtual void getArrays(jsi::Runtime &rt, const jsi::Object &options) = 0;
}
`;
exports[`GenerateModuleH can generate fixture EMPTY_NATIVE_MODULES 1`] = `
exports[`GenerateModuleH can generate fixture empty_native_modules 1`] = `
Map {
"NativeModules.h" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
Expand Down Expand Up @@ -67,7 +99,7 @@ public:
}
`;
exports[`GenerateModuleH can generate fixture NATIVE_MODULES_WITH_TYPE_ALIASES 1`] = `
exports[`GenerateModuleH can generate fixture native_modules_with_type_aliases 1`] = `
Map {
"NativeModules.h" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
Expand Down Expand Up @@ -100,7 +132,7 @@ virtual void cropImage(jsi::Runtime &rt, const jsi::Object &cropData) = 0;
}
`;
exports[`GenerateModuleH can generate fixture REAL_MODULE_EXAMPLE 1`] = `
exports[`GenerateModuleH can generate fixture real_module_example 1`] = `
Map {
"NativeModules.h" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
Expand Down Expand Up @@ -155,7 +187,7 @@ virtual void dismissRedbox(jsi::Runtime &rt) = 0;
}
`;
exports[`GenerateModuleH can generate fixture SIMPLE_NATIVE_MODULES 1`] = `
exports[`GenerateModuleH can generate fixture simple_native_modules 1`] = `
Map {
"NativeModules.h" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
Expand Down Expand Up @@ -197,7 +229,7 @@ virtual jsi::Value getValueWithPromise(jsi::Runtime &rt, bool error) = 0;
}
`;
exports[`GenerateModuleH can generate fixture TWO_MODULES_DIFFERENT_FILES 1`] = `
exports[`GenerateModuleH can generate fixture two_modules_different_files 1`] = `
Map {
"NativeModules.h" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,59 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`GenerateModuleHObjCpp can generate fixture COMPLEX_OBJECTS 1`] = `
exports[`GenerateModuleHObjCpp can generate fixture SampleWithUppercaseName 1`] = `
Map {
"COMPLEX_OBJECTS.h" => "/**
"SampleWithUppercaseName.h" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated by codegen project: GenerateModuleObjCpp
*
* We create an umbrella header (and corresponding implementation) here since
* Cxx compilation in BUCK has a limitation: source-code producing genrule()s
* must have a single output. More files => more genrule()s => slower builds.
*/
#ifndef __cplusplus
#error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
#endif
#import <Foundation/Foundation.h>
#import <RCTRequired/RCTRequired.h>
#import <RCTTypeSafety/RCTConvertHelpers.h>
#import <RCTTypeSafety/RCTTypedModuleConstants.h>
#import <React/RCTBridgeModule.h>
#import <React/RCTCxxConvert.h>
#import <React/RCTManagedPointer.h>
#import <ReactCommon/RCTTurboModule.h>
#import <folly/Optional.h>
#import <vector>
@protocol NativeSampleTurboModuleSpec <RCTBridgeModule, RCTTurboModule>
@end
namespace facebook {
namespace react {
/**
* ObjC++ class for module 'NativeSampleTurboModule'
*/
class JSI_EXPORT NativeSampleTurboModuleSpecJSI : public ObjCTurboModule {
public:
NativeSampleTurboModuleSpecJSI(const ObjCTurboModule::InitParams &params);
};
} // namespace react
} // namespace facebook
",
}
`;
exports[`GenerateModuleHObjCpp can generate fixture complex_objects 1`] = `
Map {
"complex_objects.h" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
Expand Down Expand Up @@ -258,9 +309,9 @@ inline facebook::react::LazyVector<JS::NativeSampleTurboModule::SpecGetArraysOpt
}
`;
exports[`GenerateModuleHObjCpp can generate fixture EMPTY_NATIVE_MODULES 1`] = `
exports[`GenerateModuleHObjCpp can generate fixture empty_native_modules 1`] = `
Map {
"EMPTY_NATIVE_MODULES.h" => "/**
"empty_native_modules.h" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
Expand Down Expand Up @@ -309,9 +360,9 @@ namespace facebook {
}
`;
exports[`GenerateModuleHObjCpp can generate fixture NATIVE_MODULES_WITH_TYPE_ALIASES 1`] = `
exports[`GenerateModuleHObjCpp can generate fixture native_modules_with_type_aliases 1`] = `
Map {
"NATIVE_MODULES_WITH_TYPE_ALIASES.h" => "/**
"native_modules_with_type_aliases.h" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
Expand Down Expand Up @@ -480,9 +531,9 @@ inline folly::Optional<bool> JS::AliasTurboModule::Options::allowExternalStorage
}
`;
exports[`GenerateModuleHObjCpp can generate fixture REAL_MODULE_EXAMPLE 1`] = `
exports[`GenerateModuleHObjCpp can generate fixture real_module_example 1`] = `
Map {
"REAL_MODULE_EXAMPLE.h" => "/**
"real_module_example.h" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
Expand Down Expand Up @@ -770,9 +821,9 @@ inline bool JS::NativeImagePickerIOS::SpecOpenCameraDialogConfig::videoMode() co
}
`;
exports[`GenerateModuleHObjCpp can generate fixture SIMPLE_NATIVE_MODULES 1`] = `
exports[`GenerateModuleHObjCpp can generate fixture simple_native_modules 1`] = `
Map {
"SIMPLE_NATIVE_MODULES.h" => "/**
"simple_native_modules.h" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
Expand Down Expand Up @@ -876,9 +927,9 @@ inline JS::NativeSampleTurboModule::Constants::Builder::Builder(Constants i) : _
}
`;
exports[`GenerateModuleHObjCpp can generate fixture TWO_MODULES_DIFFERENT_FILES 1`] = `
exports[`GenerateModuleHObjCpp can generate fixture two_modules_different_files 1`] = `
Map {
"TWO_MODULES_DIFFERENT_FILES.h" => "/**
"two_modules_different_files.h" => "/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
Expand Down
Loading

0 comments on commit 28aeb7b

Please sign in to comment.