Can Gnome Builder actually produce something else than flatpaks?

1.4k Views Asked by At

I can't seem to find any documentation as to how to configure builds to produce something else than the pre-configured flatpaks. Duplicating build configurations and changing the settings doesn't seem to give me the option to produce anything else than flatpaks. Changing the application runtime to "Host System" produces only flatpaks as well. I can't even find the preliminary binaries that seem to be produced somewhere before they're packaged. What am I doing wrong?

2

There are 2 best solutions below

0
On

In addition to wappa's answer, for GNOME Builder 43, the file system is ~/.var/app/org.gnome.Builder/cache/gnome-builder/projects/<your-project-name>. The default build directory is builds/<your-application-id>.json-flatpak-org.gnome.Platform-43-x86_64-main under the file system; you can find object files, executable files, Meson and Ninja files including build.ninja, etc. here.

Besides, you can find the output Flatpak files at flatpak/staging/x86_64-main under the file system. To export a Flatpak bundle, you can click the down arrow on the top bar and click "export". The exported Flatpak bundle is at this directory. The executable binary file is under files/bin. You can also find application data, icons, font configurations, etc., under the files directory.

To configure the location, you can still click the down arrow on the top bar and click "Configure Project...". On the "Overview" page, you can view which configuration you are using currently, corresponding to the configuration options on the sidebar: "Default" (~/.var/app/org.gnome.Builder/cache/gnome-builder/install/<your-project-name>/host) and <your-application-id>.json. By default, the latter one is selected, whose installation prefix is /app. If you look at the Build Output, you can observe that the desktop file, source files, GSchema XML, AppData XML, Icons, etc., are installed into /app. The /app is the path in Flatpak's sandbox filesystem rather than the path in the main filesystem of your Linux OS.

If you want to avoid using Flatpak, you can go to the build directory and manually build by Meson and Ninja.

0
On

For reference, I am using Builder 3.36. My assumption based on your post is you're looking only for your application binary, and not a way to build some other package like .deb or .rpm.

There are a few ways you can do this.

Method 1: From your Flatpak build's directory

Click the omnibar and click "build", not "Export Bundle". When it's completed, click the "View build console contents" button from the same omnibar drop down where the "Export Bundle" button is.

Look at the last lines of output in the terminal for the "flatpak build" command. Look for the "build-dir" parameter passed to this command.

The path will be something like "~/.cache/gnome-builder/projects/AppName/builds/org.your.App.json-flatpak-org.gnome.Platform-x86_64-3.34-unversioned"

Go into this directory. It will have a subdirectory "src" which has your app.

Method 2: Change build configuration

If you click the "Switch Surface" button in the top left and go to "Build Configurations" you should see two configurations created for you by default (if you created the project through Builder). Builder defaults to your JSON file which builds Flatpaks.

Click the "Default" configuration, then click "Make Active" under "Overview". Then you can build the app as normal (e.g. with the omnibar at the top). Once it says "Build succeeded" the binary has been built.

But where? Look for the path listed in the "Overview" for the "Default" configuration -- under "Install Prefix". This will be something like "/home/user/.cache/gnome-builder/install/AppName/host"

In there is a "bin" directory with your app.

Method 3 (Preferred): Build using ninja

From the Editor surface, press CTRL+SHIFT+ALT+T to open a terminal inside Builder, which defaults to your $BUILDDIR

In the terminal that's open, simply type "ninja". If it says "ninja: no work to do." your app is already built and up to date. You can type "ninja clean" and then "ninja" if you want to do a fresh rebuild.

Inside this directory, (something like "~/.cache/gnome-builder/projects/AppName/builds/default-host-unversioned") there will be a "src" directory which is where the app is built.

Running your app

You may not be able to double click this from a file manager, so open the directory in a terminal and type "./appname" to run the app.