Skip to content

Commit 2b8597d

Browse files
committed
Use flatpak build instead of flatpak-builder
1 parent aa93296 commit 2b8597d

File tree

7 files changed

+42
-31
lines changed

7 files changed

+42
-31
lines changed

.github/workflows/CI.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,19 @@ jobs:
1111
CI:
1212
runs-on: ubuntu-24.04
1313
steps:
14-
- uses: actions/checkout@v3
14+
- uses: actions/checkout@v4
1515
with:
1616
submodules: recursive
1717

18-
- uses: actions/setup-node@v3
18+
- uses: actions/setup-node@v4
1919
with:
2020
node-version: 20
2121
cache: "npm"
2222

2323
- name: Install host dependencies
2424
run: |
25-
sudo apt-get install flatpak mutter flatpak-builder
25+
sudo apt update
26+
sudo apt-get install flatpak mutter flatpak-builder gjs
2627
2728
# Restore caches
2829
- name: Restore Flatpak dependencies

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ __pycache__
2020
.idea
2121

2222
target
23+
24+
.frun

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,8 @@
2929
"build",
3030
"builddir"
3131
],
32-
"vala.languageServerPath": "${workspaceFolder}/.flatpak/vala-language-server.sh"
32+
"vala.languageServerPath": "${workspaceFolder}/.flatpak/vala-language-server.sh",
33+
"yaml.schemas": {
34+
"https://json.schemastore.org/github-workflow.json": "file:///home/sonny/Projects/Workbench/.github/workflows/deploy.yaml"
35+
}
3336
}

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ We provide a couple of tools to make the development process pleasant.
2626

