Skip to content

Use flatpak build instead of flatpak-builder #993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ jobs:
CI:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"

- name: Install host dependencies
run: |
sudo apt-get install flatpak mutter flatpak-builder
sudo apt update
sudo apt-get install flatpak mutter flatpak-builder gjs

# Restore caches
- name: Restore Flatpak dependencies
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ __pycache__
.idea

target

.frun
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,8 @@
"build",
"builddir"
],
"vala.languageServerPath": "${workspaceFolder}/.flatpak/vala-language-server.sh"
"vala.languageServerPath": "${workspaceFolder}/.flatpak/vala-language-server.sh",
"yaml.schemas": {
"https://json.schemastore.org/github-workflow.json": "file:///home/sonny/Projects/Workbench/.github/workflows/deploy.yaml"
}
}
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ We provide a couple of tools to make the development process pleasant.

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

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

cd Workbench
make
Expand Down
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ stable:
flatpak-builder --delete-build-dirs --disable-updates --build-only --ccache --force-clean flatpak build-aux/re.sonny.Workbench.json

devel:
# flatpak --user run org.flatpak.Builder --delete-build-dirs --disable-updates --build-only --ccache --force-clean flatpak build-aux/re.sonny.Workbench.Devel.json
flatpak-builder --delete-build-dirs --disable-updates --build-only --ccache --force-clean flatpak build-aux/re.sonny.Workbench.Devel.json

./build-aux/wip/run.js --build build-aux/re.sonny.Workbench.Devel.json

build: devel

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

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

# Note that if you have Sdk extensions installed they will be used
Expand Down
4 changes: 3 additions & 1 deletion build-aux/fun
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env sh

# fun stands for Flatpak Run
flatpak-builder --run $(dirname $0)/../flatpak $(dirname $0)/re.sonny.Workbench.Devel.json "$@"
# flatpak-builder --run $(dirname $0)/../flatpak $(dirname $0)/re.sonny.Workbench.Devel.json "$@"
# flatpak-builder --env=G_MESSAGES_DEBUG=workbench-cli --run flatpak build-aux/re.sonny.Workbench.Devel.json "$@"

$(dirname $0)/wip/run.js $(dirname $0)/re.sonny.Workbench.Devel.json -- "$@"
45 changes: 26 additions & 19 deletions build-aux/wip/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ function exists(path) {
return result;
}

if (!exists(`${path}/.flatpak/repo`)) {
if (!exists(`${path}/.frun/repo`)) {
const { runtime, sdk } = manifest;
const runtime_version = manifest["runtime-version"];
// initializes repo
await run([
"flatpak",
"build-init",
`${path}/.flatpak/repo`,
`${path}/.frun/repo`,
flatpak_id,
sdk,
runtime,
Expand All @@ -71,9 +71,9 @@ const prefix = [
"--disable-updates",
];
const suffix = [
`--state-dir=${path}/.flatpak/flatpak-builder`,
`--state-dir=${path}/.frun/flatpak-builder`,
`--stop-at=${app_module.name}`,
`${path}/.flatpak/repo`,
`${path}/.frun/repo`,
Gio.File.new_for_path(path).get_relative_path(manifest_file),
];

Expand All @@ -93,23 +93,23 @@ async function buildModules() {
]);
}

if (!exists(`${path}/.flatpak/flatpak-builder`)) {
if (!exists(`${path}/.frun/flatpak-builder`)) {
await downloadSources();
await buildModules();
}

// builds workbench
if (!exists(`${path}/_build`)) {
if (!exists(`${path}/.frun/_build`)) {
await buildCommand([
"meson",
"--prefix",
"/app",
"_build",
".frun/_build",
"-Dprofile=development",
]);
}

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

// starts workbench
const command = argv["--"].length ? argv["--"] : [manifest.command];
await runCommand(command);
if (argv.build !== true) {
const command = argv["--"].length ? argv["--"] : [manifest.command];
await runCommand(command);
}

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

return [`--env=PATH=${PATH}`, `--env=LD_LIBRARY_PATH=${LD_LIBRARY_PATH}`];
}

function buildCommand(argv) {
const PKG_CONFIG_PATH =
"/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";

Expand All @@ -145,12 +151,11 @@ function buildCommand(argv) {
"build",
"--share=network",
`--filesystem=${path}`,
`--filesystem=${path}/.flatpak/repo`,
`--env=PATH=${PATH}`,
`--env=LD_LIBRARY_PATH=${LD_LIBRARY_PATH}`,
`--filesystem=${path}/.frun/repo`,
...getCommonArguments(),
`--env=PKG_CONFIG_PATH=${PKG_CONFIG_PATH}`,
`--filesystem=${path}/_build`,
`${path}/.flatpak/repo`,
`--filesystem=${path}/.frun/_build`,
`${path}/.frun/repo`,
...argv,
]);
}
Expand All @@ -165,12 +170,14 @@ async function runCommand(argv) {
`--bind-mount=/run/user/1000/doc=/run/user/1000/doc/by-app/${flatpak_id}`,
...manifest["finish-args"],

...getCommonArguments(),

// Non default permissions, see Permissions.js
// consider getting installed overrides instead with
// flatpak override --user --show re.sonny.Workbench.Devel
"--share=network",
"--socket=pulseaudio",
"--device=input",
"--device=all", // using "all" instead of "device" for broader compatibility

"--talk-name=org.freedesktop.portal.*",
"--talk-name=org.a11y.Bus",
Expand All @@ -183,7 +190,7 @@ async function runCommand(argv) {
`--filesystem=${home}/.cache/fontconfig:ro`,
`--bind-mount=/run/host/user-fonts-cache=${home}/.cache/fontconfig`,
`--bind-mount=/run/host/font-dirs.xml=${home}/.cache/font-dirs.xml`,
`${path}/.flatpak/repo`,
`${path}/.frun/repo`,
...argv,
],
{ verbose: true },
Expand Down Expand Up @@ -233,7 +240,7 @@ async function exec(argv, { cancellable = null /*, verbose = false*/ }) {
// ? Gio.SubprocessFlags.NONE
// : Gio.SubprocessFlags.STDOUT_SILENCE;

const flags = Gio.SubprocessFlags.NONE;
const flags = Gio.SubprocessFlags.STDIN_INHERIT;

const proc = new Gio.Subprocess({
argv,
Expand Down
Loading