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

Add Meson build system #193

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
- pull_request

jobs:
linux:
name: Linux
linux-autotools:
name: Linux Autotools
runs-on: ubuntu-22.04
strategy:
matrix:
Expand Down Expand Up @@ -35,3 +35,35 @@ jobs:
make
- name: "Run tests"
run: make distcheck

linux-meson:
name: Linux Meson
runs-on: ubuntu-22.04
strategy:
matrix:
configureFlags:
- ""
- "-Dglib=enabled -Dintrospection=enabled"
- "-Dgegl=enabled"
include:
- configureFlags: "-Dglib=enabled -Dintrospection=enabled"
extraDeps: "libgirepository1.0-dev"
- configureFlags: "-Dgegl=enabled"
extraDeps: "libgegl-dev"
steps:
- uses: actions/checkout@v4
- name: "Install dependencies"
run: |
sudo apt-get update
sudo apt-get install -y \
libjson-c-dev \
meson \
ninja-build \
gettext \
${{ matrix.extraDeps }}
- name: "Build"
run: |
meson setup _build --buildtype=release -Dauto_features=disabled
meson compile -C _build
- name: "Run tests"
run: meson dist -C _build
87 changes: 37 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,27 @@ License: ISC, see [COPYING](./COPYING) for details.
## Dependencies

