-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-local-android-bindings.js
44 lines (37 loc) · 1.41 KB
/
setup-local-android-bindings.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const fs = require('fs').promises;
const path = require('path');
const ktPath = 'rust/bindings/android/pubkycore.kt';
const ktDestinationPath = 'android/src/main/java/uniffi/pubkycore/';
const jniPath = 'rust/bindings/android/jniLibs';
const jniDestinationPath = 'android/src/main/jniLibs/';
async function runSetup() {
try {
console.log('Removing existing files...');
// Remove destination directories if they exist
await Promise.all([
fs.rm(ktDestinationPath, { recursive: true, force: true }),
fs.rm(jniDestinationPath, { recursive: true, force: true }),
]);
console.log('Creating directories...');
// Create destination directories if they don't exist
await Promise.all([
fs.mkdir(ktDestinationPath, { recursive: true }),
fs.mkdir(jniDestinationPath, { recursive: true }),
]);
console.log('Copying Kotlin file...');
// Copy Kotlin file to destination
const ktTargetPath = path.join(ktDestinationPath, 'pubkycore.kt');
await fs.copyFile(ktPath, ktTargetPath);
console.log('Copying JNI libraries...');
// Copy JNI libraries directory
await fs.cp(jniPath, jniDestinationPath, { recursive: true });
console.log('Android files copied successfully!');
} catch (error) {
console.error('Error during setup:', error);
process.exit(1);
}
}
runSetup().catch((error) => {
console.error('Unhandled error:', error);
process.exit(1);
});