build: meson: linux: Initial support

(cherry picked from commit 5a9e78a3be)

Note: Support for building on windows or mac was (probably) broken while cherry-picking

Signed-off-by: Thibault Lemaire <thibault.lemaire@protonmail.com>
This commit is contained in:
Simon Allen 2022-02-01 02:50:21 +11:00 committed by Thibault Lemaire
parent 2edc097665
commit 2fe7d53d69
32 changed files with 831 additions and 45 deletions

2
.gitignore vendored
View File

@ -44,6 +44,8 @@ cscope.out
.direnv/
*.DS_Store
build
# Required by clangd to properly discover headers
compile_commands.json
# Clangd's cache

View File

@ -0,0 +1,23 @@
#!/usr/bin/env python
import sys
import os
from subprocess import call, DEVNULL
in_dir = os.path.dirname(__file__)
biggie_inputs = []
for root, dirs, files in os.walk(in_dir):
for file in files:
if file in ("README.txt", "meson.build", os.path.basename(__file__)):
continue
path = os.path.abspath(os.path.join(root, file))
path = os.path.relpath(path, in_dir)
if "/." in path:
continue
biggie_inputs.append(path)
exit(call((sys.argv[1], "-f", os.path.abspath(sys.argv[2]), *biggie_inputs), cwd = in_dir, stdout = DEVNULL))

View File

@ -0,0 +1,2 @@
python = find_program('python', required: true)
script_assets_homeworldsdl_big_generate = files('generate_file_list.py')

View File

