Skip to content

Commit

Permalink
Use flatpak build instead of flatpak-builder
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnyp committed Dec 11, 2024
1 parent aa93296 commit 1ad4f82
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 24 deletions.
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
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 -- "$@"
43 changes: 25 additions & 18 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,6 +170,8 @@ 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
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

0 comments on commit 1ad4f82

Please sign in to comment.