mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-05-19 05:45:01 -04:00
[ENG-1184, ENG-1286, ENG-1330] Rework native dependencies (+ deb fixes) (#1685)
* Almost working * Downgrade libplacebo - FFMpeg 6.0 uses some now removed deprecated functions * Use -Oz for zimg * Fix CI script to run the new ffmpeg build script * Fix heif step name + Ignore docker cache while building in CI * Fix Opencl build on linux * Fix adding incorrect -target argument to linker - Update zig for windows target * Disable opengl for ffmpeg, it only uses it as an outdev, not for processing - Disable opengl and directx for libplacebo, ffmpeg only supports vulkan when using it - Add WIN32_LEAN_AND_MEAN to global cflags to optimize windows api usage - Fix 99-heif.sh incorrect bsdtar flag * Remove WIN32_LEAN_AND_MEAN from global CFLAGS as that was breaking OpenCL build - Fix Dockerfile step for cleaning up the out dir - Improve licensing handling * x86_64 windows and linux builds are working * Fix aarch64 build for windows and linux * Fix symbol visibility in linux builds - Fix soxr failing to download due to sourcefourge - Only patch zimg on windows targets - Tell cmake to hide libheif symbols * Fix Linux .so rpath - Add lzo dependency - Publish source for the built libs - Add warning for missing nasm in tauri.mjs - Remove ffmpeg install from setup.sh - Add download logic for our linux ffmpeg bundle in preprep.mjs * Remove jobs, docker doesn't support this * Fix typing * Change ffmpeg references to native deps - Rename FFMpeg.framework to Spacedrive.framework - Centralize the macOS native deps build with the windows and linux one - Change the preprep script to only download our native deps - Remove old macOS ffmpeg build scripts * Compress native deps before creating github artifact - The zip implementation for github artifact does not mantain symlinks and permissions - Remove conditional protoc, it is now always included * Don't strip dylibs, it was breaking them - Only download macOS Framework for darwin targets - Fix preprep script - Improve README.md for native-deps - Fix not finding native-deps src * Attempt to fix macOS dylib * Fix macOS dylibs - Replace lld.ld64 with apple's own linker - Add stages for building apple's compiler tools to use instead of LLVM ones * Ensure sourced file exists * All targets should build now - Fix environment sourcing in build.sh - Some minor improvements to cc.sh - Fix incorrect flag in zlib.sh - Improve how -f[...] flags are passed to compiler and linker - Add more stack hardening flags * We now can support macOS 11.0 on arm64 * Improve macOS Framework generation - Remove installed unused deps - Improve cleanup and organization logic in Dockerfile last step - Move libav* .dll.a to .lib to fix missing files in windows target - Remove apple tools from /srv folder after installation to prevent their files from being copied by other stage steps - Create all the necessary symlinks for the macOS targets while building - Remove symlink logic for macOS target from preprep.mjs * Remove native-deps from spacedrive repo - It now resides in https://github.com/spacedriveapp/native-deps - Modify preprep script to dowload native-deps from new location - Remove Github API code from scripts (not needed anymore) - Add flock.mjs to allow running tauri.mjs cleanup as soon as cargo finishes building in linux * Handle flock not present in system - Allow macOS to try using flock * Fix preprep on macOS * Add script that patch deb to fix errors and warnings raised by lintian * Fix ctrl+c/ctrl+v typo * Remove gstreamer1.0-gtk3 from deb dependencies * eval is evil * Handle tauri build release with an explicit target in fix-deb.sh * Preserve environment variables when re-executing fix-deb with sudo * Only execute fix-deb.sh when building a deb bundle * Improvements fix-deb.sh * Improve setup.sh (Add experiemental alpine support)
This commit is contained in:
committed by
GitHub
parent
c2dd3661f9
commit
48afea5a4b
@@ -18,58 +18,6 @@ async function link(origin, target, rename) {
|
||||
await (rename ? fs.rename(origin, target) : fs.symlink(path.relative(parent, origin), target))
|
||||
}
|
||||
|
||||
/**
|
||||
* Move headers and dylibs of external deps to our framework
|
||||
* @param {string} nativeDeps
|
||||
*/
|
||||
export async function setupMacOsFramework(nativeDeps) {
|
||||
// External deps
|
||||
const lib = path.join(nativeDeps, 'lib')
|
||||
const include = path.join(nativeDeps, 'include')
|
||||
|
||||
// Framework
|
||||
const framework = path.join(nativeDeps, 'FFMpeg.framework')
|
||||
const headers = path.join(framework, 'Headers')
|
||||
const libraries = path.join(framework, 'Libraries')
|
||||
const documentation = path.join(framework, 'Resources', 'English.lproj', 'Documentation')
|
||||
|
||||
// Move files
|
||||
await Promise.all([
|
||||
// Move pdfium license to framework
|
||||
fs.rename(
|
||||
path.join(nativeDeps, 'LICENSE.pdfium'),
|
||||
path.join(documentation, 'LICENSE.pdfium')
|
||||
),
|
||||
// Move dylibs to framework
|
||||
fs.readdir(lib, { recursive: true, withFileTypes: true }).then(file =>
|
||||
file
|
||||
.filter(
|
||||
entry =>
|
||||
(entry.isFile() || entry.isSymbolicLink()) && entry.name.endsWith('.dylib')
|
||||
)
|
||||
.map(entry => {
|
||||
const file = path.join(entry.path, entry.name)
|
||||
const newFile = path.resolve(libraries, path.relative(lib, file))
|
||||
return link(file, newFile, true)
|
||||
})
|
||||
),
|
||||
// Move headers to framework
|
||||
fs.readdir(include, { recursive: true, withFileTypes: true }).then(file =>
|
||||
file
|
||||
.filter(
|
||||
entry =>
|
||||
(entry.isFile() || entry.isSymbolicLink()) &&
|
||||
!entry.name.endsWith('.proto')
|
||||
)
|
||||
.map(entry => {
|
||||
const file = path.join(entry.path, entry.name)
|
||||
const newFile = path.resolve(headers, path.relative(include, file))
|
||||
return link(file, newFile, true)
|
||||
})
|
||||
),
|
||||
])
|
||||
}
|
||||
|
||||
/**
|
||||
* Symlink shared libs paths for Linux
|
||||
* @param {string} root
|
||||
@@ -87,56 +35,33 @@ export async function symlinkSharedLibsLinux(root, nativeDeps) {
|
||||
|
||||
/**
|
||||
* Symlink shared libs paths for macOS
|
||||
* @param {string} root
|
||||
* @param {string} nativeDeps
|
||||
*/
|
||||
export async function symlinkSharedLibsMacOS(nativeDeps) {
|
||||
// External deps
|
||||
const lib = path.join(nativeDeps, 'lib')
|
||||
const include = path.join(nativeDeps, 'include')
|
||||
export async function symlinkSharedLibsMacOS(root, nativeDeps) {
|
||||
// rpath=@executable_path/../Frameworks/Spacedrive.framework
|
||||
const targetFrameworks = path.join(root, 'target', 'Frameworks')
|
||||
|
||||
// Framework
|
||||
const framework = path.join(nativeDeps, 'FFMpeg.framework')
|
||||
const headers = path.join(framework, 'Headers')
|
||||
const libraries = path.join(framework, 'Libraries')
|
||||
const framework = path.join(nativeDeps, 'Spacedrive.framework')
|
||||
|
||||
// Link files
|
||||
await Promise.all([
|
||||
// Link header files
|
||||
fs.readdir(headers, { recursive: true, withFileTypes: true }).then(files =>
|
||||
// Link Spacedrive.framework to target folder so sd-server can work ootb
|
||||
await fs.rm(targetFrameworks, { recursive: true }).catch(() => {})
|
||||
await fs.mkdir(targetFrameworks, { recursive: true })
|
||||
await link(framework, path.join(targetFrameworks, 'Spacedrive.framework'))
|
||||
|
||||
// Sign dylibs (Required for them to work on macOS 13+)
|
||||
await fs
|
||||
.readdir(path.join(framework, 'Libraries'), { recursive: true, withFileTypes: true })
|
||||
.then(files =>
|
||||
Promise.all(
|
||||
files
|
||||
.filter(entry => entry.isFile() || entry.isSymbolicLink())
|
||||
.map(entry => {
|
||||
const file = path.join(entry.path, entry.name)
|
||||
return link(file, path.resolve(include, path.relative(headers, file)))
|
||||
})
|
||||
)
|
||||
),
|
||||
// Link dylibs
|
||||
fs.readdir(libraries, { recursive: true, withFileTypes: true }).then(files =>
|
||||
Promise.all(
|
||||
files
|
||||
.filter(
|
||||
entry =>
|
||||
(entry.isFile() || entry.isSymbolicLink()) &&
|
||||
entry.name.endsWith('.dylib')
|
||||
.filter(entry => entry.isFile() && entry.name.endsWith('.dylib'))
|
||||
.map(entry =>
|
||||
exec(`codesign -s "${signId}" -f "${path.join(entry.path, entry.name)}"`)
|
||||
)
|
||||
.map(entry => {
|
||||
const file = path.join(entry.path, entry.name)
|
||||
/** @type {Promise<unknown>[]} */
|
||||
const actions = [
|
||||
link(file, path.resolve(lib, path.relative(libraries, file))),
|
||||
]
|
||||
|
||||
// Sign dylib (Required for it to work on macOS 13+)
|
||||
if (entry.isFile())
|
||||
actions.push(exec(`codesign -s "${signId}" -f "${file}"`))
|
||||
|
||||
return actions.length > 1 ? Promise.all(actions) : actions[0]
|
||||
})
|
||||
)
|
||||
),
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,9 +93,10 @@ export async function copyWindowsDLLs(root, nativeDeps) {
|
||||
* Symlink shared libs paths for Linux
|
||||
* @param {string} root
|
||||
* @param {string} nativeDeps
|
||||
* @param {boolean} isDev
|
||||
* @returns {Promise<{files: string[], toClean: string[]}>}
|
||||
*/
|
||||
export async function copyLinuxLibs(root, nativeDeps) {
|
||||
export async function copyLinuxLibs(root, nativeDeps, isDev) {
|
||||
// rpath=${ORIGIN}/../lib/spacedrive
|
||||
const tauriSrc = path.join(root, 'apps', 'desktop', 'src-tauri')
|
||||
const files = await fs
|
||||
@@ -184,10 +110,17 @@ export async function copyLinuxLibs(root, nativeDeps) {
|
||||
(entry.name.endsWith('.so') || entry.name.includes('.so.'))
|
||||
)
|
||||
.map(async entry => {
|
||||
await fs.copyFile(
|
||||
path.join(entry.path, entry.name),
|
||||
path.join(tauriSrc, entry.name)
|
||||
)
|
||||
if (entry.isSymbolicLink()) {
|
||||
await fs.symlink(
|
||||
await fs.readlink(path.join(entry.path, entry.name)),
|
||||
path.join(tauriSrc, entry.name)
|
||||
)
|
||||
} else {
|
||||
const target = path.join(tauriSrc, entry.name)
|
||||
await fs.copyFile(path.join(entry.path, entry.name), target)
|
||||
// https://web.archive.org/web/20220731055320/https://lintian.debian.org/tags/shared-library-is-executable
|
||||
await fs.chmod(target, 0o644)
|
||||
}
|
||||
return entry.name
|
||||
})
|
||||
)
|
||||
@@ -195,6 +128,9 @@ export async function copyLinuxLibs(root, nativeDeps) {
|
||||
|
||||
return {
|
||||
files,
|
||||
toClean: files.map(file => path.join(tauriSrc, file)),
|
||||
toClean: [
|
||||
...files.map(file => path.join(tauriSrc, file)),
|
||||
...files.map(file => path.join(root, 'target', isDev ? 'debug' : 'release', file)),
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user