So, I'm attempting to develop my first real app for Elementary after tinkering around a bit and getting comfortable with Vala and the Developers Guide tutorial. I've got my github repo up and building, and I've linked it with the App Center, but I'm not ready to publish it yet. I'm feeling good about what I've got so far, but I noticed a gap between the guide and what most people seem to do in their own apps, specifically build systems.

I wasn't familiar with CMake, but followed the tutorial and it seems to make sense, but I see now that everyone is using Meson. I can't find a good source of tutorial/guide for Meson (and yes, I've followed the official tutorial and in-depth tutorial) to get me straightened out. I've looked through the Github repo for Harvey, and it seems much more complicated than expected. Does anyone have any suggestions for elementary OS dev w/ Meson?

  • Hey Ben, for future reference StackExchange works best when you only ask one question per post and the title refers clearly to the question being asked. This way, others that are having the same problem can easily find the answer to the question. I would really appreciate it if you would break off your question about debian packaging into a separate new question maybe with a bit more specific information about what you're trying to accomplish :) – Daniel Foré Oct 11 '17 at 15:38
  • 1
    I finally have enough reputation points to comment. Thanks for editing my question and clearing things up. I'm by no means an expert now, by I can work my way around Meson. Mission accomplished. – Ben Foote Nov 2 '17 at 15:00

Meson is definitely something we're working towards in the future, but we haven't included it in the dev guide because we're still testing it and there are a couple of gaps. When we're sure that using Meson will be simpler and more streamlined than using CMake, we'll replace it in the guide. That said, Meson has great documentation on their website and I suggest starting with their tutorial.

Harvey's Meson has a few things that you might not need in your app like libm, gresources, gsettings schemas, and tests. I pushed a couple revisions just now with some simplications I learned recently, if you still would like to use it as a reference. Really the most important thing you need to build your app is this block:

project('com.github.yourusername.yourapp', 'vala', 'c')

    dependencies: [
    install: true

In the first line you declare your project name and the programming languages used (We need c because Vala compiles down into C). Then in this next block we tell Meson that we want to:

  • Build an executable binary file when we execute ninja in Terminal and we're going to call it the same thing as our project name (com.github.yourusername.yourapp)
  • Include src/Application.vala and src/MainWindow.vala as the files we are compiling
  • Use the dependencies listed in this array to compile our vala files. These are the minimum dependencies required for a Gtk+ app
  • Install this executable to the appropriate location when we execute ninja install

With the above in a file called meson.build you can open up Terminal and run meson build --prefix=/usr, then cd build and ninja and that's all you really need to get an executable. Then to install ninja install.

  • 1
    Thanks Daniel. I'm embarrassed to have not updated my initial question with a followup. (I don't have enough SO\E reputation points yet.) Anyways, I really appreciate your answer. I was able to eventually figure out the intricacies of the meson.build files, but I will do another clone of Harvey to see what you changed just in case I missed something. In the future, I'll ask only 1 specific question to get a specific answer. And thanks for making eOS awesome. – Ben Foote Oct 12 '17 at 4:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.