Skip to content

Commit 3f52dd5

Browse files
committed
Use .so extension when building Android lib dirs
1 parent 522421d commit 3f52dd5

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

packages/react-native-node-api-cmake/src/android.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,16 @@ export async function createAndroidLibsDirectory({
135135
const arch = ANDROID_ARCHITECTURES[triplet as AndroidTriplet];
136136
const archOutputPath = path.join(outputPath, arch);
137137
await fs.promises.mkdir(archOutputPath, { recursive: true });
138-
const libraryName = path.basename(libraryPath);
139-
const libraryOutputPath = path.join(archOutputPath, libraryName);
138+
// Strip the ".node" extension from the library name
139+
const libraryName = path.basename(libraryPath, ".node");
140+
const soSuffixedName =
141+
path.extname(libraryName) === ".so" ? libraryName : `${libraryName}.so`;
142+
const finalLibraryName = libraryName.startsWith("lib")
143+
? soSuffixedName
144+
: `lib${soSuffixedName}`;
145+
const libraryOutputPath = path.join(archOutputPath, finalLibraryName);
140146
await fs.promises.copyFile(libraryPath, libraryOutputPath);
147+
// TODO: Update the install path in the library file
141148
}
142149
if (autoLink) {
143150
// Write a file to mark the Android libs directory is a Node-API module

packages/react-native-node-api-modules/src/node/cli/link-modules.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ export function getLinkedModuleOutputPath(
152152
naming: NamingStrategy
153153
): string {
154154
const libraryName = getLibraryName(modulePath, naming);
155-
const extension = PLATFORM_EXTENSIONS[platform];
156-
return path.join(getAutolinkPath(platform), `${libraryName}${extension}`);
155+
if (platform === "android") {
156+
return path.join(getAutolinkPath(platform), libraryName);
157+
} else if (platform === "apple") {
158+
return path.join(getAutolinkPath(platform), libraryName + ".xcframework");
159+
} else {
160+
throw new Error(`Unsupported platform: ${platform}`);
161+
}
157162
}

0 commit comments

Comments
 (0)