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 #256

Draft
wants to merge 39 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
6ba3973
wip
Jammyjamjamman Aug 17, 2022
da6402a
More meson progress
Jammyjamjamman Aug 22, 2022
6393268
add meson build to the CI
andy5995 Aug 23, 2022
211a376
Meson: Added most stuff to shared_lib
Jammyjamjamman Aug 24, 2022
5a2cd60
improve conditions for finding miniupnpc and libircclient
andy5995 Aug 25, 2022
159ea0f
More progress
Jammyjamjamman Aug 26, 2022
2eba0f2
mapeditor build
Jammyjamjamman Aug 27, 2022
6c2ee8c
Everything builds!
Jammyjamjamman Aug 28, 2022
ee0ba6d
Fix ubuntu build
Jammyjamjamman Aug 28, 2022
4ef15e4
Create meson.yml
andy5995 Oct 10, 2024
104e59d
meson.yml: Update
andy5995 Oct 10, 2024
e40ab05
Build and add streflop
andy5995 Oct 11, 2024
931cc7b
Use only meson.yml
andy5995 Feb 6, 2025
45bba65
Use loops to prepend directory names
andy5995 Feb 6, 2025
65072e2
Add build script
andy5995 Feb 6, 2025
912f90f
Change buildtype to debugoptimized
andy5995 Feb 6, 2025
b08e562
meson.yml: Add FreeBSD job
andy5995 Feb 6, 2025
953aca6
Adjust lookup for libircclient
andy5995 Feb 6, 2025
c6c41f5
Add fontconfig wrap
andy5995 Feb 6, 2025
c464ba4
Add lua wrap
andy5995 Feb 6, 2025
86a4ab2
remove fontconfig requirement
andy5995 Feb 6, 2025
b018159
conditionally check /usr/include/libircclient
andy5995 Feb 6, 2025
3e7eb9b
Fix default include path for libircclient
andy5995 Feb 7, 2025
ce63b71
cmake.yml: Don't run unless meson workflow completes
andy5995 Feb 7, 2025
59b9f9e
Also look in /usr/local/include for libircclient.h
andy5995 Feb 7, 2025
5847ca3
Search in /usr/local/lib for libircclient
andy5995 Feb 7, 2025
5dc07cc
Add macos
andy5995 Feb 7, 2025
ffb7ac7
Add extra flags
andy5995 Feb 7, 2025
ce16f3e
mv irclient from shared_lib to game
andy5995 Feb 7, 2025
a71e627
Add xinit to macos install (fix error?)
andy5995 Feb 7, 2025
2819bab
Create symlink to wx-config on FreeBSD
andy5995 Feb 7, 2025
7bc3282
Define streflop unconditionally
andy5995 Feb 7, 2025
254da38
Add streflop dep to game
andy5995 Feb 7, 2025
dbc00f4
Try to fix streflop and fail
andy5995 Feb 8, 2025
059e09c
Add streflop as meson subproject
andy5995 Feb 8, 2025
1891faa
add cstd=c++11 (maybe fix freebsd build)
andy5995 Feb 8, 2025
257afed
meson format recursive
andy5995 Feb 8, 2025
4c46497
add undef=false to default meson opts
andy5995 Feb 9, 2025
3396bd2
Specify streflop fpu in subproject call
andy5995 Feb 10, 2025
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
22 changes: 12 additions & 10 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ concurrency:
cancel-in-progress: true

on:
push:
branches: [ develop ]
paths-ignore:
- '**/appimage.yml'

pull_request:
branches: [ develop ]
paths-ignore:
- '**/appimage.yml'
workflow_run:
workflows: [Meson]
types: [completed]
#push:
#branches: [ develop ]
#paths-ignore:
#- '**/appimage.yml'

#pull_request:
#branches: [ develop ]
#paths-ignore:
#- '**/appimage.yml'

jobs:
freebsd:
Expand Down Expand Up @@ -209,4 +212,3 @@ jobs:
name: megaglest-x64-macos
retention-days: 1
path: release/*.tar.bz2

93 changes: 93 additions & 0 deletions .github/workflows/meson.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Meson
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

on:
push:
branches: [ develop ]
paths:
- 'source/**/**'
- '**meson.build'
- '**/meson.yml'
pull_request:
branches: [ develop ]
paths:
- 'source/**/**'
- '**meson.build'
- '**/meson.yml'

jobs:
meson:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Get dependencies
run: |
sudo apt update && sudo apt upgrade -y
sudo mk/linux/setupBuildDeps.sh
sudo apt install -y --no-install-recommends meson
# Using pip is only required if a newer version of meson is required
# sudo apt-get install -y python3-pip python3-setuptools # required for pip
# sudo -H python3 -m pip install meson ninja
- name: Build
run: |
mk/test-meson-build.sh

