musikcube/script/install-crosscompile-toolkits.js
casey langen 4f44829cda
Improve cross-compile support (#634)
* Update minimum CMake version requirement to get rid of warning.
* Include CMake compile commands for easier diagnostics.
* More improvements to arm toolchain selection while cross-compiling third-party dependencies.
* Use x-tools provided cmake toolchains
* Add a script to download and extract deb dependencies for crosscompile.
* Link against libstdc++ statically when cross-compiling to ARM to improve portability.
* Update GeneratePackage.cmake to generate better filenames.
* Ensure symbols are stripped properly when cross-compiling
* Remove old scripts that are no longer required
* Add script to install x-tools
* Add some docs that describe how to setup a crosscompile environment.
* Add docs for building standlone on Linux
* Update CHANGELOG
* Update version hash.
2023-09-07 22:05:43 -07:00

44 lines
1.4 KiB
JavaScript

const { promisify } = require('util');
const exec = promisify(require('child_process').exec);
const fs = require('fs');
const TOOLCHAINS = ['armv6-rpi-linux-gnueabihf', 'armv8-rpi3-linux-gnueabihf'];
const run = async (command) => {
console.log(' > ', command);
await exec(command, { maxBuffer: 1024 * 1024 * 8 }); /* 8mb */
};
const install = async (toolchain) => {
const archiveFn = `x-tools-${toolchain}.tar.xz`;
const toolsRootDir = `x-tools/${toolchain}`;
const sysrootDir = `${toolsRootDir}/${toolchain}/sysroot`;
const downloadUrl = `https://github.com/tttapa/docker-arm-cross-toolchain/releases/download/0.1.2/${archiveFn}`;
console.log(' * downloading...');
await run(`wget ${downloadUrl}`);
console.log(' * extracting...');
await run(`tar xvf ${archiveFn}`);
console.log(' * updating permissions...');
await run(`chmod u+w ${sysrootDir} -R`);
console.log(' * installing sysroot...');
await run(`tar xvf sysroot.tar --directory=${sysrootDir}`);
console.log(' * cleaning up...');
await run(`rm ${archiveFn} 2> /dev/null`);
};
main = async () => {
for (let i = 0; i < TOOLCHAINS.length; i++) {
console.log(`installing [${i + 1}/${TOOLCHAINS.length}] ${TOOLCHAINS[i]}`);
await install(TOOLCHAINS[i]);
}
};
if (!fs.existsSync('./sysroot.tar')) {
console.error(
'[ERROR]: sysroot.tar not found in the current directory, process will not continue'
);
process.exit(1);
}
main();