@ -7,8 +7,7 @@
If you have [Nix] installed, there is a [`flake.nix`](flake.nix) file listing the build depencies so you can just run the build in a `nix develop` environment without installing anything:
``` sh
cd Linux
nix develop
nix develop ./Linux
```
You can then go on with the [Quick Start](#quick-start) in that virtual environment.
@ -19,7 +18,21 @@ You can then go on with the [Quick Start](#quick-start) in that virtual environm
> More information can be found in the documentation files next to this one.
### x86_64 (intel/amd 64-bit)
### Meson
``` sh
meson setup build
cd build
meson compile
```
> You are free to replace `build` above with anything you like. It will be the name of the build directory
You can now [run the compiled executable for the first time](../README#running-the-game-for-the-first-time).
### Autotools (Deprecated)
#### x86_64 (intel/amd 64-bit)
``` sh
cd Linux
@ -34,10 +47,7 @@ make -j4
> The configuration step has a lot of flags, run `../configure --help` to see them. (Notably the `--disable-linux-fixme` flag)
You can now [run the compiled executable for the first time](../README#running-the-game-for-the-first-time).
### x86 (intel/amd 32-bit)
#### x86 (intel/amd 32-bit)
This is if you want to cross-compile the game to 32bit even if your machine is 64bit.
@ -67,19 +77,30 @@ cd ../../HomeworldSDL_big
You should now have a `HomeworldSDL.big` file in the root of the repo.
### Hacking
## Hacking
So you want to dive into the code and start hacking, huh?
Here are a few pointers to help you with that:
#### Clangd
### Clangd
[Clangd] is a _language server_ that can work with many editors (including [VSCode]) via a plugin.
It adds smart features to your editor: code completion, compile errors, go-to-definition and more.
To give proper hints, though, it needs to know the compile flags used (otherwise you'll get "header not found" errors).
To give proper hints, though, clangd needs to know the compile flags used (otherwise you'll get "header not found" errors).
To that end, it uses a `compile_commands.json` file describing how each file was compiled.
You can use [bear] to auto-generate it.
[Clangd]: https://clangd.llvm.org
[VSCode]: https://vscodium.com/
### With Meson
Meson automatically generates `compile_commands.json`, so if you named your build dir `build` as clangd expects, then you have nothing to do.
Enjoy your modern development environment!
#### With Autotools (Deprecated)
You can use [bear] to auto-generate `compile_commands.json`.
In the build steps outlined above, replace the `make` step with:
```sh
@ -95,17 +116,15 @@ Then link or copy the result to the root of the repo, so that clangd finds it au
ln -srv compile_commands.json ..
```
That's it! Enjoy your modern development environment!
[Clangd]: https://clangd.llvm.org
[VSCode]: https://vscodium.com/
[bear]: https://github.com/rizsotto/Bear
#### Sanitizers
### Sanitizers
[LLVM's Sanitizers] are a powerful suite of tools for memory debugging.
They can detect and help debug many kinds of invalid or dangerous memory handling patterns (like buffer overflows, use after free, or leaks).
#### With Autotools
You can build a debug version of the game that includes those sanitizers with
```sh

View File

@ -19,7 +19,10 @@
mkShell {
buildInputs = self.packages.x86_64-linux.default.buildInputs ++ [
clang-tools_16 # clangd, clang-format
bear # build `compile_commands.json` for clangd
meson
pkg-config
python3
ninja
gdb
nixpkgs-fmt
];

View File

@ -259,7 +259,7 @@ dnl HW_BUILD_FOR_DEBUGGING is set via "--enable-hwdebug";
dnl HW_BUILD_FOR_DISTRIBUTION is the default.
dnl - $SDL_CFLAGS and $SDL_LIBS should be pretty much self-explanatory. =]
dnl - We don't want to include $SDL_LIBS when building librgl.
CFLAGS="$CFLAGS $SDL_LIBS $HWGAME_CFLAGS $HWBIN_CFLAGS $SDL_CFLAGS $WIN32_FIXME"
CFLAGS="$CFLAGS $SDL_LIBS $HWGAME_CFLAGS $HWBIN_CFLAGS $SDL_CFLAGS $WIN32_FIXME -I../Missions/Generated"
LDFLAGS="$SDL_LIBS $LDFLAGS"
AC_CONFIG_HEADERS([config.h])

View File

@ -134,10 +134,10 @@ Go into the 'Mac' directory, and use the xcode project. Please note, you will n
The first time you run the game, you will have to point it to [the directory containing the required assets](#setting-up-the-assets-folder). For example, if you have [compiled the game from source](#compiling-from-source):
```sh
HW_Data=$ASSETS_FOLDER src/homeworld
HW_Data=$ASSETS_FOLDER ./homeworld
```
where `src/homeworld` is the path to your HomeworldSDL binary executable.
where `./homeworld` is the path to your HomeworldSDL binary executable.
Once the game starts, you should then [configure the OpenGL renderer](#configuring-the-opengl-renderer).

77
meson.build Normal file
View File

@ -0,0 +1,77 @@
project('homeworld',
'c',
version: '0.1',
default_options: ['warning_level=3', 'c_std=c17'])
dep_x11 = dependency('x11')
dep_gl = dependency('gl')
dep_sdl = dependency('sdl2')
dep_math = meson.get_compiler('c').find_library('m', required: false)
c_base_args = ['-DHW_GAME_HOMEWORLD']
c_base_args += ['-DHAVE_CONFIG_H', '-D_REENTRANT']
#c_base_args += '-Wno-unused-variable'
#c_base_args += '-Wno-unused-parameter'
c_base_args += '-w'
if build_machine.cpu_family() == 'x86_64'
c_base_args += ['-D_X86_64', '-D_X86_64_FIX_ME', '-DGENERIC_ETGCALLFUNCTION']
elif build_machine.cpu_family() == 'x86'
c_base_args += ['-malign-double', '-D_X86', '-msse']
elif build_machine.cpu_family() in ['arm', 'aarch64']
c_base_args += ['-DARM', '-DGENERIC_ETGCALLFUNCTION']
endif
if build_machine.system() == 'linux'
c_base_args += ['-D_LINUX_FIX_ME', '-D_GNU_SOURCE']
elif build_machine.system() == 'darwin'
c_base_args += ['-D__APPLE___FIX_ANIM', '-D__APPLE___FIX_LAN', '-D__APPLE___FIX_MISC', '-DGENERIC_ETGCALLFUNCTION']
if build_machine.cpu_family() == 'x86_64'
c_base_args += ['-D__APPLE___64', '-D__APPLE___FIX_64']
elif build_machine.cpu_family() == 'x86'
c_base_args += ['-D__APPLE___86', '-D__APPLE___FIX_86']
endif
elif build_machine.system() == 'windows'
endif
if get_option('debug')
c_args = c_base_args + '-DHW_BUILD_FOR_DEBUGGING'
else
c_args = c_base_args + '-DHW_BUILD_FOR_DISTRIBUTION'
if build_machine.cpu_family() == 'x86_64'
c_args += '-DGENERIC_ETGCALLFUNCTION'
endif
endif
subdir('tools')
subdir('src')
subdir('tools/biggie')
subdir('tools/monochrome-btg')
if build_machine.cpu_family() == 'x86_64'
subdir('tools/x86_64')
endif
subdir('HomeworldSDL_big')
alias_target('tools', exe_tools)
python = find_program('python', required: true)
asset_homeworldsdl_big = custom_target('HomeworldSDL.big',
output: 'HomeworldSDL.big',
command: [python, script_assets_homeworldsdl_big_generate, exe_tools_biggie, '@OUTPUT@'],
depends: [exe_tools_biggie])
alias_target('assets', asset_homeworldsdl_big)
executable(meson.project_name(),
src,
include_directories: inc_src,
link_with: [lib_jpg, lib_sdl],
dependencies: [dep_x11, dep_gl, dep_sdl, dep_math],
c_args: c_args,
install: true)

View File

@ -58,24 +58,24 @@
#include "UnivUpdate.h"
#include "utility.h"
#include "../Missions/Generated/Mission01.h"
#include "../Missions/Generated/Mission02.h"
#include "../Missions/Generated/Mission03.h"
#include "../Missions/Generated/Mission04.h"
#include "../Missions/Generated/Mission05.h"
#include "../Missions/Generated/Mission05_OEM.h"
#include "../Missions/Generated/Mission06.h"
#include "../Missions/Generated/Mission07.h"
#include "../Missions/Generated/Mission08.h"
#include "../Missions/Generated/Mission09.h"
#include "../Missions/Generated/Mission10.h"
#include "../Missions/Generated/Mission11.h"
#include "../Missions/Generated/Mission12.h"
#include "../Missions/Generated/Mission13.h"
#include "../Missions/Generated/Mission14.h"
#include "../Missions/Generated/Mission15.h"
#include "../Missions/Generated/Mission16.h"
#include "../Missions/Generated/Tutorial1.h"
#include "Mission01.h"
#include "Mission02.h"
#include "Mission03.h"
#include "Mission04.h"
#include "Mission05.h"
#include "Mission05_OEM.h"
#include "Mission06.h"
#include "Mission07.h"
#include "Mission08.h"
#include "Mission09.h"
#include "Mission10.h"
#include "Mission11.h"
#include "Mission12.h"
#include "Mission13.h"
#include "Mission14.h"
#include "Mission15.h"
#include "Mission16.h"
#include "Tutorial1.h"
#ifdef _MSC_VER
#define strcasecmp _stricmp
@ -2082,7 +2082,7 @@ void spHyperspaceButtonPushed(void)
if (resourcesLeft > 0) {
char *resources_collected_strings[] = {
"Resources collected",
"Ressources collectées",
"Ressources collect<EFBFBD>es",
"Ressourcen gesammelt",
"Los recursos recaudados",
"Le risorse raccolte",

View File

@ -3,7 +3,7 @@
*/
#include "Tutor.h"
#include "../Missions/Generated/Tutorial1.h" // why does this need a relative path?
#include "Tutorial1.h"
#include <math.h>

145
src/Game/meson.build Normal file
View File

@ -0,0 +1,145 @@
src_game = files('AIAttackMan.c',
'AIDefenseMan.c',
'AIEvents.c',
'AIFleetMan.c',
'AIHandler.c',
'AIMoves.c',
'AIOrders.c',
'AIPlayer.c',
'AIResourceMan.c',
'AIShip.c',
'AITeam.c',
'AITrack.c',
'AIUtilities.c',
'AIVar.c',
'Alliance.c',
'Animatic.c',
'Attack.c',
'AutoDownloadMap.c',
'AutoLOD.c',
'Battle.c',
'BigFile.c',
'Blobs.c',
'BMP.c',
'Bounties.c',
'B-Spline.c',
'BTG.c',
'Camera.c',
'CameraCommand.c',
'Captaincy.c',
'ChannelFSM.c',
'Chatting.c',
'Clamp.c',
'Clipper.c',
'Clouds.c',
'Collision.c',
'Color.c',
'ColPick.c',
'CommandLayer.c',
'CommandNetwork.c',
'CommandWrap.c',
'ConsMgr.c',
'Crates.c',
'Damage.c',
'Debug.c',
'Demo.c',
'Dock.c',
'ETG.c',
'Eval.c',
'FEFlow.c',
'FEReg.c',
'File.c',
'FlightMan.c',
'FontReg.c',
'Formation.c',
'GameChat.c',
'GamePick.c',
'Globals.c',
'Gun.c',
'Hash.c',
'HorseRace.c',
'HS.c',
'InfoOverlay.c',
'KAS.c',
'KASFunc.c',
'KNITransform.c',
'KeyBindings.c',
'Key.c',
'LagPrint.c',
'LaunchMgr.c',
'LevelLoad.c',
'Light.c',
'LinkedList.c',
'LOD.c',
'MadLinkIn.c',
'Matrix.c',
'Memory.c',
'MeshAnim.c',
'Mesh.c',
'MEX.c',
'MultiplayerGame.c',
'MultiplayerLANGame.c',
'NavLights.c',
'Nebulae.c',
'NetCheck.c',
'NIS.c',
'Objectives.c',
'ObjTypes.c',
'Options.c',
'Particle.c',
'Physics.c',
'PiePlate.c',
'Ping.c',
'PlugScreen.c',
'ProfileTimers.c',
'Randy.c',
'Region.c',
'ResCollect.c',
'ResearchAPI.c',
'ResearchGUI.c',
'SaveGame.c',
'ScenPick.c',
'Scroller.c',
'Select.c',
'Sensors.c',
'Shader.c',
'ShipSelect.c',
'ShipView.c',
'SinglePlayer.c',
'SoundEvent.c',
'SoundEventPlay.c',
'SoundEventStop.c',
'SpeechEvent.c',
'Star3d.c',
'Stats.c',
'StatScript.c',
'StringSupport.c',
'Subtitle.c',
'Tactical.c',
'Tactics.c',
'TaskBar.c',
'Task.c',
'Teams.c',
'Timer.c',
'TitanNet.c',
'Tracking.c',
'TradeMgr.c',
'Trails.c',
'Transformer.c',
'Tutor.c',
'Tweak.c',
'Twiddle.c',
'Types.c',
'UIControls.c',
'Undo.c',
'Universe.c',
'UnivUpdate.c',
'Vector.c',
'Volume.c')
src_game += custom_target('wrapped_functions.h',
input: ['functions.h', 'wrap.h', 'wrap_types.h'],
output: 'wrapped_functions.h',
command: [meson.get_compiler('c').cmd_array(), '-E', '-o', '@OUTPUT@', '@INPUT0@'])
inc_src_game = include_directories('.')

View File

@ -0,0 +1,190 @@
mission_01_pp = custom_target('Mission01.kp',
input: 'Mission01.kas',
output: 'Mission01.kp',
capture: true,
command: [meson.get_compiler('c').cmd_array(), '-E', '-x', 'c', '@INPUT@'])
mission_02_pp = custom_target('Mission02.kp',
input: 'Mission02.kas',
output: 'Mission02.kp',
capture: true,
command: [meson.get_compiler('c').cmd_array(), '-E', '-x', 'c', '@INPUT@'])
mission_03_pp = custom_target('Mission03.kp',
input: 'Mission03.kas',
output: 'Mission03.kp',
capture: true,
command: [meson.get_compiler('c').cmd_array(), '-E', '-x', 'c', '@INPUT@'])
mission_04_pp = custom_target('Mission04.kp',
input: 'Mission04.kas',
output: 'Mission04.kp',
capture: true,
command: [meson.get_compiler('c').cmd_array(), '-E', '-x', 'c', '@INPUT@'])
mission_05_pp = custom_target('Mission05.kp',
input: 'Mission05.kas',
output: 'Mission05.kp',
capture: true,
command: [meson.get_compiler('c').cmd_array(), '-E', '-x', 'c', '@INPUT@'])
mission_05_OEM_pp = custom_target('Mission05_OEM.kp',
input: 'Mission05_OEM.kas',
output: 'Mission05_OEM.kp',
capture: true,
command: [meson.get_compiler('c').cmd_array(), '-E', '-x', 'c', '@INPUT@'])
mission_06_pp = custom_target('Mission06.kp',
input: 'Mission06.kas',
output: 'Mission06.kp',
capture: true,
command: [meson.get_compiler('c').cmd_array(), '-E', '-x', 'c', '@INPUT@'])
mission_07_pp = custom_target('Mission07.kp',
input: 'Mission07.kas',
output: 'Mission07.kp',
capture: true,
command: [meson.get_compiler('c').cmd_array(), '-E', '-x', 'c', '@INPUT@'])
mission_08_pp = custom_target('Mission08.kp',
input: 'Mission08.kas',
output: 'Mission08.kp',
capture: true,
command: [meson.get_compiler('c').cmd_array(), '-E', '-x', 'c', '@INPUT@'])
mission_09_pp = custom_target('Mission09.kp',
input: 'Mission09.kas',
output: 'Mission09.kp',
capture: true,
command: [meson.get_compiler('c').cmd_array(), '-E', '-x', 'c', '@INPUT@'])
mission_10_pp = custom_target('Mission10.kp',
input: 'Mission10.kas',
output: 'Mission10.kp',
capture: true,
command: [meson.get_compiler('c').cmd_array(), '-E', '-x', 'c', '@INPUT@'])
mission_11_pp = custom_target('Mission11.kp',
input: 'Mission11.kas',
output: 'Mission11.kp',
capture: true,
command: [meson.get_compiler('c').cmd_array(), '-E', '-x', 'c', '@INPUT@'])
mission_12_pp = custom_target('Mission12.kp',
input: 'Mission12.kas',
output: 'Mission12.kp',
capture: true,
command: [meson.get_compiler('c').cmd_array(), '-E', '-x', 'c', '@INPUT@'])
mission_13_pp = custom_target('Mission13.kp',
input: 'Mission13.kas',
output: 'Mission13.kp',
capture: true,
command: [meson.get_compiler('c').cmd_array(), '-E', '-x', 'c', '@INPUT@'])
mission_14_pp = custom_target('Mission14.kp',
input: 'Mission14.kas',
output: 'Mission14.kp',
capture: true,
command: [meson.get_compiler('c').cmd_array(), '-E', '-x', 'c', '@INPUT@'])
mission_15_pp = custom_target('Mission15.kp',
input: 'Mission15.kas',
output: 'Mission15.kp',
capture: true,
command: [meson.get_compiler('c').cmd_array(), '-E', '-x', 'c', '@INPUT@'])
mission_16_pp = custom_target('Mission16.kp',
input: 'Mission16.kas',
output: 'Mission16.kp',
capture: true,
command: [meson.get_compiler('c').cmd_array(), '-E', '-x', 'c', '@INPUT@'])
src_missions_single_player = []
src_missions_single_player += generator(exe_tools_kas2c,
depends: exe_tools_kas2c,
output: ['@BASENAME@.c', '@BASENAME@.h', '@BASENAME@.func.c'],
arguments: ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@']).process(mission_01_pp)
src_missions_single_player += generator(exe_tools_kas2c,
depends: exe_tools_kas2c,
output: ['@BASENAME@.c', '@BASENAME@.h', '@BASENAME@.func.c'],
arguments: ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@']).process(mission_02_pp)
src_missions_single_player += generator(exe_tools_kas2c,
depends: exe_tools_kas2c,
output: ['@BASENAME@.c', '@BASENAME@.h', '@BASENAME@.func.c'],
arguments: ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@']).process(mission_03_pp)
src_missions_single_player += generator(exe_tools_kas2c,
depends: exe_tools_kas2c,
output: ['@BASENAME@.c', '@BASENAME@.h', '@BASENAME@.func.c'],
arguments: ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@']).process(mission_04_pp)
src_missions_single_player += generator(exe_tools_kas2c,
depends: exe_tools_kas2c,
output: ['@BASENAME@.c', '@BASENAME@.h', '@BASENAME@.func.c'],
arguments: ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@']).process(mission_05_pp)
src_missions_single_player += generator(exe_tools_kas2c,
depends: exe_tools_kas2c,
output: ['@BASENAME@.c', '@BASENAME@.h', '@BASENAME@.func.c'],
arguments: ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@']).process(mission_05_OEM_pp)
src_missions_single_player += generator(exe_tools_kas2c,
depends: exe_tools_kas2c,
output: ['@BASENAME@.c', '@BASENAME@.h', '@BASENAME@.func.c'],
arguments: ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@']).process(mission_06_pp)
src_missions_single_player += generator(exe_tools_kas2c,
depends: exe_tools_kas2c,
output: ['@BASENAME@.c', '@BASENAME@.h', '@BASENAME@.func.c'],
arguments: ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@']).process(mission_07_pp)
src_missions_single_player += generator(exe_tools_kas2c,
depends: exe_tools_kas2c,
output: ['@BASENAME@.c', '@BASENAME@.h', '@BASENAME@.func.c'],
arguments: ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@']).process(mission_08_pp)
src_missions_single_player += generator(exe_tools_kas2c,
depends: exe_tools_kas2c,
output: ['@BASENAME@.c', '@BASENAME@.h', '@BASENAME@.func.c'],
arguments: ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@']).process(mission_09_pp)
src_missions_single_player += generator(exe_tools_kas2c,
depends: exe_tools_kas2c,
output: ['@BASENAME@.c', '@BASENAME@.h', '@BASENAME@.func.c'],
arguments: ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@']).process(mission_10_pp)
src_missions_single_player += generator(exe_tools_kas2c,
depends: exe_tools_kas2c,
output: ['@BASENAME@.c', '@BASENAME@.h', '@BASENAME@.func.c'],
arguments: ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@']).process(mission_11_pp)
src_missions_single_player += generator(exe_tools_kas2c,
depends: exe_tools_kas2c,
output: ['@BASENAME@.c', '@BASENAME@.h', '@BASENAME@.func.c'],
arguments: ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@']).process(mission_12_pp)
src_missions_single_player += generator(exe_tools_kas2c,
depends: exe_tools_kas2c,
output: ['@BASENAME@.c', '@BASENAME@.h', '@BASENAME@.func.c'],
arguments: ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@']).process(mission_13_pp)
src_missions_single_player += generator(exe_tools_kas2c,
depends: exe_tools_kas2c,
output: ['@BASENAME@.c', '@BASENAME@.h', '@BASENAME@.func.c'],
arguments: ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@']).process(mission_14_pp)
src_missions_single_player += generator(exe_tools_kas2c,
depends: exe_tools_kas2c,
output: ['@BASENAME@.c', '@BASENAME@.h', '@BASENAME@.func.c'],
arguments: ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@']).process(mission_15_pp)
src_missions_single_player += generator(exe_tools_kas2c,
depends: exe_tools_kas2c,
output: ['@BASENAME@.c', '@BASENAME@.h', '@BASENAME@.func.c'],
arguments: ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@']).process(mission_16_pp)
inc_src_missions_single_player = include_directories('.')

View File

@ -0,0 +1,14 @@
tutorial_01_pp = custom_target('Tutorial1.kp',
input: 'Tutorial1.kas',
output: 'Tutorial1.kp',
capture: true,
command: [meson.get_compiler('c').cmd_array(), '-E', '-x', 'c', '@INPUT@'])
src_missions_tutorials = []
src_missions_tutorials += generator(exe_tools_kas2c,
depends: exe_tools_kas2c,
output: ['@BASENAME@.c', '@BASENAME@.h', '@BASENAME@.func.c'],
arguments: ['@INPUT@', '@OUTPUT0@', '@OUTPUT1@', '@OUTPUT2@']).process(tutorial_01_pp)
inc_src_missions_tutorials = include_directories('.')

5
src/Missions/meson.build Normal file
View File

@ -0,0 +1,5 @@
subdir('SinglePlayer')
subdir('Tutorials')
src_missions = [src_missions_tutorials, src_missions_single_player]
inc_src_missions = [inc_src_missions_tutorials, inc_src_missions_single_player]

35
src/SDL/meson.build Normal file
View File

@ -0,0 +1,35 @@
src_sdl = files('avi.c',
'font.c',
'main.c',
'mainrgn.c',
'mixfft.c',
'mouse.c',
'NetworkInterface.c',
'prim2d.c',
'prim3d.c',
'Queue.c',
'render.c',
'rglu.c',
'rinit.c',
'screenshot.c',
'smixer.c',
'soundlow.c',
'sstream.c',
'texreg.c',
'TimeoutTimer.c',
'Titan.c',
'TitanInterfaceC.c',
'utility.c')
src_sdl += files('fqcodec.c',
'fqeffect.c',
'fquant.c',
'dct.c')
lib_sdl = static_library('hw_sdl',
src_sdl,
c_args: c_args,
dependencies: [dep_sdl],
include_directories: ['../Game', '../Ships', '../ThirdParty/CRC', '../ThirdParty/JPG'])
inc_src_sdl = include_directories('.')

42
src/Ships/meson.build Normal file
View File

@ -0,0 +1,42 @@
src_ships = files('AdvanceSupportFrigate.c',
'Carrier.c',
'CloakGenerator.c',
'DDDFrigate.c',
'DefaultShip.c',
'DefenseFighter.c',
'DFGFrigate.c',
'Drone.c',
'FloatingCity.c',
'GenericDefender.c',
'GenericInterceptor.c',
'GravWellGenerator.c',
'HeavyCorvette.c',
'HeavyCruiser.c',
'IonCannonFrigate.c',
'LightCorvette.c',
'MinelayerCorvette.c',
'MissileDestroyer.c',
'Mothership.c',
'MultiGunCorvette.c',
'P1IonArrayFrigate.c',
'P1MissileCorvette.c',
'P1Mothership.c',
'P1StandardCorvette.c',
'P2AdvanceSwarmer.c',
'P2FuelPod.c',
'P2Mothership.c',
'P2MultiBeamFrigate.c',
'P2Swarmer.c',
'P3StandardShip.c',
'Probe.c',
'ProximitySensor.c',
'RepairCorvette.c',
'ResearchShip.c',
'ResourceCollector.c',
'ResourceController.c',
'SalCapCorvette.c',
'SensorArray.c',
'StandardDestroyer.c',
'StandardFrigate.c')
inc_src_ships = include_directories('.')

6
src/ThirdParty/CRC/meson.build vendored Normal file
View File

@ -0,0 +1,6 @@
src_third_party_crc = files('CRC32.c')
inc_src_third_party_crc = include_directories('.')
lib_crc = static_library('hw_crc',
src_third_party_crc,
c_args: c_args)

81
src/ThirdParty/JPG/meson.build vendored Normal file
View File

@ -0,0 +1,81 @@
src_third_party_jpg = files(#'ansi2knr.c',
'cdjpeg.c',
#'cjpeg.c',
#'ckconfig.c',
#'djpeg.c',
#'example.c',
'interfce.c',
'jaricom.c',
'jcapimin.c',
'jcapistd.c',
'jcarith.c',
'jccoefct.c',
'jccolor.c',
'jcdctmgr.c',
'jchuff.c',
'jcinit.c',
'jcmainct.c',
'jcmarker.c',
'jcmaster.c',
'jcomapi.c',
'jcparam.c',
'jcprepct.c',
'jcsample.c',
'jctrans.c',
'jdapimin.c',
'jdapistd.c',
'jdarith.c',
'jdatadst.c',
'jdatasrc.c',
'jdcoefct.c',
'jdcolor.c',
'jddctmgr.c',
'jdhuff.c',
'jdinput.c',
'jdmainct.c',
'jdmarker.c',
'jdmaster.c',
'jdmerge.c',
'jdpostct.c',
'jdsample.c',
'jdtrans.c',
'jerror.c',
'jfdctflt.c',
'jfdctfst.c',
'jfdctint.c',
'jidctflt.c',
'jidctfst.c',
'jidctint.c',
#'jmemansi.c',
#'jmemdos.c',
#'jmemmac.c',
'jmemmgr.c',
#'jmemname.c',
'jmemnobs.c',
#'jpegtran.c',
'jquant1.c',
'jquant2.c',
'jutils.c',
'rdbmp.c',
'rdcolmap.c',
'rdgif.c',
#'rdjpgcom.c',
'rdppm.c',
'rdrle.c',
'rdswitch.c',
'rdtarga.c',
'transupp.c',
'wrbmp.c',
'wrgif.c',
#'wrjpgcom.c',
'wrppm.c',
'wrrle.c',
'wrtarga.c')
lib_jpg = static_library('hw_jpg',
src_third_party_jpg,
c_args: c_args,
dependencies: dep_sdl,
include_directories: ['../../Game', '../CRC', '../../SDL'])
inc_src_third_party_jpg = include_directories('.')

6
src/ThirdParty/LZSS/meson.build vendored Normal file
View File

@ -0,0 +1,6 @@
src_third_party_lzss = files('BitIO.c', 'LZSS.c')
inc_src_third_party_lzss = include_directories('.')
lib_lzss = static_library('hw_lzss',
src_third_party_lzss,
c_args: c_args)

1
src/ThirdParty/Titan/meson.build vendored Normal file
View File

@ -0,0 +1 @@
inc_src_third_party_titan = include_directories('')

8
src/ThirdParty/meson.build vendored Normal file
View File

@ -0,0 +1,8 @@
subdir('CRC')
subdir('LZSS')
subdir('JPG')
subdir('Titan')
src_third_party = [src_third_party_crc, src_third_party_lzss]
inc_src_third_party = [inc_src_third_party_crc, inc_src_third_party_jpg, inc_src_third_party_lzss, inc_src_third_party_titan]

8
src/meson.build Normal file
View File

@ -0,0 +1,8 @@
subdir('Game')
subdir('Missions')
subdir('Ships')
subdir('SDL')
subdir('ThirdParty')
src = [src_game, src_missions, src_ships, src_third_party]
inc_src = [inc_src_game, inc_src_sdl, inc_src_missions, inc_src_ships, inc_src_third_party]

13
tools/biggie/meson.build Normal file
View File

@ -0,0 +1,13 @@
src_tools_biggie = files('main.c',
'options.c',
'../../src/Game/BigFile.c')
exe_tools_biggie = executable('biggie',
build_by_default: false,
c_args: c_base_args,
include_directories: inc_src,
link_with: [lib_crc, lib_lzss],
dependencies: dep_sdl,
sources: src_tools_biggie)
exe_tools += exe_tools_biggie

View File

@ -5,7 +5,6 @@
#include <string.h>
#include "kas2c.h"
#include "parser.h"
#include "../../src/Game/Types.h"
extern int lineNum;
extern char curFilename[];

23
tools/kas2c/meson.build Normal file
View File

@ -0,0 +1,23 @@
src_tools_kas2c = files('kas2c.c')
prog_flex = find_program('flex', required: true)
prog_bison = find_program('bison', required: true)
gen_parser = generator(prog_bison,
output: ['@BASENAME@.c', '@BASENAME@.h'],
arguments: ['-d', '-o', '@OUTPUT0@', '@INPUT@'])
gen_lexer = generator(prog_flex,
output: '@BASENAME@.c',
arguments: ['-i', '-o', '@OUTPUT@', '@INPUT@'])
gen_output_parser = gen_parser.process('parser.y')
gen_output_lexer = gen_lexer.process('lexer.l')
exe_tools_kas2c = executable('kas2c',
src_tools_kas2c,
gen_output_parser,
gen_output_lexer,
implicit_include_directories: true,
dependencies: dep_sdl,
c_args: c_args)

4
tools/meson.build Normal file
View File

@ -0,0 +1,4 @@
subdir('kas2c')
subdir('polycount')
exe_tools = [exe_tools_kas2c, exe_tools_polycount]

View File

@ -0,0 +1,10 @@
src_tools_monochrome_btg = files('monochrome-btg.c')
exe_tools_monochrome_btg = executable('monochrome-btg',
build_by_default: false,
c_args: c_args,
include_directories: inc_src,
dependencies: dep_sdl,
sources: src_tools_monochrome_btg)
exe_tools += exe_tools_monochrome_btg

View File

@ -1,7 +1,9 @@
//
// file.cpp
// file.c
//
#include <stdbool.h>
#include <stdio.h>
#include "file.h"

View File

@ -1,5 +1,5 @@
//
// main.cpp
// main.c
//
#include <stdio.h>

View File

@ -0,0 +1,8 @@
src_tools_polycount = files('main.c',
'file.c',
'mex.c')
exe_tools_polycount = executable('polycount',
build_by_default: false,
c_args: c_args,
sources: src_tools_polycount)

View File

@ -1,8 +1,9 @@
//
// Mex.cpp
// Mex.c
// mesh-related functions
//
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include "mex.h"
@ -31,7 +32,7 @@ meshdata* meshLoad(char* filePrefix, char* fileName)
fread(&header, sizeof(header), 1, file);
data = new ubyte[fileLength - sizeof(header) + sizeof(meshdata) - sizeof(polygonobject)];
data = malloc(fileLength - sizeof(header) + sizeof(meshdata) - sizeof(polygonobject));
mesh = (meshdata*)data;
offset = (udword)mesh - sizeof(header) + sizeof(meshdata) - sizeof(polygonobject);
mesh->localSize = header.localSize;

59
tools/x86_64/meson.build Normal file
View File

@ -0,0 +1,59 @@
exe_tools_x86_64 = []
exe_tools_x86_64 += executable('bank',
include_directories: inc_src,
implicit_include_directories: true,
dependencies: dep_sdl,
c_args: c_args,
sources: ['bank.c', 'file.c'])
exe_tools_x86_64 += executable('fib',
include_directories: inc_src,
implicit_include_directories: true,
dependencies: dep_sdl,
c_args: c_args,
sources: ['fib.c', 'file.c'])
exe_tools_x86_64 += executable('font',
include_directories: inc_src,
implicit_include_directories: true,
dependencies: dep_sdl,
c_args: c_args,
sources: ['font.c', 'file.c'])
#exe_tools_x86_64 += executable('geo',
# include_directories: inc_src,
# implicit_include_directories: true,
# dependencies: dep_sdl,
# c_args: c_args,
# sources: ['geo.c', 'file.c'])
exe_tools_x86_64 += executable('lif',
include_directories: inc_src,
implicit_include_directories: true,
dependencies: dep_sdl,
c_args: c_args,
sources: ['lif.c', 'file.c'])
exe_tools_x86_64 += executable('ll',
include_directories: inc_src,
implicit_include_directories: true,
dependencies: dep_sdl,
c_args: c_args,
sources: ['ll.c', 'file.c'])
exe_tools_x86_64 += executable('mad',
include_directories: inc_src,
implicit_include_directories: true,
dependencies: dep_sdl,
c_args: c_args,
sources: ['mad.c', 'file.c'])
exe_tools_x86_64 += executable('nis',
include_directories: inc_src,
implicit_include_directories: true,
dependencies: dep_sdl,
c_args: c_args,
sources: ['nis.c', 'file.c'])
exe_tools += exe_tools_x86_64