diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index c1b1a4b7d..1fd8012d6 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -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: @@ -209,4 +212,3 @@ jobs: name: megaglest-x64-macos retention-days: 1 path: release/*.tar.bz2 - diff --git a/.github/workflows/meson.yml b/.github/workflows/meson.yml new file mode 100644 index 000000000..276253034 --- /dev/null +++ b/.github/workflows/meson.yml @@ -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 diff --git a/.gitignore b/.gitignore index 0a4e799f0..61aed0cdf 100644 --- a/.gitignore +++ b/.gitignore @@ -100,3 +100,7 @@ $RECYCLE.BIN/ *.msi *.pdb # + +# meson +subprojects/* +!subprojects/*.wrap diff --git a/meson.build b/meson.build new file mode 100644 index 000000000..54cbdfe49 --- /dev/null +++ b/meson.build @@ -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') diff --git a/mk/macos/setupBuildDeps.sh b/mk/macos/setupBuildDeps.sh index 40aab3619..2db345038 100755 --- a/mk/macos/setupBuildDeps.sh +++ b/mk/macos/setupBuildDeps.sh @@ -13,10 +13,12 @@ brew install cmake \ libogg \ libpng \ libvorbis \ - lua \ + lua@5.3 \ + meson \ miniupnpc \ pkg-config \ sdl2 \ wxwidgets \ + xinit \ xorg-server \ zstd diff --git a/mk/test-meson-build.sh b/mk/test-meson-build.sh new file mode 100755 index 000000000..840c7d810 --- /dev/null +++ b/mk/test-meson-build.sh @@ -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 diff --git a/source/g3d_viewer/meson.build b/source/g3d_viewer/meson.build new file mode 100644 index 000000000..8ca1323bc --- /dev/null +++ b/source/g3d_viewer/meson.build @@ -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', + # ] +) diff --git a/source/glest_game/meson.build b/source/glest_game/meson.build new file mode 100644 index 000000000..ccd2ae954 --- /dev/null +++ b/source/glest_game/meson.build @@ -0,0 +1,217 @@ +src_game = [ + 'ai/ai.cpp', + 'ai/ai_interface.cpp', + 'ai/ai_rule.cpp', + 'ai/path_finder.cpp', + 'game/achievement.cpp', + 'game/chat_manager.cpp', + 'game/commander.cpp', + 'game/console.cpp', + 'game/game_camera.cpp', + 'game/game.cpp', + 'game/script_manager.cpp', + 'game/stats.cpp', + 'global/config.cpp', + 'global/core_data.cpp', + 'global/lang.cpp', + 'global/metrics.cpp', + 'graphics/particle_type.cpp', + 'graphics/renderer.cpp', + 'graphics/unit_particle_type.cpp', + 'gui/display.cpp', + 'gui/gui.cpp', + 'gui/selection.cpp', + 'main/battle_end.cpp', + 'main/intro.cpp', + 'main/main.cpp', + 'main/program.cpp', + 'menu/main_menu.cpp', + 'menu/menu_background.cpp', + 'menu/menu_state_about.cpp', + 'menu/menu_state_connected_game.cpp', + 'menu/menu_state_custom_game.cpp', + 'menu/menu_state_graphic_info.cpp', + 'menu/menu_state_join_game.cpp', + 'menu/menu_state_keysetup.cpp', + 'menu/menu_state_load_game.cpp', + 'menu/menu_state_masterserver.cpp', + 'menu/menu_state_mods.cpp', + 'menu/menu_state_new_game.cpp', + 'menu/menu_state_options.cpp', + 'menu/menu_state_options_graphics.cpp', + 'menu/menu_state_options_network.cpp', + 'menu/menu_state_options_sound.cpp', + 'menu/menu_state_root.cpp', + 'menu/menu_state_scenario.cpp', + 'menu/server_line.cpp', + 'network/client_interface.cpp', + 'network/connection_slot.cpp', + 'network/network_interface.cpp', + 'network/network_manager.cpp', + 'network/network_message.cpp', + 'network/network_protocol.cpp', + 'network/network_types.cpp', + 'network/server_interface.cpp', + 'sound/sound_container.cpp', + 'sound/sound_renderer.cpp', + 'steam/steam.cpp', + 'steamshim/steamshim_child.c', + 'type_instances/command.cpp', + 'type_instances/faction.cpp', + 'type_instances/object.cpp', + 'type_instances/resource.cpp', + 'type_instances/unit.cpp', + 'type_instances/upgrade.cpp', + 'types/command_type.cpp', + 'types/damage_multiplier.cpp', + 'types/element_type.cpp', + 'types/faction_type.cpp', + 'types/object_type.cpp', + 'types/projectile_type.cpp', + 'types/resource_type.cpp', + 'types/skill_type.cpp', + 'types/tech_tree.cpp', + 'types/tileset_model_type.cpp', + 'types/unit_type.cpp', + 'types/upgrade_type.cpp', + 'world/map.cpp', + 'world/minimap.cpp', + 'world/scenario.cpp', + 'world/surface_atlas.cpp', + 'world/tileset.cpp', + 'world/time_flow.cpp', + 'world/unit_updater.cpp', + 'world/water_effects.cpp', + 'world/world.cpp', + 'facilities/auto_test.cpp', + 'facilities/components.cpp', + 'facilities/game_util.cpp', + 'facilities/logger.cpp', +] + + +inc_game = [ + 'types', + 'ai', + 'menu', + 'steam', + 'facilities', + 'main', + 'steamshim', + 'network', + 'world', + 'global', + 'type_instances', + 'gui', + 'sound', + 'graphics', + 'game', +] + +inc_common = [ + 'platform', + 'platform/posix', + 'platform/common', + 'platform/win32', + 'platform/sdl', + 'util', + 'util/utf8', + 'map', + 'compression', + 'feathery_ftp', + # 'streflop', + # 'streflop/softfloat', + # 'streflop/libm', + # 'streflop/libm/headers', + # 'streflop/libm/flt-32', + 'lua', + 'xml', + 'xml/rapidxml', + 'sound', + 'sound/openal', + 'graphics', + 'graphics/gl', +] + +inc_ircclient = [] +irclient_dep = [] +ircclient_dep = dependency('ircclient', required: false) +if not ircclient_dep.found() + ircclient_dep = cc.find_library( + 'ircclient', + has_headers: 'libircclient.h', + required: false, + ) + if not ircclient_dep.found() + inc_ircclient = ['/usr/include', '/usr/local/include'] + path = '/usr/include/libircclient' + result = run_command('test', '-d', path, check: false) + if result.returncode() == 0 + inc_ircclient += path + endif + ircclient_dep = cc.find_library( + 'ircclient', + dirs: '/usr/local/lib', + has_headers: 'libircclient.h', + header_include_directories: include_directories(inc_ircclient), + ) + endif +endif + +inc_shared_lib = [] +foreach dir : inc_common + inc_shared_lib += [join_paths('..', 'shared_lib', 'include', dir)] +endforeach + +dep_cppunit = dependency('cppunit') +dep_fribidi = dependency('fribidi') +dep_glib = dependency('glib-2.0') +dep_pthread = dependency('threads') +dep_gl = dependency('gl') +dep_openal = dependency('openal') +dep_x11 = dependency('x11') +# dep_ogg = dependency('ogg') +dep_vorbis = dependency('vorbisfile') +dep_glew = dependency('glew') +dep_png = dependency('libpng') +dep_jpeg = dependency('libjpeg') +dep_ftgl = dependency('ftgl') +dep_freetype = dependency('freetype2') + +executable( + 'megaglest', + [src_game, '../shared_lib/sources/platform/posix/ircclient.cpp'], + include_directories: [inc_ircclient, inc_game, inc_shared_lib], + dependencies: [ + dep_libmegaglest, + shared_lib_game_deps, + ircclient_dep, + lua_dep, + dep_sdl, + dep_cppunit, + dep_fribidi, + dep_glib, + dep_pthread, + # dep_gl, + dep_openal, + dep_x11, + # dep_ogg, + dep_vorbis, + dep_glew, + dep_png, + dep_jpeg, + dep_ftgl, + dep_freetype, + ], + cpp_args: ['-DGITVERSION="HELPME"'], + # link_args: ['-lm', + # '-lSM', + # '-lICE', + # '-lGLU', + # '-ldl', + # '-lXext', + # '-Wl,-Bstatic', + # '-lSDL2main', + # '-Wl,-Bdynamic', + # ] +) diff --git a/source/glest_map_editor/meson.build b/source/glest_map_editor/meson.build new file mode 100644 index 000000000..4e3842ab9 --- /dev/null +++ b/source/glest_map_editor/meson.build @@ -0,0 +1,28 @@ +src_map_editor = ['program.cpp', 'main.cpp', '../glest_game/global/config.cpp'] + +inc_common = [ + '../shared_lib/include/map', + '../shared_lib/include/util', + '../shared_lib/include/graphics', + '../shared_lib/include/graphics/gl', + '../shared_lib/include/platform/sdl', + '../shared_lib/include/platform/common', + '../glest_game/global', + '../glest_game/game', + '../glest_game/facilities', +] + +dep_wx = dependency( + 'wxwidgets', + version: '>=3.0.0', + modules: ['gl', 'core', 'base'], +) +dep_glu = dependency('glu') + +executable( + 'megaglest_editor', + src_map_editor, + include_directories: inc_common, + dependencies: [dep_libmegaglest, dep_wx, dep_sdl, dep_gl, dep_glu], + cpp_args: ['-DNDEBUG'], +) diff --git a/source/meson.build b/source/meson.build new file mode 100644 index 000000000..3ea665348 --- /dev/null +++ b/source/meson.build @@ -0,0 +1,13 @@ +shared_lib_game_deps = [] + +shared_lib_game_common = ['libcurl'] + +foreach dep : shared_lib_game_common + shared_lib_game_deps += dependency(dep) +endforeach + +subdir('shared_lib') +subdir('glest_game') +subdir('glest_map_editor') +subdir('g3d_viewer') +subdir('tools/glexemel') diff --git a/source/shared_lib/include/platform/common/math_wrapper.h b/source/shared_lib/include/platform/common/math_wrapper.h index e90550b83..d2bade288 100644 --- a/source/shared_lib/include/platform/common/math_wrapper.h +++ b/source/shared_lib/include/platform/common/math_wrapper.h @@ -14,7 +14,7 @@ #ifdef USE_STREFLOP -#include +// #include #include #else diff --git a/source/shared_lib/include/platform/common/streflop_cond.h b/source/shared_lib/include/platform/common/streflop_cond.h index 1ec17a788..3c7a1f473 100644 --- a/source/shared_lib/include/platform/common/streflop_cond.h +++ b/source/shared_lib/include/platform/common/streflop_cond.h @@ -14,8 +14,8 @@ When faced with ambiguous call errors with e.g. fabs, use math::function. Add it to math namespace if it doesn't exist there yet. */ -#ifndef STREFLOP_COND_H -#define STREFLOP_COND_H +#ifndef _STREFLOP_COND_H +#define _STREFLOP_COND_H #if defined(STREFLOP_X87) || defined(STREFLOP_SSE) || defined(STREFLOP_SOFT) #include diff --git a/source/shared_lib/meson.build b/source/shared_lib/meson.build new file mode 100644 index 000000000..e449bc236 --- /dev/null +++ b/source/shared_lib/meson.build @@ -0,0 +1,219 @@ +# subdir('sources/util') +subdir('sources/feathery_ftp') + +src = [] + +src_basename = [ + 'string_utils.cpp', + 'util.cpp', + 'properties.cpp', + 'profiler.cpp', + 'leak_dumper.cpp', + 'checksum.cpp', + 'conversion.cpp', + 'randomgen.cpp', +] + +foreach file : src_basename + src += [join_paths('sources/util', file)] +endforeach + +src_basename = [ + 'base_thread.cpp', + 'byte_order.cpp', + 'cache_manager.cpp', + 'platform_common.cpp', + 'simple_threads.cpp', +] + +foreach file : src_basename + src += [join_paths('sources/platform/common', file)] +endforeach + +src_basename = ['miniftpclient.cpp', 'miniftpserver.cpp', 'socket.cpp'] + +foreach file : src_basename + src += [join_paths('sources/platform/posix', file)] +endforeach + +src_basename = [ + 'factory_repository.cpp', + 'gl_wrap.cpp', + 'platform_util.cpp', + 'thread.cpp', + 'window.cpp', + 'window_gl.cpp', +] + +foreach file : src_basename + src += [join_paths('sources/platform/sdl', file)] +endforeach + +src_basename = [ + 'BMPReader.cpp', + 'graphics_interface.cpp', + 'quaternion.cpp', + 'buffer.cpp', + 'ImageReaders.cpp', + 'shader.cpp', + 'camera.cpp', + 'interpolation.cpp', + 'shader_manager.cpp', + 'context.cpp', + 'JPGReader.cpp', + 'texture.cpp', + 'FileReader.cpp', + 'model.cpp', + 'texture_manager.cpp', + 'font.cpp', + 'model_manager.cpp', + 'TGAReader.cpp', + 'font_manager.cpp', + 'particle.cpp', + 'video_player.cpp', + 'font_text.cpp', + 'pixmap.cpp', + 'PNGReader.cpp', +] + +foreach file : src_basename + src += [join_paths('sources/graphics', file)] +endforeach + +src_basename = [ + 'base_renderer.cpp', + 'opengl.cpp', + 'context_gl.cpp', + 'particle_renderer_gl.cpp', + 'font_gl.cpp', + 'shader_gl.cpp', + 'font_textFTGL.cpp', + 'text_renderer_gl.cpp', + 'model_gl.cpp', + 'texture_gl.cpp', + 'model_renderer_gl.cpp', +] + +foreach file : src_basename + src += [join_paths('sources/graphics/gl', file)] +endforeach + +src_basename = [ + 'sound_file_loader.cpp', + 'sound_player.cpp', + 'sound.cpp', + 'sound_interface.cpp', +] + +foreach file : src_basename + src += [join_paths('sources/sound', file)] +endforeach + +src_shared_lib_misc = [ + 'sound/openal/sound_player_openal.cpp', + 'platform/unix/gl_wrap.cpp', + 'compression/compression_utils.cpp', + 'lua/lua_script.cpp', + 'miniz/miniz.c', + 'map/map_preview.cpp', + 'xml/xml_parser.cpp', +] + +foreach file : src_shared_lib_misc + src += [join_paths('sources', file)] +endforeach + +dep_sdl = dependency('sdl2') +dep_openal = dependency('openal') +dep_ftgl = dependency('ftgl') + +# This will get changed to 5.3 +lua_dep = dependency('lua-5.3', required: true) +if not lua_dep.found() + lua_dep = cc.find_library('lua', has_headers: 'lua.h', required: true) + # if not lua_dep.found() + # # This will use the fallback + # lua_dep = dependency( + # 'lua-5.3', + # required: true, + # fallback: 'lua', + # default_options: ['default_library=static'] + # ) + # endif +endif + +# By default, meson will look in the repo roots 'subproject' directory # Note +# changing a default options might not be enough to trigger meson to rerun +# setup. In the build directory, you can change the option manually +# Example: meson configure -Dstreflop:fpu=soft (where the value preceding the +# colon is the subproject name) and then rebuild. +streflop_subproj = subproject( + 'streflop', + default_options: ['default_library=static', 'fpu=sse', 'no_denormals=true'], +) +# TODO: The binaries don't need the dep object, but they do need the includes. +# Get them from the dep object instead of hard-coding them in the three +# binary meson builds. +streflop_dep = streflop_subproj.get_variable('streflop_dep') +streflop_includes = streflop_dep.partial_dependency(includes: true) + +inc_miniupnpc = ['include/platform/miniupnpc'] +dep_miniupnpc = [] +dep_miniupnpc = dependency('miniupnpc') +if not dep_miniupnpc.found() # TODO: review/test for if the library isn't installed. + dep_miniupnpc = cxx.find_library('miniupnpc', required: false) + inc_miniupnpc += '/usr/include/miniupnpc' +endif +# if miniupnpc isn't installed, add these flags. Check existing cmake in +# shared_lib to see about other platforms +#c_args: ['-DMINIUPNPC_SET_SOCKET_TIMEOUT', '-D_BSD_SOURCE'], +# cpp_args: ['-DMINIUPNPC_SET_SOCKET_TIMEOUT', '-D_BSD_SOURCE'], + +inc_shared_lib_misc_basename = [ + 'graphics', + 'map', + 'xml', + 'sound', + 'sound/openal', + 'platform/common', + 'platform/posix', + 'platform/sdl', + 'graphics', + 'graphics/gl', + 'util/', + 'util/utf8', + 'compression', + 'lua', +] + +inc_shared_lib_misc = [] + +foreach file : inc_shared_lib_misc_basename + inc_shared_lib_misc += [join_paths('include', file)] +endforeach + +lib_megaglest = static_library( + 'megaglest', + src, + include_directories: [ + inc_shared_lib_misc, + 'sources', # for miniz + inc_miniupnpc, + ], + dependencies: [ + streflop_dep, + shared_lib_game_deps, + lua_dep, + dep_sdl, + dep_openal, + dep_feathery_ftp, + dep_miniupnpc, + dep_ftgl, + ], + pic: true, +) + +dep_libmegaglest = declare_dependency( + link_with: lib_megaglest, + dependencies: streflop_includes, +) diff --git a/source/shared_lib/sources/feathery_ftp/meson.build b/source/shared_lib/sources/feathery_ftp/meson.build new file mode 100644 index 000000000..119eb5dea --- /dev/null +++ b/source/shared_lib/sources/feathery_ftp/meson.build @@ -0,0 +1,31 @@ +src_feathery_ftp = [ + 'ftpTargetWin32.c', + 'ftpServer.c', + 'ftpTargetPosix.c', + 'ftpLib.c', + 'ftpRuntime.c', + 'ftpCmds.c', + 'ftpSession.c', + 'ftpAccount.c', + 'ftpMessages.c', +] + +inc_feathery_ftp = ['../../include/feathery_ftp/'] + +lib_featheryftp = static_library( + 'feathery_ftp', + src_feathery_ftp, + include_directories: inc_feathery_ftp, + # dependencies: [ + # dep_curl, + # dep_sdl, dep_x11, dep_openal, dep_lua, + # dep_cppunit, + # dep_fribidi, + # dep_glib + # ] +) + +dep_feathery_ftp = declare_dependency( + link_with: lib_featheryftp, + include_directories: inc_feathery_ftp, +) diff --git a/source/tools/glexemel/meson.build b/source/tools/glexemel/meson.build new file mode 100644 index 000000000..d5ccf4754 --- /dev/null +++ b/source/tools/glexemel/meson.build @@ -0,0 +1,3 @@ +executable('g2xml', 'g2xml.c') + +executable('xml2g', 'xml2g.c', dependencies: dependency('libxml-2.0')) diff --git a/subprojects/lua.wrap b/subprojects/lua.wrap new file mode 100644 index 000000000..8d13d5656 --- /dev/null +++ b/subprojects/lua.wrap @@ -0,0 +1,11 @@ +[wrap-file] +directory = lua-5.1.5 +source_url = https://www.lua.org/ftp/lua-5.1.5.tar.gz +source_filename = lua-5.1.5.tar.gz +source_hash = 2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333 +patch_directory = lua +method = meson + +[provide] +lua-5.1 = lua_dep + diff --git a/subprojects/packagefiles/lua/meson.build b/subprojects/packagefiles/lua/meson.build new file mode 100644 index 000000000..2e2d58443 --- /dev/null +++ b/subprojects/packagefiles/lua/meson.build @@ -0,0 +1,131 @@ +project( + 'lua-5.1', 'c', + license: 'MIT', + meson_version: '>=0.49.2', + version: '5.1.5', +) + +lua_versions = meson.project_version().split('.') +# Override the c_std and warning_level of any superproject. +project_options = ['c_std=c99', 'warning_level=2'] +cc = meson.get_compiler('c') + +# Skip bogus warning. +if cc.get_id() == 'clang' + add_project_arguments('-Wno-string-plus-int', language: 'c') +elif cc.get_id() == 'gcc' + add_project_arguments('-Wno-stringop-overflow', language: 'c') +endif + +add_project_arguments('-D_XOPEN_SOURCE=600', language: 'c') + +# Platform-specific defines. +is_posix = host_machine.system() not in ['windows', 'emscripten', 'android'] +if is_posix + add_project_arguments('-DLUA_USE_POSIX', language: 'c') +endif + +# Library dependencies. +lua_lib_deps = [cc.find_library('m', required: false)] + +if get_option('loadlib') + dl_dep = cc.find_library('dl', required: false) + lua_lib_deps += [dl_dep] + add_project_arguments('-DLUA_USE_DLOPEN', language: 'c') +endif + +# Interpreter dependencies. +lua_exe_deps = [] +lua_exe_args = [] + +if get_option('line_editing') + readline_dep = dependency('readline', required: false) + if not readline_dep.found() + readline_dep = dependency('libedit', required: false) + if not readline_dep.found() + error('''Didn't find readline or libedit, can't enable line editing.''') + endif + endif + lua_exe_deps += [readline_dep] + lua_exe_args += ['-DLUA_USE_READLINE'] +endif + +# Targets. +lua_static = static_library('_lua', + 'src/print.c', + 'src/lstring.c', + 'src/ltablib.c', + 'src/loadlib.c', + 'src/lmathlib.c', + 'src/lstate.c', + 'src/ldump.c', + 'src/loslib.c', + 'src/liolib.c', + 'src/ldblib.c', + 'src/lbaselib.c', + 'src/lapi.c', + 'src/llex.c', + 'src/lopcodes.c', + 'src/lvm.c', + 'src/ltable.c', + 'src/linit.c', + 'src/lobject.c', + 'src/lstrlib.c', + 'src/lcode.c', + 'src/ldebug.c', + 'src/lauxlib.c', + 'src/ldo.c', + 'src/lfunc.c', + 'src/lzio.c', + 'src/ltm.c', + 'src/lgc.c', + 'src/lmem.c', + 'src/lparser.c', + 'src/lundump.c', + + dependencies: lua_lib_deps, + override_options: project_options, + implicit_include_directories: false, +) + +lua_lib = library('lua', + link_whole: lua_static, + dependencies: lua_lib_deps, + version: meson.project_version(), + soversion: lua_versions[0] + '.' + lua_versions[1], + override_options: project_options, + implicit_include_directories: false, +) + +if cc.get_id() == 'msvc' + # Lua does not export symbols + # so we have to compile executables + # statically + lua_link = lua_static +else + lua_link = lua_lib +endif + +if get_option('interpreter') + lua_exe = executable('lua', + 'src/lua.c', + c_args: lua_exe_args, + link_with: lua_link, + dependencies: lua_exe_deps, + export_dynamic: get_option('loadlib'), + override_options: project_options, + implicit_include_directories: false, + ) + + if get_option('default_library') == 'static' + luac_exe = executable('luac', + 'src/luac.c', + link_with: lua_link, + override_options: project_options, + implicit_include_directories: false, + ) + endif +endif + +inc = include_directories('src') +lua_dep = declare_dependency(link_with: lua_lib, include_directories: inc) diff --git a/subprojects/packagefiles/lua/meson_options.txt b/subprojects/packagefiles/lua/meson_options.txt new file mode 100644 index 000000000..8c549e45b --- /dev/null +++ b/subprojects/packagefiles/lua/meson_options.txt @@ -0,0 +1,12 @@ +option( + 'loadlib', type: 'boolean', value: false, + description: 'Allow Lua to "require" C extension modules' +) +option( + 'line_editing', type: 'boolean', value: false, + description: 'Link with GNU readline (or libedit) to add history to the Lua interpreter.' +) +option( + 'interpreter', type: 'boolean', value: true, + description: 'Build the Lua interpreter.' +) diff --git a/subprojects/streflop.wrap b/subprojects/streflop.wrap new file mode 100644 index 000000000..d3e6ef0f2 --- /dev/null +++ b/subprojects/streflop.wrap @@ -0,0 +1,13 @@ +[wrap-git] +directory = streflop-0.3 +url = https://github.com/andy5995/streflop +revision = add-meson +#source_url = https://nicolas.brodu.net/common/programmation/streflop/streflop-0.3.tar.bz2 +#source_filename = streflop-0.3.tar.bz2 +#source_hash = 53642f71be5df5d8d2b766a77cd48d537e02fb366f09f902473818e9f8cd3817 +#patch_directory = streflop-ng +#method = meson + +[provide] +streflop = streflop_dep +