Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,40 @@ describe('android::getDependencyConfig', () => {
noPackage: {
android: {},
},
pureCxx: {
android: {},
},
});
});

it('returns an object with android project configuration', () => {
expect(getDependencyConfig('/nested', userConfig)).not.toBeNull();
expect(typeof getDependencyConfig('/nested', userConfig)).toBe('object');
const config = getDependencyConfig('/nested', userConfig);

expect(config).not.toBeNull();
expect(typeof config).toBe('object');
expect(config).toMatchObject({
cmakeListsPath:
'/nested/android/build/generated/source/codegen/jni/CMakeLists.txt',
isPureCxxDependency: false,
});
});

it('sets cmakeListsPath to null for pure C++ dependencies', () => {
expect(
getDependencyConfig('/pureCxx', {
cxxModuleCMakeListsModuleName: 'PureCxxModule',
cxxModuleCMakeListsPath: 'src/main/jni/CMakeLists.txt',
cxxModuleHeaderName: 'PureCxxModule.h',
}),
).toMatchObject({
cmakeListsPath: null,
cxxModuleCMakeListsModuleName: 'PureCxxModule',
cxxModuleCMakeListsPath: '/pureCxx/android/src/main/jni/CMakeLists.txt',
cxxModuleHeaderName: 'PureCxxModule.h',
isPureCxxDependency: true,
packageImportPath: null,
packageInstance: null,
});
});

it('returns `null` if manifest file has not been found', () => {
Expand Down
9 changes: 8 additions & 1 deletion packages/cli-config-android/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,13 @@ export function dependencyConfig(
userConfig.libraryName || findLibraryName(root, sourceDir);
const componentDescriptors =
userConfig.componentDescriptors || findComponentDescriptors(root);

let cmakeListsPath = userConfig.cmakeListsPath
? path.join(sourceDir, userConfig.cmakeListsPath)
: isPureCxxDependency
? null
: path.join(sourceDir, 'build/generated/source/codegen/jni/CMakeLists.txt');

const cxxModuleCMakeListsModuleName =
userConfig.cxxModuleCMakeListsModuleName || null;
const cxxModuleHeaderName = userConfig.cxxModuleHeaderName || null;
Expand All @@ -176,7 +180,10 @@ export function dependencyConfig(
: null;

if (process.platform === 'win32') {
cmakeListsPath = cmakeListsPath.replace(/\\/g, '/');
if (cmakeListsPath) {
cmakeListsPath = cmakeListsPath.replace(/\\/g, '/');
}

if (cxxModuleCMakeListsPath) {
cxxModuleCMakeListsPath = cxxModuleCMakeListsPath.replace(/\\/g, '/');
}
Expand Down
Loading