* All configurations and builds:
- C compiler, linker etc.
- [Python](http://python.org/)
- [Meson](https://en.wikipedia.org/wiki/Meson_(software)) and [ninja](https://en.wikipedia.org/wiki/Ninja_(build_system))
- Alternately, Autotools can be used instead but they are now considered deprecated.
- [json-c](https://github.com/json-c/json-c/wiki) (>= 0.11)
- C compiler, `make` etc.
* Most configurations (all except `--disable-introspection --without-glib`):
- [gettext](https://www.gnu.org/software/gettext/gettext.html) (unless `-Di18n=disabled`)
* Most configurations (all except `-Dintrospection=disabled -Dglib=disabled`):
- [GObject-Introspection](https://live.gnome.org/GObjectIntrospection)
- [GLib](https://wiki.gnome.org/Projects/GLib)
* When building from `git` (developer package names vary by distribution):
- [Python](http://python.org/)
- [autotools](https://en.wikipedia.org/wiki/GNU_Build_System)
- [intltool](https://freedesktop.org/wiki/Software/intltool/)
- [gettext](https://www.gnu.org/software/gettext/gettext.html)
* For `--enable-gegl` (GIMP *does not* require this):
* For `-Dgegl=enabled` (GIMP *does not* require this):
- [GEGL + BABL](http://gegl.org/)

### Install dependencies (Debian and derivatives)

On recent Debian-like systems, you can type the following
to get started with a standard configuration:

# apt install -y build-essential
# apt install -y build-essential meson
# apt install -y libjson-c-dev libgirepository1.0-dev libglib2.0-dev

When building from git:
Additionally, when using the deprecated Autotools build system:

# apt install -y python autotools-dev intltool gettext libtool

Expand All @@ -44,11 +43,11 @@ You might also try using your package manager:

### Install dependencies (Red Hat and derivatives)

The following works on a minimal CentOS 7 installation:
The following should works on a minimal CentOS 7 installation:

# yum install -y gcc gobject-introspection-devel json-c-devel glib2-devel
# yum install -y gcc meson gobject-introspection-devel json-c-devel glib2-devel

When building from git, you'll want to add:
Additionally, when using the deprecated Autotools build system:

# yum install -y git python autoconf intltool gettext libtool

Expand All @@ -60,9 +59,9 @@ You might also try your package manager:

Works with a fresh OpenSUSE Tumbleweed Docker image:

# zypper install gcc13 gobject-introspection-devel libjson-c-devel glib2-devel
# zypper install gcc13 meson gobject-introspection-devel libjson-c-devel glib2-devel

When building from git:
Additionally, when using the deprecated Autotools build system:

# zypper install git python311 autoconf intltool gettext-tools libtool

Expand All @@ -72,61 +71,53 @@ Package manager:

## Build and install

You can use [Meson](https://mesonbuild.com/) build system.

$ meson setup _build --prefix=/usr
$ meson compile -C _build
# meson install -C _build
# ldconfig

MyPaint and libmypaint benefit dramatically from autovectorization and other compiler optimizations.
You may want to set your CFLAGS before compiling (for gcc):
You may want to set your CFLAGS before compiling (for gcc) by passing something like the following as an argument to `meson setup`:

$ export CFLAGS='-Ofast -ftree-vectorize -fopt-info-vec-optimized -march=native -mtune=native -funsafe-math-optimizations -funsafe-loop-optimizations'
-Dc_args='-Ofast -ftree-vectorize -fopt-info-vec-optimized -march=native -mtune=native -funsafe-math-optimizations -funsafe-loop-optimizations'

The traditional setup works just fine.
Alternately, you can use the traditional Autotools build system for now (it is deprecated and will be eventually removed):

$ ./autogen.sh # Only needed when building from git.
$ ./autogen.sh
$ ./configure
# make install
# ldconfig

### Maintainer mode

We don't ship a `configure` script in our git repository. If you're
building from git, you have to kickstart the build environment with:

$ git clone https://github.com/mypaint/libmypaint.git
$ cd libmypaint
$ ./autogen.sh

This script generates `configure` from `configure.ac`, after running a
few checks to make sure your build environment is broadly OK. It also
regenerates certain important generated headers if they need it.

Folks building from a release tarball don't need to do this: they will
have a `configure` script from the start.

### Configure

$ ./configure
$ ./configure --prefix=/tmp/junk/example
Meson requires out-of-tree builds so you need to specify a build directory.

There are several MyPaint-specific options.
These can be shown by running
$ meson setup _build
$ meson setup _build --prefix=/tmp/junk/example

$ ./configure --help
In addition to to [Meson options](https://mesonbuild.com/Builtin-options.html#compiler-options), there are several libmypaint-specific options, see `meson_options.txt` file for details.

$ meson setup _build -Dgegl=disabled -Ddocs=true -Di18n=enabled

### Build

$ make
$ meson compile -C _build

Once MyPaint is built, you can run the test suite and/or install it.

### Test

$ make check
$ meson test -C _build

This runs all the unit tests.

### Install

# make install
# meson install -C _build

Uninstall libmypaint with `make uninstall`.
Uninstall libmypaint with `meson uninstall -C _build`.

### Check availability

Expand Down Expand Up @@ -172,11 +163,7 @@ for details of how you can begin contributing.

The distribution release can be generated with:

$ make dist

And it should be checked before public release with:

$ make distcheck
$ meson dist -C _build

## Localization

Expand All @@ -198,7 +185,7 @@ in `po/POTFILES.in`.
You can update the .po files when translated strings in the code change
using:

$ cd po && make update-po
$ meson compile -C _build update-po

When the results of this are pushed, Weblate translators will see the
new strings immediately.
Expand Down
9 changes: 8 additions & 1 deletion appveyor_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ pacman --noconfirm -S --needed \
base-devel \
${PKG_PREFIX}-json-c \
${PKG_PREFIX}-glib2 \
${PKG_PREFIX}-gobject-introspection
${PKG_PREFIX}-gobject-introspection \
${PKG_PREFIX}-meson \
git


# Add m4 directories to the ACLOCAL_PATH
Expand All @@ -30,6 +32,11 @@ done
export ACLOCAL_PATH
export PWD="$APPVEYOR_BULD_FOLDER"

# Check that Meson build works.
meson setup _build --buildtype=release -Dgegl=false -Ddocs=false
meson dist -C _build
rm -rf _build

./autogen.sh
./configure
make distcheck
21 changes: 21 additions & 0 deletions build-aux/fix-po-location.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python3

"""
The `generate.py` script will pass location info as a translator note.
This script converts it to a proper location comment.
"""

import re
import sys

LOCATION_PATTERN = re.compile(r"^#\. (: \.\./brushsettings.json:.*)", re.MULTILINE)

match sys.argv:
case [_, input_path, output_path]:
pass
case _:
print("usage: fix-po-location.py <input> <output>", file=sys.stderr)
sys.exit(1)

with open(input_path) as po_in, open(output_path, "w") as po_out:
po_out.write(LOCATION_PATTERN.sub(r"#\1", po_in.read()))
7 changes: 7 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -296,12 +296,19 @@ fi
AM_CONDITIONAL(ENABLE_GEGL, test "x$enable_gegl" = "xyes")
AC_SUBST(DOXYGEN_EXCLUDED)

DOXYXML_BUILD_PATH="$PWD/doc"
AC_SUBST(DOXYXML_BUILD_PATH)

DOXYGEN_SOURCE_ROOT="$PWD"
AC_SUBST(DOXYGEN_SOURCE_ROOT)

# Set pkg-config variables before generation.
AC_SUBST(PKG_CONFIG_REQUIRES)

AC_CONFIG_FILES([
doc/Doxyfile
doc/Makefile
doc/source/conf.py
gegl/libmypaint-gegl-]libmypaint_api_platform_version()[.pc:gegl/libmypaint-gegl.pc.in
gegl/Makefile
libmypaint-]libmypaint_api_platform_version()[.pc:libmypaint.pc.in
Expand Down
1 change: 1 addition & 0 deletions doc/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
source/conf.py
Doxyfile
doxygen/
build/
6 changes: 3 additions & 3 deletions doc/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "libmypaint"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.1
PROJECT_NUMBER = @LIBMYPAINT_VERSION@

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand All @@ -58,7 +58,7 @@ PROJECT_LOGO =
# entered, it will be relative to the location where doxygen was started. If
# left blank the current directory will be used.

OUTPUT_DIRECTORY =
OUTPUT_DIRECTORY = @DOXYXML_BUILD_PATH@

# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
# directories (in 2 levels) under the output directory of each output format and
Expand Down Expand Up @@ -819,7 +819,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = ../..
INPUT = @DOXYGEN_SOURCE_ROOT@

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down
1 change: 0 additions & 1 deletion doc/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
EXTRA_DIST = \
source/conf.py \
source/index.rst

if ENABLE_DOCS
Expand Down
37 changes: 37 additions & 0 deletions doc/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
doc_conf = configuration_data()
doc_conf.merge_from(conf)

doc_conf.set('DOXYGEN_SOURCE_ROOT', meson.project_source_root())
doc_conf.set('DOXYXML_BUILD_PATH', meson.current_build_dir())
doc_conf.set('DOXYGEN_EXCLUDED', '')

doxyfile = configure_file(
input: 'Doxyfile.in',
output: 'Doxyfile',
configuration: doc_conf,
)

doxygen_index = custom_target(
'doxygen',
input: doxyfile,
output: 'index.xml',
command: [
doxygen,
'@INPUT@',
],
)

subdir('source')

run_target(
'sphinx',
depends: [
doxygen_index,
],
command: [
sphinx_build,
'-c', meson.current_build_dir() / 'source',
meson.current_source_dir() / 'source',
meson.current_build_dir() / 'build',
],
)
6 changes: 3 additions & 3 deletions doc/source/conf.py → doc/source/conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

# Breathe setup, for integrating doxygen content
extensions.append('breathe')
doxyxml_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), '../doxygen')
doxyxml_dir = '@DOXYXML_BUILD_PATH@'
print(doxyxml_dir)
breathe_projects = {"libmypaint": doxyxml_dir}
breathe_default_project = "libmypaint"
Expand All @@ -63,9 +63,9 @@
# built documents.
#
# The short X.Y version.
version = '0.1'
version = '@LIBMYPAINT_VERSION@'
# The full version, including alpha/beta/rc tags.
release = '0.1'
release = '@LIBMYPAINT_VERSION_FULL@'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
5 changes: 5 additions & 0 deletions doc/source/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sphinx_conf_file = configure_file(
input: 'conf.py.in',
output: 'conf.py',
configuration: doc_conf,
)
Loading