diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 32adb21bf..38f756b0f 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -23,7 +23,7 @@ jobs: - name: Install host dependencies run: | sudo apt-get update - sudo apt-get install flatpak flatpak-builder mutter + sudo apt-get install flatpak mutter # Restore caches - name: Restore Flatpak dependencies diff --git a/.vscode/settings.json b/.vscode/settings.json index 00f2c3e71..cad2dd06c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -29,8 +29,5 @@ "[json]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, - "vala.languageServerPath": "${workspaceFolder}/.flatpak/vala-language-server.sh", - "mesonbuild.configureOnOpen": false, - "mesonbuild.buildFolder": "_build", - "mesonbuild.mesonPath": "${workspaceFolder}/.flatpak/meson.sh" + "vala.languageServerPath": "${workspaceFolder}/.flatpak/vala-language-server.sh" } diff --git a/Makefile b/Makefile index 10562ed5e..b7cf1d482 100644 --- a/Makefile +++ b/Makefile @@ -14,11 +14,10 @@ setup: @echo "✅ You can use "make build" to build Workbench" stable: - flatpak-builder --delete-build-dirs --disable-updates --build-only --ccache --force-clean flatpak build-aux/re.sonny.Workbench.json + flatpak run org.flatpak.Builder --delete-build-dirs --disable-updates --build-only --ccache --force-clean flatpak build-aux/re.sonny.Workbench.json devel: - flatpak-builder --version - flatpak-builder --delete-build-dirs --disable-updates --build-only --ccache --force-clean flatpak build-aux/re.sonny.Workbench.Devel.json + flatpak run org.flatpak.Builder --delete-build-dirs --disable-updates --build-only --ccache --force-clean flatpak build-aux/re.sonny.Workbench.Devel.json build: devel @@ -72,12 +71,12 @@ sandbox: setup flatpak run --command="bash" re.sonny.Workbench.Devel flatpak: - flatpak run org.flatpak.Builder --ccache --force-clean flatpak build-aux/re.sonny.Workbench.Devel.json + flatpak run org.flatpak.Builder --ccache --force-clean flatpak build-aux/re.sonny.Workbench.Devel.json # This is what Flathub does - consider moving to lint flatpak run --env=G_DEBUG=fatal-criticals --command=appstream-util org.flatpak.Builder validate flatpak/files/share/appdata/re.sonny.Workbench.Devel.appdata.xml flatpak run --command="desktop-file-validate" --filesystem=host:ro org.freedesktop.Sdk//23.08 flatpak/files/share/applications/re.sonny.Workbench.Devel.desktop # appstreamcli validate --override=release-time-missing=info /path/to/your/app.metainfo.xml - flatpak run org.flatpak.Builder --run flatpak build-aux/re.sonny.Workbench.Devel.json bash + flatpak run org.flatpak.Builder --run flatpak build-aux/re.sonny.Workbench.Devel.json bash # Sync with .gitignore clean: diff --git a/build-aux/re.sonny.Workbench.Devel.json b/build-aux/re.sonny.Workbench.Devel.json index da9c18381..b867a95d7 100644 --- a/build-aux/re.sonny.Workbench.Devel.json +++ b/build-aux/re.sonny.Workbench.Devel.json @@ -1,4 +1,5 @@ { + "$schema": "https://raw.githubusercontent.com/flatpak/flatpak-builder/main/data/flatpak-manifest.schema.json", "id": "re.sonny.Workbench.Devel", "runtime": "org.gnome.Sdk", "runtime-version": "master", diff --git a/build-aux/re.sonny.Workbench.json b/build-aux/re.sonny.Workbench.json index fea9e01d2..4f6e3ab48 100644 --- a/build-aux/re.sonny.Workbench.json +++ b/build-aux/re.sonny.Workbench.json @@ -1,4 +1,5 @@ { + "$schema": "https://raw.githubusercontent.com/flatpak/flatpak-builder/main/data/flatpak-manifest.schema.json", "id": "re.sonny.Workbench", "runtime": "org.gnome.Sdk", "runtime-version": "46", diff --git a/src/Extensions/Extensions.blp b/src/Extensions/Extensions.blp index 6017b5ac0..266b05e7f 100644 --- a/src/Extensions/Extensions.blp +++ b/src/Extensions/Extensions.blp @@ -53,17 +53,14 @@ Adw.Dialog dialog { $Extension extension_rust { title: _("Rust"); - command: "flatpak install flathub org.freedesktop.Sdk.Extension.rust-stable//24.08 org.freedesktop.Sdk.Extension.llvm18//24.08"; } $Extension extension_vala { title: _("Vala"); - command: "flatpak install flathub org.freedesktop.Sdk.Extension.vala//24.08"; } $Extension extension_typescript { title: _("TypeScript"); - command: "flatpak install flathub org.freedesktop.Sdk.Extension.node20//24.08 org.freedesktop.Sdk.Extension.typescript//24.08"; } } diff --git a/src/Extensions/Extensions.js b/src/Extensions/Extensions.js index 06279bfd9..570bcab24 100644 --- a/src/Extensions/Extensions.js +++ b/src/Extensions/Extensions.js @@ -6,6 +6,7 @@ import Interface from "./Extensions.blp" with { type: "uri" }; import illustration from "./extensions.svg"; import "./Extension.js"; +import { getFlatpakInfo } from "../util.js"; export const action_extensions = new Gio.SimpleAction({ name: "extensions", @@ -26,8 +27,13 @@ export function Extensions({ window }) { picture_illustration.set_resource(illustration); extension_rust.enabled = isRustEnabled(); + extension_rust.command = `flatpak install flathub org.freedesktop.Sdk.Extension.rust-stable//${freedesktop_version} org.freedesktop.Sdk.Extension.${llvm}//${freedesktop_version}`; + extension_vala.enabled = isValaEnabled(); + extension_vala.command = `flatpak install flathub org.freedesktop.Sdk.Extension.vala//${freedesktop_version}`; + extension_typescript.enabled = isTypeScriptEnabled(); + extension_typescript.command = `flatpak install flathub org.freedesktop.Sdk.Extension.${node}//${freedesktop_version} org.freedesktop.Sdk.Extension.typescript//${freedesktop_version}`; for (const extension of [ extension_rust, @@ -47,25 +53,30 @@ export function Extensions({ window }) { window.add_action(action_extensions); } -let rust_enabled; +let rust_enabled = false; export function isRustEnabled() { rust_enabled ??= Gio.File.new_for_path("/usr/lib/sdk/rust-stable").query_exists(null) && - Gio.File.new_for_path("/usr/lib/sdk/llvm18").query_exists(null); + Gio.File.new_for_path(`/usr/lib/sdk/${llvm}`).query_exists(null); return rust_enabled; } -let vala_enabled; +let vala_enabled = false; export function isValaEnabled() { vala_enabled ??= Gio.File.new_for_path("/usr/lib/sdk/vala").query_exists(null); return vala_enabled; } -let typescript_enabled; +let typescript_enabled = false; export function isTypeScriptEnabled() { typescript_enabled ??= Gio.File.new_for_path("/usr/lib/sdk/typescript").query_exists(null) && - Gio.File.new_for_path("/usr/lib/sdk/node20").query_exists(null); + Gio.File.new_for_path(`/usr/lib/sdk/${node}`).query_exists(null); return typescript_enabled; } + +const llvm = "llvm18"; +const node = "node20"; +const runtime = getFlatpakInfo().get_string("Application", "runtime"); +const freedesktop_version = runtime.endsWith("master") ? "24.08beta" : "23.08"; diff --git a/src/util.js b/src/util.js index 028cfbdc5..958307cb2 100644 --- a/src/util.js +++ b/src/util.js @@ -25,17 +25,19 @@ export function ensureDir(file) { } } +let flatpak_info; export function getFlatpakInfo() { - const keyFile = new GLib.KeyFile(); + if (flatpak_info) return flatpak_info; + flatpak_info = new GLib.KeyFile(); try { - keyFile.load_from_file("/.flatpak-info", GLib.KeyFileFlags.NONE); + flatpak_info.load_from_file("/.flatpak-info", GLib.KeyFileFlags.NONE); } catch (err) { if (!err.matches(GLib.FileError, GLib.FileError.NOENT)) { console.error(err); } return null; } - return keyFile; + return flatpak_info; } export { getLanguage };