freebsd:
runs-on: ubuntu-latest
name: FreeBSD
steps:
- uses: actions/checkout@v4
- name: Test in FreeBSD
id: test
uses: vmactions/freebsd-vm@v1
with:
usesh: true
prepare: |
pkg install -y \
bash \
meson \
cmake \
cppunit \
curl \
freetype2 \
fribidi \
ftgl \
git \
glew \
jpeg-turbo \
libGLU \
libircclient \
libogg \
libvorbis \
libX11 \
libxml2 \
lua53 \
mesa-libs \
miniupnpc \
openal-soft \
pkgconf \
png \
sdl2 \
wx30-gtk3

run: |
git config --global --add safe.directory /home/runner/work/megaglest-source/megaglest-source
cd /usr/local/bin
ln -s wxgtk3u-3.0-config wx-config
cd -
mk/test-meson-build.sh

build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4

- name: Get dependencies
run: |
mk/macos/setupBuildDeps.sh

- name: Build MegaGlest With Clang Compiler
run: |
mk/test-meson-build.sh
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,7 @@ $RECYCLE.BIN/
*.msi
*.pdb
#

# meson
subprojects/*
!subprojects/*.wrap
30 changes: 30 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
project(
'MegaGlest',
['c', 'cpp'],
version: '3.13.0.999',
meson_version: '>= 0.55.0',
default_options: [
'warning_level=1',
'buildtype=debugoptimized',
'cpp_std=c++11',
],
)

# Setup compiler.
cxx = meson.get_compiler('cpp')
cc = meson.get_compiler('c')

extra_flags = [
'-fno-common',
'-Werror=odr',
'-Werror=lto-type-mismatch',
# '-Werror=strict-aliasing',
'-DUSE_FTGL',
'-DUSE_STREFLOP',
'-DSTREFLOP_SSE',
]

add_project_arguments(cc.get_supported_arguments(extra_flags), language: 'c')
add_project_arguments(cxx.get_supported_arguments(extra_flags), language: 'cpp')

subdir('source')
4 changes: 3 additions & 1 deletion mk/macos/setupBuildDeps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ brew install cmake \
libogg \
libpng \
libvorbis \
lua \
[email protected] \
meson \
miniupnpc \
pkg-config \
sdl2 \
wxwidgets \
xinit \
xorg-server \
zstd
38 changes: 38 additions & 0 deletions mk/test-meson-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/sh

set -e

HERE="$(readlink -f "$(dirname "$0")")"
SOURCE_ROOT="$HERE/.."
BUILD_DIR="${BUILD_DIR:-$HERE/_build}"

# Ensure BUILD_DIR is an absolute path
[ "${BUILD_DIR#/}" != "$BUILD_DIR" ] || { echo "Error: BUILD_DIR must be an absolute path!"; exit 1; }

# Detect OS type
OS_TYPE="$(uname -s)"

if [ ! -d "$BUILD_DIR" ]; then
cd "$SOURCE_ROOT"
meson setup "$BUILD_DIR" "$@"
fi

cd "$HERE"

meson compile -C "$BUILD_DIR"

GAME_BIN="$BUILD_DIR/source/glest_game/megaglest"
EDITOR_BIN="$BUILD_DIR/source/glest_map_editor/megaglest_editor"
VIEWER_BIN="$BUILD_DIR/source/g3d_viewer/megaglest_g3d_viewer"

# Determine the correct directory based on OS
if [ "$OS_TYPE" = "Darwin" ]; then
TARGET_DIR="$HERE/macos"
else
TARGET_DIR="$HERE/linux"
fi

# Move binaries to the correct directory
for bin in "$GAME_BIN" "$EDITOR_BIN" "$VIEWER_BIN"; do
mv -vf "$bin" "$TARGET_DIR"
done
42 changes: 42 additions & 0 deletions source/g3d_viewer/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
src_g3d_viewer = [
'main.cpp',
'renderer.cpp',
'../glest_game/global/config.cpp',
'../glest_game/graphics/unit_particle_type.cpp',
'../glest_game/graphics/particle_type.cpp',
]

inc_common = [
'../shared_lib/include/graphics',
'../shared_lib/include/platform/sdl',
'../shared_lib/include/platform/common',
'../shared_lib/include/util',
'../shared_lib/include/xml',
'../shared_lib/include/map',
'../shared_lib/include/graphics/gl',
'../shared_lib/include/sound',
'../glest_game/global',
'../glest_game/game',
'../glest_game/graphics',
'../glest_game/facilities',
'../glest_game/sound',
]

executable(
'megaglest_g3d_viewer',
src_g3d_viewer,
include_directories: inc_common,
dependencies: [
dep_libmegaglest,
dep_wx,
dep_sdl,
dep_gl,
dep_x11,
dep_jpeg,
dep_png,
dep_glew,
],
# cpp_args: [
# '-DNDEBUG',
# ]
)
Loading
Loading