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 62 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
3275e5e
wip
Jammyjamjamman Aug 17, 2022
56b6056
More meson progress
Jammyjamjamman Aug 22, 2022
51f2c5a
add meson build to the CI
andy5995 Aug 23, 2022
40f0130
Meson: Added most stuff to shared_lib
Jammyjamjamman Aug 24, 2022
f62b701
improve conditions for finding miniupnpc and libircclient
andy5995 Aug 25, 2022
34867fb
More progress
Jammyjamjamman Aug 26, 2022
7878558
mapeditor build
Jammyjamjamman Aug 27, 2022
e7d66ca
Everything builds!
Jammyjamjamman Aug 28, 2022
a45411a
Fix ubuntu build
Jammyjamjamman Aug 28, 2022
12b448f
Create meson.yml
andy5995 Oct 10, 2024
eec91fa
meson.yml: Update
andy5995 Oct 10, 2024
6d221b6
Build and add streflop
andy5995 Oct 11, 2024
869ed23
Use only meson.yml
andy5995 Feb 6, 2025
7dfe0a8
Use loops to prepend directory names
andy5995 Feb 6, 2025
6edcf00
Add build script
andy5995 Feb 6, 2025
51843df
Change buildtype to debugoptimized
andy5995 Feb 6, 2025
0493c39
meson.yml: Add FreeBSD job
andy5995 Feb 6, 2025
2c0ac7a
Adjust lookup for libircclient
andy5995 Feb 6, 2025
5695519
Add fontconfig wrap
andy5995 Feb 6, 2025
dfc231b
Add lua wrap
andy5995 Feb 6, 2025
6ab0b7f
remove fontconfig requirement
andy5995 Feb 6, 2025
8c4ce9b
conditionally check /usr/include/libircclient
andy5995 Feb 6, 2025
2cbd8f0
Fix default include path for libircclient
andy5995 Feb 7, 2025
bb54a9b
cmake.yml: Don't run unless meson workflow completes
andy5995 Feb 7, 2025
091f1df
Also look in /usr/local/include for libircclient.h
andy5995 Feb 7, 2025
9fc30b3
Search in /usr/local/lib for libircclient
andy5995 Feb 7, 2025
48bc5b4
Add macos
andy5995 Feb 7, 2025
35cce11
Add extra flags
andy5995 Feb 7, 2025
58002b4
mv irclient from shared_lib to game
andy5995 Feb 7, 2025
e661665
Add xinit to macos install (fix error?)
andy5995 Feb 7, 2025
06f86f0
Create symlink to wx-config on FreeBSD
andy5995 Feb 7, 2025
a0bfddc
Define streflop unconditionally
andy5995 Feb 7, 2025
1cdb436
Add streflop dep to game
andy5995 Feb 7, 2025
a3ed62c
Try to fix streflop and fail
andy5995 Feb 8, 2025
f65f0f3
Add streflop as meson subproject
andy5995 Feb 8, 2025
434e883
add cstd=c++11 (maybe fix freebsd build)
andy5995 Feb 8, 2025
7044adc
meson format recursive
andy5995 Feb 8, 2025
028e799
add undef=false to default meson opts
andy5995 Feb 9, 2025
13bade7
Specify streflop fpu in subproject call
andy5995 Feb 10, 2025
7eadd5d
some organizing and streflop work
andy5995 Feb 13, 2025
c378fbe
Fix freeze and crash when starting network game
andy5995 Feb 13, 2025
9b1e5b4
Various unremarkable changes
andy5995 Feb 13, 2025
e12175a
For macos lua dep, don't specify 5.3 (which has been disabled)
andy5995 Feb 13, 2025
35b326e
Use newer Ubuntu
andy5995 Feb 13, 2025
cb01d5d
undefine a couple macros
andy5995 Feb 13, 2025
8660932
Add '-ng' to streflop stuff
andy5995 Feb 13, 2025
6ff91d2
Add b_ndebug to default build
andy5995 Feb 14, 2025
b53b027
Initial implementation of config_whole for macros
andy5995 Feb 14, 2025
6a00208
Add git rev, add basic options, some improvements and cleanup
andy5995 Feb 17, 2025
71e934a
Reformat meson files
andy5995 Feb 17, 2025
9cc2937
output git ver to gitversion.h
andy5995 Feb 17, 2025
3fe02d6
More cleanup
andy5995 Feb 17, 2025
018d735
Move feathery and miniupnpc from shared lib to game
andy5995 Feb 17, 2025
18e44f2
streflop-ng.wrap: Change revision to HEAD
andy5995 Feb 17, 2025
94b20d6
Organizing dependencies
andy5995 Feb 18, 2025
64ca8d3
script: only move binaries if they exists
andy5995 Feb 18, 2025
11417b2
cmake.yml: reenable
andy5995 Feb 18, 2025
a9530a2
math_wrapper: Revert comment (#include)
andy5995 Feb 18, 2025
e8c033a
streflop_cond: Revert macro rename
andy5995 Feb 18, 2025
0a46760
meson.yml: Rename jobs
andy5995 Feb 18, 2025
e9bea5a
Conditionally include gitversion.h
andy5995 Feb 18, 2025
c42d343
CI: Add MSYS2 job
andy5995 Feb 20, 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
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ root = true
end_of_line = lf
insert_final_newline = true
charset = utf-8

[meson.build]
indent_style = space
indent_size = 2
1 change: 0 additions & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,3 @@ jobs:
name: megaglest-x64-macos
retention-days: 1
path: release/*.tar.bz2

127 changes: 127 additions & 0 deletions .github/workflows/meson.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
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:
linux:
runs-on: ubuntu-24.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

#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

MSYS:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: msys2/setup-msys2@v2
with:
msystem: mingw64
install: >-
bison
dos2unix
flex
git
pacboy: >-
gcc:p
cmake:p
ninja:p
pkgconf:p
python-certifi:p
update: true

- name: Install dependencies
shell: msys2 {0}
run: |
pacman --noconfirm --needed -S \
mingw-w64-x86_64-libpng \
mingw-w64-x86_64-meson \
mingw-w64-x86_64-SDL2

- name: Build
shell: msys2 {0}
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
69 changes: 69 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
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',
'b_ndebug=true',
],
)
# -Db_ndebug=true | Disable assertions.
# Normally meson will add _GLIBCXX_ASSERTIONS to the build flags. When that's
# added, multiplayer network games will crash after starting.

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

# OS name reference chart
#https://mesonbuild.com/Reference-tables.html#operating-system-names
#
# s_posix = host_machine.system() not in ['windows', 'emscripten', 'android']
host_system = host_machine.system()

# Compiler id reference chart
# https://mesonbuild.com/Reference-tables.html#compiler-ids
#
#if cxx.get_id() == 'msvc'

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

# Defined in cmake but I didn't find references in the source code
# '-DX11_AVAILABLE'
# -DHAVE_FONTCONFIG'

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

git = find_program('git')
git_version = 'unversioned'
if git.found()
git_version = run_command(
[git, 'rev-parse', '--short', 'HEAD'],
capture: true,
check: true,
)
endif
gitver = configuration_data()
gitver.set_quoted('GITVERSION', git_version.stdout().strip())
gitversion_h = configure_file(output: 'gitversion.h', configuration: gitver)

# Macros will be written to config.h later when configure_file() runs
conf = configuration_data()
conf.set('MESON_BUILD', 1)

subdir('source')

# The config.h file finally is output here, all the data assigned by
# conf.set() will be written to it.
config_h = configure_file(output: 'config_whole.h', configuration: conf)
7 changes: 7 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Build options
option('build_game', type: 'boolean', value: true, description: 'Build editor')
option('build_editor', type: 'boolean', value: true, description: 'Build the map editor')
option('build_viewer', type: 'boolean', value: true, description: 'Build the g3d viewer')

#option('docdir', type : 'string', value : 'share/doc/megaglest',
# description : 'directory where the documentation should be installed to')
2 changes: 2 additions & 0 deletions mk/macos/setupBuildDeps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ brew install cmake \
libpng \
libvorbis \
lua \
meson \
miniupnpc \
pkg-config \
sdl2 \
wxwidgets \
xinit \
xorg-server \
zstd
44 changes: 44 additions & 0 deletions mk/test-meson-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/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)"

SETUP_OPTS="${BUILD_DIR} ${@}"

cd "$SOURCE_ROOT"
if [ ! -d "$BUILD_DIR" ]; then
meson setup ${SETUP_OPTS}
else
meson setup --reconfigure ${SETUP_OPTS}
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
if [ -f "$bin" ]; then
mv -vf "$bin" "$TARGET_DIR"
fi
done
6 changes: 6 additions & 0 deletions source/config_whole.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// This file is used for the cmake file and is used now as a placeholder.
// The meson build generates this automatically

#pragma once


1 change: 1 addition & 0 deletions source/g3d_viewer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER)
ENDIF()

INCLUDE_DIRECTORIES(${GLEST_LIB_INCLUDE_DIRS})
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source) # For config_whole.h

IF(WIN32)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source/shared_lib/include/platform/win32)
Expand Down
32 changes: 32 additions & 0 deletions source/g3d_viewer/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
src_viewer = [
'main.cpp',
'renderer.cpp',
'../glest_game/global/config.cpp',
'../glest_game/graphics/unit_particle_type.cpp',
'../glest_game/graphics/particle_type.cpp',
]

# Some includes from the game are required for the viewer.
# Other required includes are imported from the dep_libmegaglest object
inc_viewer = [
'../glest_game/global',
'../glest_game/game',
'../glest_game/graphics',
'../glest_game/facilities',
'../glest_game/sound',
]

executable(
'megaglest_g3d_viewer',
src_viewer,
include_directories: inc_viewer,
dependencies: [
dep_libmegaglest,
wx_dep,
gl_dep,
x11_dep,
jpeg_dep,
png_dep,
glew_dep,
],
)
1 change: 1 addition & 0 deletions source/glest_game/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ IF(WANT_USE_STREFLOP AND NOT STREFLOP_FOUND)
ENDIF()

INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_DIRS} )
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/source) # For config_whole.h

#INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_ROOT}platform/${SDL_VERSION_SNAME} )

Expand Down
7 changes: 7 additions & 0 deletions source/glest_game/facilities/game_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
// License, or (at your option) any later version
// ==============================================================

// This condition can be removed after the cmake build is deprecated
#ifdef MESON_BUILD
#include "gitversion.h"
#endif

#include "game_util.h"

#include "util.h"
Expand All @@ -35,9 +40,11 @@ const char *mailString = " http://bugs.megaglest.org";
const string glestVersionString = "v3.13-dev";
const string lastCompatibleSaveGameVersionString = "v3.11.1";

// This won't be needed after the cmake build is deprecated
#if defined(GITVERSIONHEADER)
#include "gitversion.h"
#endif

#if defined(GITVERSION) || defined(GITVERSIONHEADER)
const string GIT_RawRev = string(GITVERSION);
#else
Expand Down
Loading
Loading