Build and run project outside of Builder

What shell command(s) can I use to build and run my project outside of Builder? I’m guessing something involving Meson and / or Flatpak, but I’m a bit lost in their respective documentation.

When I build and run the project inside Builder, the only thing that seems to have changed in the project directory is a json file ; Is some sort of executable built somewhere else?

Exactly what command(s) does Builder run when I press Ctrl+F5?

In the Builder (43.1 Flatpak) side pane there is this list of tasks:

To build my project I click (yes, with the mouse :confused: ) on the last item, all the undone items are done in sequence, and I get thrown in a shell window where my build lives. And that’s very nice, but:

For each of those steps, it would be even nicer if Builder would allow me to see (like in some sort of tooltip? But just in the output logs would be fine) exactly what it is that it’s doing, or going to do.

So what I meant is: I really need to know the exact sequence of build command(s) that Builder is running to be able to build independantly of the IDE / Editor.

It’s clearly a combination of meson this and ninja that, but which one exactly?

Also that would allow me to go back to my habitual editor that I’ve been using for 20+ years now :slight_smile: incorporating some Builder things that I liked in the process.

I can’t tell exactly what builder do, but when I want to build something I do “meson build” at the project’s root, “build” is the directory where I want to place my build files and then “cd ./build” and “ninja” to build. If you want to install your project type “ninja install” and “ninja uninstall” to uninstall it.

1 Like

Thanks! The thing is I already tried that (and a lot of other invocations) after reading the meson “getting started” docs but it always fails:

# cat /home/px/Projects/matinee/build/meson-logs/meson-log.txt
Build started at 2022-11-15T18:59:50.851437
Main binary: /usr/bin/python3
Build Options: 
Python system: Linux
The Meson build system
Version: 0.61.2
Source dir: /home/px/Projects/matinee
Build dir: /home/px/Projects/matinee/build
Build type: native build
Project name: matinee
Project version: 0.1.0
Build machine cpu family: x86_64
Build machine cpu: x86_64
Host machine cpu family: x86_64
Host machine cpu: x86_64
Target machine cpu family: x86_64
Target machine cpu: x86_64
WARNING: Gettext not found, all translation targets will be ignored.

data/ ERROR: Can not assign None to variable.

And here is the offending data/ file:

# cat data/ 
desktop_file = i18n.merge_file(
        input: '',
       output: 'org.yphil.matinee.desktop',
         type: 'desktop',
       po_dir: '../po',
      install: true,
  install_dir: join_paths(get_option('datadir'), 'applications')

desktop_utils = find_program('desktop-file-validate', required: false)
if desktop_utils.found()
  test('Validate desktop file', desktop_utils, args: [desktop_file])

appstream_file = i18n.merge_file(
        input: '',
       output: 'org.yphil.matinee.appdata.xml',
       po_dir: '../po',
      install: true,
  install_dir: join_paths(get_option('datadir'), 'appdata')

appstream_util = find_program('appstream-util', required: false)
if appstream_util.found()
  test('Validate appstream file', appstream_util, args: ['validate', appstream_file])

  install_dir: join_paths(get_option('datadir'), 'glib-2.0/schemas')

compile_schemas = find_program('glib-compile-schemas', required: false)
if compile_schemas.found()
  test('Validate schema file',
       args: ['--strict', '--dry-run', meson.current_source_dir()])


Builder obviously uses its own “bundled” version of meson (I actually had to install it with apt) or maybe it’s in the runtime:

flatpak list

Builder                                     org.gnome.Builder                      43.1     stable  flathub          system
GNOME Application Platform version 42       org.gnome.Platform                              42      flathub          system
GNOME Application Platform version 43       org.gnome.Platform                              43      flathub          system
GNOME Software Development Kit version 43   org.gnome.Sdk                                   43      flathub          system

That adds another layer of difficulty :thinking: I’m guessing that it probably involves flatpak, I mean the way I see it, Builder (at least in this config: Gtk4+Python) talks to flatpak which in turn talks to meson and ninja, am I mistaking?

Ok I found (in this page of the docs) a way to launch Builder (Flatpak) via command line in verbose mode, and that’s great, every stage is cleanly exposed when I press “Create flatpak bundle” so as I suspected it’s a flatpak command, but apparently it’s in a container somewhere.

My question is at least partially answered:

20:11:17.2654                           ide-run-context[    2]:    DEBUG: Mapping Builder FD 53 to target FD 2 via flatpak-spawn
20:11:17.2654                   ide-subprocess-launcher[    2]:    DEBUG: Launching 'flatpak-spawn --host --watch-bus --env=CCACHE_DIR=/home/px/.var/app/org.gnome.Builder/cache/gnome-builder/flatpak-builder/ccache --env=COLORTERM=truecolor --env=FLATPAK_CONFIG_DIR=/home/px/.var/app/org.gnome.Builder/data/gnome-builder/flatpak/etc --env=TERM=xterm-256color --directory=/home/px/.var/app/org.gnome.Builder/cache/gnome-builder/projects/matinee/builds/org.yphil.matinee.json-flatpak-org.gnome.Platform-43-x86_64-newdev --forward-fd=2 flatpak build --with-appdir --allow=devel --die-with-parent --filesystem=/home/px/Projects/matinee --filesystem=/home/px/.var/app/org.gnome.Builder/cache/gnome-builder/projects/matinee/builds/org.yphil.matinee.json-flatpak-org.gnome.Platform-43-x86_64-newdev --filesystem=/home/px/.var/app/org.gnome.Builder/cache/gnome-builder --nofilesystem=host --share=network --env=BUILDDIR=/home/px/.var/app/org.gnome.Builder/cache/gnome-builder/projects/matinee/builds/org.yphil.matinee.json-flatpak-org.gnome.Platform-43-x86_64-newdev --env=COLORTERM=truecolor --env=SRCDIR=/home/px/Projects/matinee --env=TERM=xterm-256color --env=PATH=/app/bin:/usr/bin /home/px/.var/app/org.gnome.Builder/cache/gnome-builder/projects/matinee/flatpak/staging/x86_64-newdev ninja install' from directory '.' with environment  inheriting parent environment

But when I try to replicate the commands I get a

error: Build directory /home/px/.var/app/org.gnome.Builder/cache/gnome-builder/projects/matinee/flatpak/staging/x86_64-newdev not initialised, use flatpak build-init

And then a

# flatpak build-init /home/px/.var/app/org.gnome.Builder/cache/gnome-builder/projects/matinee/flatpak/staging/x86_64-newdev
error: RUNTIME must be specified

Anybody knows how I can find the name of said runtime?
I think this might help you, you’ll build the project using flatpack and this will maybe avoid the error you’re getting.
What is happening seems to be that something that helps to build the project should return something else than None, but returns nothing if it’s used outside flatpak.

Build with

flatpak-builder flatpak-build-dir <app-id>.json --force-clean --user --install

Run with

flatpak run <app-id>//master

Just replace <app-id> with the actual application id of your app.

Fantastic! It works ; Well, I had to change modules.sources.url in the json file because it was pointing to

"url" : "file:///home/me/Projects/"
fatal: '/home/me/Projects' does not appear to be a git repository

instead of
"url" : "file:///home/me/Projects/matinee"

But it works now :slightly_smiling_face: Thank you very much.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.