Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
degville opened this issue Jan 25, 2024 · 5 comments
Closed

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

degville opened this issue Jan 25, 2024 · 5 comments
Assignees
Labels
help wanted We welcome community help with this issue how-to Create a edit a how-to to achieve a specific task size 5 Fix a known documentation issue (size 5/8) update Update potentially outdated instructions, commands, or version numbers

Comments

@degville
Copy link
Collaborator

degville commented Jan 25, 2024

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:

  • update the core snap to the latest supported (such as from core18 to core22)
  • an updated core will typically require changes to the associated plugin
  • replace an inappropriate or no longer relevant example

Prerequisites

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

See also Contribute to our documentation.

@degville degville added help wanted We welcome community help with this issue size 5 Fix a known documentation issue (size 5/8) how-to Create a edit a how-to to achieve a specific task update Update potentially outdated instructions, commands, or version numbers labels Jan 25, 2024
@degville degville changed the title Snapcraft: Update C/C++ applications example to use core22 Snapcraft: Update C/C++ example to use core22 Jan 25, 2024
@popey
Copy link

popey commented Mar 1, 2024

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:

  • We have to prime out a library (libcaca), which gets pulled in for some reason
  • Audio doesn't work - DOSBox needs ALSA ideally, so we could use the whole boilerplate we cargo-cult into every other SDL game to get audio working. But that's super long and messy. The other option is just to ship the example code with no audio support

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
Copy link
Collaborator Author

degville commented Mar 1, 2024

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
Copy link

popey commented Apr 2, 2024

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
Copy link
Collaborator Author

@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
Copy link
Collaborator Author

Thanks @popey. Marking this as complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted We welcome community help with this issue how-to Create a edit a how-to to achieve a specific task size 5 Fix a known documentation issue (size 5/8) update Update potentially outdated instructions, commands, or version numbers
Projects
None yet
Development

No branches or pull requests

2 participants