From f1781d976da63c6e940754db76a023cab41b81b3 Mon Sep 17 00:00:00 2001 From: Brendan Allan Date: Wed, 13 Nov 2024 19:16:10 +0800 Subject: [PATCH 1/8] try --- .github/actions/install-desktop-deps/action.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/actions/install-desktop-deps/action.yml b/.github/actions/install-desktop-deps/action.yml index 8e8c89f7..5f4731ce 100644 --- a/.github/actions/install-desktop-deps/action.yml +++ b/.github/actions/install-desktop-deps/action.yml @@ -7,5 +7,13 @@ runs: if: ${{ runner.os == 'Linux' }} shell: bash run: | - sudo apt-get update - sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf libasound2-dev libxtst-dev libevdev-dev libxdo-dev libsoup-3.0-dev + sudo apt update + sudo apt install libwebkit2gtk-4.1-dev \ + build-essential \ + curl \ + wget \ + file \ + libxdo-dev \ + libssl-dev \ + libayatana-appindicator3-dev \ + librsvg2-dev From 5c76ccb6cf33c3b0723fb37c54f32970ef30ef34 Mon Sep 17 00:00:00 2001 From: Brendan Allan Date: Wed, 13 Nov 2024 19:20:44 +0800 Subject: [PATCH 2/8] pipewire --- .github/actions/install-desktop-deps/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/install-desktop-deps/action.yml b/.github/actions/install-desktop-deps/action.yml index 5f4731ce..b7dff16b 100644 --- a/.github/actions/install-desktop-deps/action.yml +++ b/.github/actions/install-desktop-deps/action.yml @@ -16,4 +16,5 @@ runs: libxdo-dev \ libssl-dev \ libayatana-appindicator3-dev \ - librsvg2-dev + librsvg2-dev \ + libpipewire-0.3-dev From b489aa946125e63c140f15bced04f6b5fdb96c33 Mon Sep 17 00:00:00 2001 From: Brendan Allan Date: Wed, 13 Nov 2024 19:26:34 +0800 Subject: [PATCH 3/8] ffmpeg --- .github/actions/install-desktop-deps/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/actions/install-desktop-deps/action.yml b/.github/actions/install-desktop-deps/action.yml index b7dff16b..31a37416 100644 --- a/.github/actions/install-desktop-deps/action.yml +++ b/.github/actions/install-desktop-deps/action.yml @@ -17,4 +17,5 @@ runs: libssl-dev \ libayatana-appindicator3-dev \ librsvg2-dev \ - libpipewire-0.3-dev + libpipewire-0.3-dev \ + ffmpeg From 723b4d6c0b2a869ebec87d6b358f10ab6514e595 Mon Sep 17 00:00:00 2001 From: Brendan Allan Date: Wed, 13 Nov 2024 19:32:39 +0800 Subject: [PATCH 4/8] more deps --- .github/actions/install-desktop-deps/action.yml | 2 +- .github/prebuild.js | 8 ++++++-- .github/workflows/debug.yml | 4 ++-- .github/workflows/publish.yml | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/actions/install-desktop-deps/action.yml b/.github/actions/install-desktop-deps/action.yml index 31a37416..2076fa4c 100644 --- a/.github/actions/install-desktop-deps/action.yml +++ b/.github/actions/install-desktop-deps/action.yml @@ -18,4 +18,4 @@ runs: libayatana-appindicator3-dev \ librsvg2-dev \ libpipewire-0.3-dev \ - ffmpeg + ffmpeg clang libavcodec-dev libavformat-dev libavutil-dev pkg-config diff --git a/.github/prebuild.js b/.github/prebuild.js index 46754bf5..2d6c5943 100644 --- a/.github/prebuild.js +++ b/.github/prebuild.js @@ -68,7 +68,7 @@ rustflags = [ await fs.rm(nativeDeps, { recursive: true, force: true }); await fs.mkdir(nativeDeps, { recursive: true }); const res = await fetch( - `${NATIVE_DEPS_URL}/${NATIVE_DEPS_ASSETS.Darwin[process.argv[2]]}` + `${NATIVE_DEPS_URL}/${NATIVE_DEPS_ASSETS[process.argv[2]][process.argv[3]]}` ); const body = await res.blob(); @@ -105,8 +105,12 @@ const NATIVE_DEPS_URL = "https://github.com/spacedriveapp/native-deps/releases/latest/download"; const NATIVE_DEPS_ASSETS = { - Darwin: { + darwin: { x86_64: "native-deps-x86_64-darwin-apple.tar.xz", aarch64: "native-deps-aarch64-darwin-apple.tar.xz", }, + windows: { + x86_64: "native-deps-x86_64-windows-gnu.tar.xz ", + aarch64: "native-deps-aarch64-windows-gnu.tar.xz", + }, }; diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 10aad21a..2872fa99 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -68,7 +68,7 @@ jobs: working-directory: apps/desktop run: | export TARGET_TRIPLE=aarch64-apple-darwin - node ${{ github.workspace }}/.github/prebuild.js aarch64 + node ${{ github.workspace }}/.github/prebuild.js darwin aarch64 pnpm tauri build --target aarch64-apple-darwin --debug env: CI: false @@ -90,4 +90,4 @@ jobs: with: name: debug-build-aarch64-apple-darwin path: apps/desktop/src-tauri/target/aarch64-apple-darwin/debug/bundle/**/*.app - if-no-files-found: error \ No newline at end of file + if-no-files-found: error diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1a8c8d75..cbc5895f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -146,7 +146,7 @@ jobs: working-directory: apps/desktop run: | export TARGET_TRIPLE=${{ matrix.settings.target }} - node ${{ github.workspace }}/.github/prebuild.js ${{ matrix.settings.prebuild }} + node ${{ github.workspace }}/.github/prebuild.js darwin ${{ matrix.settings.prebuild }} pnpm tauri build --target ${{ matrix.settings.target }} --config src-tauri/tauri.conf.prod.json env: # https://github.com/tauri-apps/tauri-action/issues/740 From 00b430e4066557c22e54a305983a619ad35a8033 Mon Sep 17 00:00:00 2001 From: Brendan Allan Date: Wed, 13 Nov 2024 19:45:04 +0800 Subject: [PATCH 5/8] libavfilter --- .../actions/install-desktop-deps/action.yml | 2 +- .github/prebuild.js | 113 +++++++++--------- 2 files changed, 60 insertions(+), 55 deletions(-) diff --git a/.github/actions/install-desktop-deps/action.yml b/.github/actions/install-desktop-deps/action.yml index 2076fa4c..9ad5a4e2 100644 --- a/.github/actions/install-desktop-deps/action.yml +++ b/.github/actions/install-desktop-deps/action.yml @@ -18,4 +18,4 @@ runs: libayatana-appindicator3-dev \ librsvg2-dev \ libpipewire-0.3-dev \ - ffmpeg clang libavcodec-dev libavformat-dev libavutil-dev pkg-config + ffmpeg clang libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev pkg-config diff --git a/.github/prebuild.js b/.github/prebuild.js index 2d6c5943..0a729f7b 100644 --- a/.github/prebuild.js +++ b/.github/prebuild.js @@ -12,32 +12,6 @@ const keychain = env.APPLE_KEYCHAIN ? `--keychain ${env.APPLE_KEYCHAIN}` : ""; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); -async function symlinkSharedLibsMacOS(nativeDeps) { - // Framework - const framework = path.join(nativeDeps, "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.name.endsWith(".dylib")) - .map((entry) => - exec( - `codesign ${keychain} -s "${signId}" -f "${path.join( - entry.path, - entry.name - )}"` - ) - ) - ) - ); -} - const __root = path.resolve(path.join(__dirname, "..")); const nativeDeps = path.join(__root, "native-deps"); @@ -46,8 +20,7 @@ async function main() { await fs.writeFile( path.join(__root, ".cargo/config.toml"), - ` -[env] + `[env] FFMPEG_DIR = { force = true, value = "${nativeDeps}" } [target.x86_64-apple-darwin] @@ -65,38 +38,44 @@ rustflags = [ ]` ); + const os = process.argv[2]; + const arch = process.argv[3]; + + if (!os) throw new Error("OS not provided"); + if (!arch) throw new Error("Arch not provided"); + await fs.rm(nativeDeps, { recursive: true, force: true }); await fs.mkdir(nativeDeps, { recursive: true }); - const res = await fetch( - `${NATIVE_DEPS_URL}/${NATIVE_DEPS_ASSETS[process.argv[2]][process.argv[3]]}` - ); + const res = await fetch(`${NATIVE_DEPS_URL}/${NATIVE_DEPS_ASSETS[os][arch]}`); const body = await res.blob(); - await fs.writeFile( - `${__root}/native-deps.tar.xz`, - Buffer.from(await body.arrayBuffer()) - ); - await exec(`tar xf ${__root}/native-deps.tar.xz -C ${nativeDeps}`); - - await symlinkSharedLibsMacOS(nativeDeps).catch((e) => { - console.error(`Failed to symlink shared libs.`); - throw e; - }); - - await fs.writeFile( - `${__root}/apps/desktop/src-tauri/tauri.macos.conf.json`, - JSON.stringify( - { - bundle: { - macOS: { - frameworks: [path.join(nativeDeps, "Spacedrive.framework")], + if (os === "darwin") { + await fs.writeFile( + `${__root}/native-deps.tar.xz`, + Buffer.from(await body.arrayBuffer()) + ); + await exec(`tar xf ${__root}/native-deps.tar.xz -C ${nativeDeps}`); + + await symlinkSharedLibsMacOS(nativeDeps).catch((e) => { + console.error(`Failed to symlink shared libs.`); + throw e; + }); + + await fs.writeFile( + `${__root}/apps/desktop/src-tauri/tauri.macos.conf.json`, + JSON.stringify( + { + bundle: { + macOS: { + frameworks: [path.join(nativeDeps, "Spacedrive.framework")], + }, }, }, - }, - null, - 4 - ) - ); + null, + 4 + ) + ); + } } main(); @@ -114,3 +93,29 @@ const NATIVE_DEPS_ASSETS = { aarch64: "native-deps-aarch64-windows-gnu.tar.xz", }, }; + +async function symlinkSharedLibsMacOS(nativeDeps) { + // Framework + const framework = path.join(nativeDeps, "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.name.endsWith(".dylib")) + .map((entry) => + exec( + `codesign ${keychain} -s "${signId}" -f "${path.join( + entry.path, + entry.name + )}"` + ) + ) + ) + ); +} From 559f4eced09c57329a231b7fe61c9cd2248ebfbd Mon Sep 17 00:00:00 2001 From: Brendan Allan Date: Wed, 13 Nov 2024 22:11:05 +0800 Subject: [PATCH 6/8] libavdevice --- .github/actions/install-desktop-deps/action.yml | 2 +- .github/prebuild.js | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/actions/install-desktop-deps/action.yml b/.github/actions/install-desktop-deps/action.yml index 9ad5a4e2..41c5054a 100644 --- a/.github/actions/install-desktop-deps/action.yml +++ b/.github/actions/install-desktop-deps/action.yml @@ -18,4 +18,4 @@ runs: libayatana-appindicator3-dev \ librsvg2-dev \ libpipewire-0.3-dev \ - ffmpeg clang libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev pkg-config + ffmpeg clang libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev libavdevice-dev pkg-config diff --git a/.github/prebuild.js b/.github/prebuild.js index 0a729f7b..28cf5844 100644 --- a/.github/prebuild.js +++ b/.github/prebuild.js @@ -49,13 +49,14 @@ rustflags = [ const res = await fetch(`${NATIVE_DEPS_URL}/${NATIVE_DEPS_ASSETS[os][arch]}`); const body = await res.blob(); - if (os === "darwin") { - await fs.writeFile( - `${__root}/native-deps.tar.xz`, - Buffer.from(await body.arrayBuffer()) - ); - await exec(`tar xf ${__root}/native-deps.tar.xz -C ${nativeDeps}`); + await fs.writeFile( + `${__root}/native-deps.tar.xz`, + Buffer.from(await body.arrayBuffer()) + ); + + await exec(`tar xf ${__root}/native-deps.tar.xz -C ${nativeDeps}`); + if (os === "darwin") { await symlinkSharedLibsMacOS(nativeDeps).catch((e) => { console.error(`Failed to symlink shared libs.`); throw e; @@ -75,6 +76,7 @@ rustflags = [ 4 ) ); + } else if (os === "windows") { } } @@ -89,7 +91,7 @@ const NATIVE_DEPS_ASSETS = { aarch64: "native-deps-aarch64-darwin-apple.tar.xz", }, windows: { - x86_64: "native-deps-x86_64-windows-gnu.tar.xz ", + x86_64: "native-deps-x86_64-windows-gnu.tar.xz", aarch64: "native-deps-aarch64-windows-gnu.tar.xz", }, }; From 7246689af9907751b8559d5535857a76081cb2e7 Mon Sep 17 00:00:00 2001 From: Brendan Allan Date: Wed, 13 Nov 2024 22:22:46 +0800 Subject: [PATCH 7/8] libasound --- .github/actions/install-desktop-deps/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/install-desktop-deps/action.yml b/.github/actions/install-desktop-deps/action.yml index 41c5054a..726db4e2 100644 --- a/.github/actions/install-desktop-deps/action.yml +++ b/.github/actions/install-desktop-deps/action.yml @@ -18,4 +18,4 @@ runs: libayatana-appindicator3-dev \ librsvg2-dev \ libpipewire-0.3-dev \ - ffmpeg clang libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev libavdevice-dev pkg-config + ffmpeg clang libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev libavdevice-dev pkg-config libasound2-dev From 2a16458d57377d54a0251ee95c03ce7bde43352c Mon Sep 17 00:00:00 2001 From: Brendan Allan Date: Wed, 13 Nov 2024 22:46:47 +0800 Subject: [PATCH 8/8] cleanup --- .github/prebuild.js | 22 +++++++++++++++++++++- .gitignore | 5 +++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/.github/prebuild.js b/.github/prebuild.js index 28cf5844..dcddb625 100644 --- a/.github/prebuild.js +++ b/.github/prebuild.js @@ -14,6 +14,7 @@ const __dirname = path.dirname(__filename); const __root = path.resolve(path.join(__dirname, "..")); const nativeDeps = path.join(__root, "native-deps"); +const srcTauri = path.join(__root, "apps/desktop/src-tauri"); async function main() { await fs.mkdir(path.join(__root, ".cargo"), { recursive: true }); @@ -63,7 +64,7 @@ rustflags = [ }); await fs.writeFile( - `${__root}/apps/desktop/src-tauri/tauri.macos.conf.json`, + `${srcTauri}/tauri.macos.conf.json`, JSON.stringify( { bundle: { @@ -77,6 +78,25 @@ rustflags = [ ) ); } else if (os === "windows") { + const binFiles = await fs.readdir(path.join(nativeDeps, "bin")); + + await fs.writeFile( + `${srcTauri}/tauri.windows.conf.json`, + JSON.stringify( + { + bundle: { + resources: binFiles.filter( + (f) => + f.endsWith(".dll") && (f.startsWith("av") || f.startsWith("sw")) + ), + }, + }, + null, + 4 + ) + ); + + console.log(); } } diff --git a/.gitignore b/.gitignore index cfed069c..d1b88374 100644 --- a/.gitignore +++ b/.gitignore @@ -32,5 +32,6 @@ pnpm-lock.yaml .zed .output .vinxi -native-deps -apps/storybook/storybook-static \ No newline at end of file +native-deps* +apps/storybook/storybook-static +tauri.*.conf.json