Skip to content

Commit 2d9b184

Browse files
authored
Use org.flatpak.Builder (#962)
1 parent 60cfdb3 commit 2d9b184

File tree

8 files changed

+29
-21
lines changed

8 files changed

+29
-21
lines changed

.github/workflows/CI.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Install host dependencies
2424
run: |
2525
sudo apt-get update
26-
sudo apt-get install flatpak flatpak-builder mutter
26+
sudo apt-get install flatpak mutter
2727
2828
# Restore caches
2929
- name: Restore Flatpak dependencies

.vscode/settings.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,5 @@
2929
"[json]": {
3030
"editor.defaultFormatter": "esbenp.prettier-vscode"
3131
},
32-
"vala.languageServerPath": "${workspaceFolder}/.flatpak/vala-language-server.sh",
33-
"mesonbuild.configureOnOpen": false,
34-
"mesonbuild.buildFolder": "_build",
35-
"mesonbuild.mesonPath": "${workspaceFolder}/.flatpak/meson.sh"
32+
"vala.languageServerPath": "${workspaceFolder}/.flatpak/vala-language-server.sh"
3633
}

Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ setup:
1414
@echo "✅ You can use "make build" to build Workbench"
1515

1616
stable:
17-
flatpak-builder --delete-build-dirs --disable-updates --build-only --ccache --force-clean flatpak build-aux/re.sonny.Workbench.json
17+
flatpak run org.flatpak.Builder --delete-build-dirs --disable-updates --build-only --ccache --force-clean flatpak build-aux/re.sonny.Workbench.json
1818

1919
devel:
20-
flatpak-builder --version
21-
flatpak-builder --delete-build-dirs --disable-updates --build-only --ccache --force-clean flatpak build-aux/re.sonny.Workbench.Devel.json
20+
flatpak run org.flatpak.Builder --delete-build-dirs --disable-updates --build-only --ccache --force-clean flatpak build-aux/re.sonny.Workbench.Devel.json
2221

2322
build: devel
2423

@@ -72,12 +71,12 @@ sandbox: setup
7271
flatpak run --command="bash" re.sonny.Workbench.Devel
7372

7473
flatpak:
75-
flatpak run org.flatpak.Builder --ccache --force-clean flatpak build-aux/re.sonny.Workbench.Devel.json
74+
flatpak run org.flatpak.Builder --ccache --force-clean flatpak build-aux/re.sonny.Workbench.Devel.json
7675
# This is what Flathub does - consider moving to lint
7776
flatpak run --env=G_DEBUG=fatal-criticals --command=appstream-util org.flatpak.Builder validate flatpak/files/share/appdata/re.sonny.Workbench.Devel.appdata.xml
7877
flatpak run --command="desktop-file-validate" --filesystem=host:ro org.freedesktop.Sdk//23.08 flatpak/files/share/applications/re.sonny.Workbench.Devel.desktop
7978
# appstreamcli validate --override=release-time-missing=info /path/to/your/app.metainfo.xml
80-
flatpak run org.flatpak.Builder --run flatpak build-aux/re.sonny.Workbench.Devel.json bash
79+
flatpak run org.flatpak.Builder --run flatpak build-aux/re.sonny.Workbench.Devel.json bash
8180

8281
# Sync with .gitignore
8382
clean:

build-aux/re.sonny.Workbench.Devel.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "https://raw.githubusercontent.com/flatpak/flatpak-builder/main/data/flatpak-manifest.schema.json",
23
"id": "re.sonny.Workbench.Devel",
34
"runtime": "org.gnome.Sdk",
45
"runtime-version": "master",

build-aux/re.sonny.Workbench.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"$schema": "https://raw.githubusercontent.com/flatpak/flatpak-builder/main/data/flatpak-manifest.schema.json",
23
"id": "re.sonny.Workbench",
34
"runtime": "org.gnome.Sdk",
45
"runtime-version": "46",