2727
```sh
2828
# Ubuntu requirements
29-
# sudo apt install flatpak flatpak-builder nodejs make gcc g++
29+
# sudo apt install flatpak flatpak-builder gjs nodejs make gcc g++
3030

3131
# Fedora requirements
32-
# sudo dnf install flatpak flatpak-builder nodejs make gcc gcc-c++
32+
# sudo dnf install flatpak flatpak-builder gjs nodejs make gcc gcc-c++
3333

3434
cd Workbench
3535
make

Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ stable:
1717
flatpak-builder --delete-build-dirs --disable-updates --build-only --ccache --force-clean flatpak build-aux/re.sonny.Workbench.json
1818

1919
devel:
20-
# flatpak --user run org.flatpak.Builder --delete-build-dirs --disable-updates --build-only --ccache --force-clean flatpak build-aux/re.sonny.Workbench.Devel.json
21-
flatpak-builder --delete-build-dirs --disable-updates --build-only --ccache --force-clean flatpak build-aux/re.sonny.Workbench.Devel.json
22-
20+
./build-aux/wip/run.js --build build-aux/re.sonny.Workbench.Devel.json
2321

2422
build: devel
2523

@@ -65,8 +63,6 @@ test: unit lint
6563
# ./build-aux/wip/run.js build-aux/re.sonny.Workbench.Devel.json -- workbench-cli ci demos/src/Welcome/
6664

6765
ci: setup build test
68-
# See Permissions.js
69-
# flatpak override --user --share=network --socket=pulseaudio --device=input re.sonny.Workbench.Devel
7066
./build-aux/fun workbench-cli ci demos/src/*
7167

7268
# Note that if you have Sdk extensions installed they will be used

build-aux/fun

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env sh
22

33
# fun stands for Flatpak Run
4-
flatpak-builder --run $(dirname $0)/../flatpak $(dirname $0)/re.sonny.Workbench.Devel.json "$@"
4+
# flatpak-builder --run $(dirname $0)/../flatpak $(dirname $0)/re.sonny.Workbench.Devel.json "$@"
55
# flatpak-builder --env=G_MESSAGES_DEBUG=workbench-cli --run flatpak build-aux/re.sonny.Workbench.Devel.json "$@"
6+
7+
$(dirname $0)/wip/run.js $(dirname $0)/re.sonny.Workbench.Devel.json -- "$@"

build-aux/wip/run.js

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ function exists(path) {
4949
return result;
5050
}
5151

52-
if (!exists(`${path}/.flatpak/repo`)) {
52+
if (!exists(`${path}/.frun/repo`)) {
5353
const { runtime, sdk } = manifest;
5454
const runtime_version = manifest["runtime-version"];
5555
// initializes repo
5656
await run([
5757
"flatpak",
5858
"build-init",
59-
`${path}/.flatpak/repo`,
59+
`${path}/.frun/repo`,
6060
flatpak_id,
6161
sdk,
6262
runtime,
@@ -71,9 +71,9 @@ const prefix = [
7171
"--disable-updates",
7272
];
7373
const suffix = [
74-
`--state-dir=${path}/.flatpak/flatpak-builder`,
74+
`--state-dir=${path}/.frun/flatpak-builder`,
7575
`--stop-at=${app_module.name}`,
76-
`${path}/.flatpak/repo`,
76+
`${path}/.frun/repo`,
7777
Gio.File.new_for_path(path).get_relative_path(manifest_file),
7878
];
7979

@@ -93,23 +93,23 @@ async function buildModules() {
9393
]);
9494
}
9595

96-
if (!exists(`${path}/.flatpak/flatpak-builder`)) {
96+
if (!exists(`${path}/.frun/flatpak-builder`)) {
9797
await downloadSources();
9898
await buildModules();
9999
}
100100

101101
// builds workbench
102-
if (!exists(`${path}/_build`)) {
102+
if (!exists(`${path}/.frun/_build`)) {
103103
await buildCommand([
104104
"meson",
105105
"--prefix",
106106
"/app",
107-
"_build",
107+
".frun/_build",
108108
"-Dprofile=development",
109109
]);
110110
}
111111

112-
await buildCommand(["meson", "install", "-C", "_build"]);
112+
await buildCommand(["meson", "install", "-C", ".frun/_build"]);
113113
// await buildCommand([
114114
// `troll/gjspack/bin/gjspack`,
115115
// `--appid=${flatpak_id}`,
@@ -123,10 +123,12 @@ await buildCommand(["meson", "install", "-C", "_build"]);
123123
// ]);
124124

125125
// starts workbench
126-
const command = argv["--"].length ? argv["--"] : [manifest.command];
127-
await runCommand(command);
126+
if (argv.build !== true) {
127+
const command = argv["--"].length ? argv["--"] : [manifest.command];
128+
await runCommand(command);
129+
}
128130

129-
function buildCommand(argv) {
131+
function getCommonArguments() {
130132
let PATH =
131133
"/app/bin:/app/bin:/app/bin:/usr/bin:${home}/.var/app/com.visualstudio.code/data/node_modules/bin:/app/bin:/usr/bin";
132134
const append_path = manifest["build-options"]?.["append-path"];
@@ -137,6 +139,10 @@ function buildCommand(argv) {
137139
manifest["build-options"]?.["append-ls-library-path"];
138140
if (append_ld_library_path) LD_LIBRARY_PATH += `:${append_ld_library_path}`;
139141

142+
return [`--env=PATH=${PATH}`, `--env=LD_LIBRARY_PATH=${LD_LIBRARY_PATH}`];
143+
}
144+
145+
function buildCommand(argv) {
140146
const PKG_CONFIG_PATH =
141147
"/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib64/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig:/app/lib/pkgconfig:/app/share/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig";
142148

@@ -145,12 +151,11 @@ function buildCommand(argv) {
145151
"build",
146152
"--share=network",
147153
`--filesystem=${path}`,
148-
`--filesystem=${path}/.flatpak/repo`,
149-
`--env=PATH=${PATH}`,
150-
`--env=LD_LIBRARY_PATH=${LD_LIBRARY_PATH}`,
154+
`--filesystem=${path}/.frun/repo`,
155+
...getCommonArguments(),
151156
`--env=PKG_CONFIG_PATH=${PKG_CONFIG_PATH}`,
152-
`--filesystem=${path}/_build`,
153-
`${path}/.flatpak/repo`,
157+
`--filesystem=${path}/.frun/_build`,
158+
`${path}/.frun/repo`,
154159
...argv,
155160
]);
156161
}
@@ -165,12 +170,14 @@ async function runCommand(argv) {
165170
`--bind-mount=/run/user/1000/doc=/run/user/1000/doc/by-app/${flatpak_id}`,
166171
...manifest["finish-args"],
167172

173+
...getCommonArguments(),
174+
168175
// Non default permissions, see Permissions.js
169176
// consider getting installed overrides instead with
170177
// flatpak override --user --show re.sonny.Workbench.Devel
171178
"--share=network",
172179
"--socket=pulseaudio",
173-
"--device=input",
180+
"--device=all", // using "all" instead of "device" for broader compatibility
174181

175182
"--talk-name=org.freedesktop.portal.*",
176183
"--talk-name=org.a11y.Bus",
@@ -183,7 +190,7 @@ async function runCommand(argv) {
183190
`--filesystem=${home}/.cache/fontconfig:ro`,
184191
`--bind-mount=/run/host/user-fonts-cache=${home}/.cache/fontconfig`,
185192
`--bind-mount=/run/host/font-dirs.xml=${home}/.cache/font-dirs.xml`,
186-
`${path}/.flatpak/repo`,
193+
`${path}/.frun/repo`,
187194
...argv,
188195
],
189196
{ verbose: true },
@@ -233,7 +240,7 @@ async function exec(argv, { cancellable = null /*, verbose = false*/ }) {
233240
// ? Gio.SubprocessFlags.NONE
234241
// : Gio.SubprocessFlags.STDOUT_SILENCE;
235242

236-
const flags = Gio.SubprocessFlags.NONE;
243+
const flags = Gio.SubprocessFlags.STDIN_INHERIT;
237244

238245
const proc = new Gio.Subprocess({
239246
argv,

0 commit comments

Comments
 (0)