Cross-compile SQLCipher for aarch64-apple-darwin

This commit is contained in:
J. Ryan Stinnett 2021-06-22 16:35:26 +01:00
parent c57a173649
commit f3c1db3313
3 changed files with 31 additions and 4 deletions

View file

@ -182,9 +182,36 @@ async function buildSqlCipherUnix(hakEnv, moduleInfo) {
if (hakEnv.isMac()) {
args.push('--with-crypto-lib=commoncrypto');
}
args.push('CFLAGS=-DSQLITE_HAS_CODEC');
if (!hakEnv.isHost()) {
// In the nonsense world of `configure`, it is assumed you are building
// a compiler like `gcc`, so the `host` option actually means the target
// the build output runs on.
args.push(`--host=${hakEnv.getTargetId()}`);
}
const cflags = [
'-DSQLITE_HAS_CODEC',
];
if (!hakEnv.isHost()) {
// `clang` uses more logical option naming.
cflags.push(`--target=${hakEnv.getTargetId()}`);
}
if (cflags.length) {
args.push(`CFLAGS=${cflags.join(' ')}`);
}
const ldflags = [];
if (hakEnv.isMac()) {
args.push('LDFLAGS=-framework Security -framework Foundation');
ldflags.push('-framework Security');
ldflags.push('-framework Foundation');
}
if (ldflags.length) {
args.push(`LDFLAGS=${ldflags.join(' ')}`);
}
await new Promise((resolve, reject) => {

View file

@ -67,7 +67,7 @@ module.exports = async function(hakEnv, moduleInfo) {
if (err) {
reject("Can't find rustup");
}
const target = hakEnv.getRustTarget();
const target = hakEnv.getTargetId();
if (!out.includes(target)) {
reject(`Rust target ${target} not installed`);
}

View file

@ -80,7 +80,7 @@ module.exports = class HakEnv {
return this.getRuntimeAbi() + '-' + this.target.platform + '-' + this.target.arch;
}
getRustTarget() {
getTargetId() {
return this.target.id;
}