src/Extensions/Extensions.blp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,14 @@ Adw.Dialog dialog {
5353

5454
$Extension extension_rust {
5555
title: _("Rust");
56-
command: "flatpak install flathub org.freedesktop.Sdk.Extension.rust-stable//24.08 org.freedesktop.Sdk.Extension.llvm18//24.08";
5756
}
5857

5958
$Extension extension_vala {
6059
title: _("Vala");
61-
command: "flatpak install flathub org.freedesktop.Sdk.Extension.vala//24.08";
6260
}
6361

6462
$Extension extension_typescript {
6563
title: _("TypeScript");
66-
command: "flatpak install flathub org.freedesktop.Sdk.Extension.node20//24.08 org.freedesktop.Sdk.Extension.typescript//24.08";
6764
}
6865
}
6966

src/Extensions/Extensions.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Interface from "./Extensions.blp" with { type: "uri" };
66
import illustration from "./extensions.svg";
77

88
import "./Extension.js";
9+
import { getFlatpakInfo } from "../util.js";
910

1011
export const action_extensions = new Gio.SimpleAction({
1112
name: "extensions",
@@ -26,8 +27,13 @@ export function Extensions({ window }) {
2627
picture_illustration.set_resource(illustration);
2728

2829
extension_rust.enabled = isRustEnabled();
30+
extension_rust.command = `flatpak install flathub org.freedesktop.Sdk.Extension.rust-stable//${freedesktop_version} org.freedesktop.Sdk.Extension.${llvm}//${freedesktop_version}`;
31+
2932
extension_vala.enabled = isValaEnabled();
33+
extension_vala.command = `flatpak install flathub org.freedesktop.Sdk.Extension.vala//${freedesktop_version}`;
34+
3035
extension_typescript.enabled = isTypeScriptEnabled();
36+
extension_typescript.command = `flatpak install flathub org.freedesktop.Sdk.Extension.${node}//${freedesktop_version} org.freedesktop.Sdk.Extension.typescript//${freedesktop_version}`;
3137

3238
for (const extension of [
3339
extension_rust,
@@ -47,25 +53,30 @@ export function Extensions({ window }) {
4753
window.add_action(action_extensions);
4854
}
4955

50-
let rust_enabled;
56+
let rust_enabled = false;
5157
export function isRustEnabled() {
5258
rust_enabled ??=
5359
Gio.File.new_for_path("/usr/lib/sdk/rust-stable").query_exists(null) &&
54-
Gio.File.new_for_path("/usr/lib/sdk/llvm18").query_exists(null);
60+
Gio.File.new_for_path(`/usr/lib/sdk/${llvm}`).query_exists(null);
5561
return rust_enabled;
5662
}
5763

58-
let vala_enabled;
64+
let vala_enabled = false;
5965
export function isValaEnabled() {
6066
vala_enabled ??=
6167
Gio.File.new_for_path("/usr/lib/sdk/vala").query_exists(null);
6268
return vala_enabled;
6369
}
6470

65-
let typescript_enabled;
71+
let typescript_enabled = false;
6672
export function isTypeScriptEnabled() {
6773
typescript_enabled ??=
6874
Gio.File.new_for_path("/usr/lib/sdk/typescript").query_exists(null) &&
69-
Gio.File.new_for_path("/usr/lib/sdk/node20").query_exists(null);
75+
Gio.File.new_for_path(`/usr/lib/sdk/${node}`).query_exists(null);
7076
return typescript_enabled;
7177
}
78+
79+
const llvm = "llvm18";
80+
const node = "node20";
81+
const runtime = getFlatpakInfo().get_string("Application", "runtime");
82+
const freedesktop_version = runtime.endsWith("master") ? "24.08beta" : "23.08";

src/util.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,19 @@ export function ensureDir(file) {
2525
}
2626
}
2727

28+
let flatpak_info;
2829
export function getFlatpakInfo() {
29-
const keyFile = new GLib.KeyFile();
30+
if (flatpak_info) return flatpak_info;
31+
flatpak_info = new GLib.KeyFile();
3032
try {
31-
keyFile.load_from_file("/.flatpak-info", GLib.KeyFileFlags.NONE);
33+
flatpak_info.load_from_file("/.flatpak-info", GLib.KeyFileFlags.NONE);
3234
} catch (err) {
3335
if (!err.matches(GLib.FileError, GLib.FileError.NOENT)) {
3436
console.error(err);
3537
}
3638
return null;
3739
}
38-
return keyFile;
40+
return flatpak_info;
3941
}
4042

4143
export { getLanguage };

0 commit comments

Comments
 (0)