Skip to content

Commit

Permalink
Implement Meson
Browse files Browse the repository at this point in the history
The intent of this commit is to provide a working
meson build that implementation that is as close
to the existing autotools build as is reasonable.

Autotools should be considered deprecated; followup
commits that modernise the codebase (e.g `time.h` vs
`sys/time.h`) may include changes to autotools, and
bugs will be fixed, however no enhancements to the
autotools build will be made.

Porting notes:

FwvmPrompt: We use a script that calls 'find' to generate
a list of sources to feed to golang in a custom target as
there is not currently direct support for golang in Meson.

bin/: Configured scripts are manually set to 'rwxr-xr-x'.

drop -Wno-implicit-int:

Modern compilers complain about this for a reason;
we should not mask this.

I can't find any current occurrances in the codebase
and this will catch any future instances before they
are merged.

po:

- Set GETTEXT_PACKAGE (mandatory for i18n module)
- Add POTFILES to define files which need to be scanned
  for strings to translate

See:

- https://mesonbuild.com/Localisation.html
- https://mesonbuild.com/i18n-module.html#i18n-module

PRIVATE_COLORSET: always assume this is true

For years, we've been setting FVWM_COLORSET_PRIVATE=1, so there
is no need for the include guards.

ci:

We now include a Meson build that uses Clang + lld as
the build system to catch bugs and warnings that our
traditional autotools + GCC builds might miss.

We no longer build a docker image, instead we directly
execute the fvwm3-build container as a GitHub Action.
GH Actions have been factored out into a common set, and are
used as a matrix set to apply to Ubuntu (glibc) and Alpine (musl).

The Go version in fvwm3-build has been updated to enable use
with meson and eliminate the need for a complex envvar setup
and invocation, however older golang is still supported (>=1.14);
we're just relying on users to tell us if something is broken.

While the issue with LTO builds has been resolved in this PR, it was
incidental and the introduced changes will catch LTO errors before
they make it into a release.

Closes: fvwmorg#1056
Co-authored-by: Thomas Adam <[email protected]>
Signed-off-by: Matt Jolly <[email protected]>
  • Loading branch information
Kangie and ThomasAdam committed Oct 16, 2024
1 parent 4284790 commit fb80c60
Show file tree
Hide file tree
Showing 112 changed files with 2,790 additions and 38 deletions.
45 changes: 38 additions & 7 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,44 @@ on:
jobs:
build:
runs-on: ubuntu-latest
container:
image: ${{ matrix.os == 'alpine' && 'fvwmorg/fvwm3-build-alpine:latest' || 'fvwmorg/fvwm3-build:latest' }}
env:
GO111MODULE: "on"

strategy:
matrix:
os: [ubuntu-latest, alpine]
build-system: [autotools, meson]
compiler: [gcc, clang]

steps:
- uses: actions/checkout@v2
- name: Pulling docker image
run: docker pull fvwmorg/fvwm3-build:latest
- name: Build Package
run: 'docker build -t fvwm3 .'
- name: Checkout repository
uses: actions/checkout@v4

- name: Set git safe directory
run: git config --global --add safe.directory ${GITHUB_WORKSPACE}

