1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00
joplin/packages/tools/gulp/tasks/compileExtensions.js

56 lines
1.8 KiB
JavaScript
Raw Normal View History

2020-09-06 14:07:00 +02:00
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();
2020-11-05 18:58:23 +02:00
const dest = `${rootDir}/packages/app-mobile/lib/sql-extensions`;
2020-09-06 14:07:00 +02:00
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);
}
2020-09-21 13:35:20 +02:00
await fs.remove(`${dest}/sqlite.tar.gz`);
await fs.remove(`${dest}/amalgamation.tar.gz`);
await fs.remove(`${dest}/sqlite`);
await fs.remove(`${dest}/sqlite-autoconf-3330000`);
2020-09-06 14:07:00 +02:00
}
module.exports = main;