spacedrive/scripts/suffix.mjs
Vítor Vasconcellos d75a6e9b12
[ENG-1054] libheif for Linux (plus fixes) + Webp update (#1405)
* Move postinstall script to a preprep script
 - Fix libheif crate failing to build with our libheif
 - Rework CI due to postinstall to preprep changes

* Linux heif build script + Update webp

* Fix ctrl+c/ctrl+v bug

* Improve libheif linux script
 - Add support for linux aarch64
 - Add CI workflow to build libheif for linux
 - Some other misc fixes

* Fix libheif CI requires sudo

* Fix wrong path for libheif build.rs override in Windows

* Fix wrong path manipulations in libheif build script

* 🤦

* Use ubuntu-latest in libheif action
 - Specify glib version in target triple to support old distros
 - Fix libheif artifact publishing

* Fix artifact upload path again

* Add musl support for libheif
 - Remove unused files from libheif artifact
 - Add setup logic for libheif in postinstall script

* Build libheif for linux as a shared lib

* Fix meson not building the correct arch
 - Add logic to get git branch from githubs CI env vars

* libheif finnaly works on linux
 - Make spacedrive binary rpath point to where appimage and deb expects our libs to be
 - Add some logic to tauri.js to convince tauri to bundle our shared libs
 - Work-around appimage bundling step breaking sometimes
 - Add logic to handle sigint in tauri.js to ensure we clean up after ourselves
 - Rename postinstall.mjs to setup.mjs
 - Add logic to setup.mjs to point our dev build to our shared libs in linux

* Fix windows dekstop dev
 - Rename setup.mjs to preprep.mjs

* test cache-factory

* Fix preprep script not parsing the cross compilation target triple and always using the host info to download dependencies
 - Fix action env vars not being correctly passed
 - Remove possibility to pass multiple targests to rust action

* Don't compile mobile crates on desktop targets

* Remove cache-factory pull_request trigger

* remove patched tauri cli

* Use git plumbing command to get remote branch name
 - Fallback to reading .git/HEAD if remote name was not retrieved

* fix type

---------

Co-authored-by: Brendan Allan <brendonovich@outlook.com>
2023-10-03 17:31:33 +00:00

107 lines
2 KiB
JavaScript

// Suffixes
export const PROTOC_SUFFIX = {
Linux: {
i386: 'linux-x86_32',
i686: 'linux-x86_32',
x86_64: 'linux-x86_64',
arm64: 'linux-aarch_64',
aarch64: 'linux-aarch_64'
},
Darwin: {
x86_64: 'osx-x86_64',
arm64: 'osx-aarch_64',
aarch64: 'osx-aarch_64'
},
Windows_NT: {
i386: 'win32',
i686: 'win32',
x86_64: 'win64'
}
};
export const PDFIUM_SUFFIX = {
Linux: {
x86_64: {
musl: 'linux-musl-x64',
glibc: 'linux-x64'
},
arm64: 'linux-arm64',
aarch64: 'linux-arm64'
},
Darwin: {
x86_64: 'mac-x64',
arm64: 'mac-arm64',
aarch64: 'mac-arm64'
},
Windows_NT: {
x86_64: 'win-x64',
arm64: 'win-arm64',
aarch64: 'win-arm64'
}
};
export const FFMPEG_SUFFFIX = {
Darwin: {
x86_64: 'x86_64',
arm64: 'arm64',
aarch64: 'arm64'
},
Windows_NT: {
x86_64: 'x86_64'
}
};
export const FFMPEG_WORKFLOW = {
Darwin: 'ffmpeg-macos.yml',
Windows_NT: 'ffmpeg-windows.yml'
};
export const LIBHEIF_SUFFIX = {
Linux: {
x86_64: {
musl: 'x86_64-linux-musl',
glibc: 'x86_64-linux-gnu'
},
arm64: {
musl: 'aarch64-linux-musl',
glibc: 'aarch64-linux-gnu'
},
aarch64: {
musl: 'aarch64-linux-musl',
glibc: 'aarch64-linux-gnu'
}
}
};
export const LIBHEIF_WORKFLOW = {
Linux: 'libheif-linux.yml'
};
/**
* @param {Record<string, unknown>} constants
* @param {string[]} identifiers
* @returns {string?}
*/
export function getConst(constants, identifiers) {
/** @type {string | Record<string, unknown>} */
let constant = constants;
for (const id of identifiers) {
constant = /** @type {string | Record<string, unknown>} */ (constant[id]);
if (!constant) return null;
if (typeof constant !== 'object') break;
}
return typeof constant === 'string' ? constant : null;
}
/**
* @param {Record<string, unknown>} suffixes
* @param {string[]} identifiers
* @returns {RegExp?}
*/
export function getSuffix(suffixes, identifiers) {
const suffix = getConst(suffixes, identifiers);
return suffix ? new RegExp(`${suffix}(\\.[^\\.]+)*$`) : null;
}