mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-18 09:35:20 +02:00
51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
|
const fs = require('fs-extra');
|
||
|
const utils = require('../utils');
|
||
|
|
||
|
|
||
|
async function getSourceCode(dest) {
|
||
|
await utils.execCommand(`curl -o ${dest}/sqlite.tar.gz "https://www.sqlite.org/src/tarball/sqlite.tar.gz?r=release"`);
|
||
|
await utils.execCommand(`curl -o ${dest}/amalgamation.tar.gz "https://www.sqlite.org/2020/sqlite-autoconf-3330000.tar.gz"`);
|
||
|
await utils.execCommand(`tar -xzvf ${dest}/sqlite.tar.gz -C ${dest}`);
|
||
|
await utils.execCommand(`tar -xzvf ${dest}/amalgamation.tar.gz -C ${dest}`);
|
||
|
}
|
||
|
|
||
|
async function main() {
|
||
|
const rootDir = utils.rootDir();
|
||
|
const dest = `${rootDir}/ReactNativeClient/lib/sql-extensions`;
|
||
|
|
||
|
try {
|
||
|
await fs.ensureDir(dest);
|
||
|
|
||
|
if (utils.isLinux()) {
|
||
|
try {
|
||
|
await fs.promises.access(`${dest}/spellfix.so`);
|
||
|
} catch (e) {
|
||
|
await getSourceCode(dest);
|
||
|
await utils.execCommand(`gcc -shared -fPIC -Wall -I${dest}/sqlite-autoconf-3330000/ ${dest}/sqlite/ext/misc/spellfix.c -o ${dest}/spellfix.so`);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (utils.isMac()) {
|
||
|
try {
|
||
|
await fs.promises.access(`${dest}/spellfix.dylib`);
|
||
|
} catch (e) {
|
||
|
await getSourceCode(dest);
|
||
|
await utils.execCommand(`gcc -shared -fPIC -Wall -I${dest}/sqlite-autoconf-3330000/ -dynamiclib ${dest}/sqlite/ext/misc/spellfix.c -o ${dest}/spellfix.dylib`);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// if (utils.isWindows()) {
|
||
|
// try {
|
||
|
// await fs.promises.access(`${dest}/spellfix.dll`);
|
||
|
// } catch (e) {
|
||
|
// await getSourceCode(dest);
|
||
|
// await utils.execCommand(`cl /I ${dest}/sqlite-autoconf-3330000 ${dest}/sqlite/ext/misc/spellfix.c -link -dll -out:spellfix.dll `)
|
||
|
// }
|
||
|
// }
|
||
|
} catch (e) {
|
||
|
console.warn(e);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = main;
|