2023-05-04 16:42:31 -04:00
|
|
|
project('mkxp-z', 'c', 'cpp', version: '2.4.2', meson_version: '>=0.56.0', default_options: ['cpp_std=c++14', 'buildtype=release'])
|
2019-07-29 07:56:45 -04:00
|
|
|
|
|
|
|
host_system = host_machine.system()
|
2019-12-14 17:12:53 -05:00
|
|
|
|
2020-12-30 18:21:59 -05:00
|
|
|
if host_system == 'darwin'
|
|
|
|
error('\nThis Meson project no longer supports macOS. Please use the Xcode project instead.')
|
|
|
|
endif
|
|
|
|
|
|
|
|
xxd = find_program('xxd', native: true)
|
|
|
|
|
2023-05-19 08:49:32 -04:00
|
|
|
git_hash = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip()
|
|
|
|
|
2020-11-22 03:48:03 -05:00
|
|
|
compilers = {'cpp': meson.get_compiler('cpp')}
|
2019-12-17 22:23:13 -05:00
|
|
|
|
2019-12-14 17:12:53 -05:00
|
|
|
global_sources = []
|
|
|
|
global_dependencies = []
|
|
|
|
global_include_dirs = []
|
|
|
|
global_args = []
|
|
|
|
global_link_args = []
|
|
|
|
|
2020-02-28 03:23:16 -05:00
|
|
|
sizeof = {'void*': compilers['cpp'].sizeof('void*'),
|
|
|
|
'long': compilers['cpp'].sizeof('long')
|
|
|
|
}
|
|
|
|
win64 = (sizeof['void*'] != sizeof['long'])
|
2020-11-13 01:42:22 -05:00
|
|
|
|
2020-11-19 03:56:35 -05:00
|
|
|
global_args += '-DMKXPZ_BUILD_MESON'
|
2020-12-31 17:26:14 -05:00
|
|
|
global_args += '-DMKXPZ_VERSION="@0@"'.format(meson.project_version())
|
2023-05-19 08:49:32 -04:00
|
|
|
global_args += '-DMKXPZ_GIT_HASH="@0@"'.format(git_hash)
|
2021-03-28 15:32:24 -04:00
|
|
|
global_args += '-DHAVE_NANOSLEEP'
|
2019-09-04 05:48:23 -04:00
|
|
|
# ====================
|
|
|
|
# Ext libs
|
|
|
|
# ====================
|
|
|
|
|
2020-02-28 03:23:16 -05:00
|
|
|
# STEAMWORKS
|
|
|
|
|
|
|
|
steamworks = false
|
|
|
|
steamworks_path = get_option('steamworks_path')
|
|
|
|
if steamworks_path != ''
|
|
|
|
libname = 'steam_api'
|
|
|
|
if host_system == 'linux'
|
|
|
|
if sizeof['void*'] == 4
|
|
|
|
bindir = 'linux32'
|
|
|
|
else
|
|
|
|
bindir = 'linux64'
|
|
|
|
endif
|
2020-12-30 18:21:59 -05:00
|
|
|
else
|
2020-02-28 03:23:16 -05:00
|
|
|
if win64 == true
|
|
|
|
bindir = 'win64'
|
|
|
|
libname += '64'
|
|
|
|
else
|
|
|
|
bindir = ''
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
steam_libpath = steamworks_path + '/redistributable_bin/' + bindir
|
|
|
|
steamlib = compilers['cpp'].find_library(libname, required: false, dirs: [steam_libpath])
|
|
|
|
|
|
|
|
if steamlib.found() == true
|
2020-03-02 03:52:42 -05:00
|
|
|
global_include_dirs += include_directories('steamshim')
|
2020-12-31 14:50:07 -05:00
|
|
|
global_args += '-DMKXPZ_STEAM'
|
2020-03-02 03:52:42 -05:00
|
|
|
global_sources += 'steamshim/steamshim_child.c'
|
2020-02-29 03:25:25 -05:00
|
|
|
steamworks = true
|
2020-02-28 03:23:16 -05:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2020-11-19 03:56:35 -05:00
|
|
|
# GLES
|
|
|
|
gfx_backend = get_option('gfx_backend')
|
|
|
|
if gfx_backend == 'gles'
|
2020-11-16 20:26:49 -05:00
|
|
|
# Needs to be manually set up for now
|
|
|
|
global_args += '-DGLES2_HEADER'
|
|
|
|
elif gfx_backend == 'gl'
|
|
|
|
global_dependencies += dependency('gl')
|
|
|
|
# boop
|
|
|
|
endif
|
|
|
|
|
2019-09-04 05:48:23 -04:00
|
|
|
# ====================
|
|
|
|
# Main source
|
|
|
|
# ====================
|
2019-12-14 13:31:48 -05:00
|
|
|
|
|
|
|
# Suppress warnings
|
2021-05-23 21:55:02 -04:00
|
|
|
global_args += ['-Wno-non-virtual-dtor', '-Wno-reorder', '-Wno-uninitialized', '-Wno-unknown-pragmas', '-Wno-stringop-truncation']
|
2020-11-22 03:48:03 -05:00
|
|
|
if compilers['cpp'].get_id() == 'clang'
|
2019-12-17 22:23:13 -05:00
|
|
|
global_args += ['-Wno-undefined-var-template', '-Wno-delete-non-abstract-non-virtual-dtor']
|
2019-12-14 17:12:53 -05:00
|
|
|
endif
|
2020-02-29 21:31:25 -05:00
|
|
|
if host_system == 'windows'
|
2020-12-31 14:50:07 -05:00
|
|
|
if compilers['cpp'].get_id() != 'clang'
|
|
|
|
global_args += '-masm=intel'
|
|
|
|
endif
|
2020-02-29 21:31:25 -05:00
|
|
|
endif
|
2019-09-04 05:48:23 -04:00
|
|
|
|
2019-12-31 13:42:44 -05:00
|
|
|
# Decide whether or not to use MiniFFI
|
|
|
|
miniffi = get_option('use_miniffi')
|
|
|
|
if miniffi == true
|
2020-12-31 16:58:47 -05:00
|
|
|
miniffi = true
|
|
|
|
global_args += '-DMKXPZ_MINIFFI'
|
2019-12-31 13:42:44 -05:00
|
|
|
endif
|
|
|
|
|
|
|
|
# Defines
|
2019-08-10 04:35:37 -04:00
|
|
|
if get_option('workdir_current')
|
2019-12-14 13:31:48 -05:00
|
|
|
global_args += '-DWORKDIR_CURRENT'
|
2019-07-29 08:20:40 -04:00
|
|
|
endif
|
|
|
|
|
2020-11-23 02:25:02 -05:00
|
|
|
if get_option('cxx11_experimental') == true
|
2020-12-31 14:50:07 -05:00
|
|
|
global_args += '-DMKXPZ_EXP_FS'
|
2020-11-23 02:25:02 -05:00
|
|
|
endif
|
|
|
|
|
2020-04-29 21:59:19 -04:00
|
|
|
if get_option('force32') == true
|
|
|
|
global_args += '-m32'
|
|
|
|
endif
|
|
|
|
|
2020-02-28 05:35:14 -05:00
|
|
|
build_static = false
|
2022-01-19 04:06:43 -05:00
|
|
|
if get_option('static_executable') == true
|
2020-02-28 05:35:14 -05:00
|
|
|
build_static = true
|
|
|
|
endif
|
|
|
|
|
2020-12-31 14:50:07 -05:00
|
|
|
global_args += '-DMKXPZ_INIT_GL_LATER'
|
2020-02-10 12:38:27 -05:00
|
|
|
|
2019-07-29 07:56:45 -04:00
|
|
|
subdir('src')
|
2019-07-31 08:47:44 -04:00
|
|
|
subdir('binding')
|
2019-07-29 07:56:45 -04:00
|
|
|
subdir('shader')
|
|
|
|
subdir('assets')
|
|
|
|
|
2019-12-14 13:31:48 -05:00
|
|
|
global_include_dirs += include_directories('src', 'binding')
|
2019-08-19 08:59:35 -04:00
|
|
|
|
2020-04-29 23:27:28 -04:00
|
|
|
rpath = ''
|
|
|
|
|
2019-07-29 07:56:45 -04:00
|
|
|
if host_system == 'windows'
|
2023-10-26 04:10:26 +00:00
|
|
|
windows_resource_directory = '../' + get_option('windows_resource_directory')
|
|
|
|
subdir('windows')
|
2019-12-14 13:31:48 -05:00
|
|
|
global_sources += windows_resources
|
2023-10-26 04:10:26 +00:00
|
|
|
global_include_dirs += include_directories('windows')
|
2019-10-22 02:30:07 -04:00
|
|
|
else
|
|
|
|
subdir('linux')
|
2020-04-29 23:27:28 -04:00
|
|
|
rpath = '$ORIGIN/lib'
|
2020-04-29 22:33:01 -04:00
|
|
|
if get_option('appimage') != true
|
2020-04-29 23:46:05 -04:00
|
|
|
if sizeof['long'] == 8 and get_option('force32') != true
|
2020-04-29 23:27:28 -04:00
|
|
|
rpath += '64'
|
2020-05-01 23:39:42 -04:00
|
|
|
else
|
|
|
|
rpath += '32'
|
2020-04-29 22:33:01 -04:00
|
|
|
endif
|
|
|
|
endif
|
2019-07-29 07:56:45 -04:00
|
|
|
endif
|
|
|
|
|
2020-03-02 03:52:42 -05:00
|
|
|
exe_name = meson.project_name()
|
2022-01-19 04:06:43 -05:00
|
|
|
|
|
|
|
if host_system == 'linux' and get_option('appimage') == false
|
|
|
|
exe_name += '.' + host_machine.cpu()
|
|
|
|
endif
|
|
|
|
|
2020-03-02 03:52:42 -05:00
|
|
|
if steamworks == true
|
2022-01-20 02:26:22 -05:00
|
|
|
exe_name = 'steam_' + exe_name
|
2020-03-02 03:52:42 -05:00
|
|
|
la = ''
|
|
|
|
if build_static == true
|
2022-01-19 04:06:43 -05:00
|
|
|
if host_system == 'windows'
|
|
|
|
la = '-static'
|
|
|
|
else
|
|
|
|
la = '-static-libgcc -static-libstdc++'
|
|
|
|
endif
|
2020-03-02 03:52:42 -05:00
|
|
|
endif
|
2022-01-13 16:29:17 -05:00
|
|
|
|
|
|
|
shim_args = [
|
|
|
|
'-DGAME_LAUNCH_NAME="' + exe_name + '"',
|
|
|
|
'-I' + steamworks_path + '/public'
|
|
|
|
]
|
|
|
|
|
2020-03-02 04:44:10 -05:00
|
|
|
if get_option('steam_appid') != ''
|
|
|
|
shim_args += '-DSTEAM_APPID=' + get_option('steam_appid')
|
|
|
|
endif
|
|
|
|
|
2021-03-15 23:13:25 -04:00
|
|
|
if get_option('steamshim_debug') == true
|
2020-03-11 13:55:47 -04:00
|
|
|
shim_args += '-DSTEAMSHIM_DEBUG'
|
2022-07-05 21:37:18 -04:00
|
|
|
shim_ws = 'console'
|
|
|
|
else
|
|
|
|
shim_ws = 'windows'
|
2020-03-11 13:55:47 -04:00
|
|
|
endif
|
|
|
|
|
2020-03-02 03:52:42 -05:00
|
|
|
executable(meson.project_name(),
|
|
|
|
sources: files('steamshim/steamshim_parent.cpp'),
|
|
|
|
dependencies: steamlib,
|
2020-03-02 04:44:10 -05:00
|
|
|
cpp_args: shim_args,
|
2020-03-02 03:52:42 -05:00
|
|
|
link_args: la.split(),
|
2022-07-05 21:37:18 -04:00
|
|
|
win_subsystem: shim_ws,
|
2020-03-02 03:52:42 -05:00
|
|
|
install: (host_system != 'windows'))
|
|
|
|
endif
|
|
|
|
|
|
|
|
executable(exe_name,
|
2019-12-14 13:31:48 -05:00
|
|
|
sources: global_sources,
|
2019-12-14 17:12:53 -05:00
|
|
|
dependencies: global_dependencies,
|
2019-12-14 13:31:48 -05:00
|
|
|
include_directories: global_include_dirs,
|
2020-04-29 23:27:28 -04:00
|
|
|
install_rpath: rpath,
|
2019-12-14 13:31:48 -05:00
|
|
|
link_args: global_link_args,
|
|
|
|
cpp_args: global_args,
|
|
|
|
objc_args: global_args,
|
|
|
|
objcpp_args: global_args,
|
2022-04-02 20:58:52 -04:00
|
|
|
win_subsystem: 'windows',
|
2019-10-22 02:30:07 -04:00
|
|
|
install: (host_system != 'windows')
|
2019-07-29 07:56:45 -04:00
|
|
|
)
|