canonical / open-documentation-academy

Learn open-source software documentation skills with Canonical
https://canonical.com/documentation/open-documentation-academy
Apache License 2.0
71 stars 41 forks source link

Snapcraft: Update C/C++ example to use core22 #1

Closed degville closed 6 months ago

degville commented 9 months ago

Update the following how-to guide to use core22 (or core24):

https://snapcraft.io/docs/c-c-applications

Background

Snapcraft's platform quickstart how-to guides help snap developers create a first snap with their chosen framework or development environment. Many of these guides become out of date and need to be revised. Specifically, they may need to be updated to address the following:

Prerequisites

You will need some experience building snaps, and some knowledge of the target framework or development environment.

See also Contribute to our documentation.

popey commented 8 months ago

I looked at this task to update the DOSBox example to the latest core22 and more modern adopted practices.

However, I got most of the way in, and it's getting too complex for an early example. I wanted to see what you think. Is it worth continuing, or should we switch to another C/C++ example that uses auto tools and is easy to run?

It's better to go for something with no audio requirements and isn't built with SDL. A command line utility that only needs network access, perhaps.

Issues:

The Yaml - without audio support.

name: dosbox
version: "0.74-3"
summary: DOS emulator
description: |
  DOSBox is a x86 emulator with Tandy/Hercules/
  CGA/EGA/VGA/SVGA graphics sound and DOS. It's
  been designed to run old DOS games under
  platforms that don't support it.

confinement: strict
base: core22
grade: stable
compression: lzo

icon: snap/gui/dosbox.png
website: https://www.dosbox.com/
source-code: https://sourceforge.net/projects/dosbox/files/
issues: https://sourceforge.net/p/dosbox/bugs/
contact: https://sourceforge.net/p/dosbox/_list/tickets

architectures:
  - build-on: amd64
  - build-on: armhf
  - build-on: arm64
  - build-on: s390x
  - build-on: ppc64el

parts:
  dosbox:
    plugin: autotools
    source-type: tar
    autotools-configure-parameters: ['--prefix=/usr']
    source: http://source.dosbox.com/dosboxsvn.tgz
    build-packages:
      - g++
      - make
      - libsdl1.2-dev
      - libpng-dev
      - libsdl-net1.2-dev
      - libsdl-sound1.2-dev
      - libasound2-dev
    stage-packages:
      - libsdl-sound1.2
      - libsdl-net1.2
      - libxss1
      - libmikmod3
      - libsdl1.2debian
      - libsdl2-2.0-0
      - libopenal1
      - libsndio7.0
    prime:
      - -usr/lib/x86_64-linux-gnu/libcaca++.so.0.*

apps:
  dosbox:
    command: usr/bin/dosbox
    desktop: snap/gui/dosbox.desktop
    common-id: com.dosbox.DOSBox
    extensions: [ gnome ]
    environment:
      SDL_AUDIODRIVER: pulse
    plugs:
      - audio-playback
      - removable-media
      - joystick
degville commented 8 months ago

Hello! Thanks so much for taking a look. To be completely honest, I think you have more experience with this than I do, but it sounds like a straightforward autotools example would be more useful for most readers.

I know we don't want to set naive expectations for how easy something might be to build, but neither do we want to put potential snap builders off with too many concepts (and workarounds!) in these early examples.

Feel free to swap DOSBox out if you have any ideas. I'm happy to look into something too - I'm sure I've recently built something useful with autotools that should work. I'll have a look over this weekend.

popey commented 7 months ago

Okay, I finally got around to sorting this. Moon Buggy! It's delightfully simple, with only two build packages, no stage packages, and no faffing around to make it work.

I'm not sure how to submit it, so I'm just attaching the screenshots here and a Markdown file to update the forum post/doc.

snapcraft_c_c++_example_core22.md Screenshot from 2024-04-02 12-53-42 Screenshot from 2024-04-02 12-53-32

Feedback welcome!

degville commented 6 months ago

@popey Sorry for the delay getting back to you! I was off last week and I've spent a couple of days catching up.

Thank you so much for this. The project and what you've written seems perfect - I love Moon Buggy! I've copied the file across to the forum, created the snapcraft-docs/moon-buggy repo (and tested it) and tweaked a few things like some double single quotes. I've also started to remove the dollar quotes from single bash commands in-line with our broader style guide (there are lots of places in the docs where I've yet to do this).

The quick start guide has now been updated: https://forum.snapcraft.io/t/c-c-applications/7817/8

And I think we could actually close issue #1! Thanks again @popey.

degville commented 6 months ago

Thanks @popey. Marking this as complete.