- name: Configure and Build
run: |
if [ "${{ matrix.build-system }}" = "autotools" ]; then
if [ "${{ matrix.compiler }}" = "gcc" ]; then
export CFLAGS="-flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing"
else
export CC_LD=lld
fi
export CC=${{ matrix.compiler }}
./autogen.sh && ./configure --enable-mandoc --enable-golang && make -j
fi
if [ "${{ matrix.build-system }}" = "meson" ]; then
if [ "${{ matrix.compiler }}" = "gcc" ]; then
export CFLAGS="-flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing"
else
export CC_LD=lld
fi
export CC=${{ matrix.compiler }}
meson setup builddir -Dhtmldoc=true -Dmandoc=true && ninja -C builddir
fi
notification:
runs-on: ubuntu-20.04
Expand All @@ -26,7 +57,7 @@ jobs:
uses: Gottox/[email protected]
if: github.event_name == 'pull_request'
with:
server: "irc.libera.chat"
server: irc.libera.chat
notice: false
channel: "#fvwm"
nickname: fvwm3-gh-pr
Expand All @@ -35,7 +66,7 @@ jobs:
uses: Gottox/[email protected]
if: github.event_name == 'create' && github.event.ref_type == 'tag'
with:
server: "irc.libera.chat"
server: irc.libera.chat
notice: false
channel: "#fvwm"
nickname: fvwm-gh
Expand Down
2 changes: 2 additions & 0 deletions acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,8 @@ AC_DEFUN([AM_GNU_FGETTEXT],
if test "$no_dgettext" != "yes"; then
CFLAGS="$CFLAGS $intl_LIBS $iconv_LIBS"
LIBS="$LIBS $intl_LIBS $iconv_LIBS"
echo "LIBS: $LIBS"
echo "CFLAGS: $CFLAGS"
AC_MSG_CHECKING(if a simple gettext program link)
AC_TRY_LINK([
#include <libintl.h>
Expand Down
6 changes: 6 additions & 0 deletions bin/FvwmPrompt/find-go-sources.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

# Find all Go source files in the current directory and its subdirectories.
# That is all

find "$(pwd)" -type f -name '*.go'
28 changes: 28 additions & 0 deletions bin/FvwmPrompt/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Fvwmprompt is written in golang. Unfortunately there is still
# no automagic in meson to handle golang projects. So we have to
# do it manually.

# Extract all of the go sources from the current directory
r = run_command('find-go-sources.sh', meson.current_source_dir(), check: true)
fvwmprompt_files = r.stdout().strip().split()
fvwmprompt_files += 'go.mod'
fvwmprompt_files += 'go.sum'

fvwmprompt_build = meson.current_source_dir()
fvwmprompt_output = meson.current_build_dir() + '/FvwmPrompt'

fvwmprompt = custom_target(
'FvwmPrompt',
output: 'FvwmPrompt',
input: fvwmprompt_files,
command: [
golang,
'build',
'-C', fvwmprompt_build,
'-v',
'-mod=vendor',
'-o', fvwmprompt_output,
],
install: true,
install_dir: bindir,
)
72 changes: 72 additions & 0 deletions bin/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
if golang.found()
subdir('FvwmPrompt')
endif

FvwmCommand = configure_file(
input: 'FvwmCommand.in',
output: 'FvwmCommand',
configuration: file_config,
install: true,
install_dir: bindir,
install_mode: install_mask_755,
)

# We should tighten up the dependencies here, but for now we'll just use all_found_deps.
fvwm_root = executable(
'fvwm-root',
'fvwm-root.c',
include_directories: includedirs,
link_with: libfvwm3,
dependencies: all_found_deps,
install: true,
)

fvwm_perllib = configure_file(
input: 'fvwm-perllib.in',
output: 'fvwm-perllib',
configuration: file_config,
install: true,
install_dir: bindir,
install_mode: install_mask_755,
)

fvwm_convert = configure_file(
input: 'fvwm-convert-2.6.in',
output: 'fvwm-convert-2.6',
configuration: file_config,
install: true,
install_dir: bindir,
install_mode: install_mask_755,
)

fvwm_menu_xlock = configure_file(
input: 'fvwm-menu-xlock.in',
output: 'fvwm-menu-xlock',
configuration: file_config,
install: true,
install_dir: bindir,
install_mode: install_mask_755,
)

fvwm_menu_directory = configure_file(
input: 'fvwm-menu-directory.in',
output: 'fvwm-menu-directory',
configuration: file_config,
install: true,
install_dir: bindir,
install_mode: install_mask_755,
)

fvwm_menu_desktop = configure_file(
input: 'fvwm-menu-desktop.in',
output: 'fvwm-menu-desktop',
configuration: file_config,
install: true,
install_dir: bindir,
install_mode: install_mask_755,
)

config_data = install_data(
'fvwm-menu-desktop-config.fpl',
install_dir: fvwm_datadir,
)
88 changes: 88 additions & 0 deletions config_defines.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#include <stdio.h>

#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#ifdef HAVE_MEMORY_H
# include <memory.h>
#endif
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif

#if defined (HAVE_MALLOC_H) && !defined (__FreeBSD__) && !defined (__OpenBSD__) && !defined(__NetBSD__)
# include <malloc.h>
#endif
#ifdef HAVE_FCNTL_H
# include <fcntl.h>
#endif
#ifndef HAVE_STRCHR
# define strchr(_s,_c) index((_s),(_c))
# define strrchr(_s,_c) rindex((_s),(_c))
#endif

#ifndef HAVE_MEMCPY
# define memcpy(_d,_s,_l) bcopy((_s),(_d),(_l))
#endif
#ifndef HAVE_MEMMOVE
# define memmove(_d,_s,_l) bcopy((_s),(_d),(_l))
#endif

#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif

#if HAVE_UNISTD_H
# include <unistd.h>
#endif

#ifndef min
# define min(a,b) (((a)<(b)) ? (a) : (b))
#endif
#ifndef max
# define max(a,b) (((a)>(b)) ? (a) : (b))
#endif
#ifndef abs
# define abs(a) (((a)>=0)?(a):-(a))
#endif

//#include "libs/defaults.h"

#ifndef O_NOFOLLOW
#define O_NOFOLLOW 0
#endif

#ifdef HAVE_LSTAT
#define DO_USE_LSTAT 1
#define fvwm_lstat(x,y) lstat(x,y)
#else
#define DO_USE_LSTAT 0
#define fvwm_lstat(x,y) -1
#endif

/* A macro that touches a variable in a compiler independent way to suppress
* warnings. */
#define SUPPRESS_UNUSED_VAR_WARNING(x) \
do { void *p; p = (void *)&x; (void)p; } while (0);

#ifdef HOST_MACOS
#undef HAVE_STRLCAT
#undef HAVE_STRLCPY
#else
#ifndef HAVE_STRLCAT
# include "libs/strlcat.h"
#endif

#ifndef HAVE_STRLCPY
# include "libs/strlcpy.h"
#endif
#endif

#ifndef HAVE_ASPRINTF
# include <stdarg.h>
int asprintf(char **, const char *, ...);
int vasprintf(char **, const char *, va_list);
#endif
53 changes: 53 additions & 0 deletions default-config/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
default_confdir = join_paths(
get_option('datadir'),
meson.project_name(),
'default-config',
)

default_conf_files = [
'images/background/bg1.png',
'images/background/bg2.png',
'images/background/bg3.png',
'images/bgicons/bg1.png',
'images/bgicons/bg2.png',
'images/bgicons/bg3.png',
'images/icons/win/bottom.png',
'images/icons/win/close.png',
'images/icons/win/destroy.png',
'images/icons/win/done.png',
'images/icons/win/iconify.png',
'images/icons/win/lower.png',
'images/icons/win/max.png',
'images/icons/win/move.png',
'images/icons/win/raise.png',
'images/icons/win/resize.png',
'images/icons/win/sendto.png',
'images/icons/win/shade.png',
'images/icons/win/stays.png',
'images/icons/win/sticky.png',
'images/icons/win/title.png',
'images/icons/win/top.png',
'images/icons/apps.png',
'images/icons/conf.png',
'images/icons/help.png',
'images/icons/info.png',
'images/icons/programs.png',
'images/icons/quit.png',
'images/icons/refresh.png',
'images/icons/restart.png',
'images/icons/run_arrow.png',
'images/icons/terminal.png',
'images/icons/wallpaper.png',
'images/fvwm-logo-small.png',
'FvwmScript-ConfirmCopyConfig',
'FvwmScript-ConfirmQuit',
'FvwmScript-DateTime',
'stalonetrayrc',
'config',
]

install_data(
default_conf_files,
install_dir: default_confdir,
preserve_path: true,
)
Loading

0 comments on commit fb80c60

Please sign in to comment.