name: openscad-nightly
title: OpenSCAD-Nightly
base: core20
version: "git"
summary: OpenSCAD - Design. Code. Create.
description: >
    OpenSCAD is a software for creating solid 3D CAD models. It is free software and
    available for Mac, Windows, Linux and other UNIX-like OS’es. Unlike most 3D design
    software, the focus is not on the artistic aspects of 3D design but instead on the
    CAD aspects. This might be the application you are looking for when you are planning
    to create 3D designs for machine parts but is probably not what you are looking for
    when you are more interested in creating computer-animated movies. OpenSCAD is not
    an interactive modeller. Instead it is something like a 3D-compiler that reads in
    a script file that describes your object and renders the 3D model from this script
    file. This gives you, the designer, full control over the modelling process and
    enables you to easily change any step in your process or make designs that are
    defined by configurable parameters.

    OpenSCAD provides two primary modelling techniques: Constructive solid geometry
    (aka CSG) as well as extrusion of 2D outlines. We support reading, both 2D outlines
    and 3D object from external design files, in a variety of file formats.

    NOTE: This is the development snapshot, automatically built from the source
    repository.
confinement: strict
icon: resources/icons/openscad-nightly-256.png
license: GPL-3.0
grade: stable
architectures:
  - build-on: amd64
    run-on: amd64
  - build-on: arm64
    run-on: arm64
  - build-on: s390x
    run-on: s390x
  - build-on: ppc64el
    run-on: ppc64el

apps:
  openscad-nightly:
    command: usr/bin/openscad-nightly
    command-chain: [ bin/desktop-launch ]
    plugs: [desktop, desktop-legacy, x11, wayland, opengl, home, audio-playback, pulseaudio, network, removable-media, joystick]
    desktop: usr/share/applications/openscad-nightly.desktop
    environment:
      DISABLE_WAYLAND: 1

parts:
  opencsg:
    disable-parallel: true
    source: https://www.opencsg.org/OpenCSG-1.5.1.tar.gz
    plugin: make
    override-build: |
      ( cd src && qmake INSTALLDIR=/usr && sed -i 's,-isystem /usr/include,,' Makefile )
      make -C src
      make -C src INSTALL_ROOT="${SNAPCRAFT_PART_INSTALL}" install
    build-packages:
    - libglew-dev
    - freeglut3-dev
    stage-packages:
    - libglew2.1

  cgal:
    source: https://github.com/CGAL/cgal/releases/download/v5.5.2/CGAL-5.5.2-library.tar.xz
    plugin: cmake
    cmake-parameters: [ "-DCMAKE_BUILD_TYPE=Release", "-DCMAKE_INSTALL_PREFIX=/usr" ]
    after: [ patches ]
    build-packages:
    - cmake
    - libboost-dev
    - libboost-thread-dev

  lib3mf:
    source: https://github.com/3MFConsortium/lib3mf/archive/v1.8.1.tar.gz
    plugin: cmake
    cmake-parameters: [
        "-DCMAKE_INSTALL_PREFIX=/usr",
        "-DCMAKE_BUILD_TYPE=Release",
        "-DLIB3MF_TESTS=OFF"
    ]
    build-packages:
    - uuid-dev

  openscad-nightly:
    source: .
    build-snaps: [cmake]
    plugin: cmake
    cmake-parameters: [
        "-DCMAKE_PREFIX_PATH=${SNAPCRAFT_STAGE}/usr",
        "-DCMAKE_INSTALL_PREFIX=/usr",
        "-DCMAKE_BUILD_TYPE=Release",
        "-DSUFFIX=nightly",
        "-DEXPERIMENTAL=ON",
        "-DSNAPSHOT=ON"
    ]
    override-build: |
        git -C "${SNAPCRAFT_PART_SRC}" submodule update --init --recursive
        CC=clang CXX=clang++ cmake ${SNAPCRAFT_PART_SRC} \
            -G 'Unix Makefiles' \
            -DCMAKE_PREFIX_PATH="${SNAPCRAFT_STAGE}/usr" \
            -DCMAKE_INSTALL_PREFIX=/usr \
            -DCMAKE_BUILD_TYPE=Release \
            -DSUFFIX=nightly \
            -DEXPERIMENTAL=ON \
            -DSNAPSHOT=ON
        cmake --build .
        cmake --install . --prefix "${SNAPCRAFT_PART_INSTALL}/usr"
    after: [ desktop-qt5, opencsg, cgal, lib3mf ]
    build-packages:
    - git
    - clang
    - qt5-default
    - qtbase5-dev
    - qtmultimedia5-dev
    - libqt5svg5-dev
    - libqt5opengl5-dev
    - libqt5gamepad5-dev
    - libeigen3-dev
    - libglib2.0-dev
    - bison
    - flex
    - libglew-dev
    - libglvnd-dev
    - libgmp-dev
    - libmpfr-dev
    - libcairo2-dev
    - python
    - libboost-dev
    - libboost-regex-dev
    - libboost-system-dev
    - libboost-program-options-dev
    - libdouble-conversion-dev
    - chrpath
    - gettext
    - pkg-config
    - imagemagick
    - libtbb-dev
    - libzip-dev
    - libgl-dev
    - libxml2-dev
    - libharfbuzz-dev
    - libfreetype6-dev
    - libfontconfig1-dev
    - libqscintilla2-qt5-dev
    stage-packages:
    - qtwayland5
    - libasyncns0
    - libboost-regex1.71.0
    - libboost-system1.71.0
    - libboost-program-options1.71.0
    - libdouble-conversion3
    - libflac8
    - libglew2.1
    - libglu1-mesa
    - libglvnd0
    - libopengl0
    - libmpfr6
    - libgmpxx4ldbl
    - libogg0
    - libpulse0
    - libqt5svg5
    - libqt5opengl5
    - libqt5gamepad5
    - libqt5concurrent5
    - libqt5multimedia5
    - libqt5printsupport5
    - libqscintilla2-qt5-15
    - libsndfile1
    - libvorbis0a
    - libvorbisenc2
    - libzip5
    - libtbb2
    - libatomic1

  # https://github.com/ubuntu/snapcraft-desktop-helpers/blob/master/snapcraft.yaml
  desktop-qt5:
    source: https://github.com/ubuntu/snapcraft-desktop-helpers.git
    source-subdir: qt
    plugin: make
    make-parameters: ["FLAVOR=qt5"]
    build-packages:
      - build-essential
      - qtbase5-dev
      - dpkg-dev
    stage-packages:
      - libxkbcommon0
      - ttf-ubuntu-font-family
      - dmz-cursor-theme
      - light-themes
      - adwaita-icon-theme
      - gnome-themes-standard
      - shared-mime-info
      - libqt5gui5
      - libgdk-pixbuf2.0-0
      - libqt5svg5 # for loading icon themes which are svg
      - try: [appmenu-qt5] # not available on core18
      - locales-all
      - xdg-user-dirs
      - fcitx-frontend-qt5

  patches:
    source: snap/local/patches
    plugin: dump
    prime:
      - -*
