refactor some aspects of path config, ANGLE libs in particular
This commit is contained in:
parent
0b29dd473b
commit
fadd6de76d
9 changed files with 177 additions and 61 deletions
|
@ -9,7 +9,7 @@ charset = utf-8
|
|||
indent_style = tab
|
||||
# indent_size = 4
|
||||
|
||||
[*.{py,html,js,nsi.in,rst}]
|
||||
[*.{py,html,js,nsi.in,rst,plist.in}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
|
|
|
@ -68,13 +68,13 @@ if install_docs
|
|||
)
|
||||
endforeach
|
||||
|
||||
if angle_enabled and host_machine.system() == 'windows'
|
||||
bindist_deps += custom_target(f,
|
||||
if angle_enabled
|
||||
bindist_deps += custom_target('LICENSE.ANGLE',
|
||||
command : [eolconv_command, host_eol_style, '@INPUT@', '@OUTPUT@'],
|
||||
input : 'LICENSE.ANGLE',
|
||||
output : 'LICENSE.txt',
|
||||
install : true,
|
||||
install_dir : join_paths(bindir, 'ANGLE')
|
||||
install_dir : angle_install_path
|
||||
)
|
||||
endif
|
||||
endif
|
||||
|
|
138
meson.build
138
meson.build
|
@ -270,9 +270,16 @@ force_relpath_systems = [
|
|||
|
||||
if macos_app_bundle
|
||||
bundle_dir = 'Taisei.app'
|
||||
datadir = join_paths(bundle_dir, 'Contents', 'Resources')
|
||||
bindir = join_paths(bundle_dir, 'Contents', 'MacOS')
|
||||
config.set('TAISEI_BUILDCONF_RELATIVE_DATA_PATH', true)
|
||||
|
||||
bundle_datadir = join_paths('Contents', 'Resources')
|
||||
bundle_bindir = join_paths('Contents', 'MacOS')
|
||||
bundle_libdir = bundle_bindir
|
||||
|
||||
datadir = join_paths(bundle_dir, bundle_datadir)
|
||||
bindir = join_paths(bundle_dir, bundle_bindir)
|
||||
libdir = join_paths(bundle_dir, bundle_libdir)
|
||||
|
||||
is_relocatable_install = true
|
||||
|
||||
# arguments must be strings...
|
||||
meson.add_install_script(
|
||||
|
@ -286,48 +293,62 @@ else
|
|||
datadir = get_option('datadir')
|
||||
|
||||
if force_relpath_systems.contains(host_machine.system())
|
||||
config.set('TAISEI_BUILDCONF_RELATIVE_DATA_PATH', true)
|
||||
is_relocatable_install = true
|
||||
elif get_option('install_relative') == 'auto'
|
||||
config.set('TAISEI_BUILDCONF_RELATIVE_DATA_PATH', prefer_relpath_systems.contains(host_machine.system()))
|
||||
is_relocatable_install = prefer_relpath_systems.contains(host_machine.system())
|
||||
else
|
||||
config.set('TAISEI_BUILDCONF_RELATIVE_DATA_PATH', get_option('install_relative') == 'true')
|
||||
is_relocatable_install = (get_option('install_relative') == 'true')
|
||||
endif
|
||||
|
||||
if config.get('TAISEI_BUILDCONF_RELATIVE_DATA_PATH')
|
||||
if is_relocatable_install
|
||||
bindir = '.'
|
||||
libdir = '.'
|
||||
else
|
||||
bindir = get_option('bindir')
|
||||
libdir = get_option('libdir')
|
||||
endif
|
||||
endif
|
||||
|
||||
if get_option('install_freedesktop') == 'auto'
|
||||
install_xdg = not config.get('TAISEI_BUILDCONF_RELATIVE_DATA_PATH')
|
||||
install_xdg = not is_relocatable_install
|
||||
else
|
||||
install_xdg = get_option('install_freedesktop') == 'true'
|
||||
endif
|
||||
|
||||
if config.get('TAISEI_BUILDCONF_RELATIVE_DATA_PATH')
|
||||
if is_relocatable_install
|
||||
data_path = 'data'
|
||||
doc_path = '.' # Meson bug https://github.com/mesonbuild/meson/issues/4295
|
||||
xdg_path = 'freedesktop.org'
|
||||
|
||||
# This is relative to SDL_GetBasePath()
|
||||
config.set_quoted('TAISEI_BUILDCONF_DATA_PATH', data_path)
|
||||
lib_path = '.'
|
||||
|
||||
if macos_app_bundle
|
||||
# Actual installation path
|
||||
data_path = join_paths(datadir, data_path)
|
||||
# Relative to SDL_GetBasePath() (bundle root)
|
||||
config.set_quoted('TAISEI_BUILDCONF_DATA_PATH', join_paths(bundle_datadir, data_path))
|
||||
config.set_quoted('TAISEI_BUILDCONF_LIB_PATH', join_paths(bundle_libdir))
|
||||
|
||||
# Make paths prefix-relative for installation
|
||||
|
||||
data_path = join_paths(datadir, data_path)
|
||||
lib_path = libdir
|
||||
# I don't know why would you do that, but more power to you
|
||||
xdg_path = join_paths(datadir, xdg_path)
|
||||
else
|
||||
# Relative to SDL_GetBasePath() (typically contains the executable)
|
||||
config.set_quoted('TAISEI_BUILDCONF_DATA_PATH', data_path)
|
||||
config.set_quoted('TAISEI_BUILDCONF_LIB_PATH', '.')
|
||||
endif
|
||||
else
|
||||
data_path = join_paths(datadir, 'taisei')
|
||||
config.set_quoted('TAISEI_BUILDCONF_DATA_PATH', join_paths(get_option('prefix'), data_path))
|
||||
lib_path = join_paths(libdir, 'taisei')
|
||||
doc_path = join_paths(datadir, 'doc', 'taisei')
|
||||
xdg_path = datadir
|
||||
|
||||
# Static absolute paths
|
||||
config.set_quoted('TAISEI_BUILDCONF_DATA_PATH', join_paths(get_option('prefix'), data_path))
|
||||
config.set_quoted('TAISEI_BUILDCONF_LIB_PATH', join_paths(get_option('prefix'), lib_path))
|
||||
endif
|
||||
|
||||
config.set('TAISEI_BUILDCONF_RELOCATABLE_INSTALL', is_relocatable_install)
|
||||
config.set('TAISEI_BUILDCONF_DEBUG', is_debug_build)
|
||||
config.set('TAISEI_BUILDCONF_DEVELOPER', is_developer_build)
|
||||
config.set('TAISEI_BUILDCONF_LOG_FATAL_MSGBOX', (
|
||||
|
@ -360,41 +381,70 @@ endif
|
|||
if angle_enabled
|
||||
angle_dir = 'ANGLE'
|
||||
|
||||
if host_machine.system() == 'windows'
|
||||
angle_path = angle_dir + '\\'
|
||||
gles_filename = angle_path + 'libGLESv2.dll'
|
||||
egl_filename = angle_path + 'libEGL.dll'
|
||||
# activate the Windows-Intel-ANGLE workaround
|
||||
config.set('TAISEI_BUILDCONF_WINDOWS_ANGLE_INTEL', 1)
|
||||
elif host_machine.system() == 'darwin'
|
||||
# this is relative to SDL_GetBasePath()
|
||||
# easiest way to traverse is to go up one dir
|
||||
angle_path = 'MacOS/' + angle_dir + '/'
|
||||
if not macos_app_bundle
|
||||
# if the user decides not to use the app bundle on macOS
|
||||
angle_path = 'lib/' + angle_dir + '/'
|
||||
endif
|
||||
gles_filename = '../' + angle_path + 'libGLESv2.dylib'
|
||||
egl_filename = '../' + angle_path + 'libEGL.dylib'
|
||||
else
|
||||
# FIXME: for Linux
|
||||
angle_path = 'lib/' + angle_dir + '/'
|
||||
gles_filename = '../' + angle_path + 'libGLESv2.so'
|
||||
egl_filename = '../' + angle_path + 'libEGL.so'
|
||||
angle_libgles = get_option('angle_libgles')
|
||||
angle_libegl = get_option('angle_libegl')
|
||||
|
||||
libgles_filename = angle_libgles.split('/')[-1]
|
||||
libegl_filename = angle_libegl.split('/')[-1]
|
||||
|
||||
if build_machine.system() == 'windows'
|
||||
# Windows is terrible and has TWO valid path separators
|
||||
libgles_filename = angle_libgles.split('\\')[-1]
|
||||
libegl_filename = angle_libegl.split('\\')[-1]
|
||||
endif
|
||||
|
||||
# used in gles.c for determining what libraries to use
|
||||
config.set_quoted('TAISEI_BUILDCONF_ANGLE_GLES_PATH', gles_filename )
|
||||
config.set_quoted('TAISEI_BUILDCONF_ANGLE_EGL_PATH', egl_filename )
|
||||
# Where to install the libs (prefix-relative)
|
||||
# Also used in docs/meson.build to install the license
|
||||
angle_install_path = join_paths(lib_path, angle_dir)
|
||||
|
||||
# Where the game should look (either absolute or SDL_GetBasePath()-relative, depending on configuration)
|
||||
angle_config_path = join_paths(config.get_unquoted('TAISEI_BUILDCONF_LIB_PATH'), angle_dir)
|
||||
|
||||
# use ANGLE for gles renderers by default
|
||||
config.set('TAISEI_BUILDCONF_HAVE_ANGLE', true)
|
||||
|
||||
# used in gles.c for determining what libraries to use
|
||||
config.set_quoted('TAISEI_BUILDCONF_ANGLE_GLES_PATH', join_paths(angle_config_path, libgles_filename))
|
||||
config.set_quoted('TAISEI_BUILDCONF_ANGLE_EGL_PATH', join_paths(angle_config_path, libegl_filename))
|
||||
|
||||
if host_machine.system() == 'windows'
|
||||
# Direct Intel iGPU users to the ANGLE fallback on Windows
|
||||
config.set('TAISEI_BUILDCONF_WINDOWS_ANGLE_INTEL', true)
|
||||
endif
|
||||
|
||||
# installs ANGLE to the paths specified
|
||||
install_data(
|
||||
get_option('angle_libgles'),
|
||||
get_option('angle_libegl'),
|
||||
install_dir : angle_path,
|
||||
angle_libgles,
|
||||
angle_libegl,
|
||||
install_dir : angle_install_path,
|
||||
)
|
||||
endif
|
||||
|
||||
pathconv_args = ['--escape-backslashes']
|
||||
|
||||
if build_machine.system() == 'windows'
|
||||
pathconv_args += '--from-windows'
|
||||
endif
|
||||
|
||||
if host_machine.system() == 'windows'
|
||||
pathconv_args += '--to-windows'
|
||||
endif
|
||||
|
||||
foreach pathvar : [
|
||||
'TAISEI_BUILDCONF_ANGLE_EGL_PATH',
|
||||
'TAISEI_BUILDCONF_ANGLE_GLES_PATH',
|
||||
'TAISEI_BUILDCONF_DATA_PATH',
|
||||
'TAISEI_BUILDCONF_LIB_PATH',
|
||||
]
|
||||
if config.has(pathvar)
|
||||
p = config.get_unquoted(pathvar)
|
||||
r = run_command(fix_path_command, pathconv_args, p, check : true)
|
||||
assert(r.returncode() == 0, 'path-correction script failed')
|
||||
p = r.stdout()
|
||||
# message('@0@ = @1@'.format(pathvar, p))
|
||||
config.set_quoted(pathvar, p)
|
||||
endif
|
||||
endforeach
|
||||
|
||||
systype = (have_posix ? 'POSIX (@0@)' : '@0@').format(host_machine.system())
|
||||
systype = '@0@, @1@, @2@'.format(systype, host_machine.cpu_family(), host_machine.cpu())
|
||||
|
||||
|
@ -470,7 +520,7 @@ Summary:
|
|||
enable_zip,
|
||||
package_data,
|
||||
|
||||
config.get('TAISEI_BUILDCONF_RELATIVE_DATA_PATH'),
|
||||
is_relocatable_install,
|
||||
get_option('prefix'),
|
||||
# the $ is intentional
|
||||
join_paths('$prefix', bindir),
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${VERSION({major}.{minor}.{patch}.{tweak})}</string>
|
||||
<key>SDL_FILESYSTEM_BASE_DIR_TYPE</key>
|
||||
<string>bundle</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.arcade-games</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
|
|
|
@ -149,3 +149,6 @@ check_submodules_command = [python_thunk, check_submodules_script]
|
|||
|
||||
em_set_bundle_uuid_script = files('em-set-bundle-uuid.py')
|
||||
em_set_bundle_uuid_command = [python_thunk, em_set_bundle_uuid_script]
|
||||
|
||||
fix_path_script = files('unfuck-path.py')
|
||||
fix_path_command = [python_thunk, fix_path_script]
|
||||
|
|
54
scripts/unfuck-path.py
Executable file
54
scripts/unfuck-path.py
Executable file
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from taiseilib.common import (
|
||||
run_main,
|
||||
)
|
||||
|
||||
from pathlib import Path, PureWindowsPath, PurePosixPath
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def main(args):
|
||||
import argparse
|
||||
parser = argparse.ArgumentParser(description='Because Windows is the worst.', prog=args[0])
|
||||
|
||||
parser.add_argument('path',
|
||||
help='the path to operate on'
|
||||
)
|
||||
|
||||
parser.add_argument('--from-windows',
|
||||
action='store_true',
|
||||
help='interpret source as a Windows path (default: POSIX path)'
|
||||
)
|
||||
|
||||
parser.add_argument('--to-windows',
|
||||
action='store_true',
|
||||
help='output a Windows path (default: POSIX path)'
|
||||
)
|
||||
|
||||
parser.add_argument('--escape-backslashes',
|
||||
action='store_true',
|
||||
help='escape any backslashes in the output'
|
||||
)
|
||||
|
||||
args = parser.parse_args(args[1:])
|
||||
|
||||
if args.from_windows:
|
||||
path = PureWindowsPath(args.path)
|
||||
else:
|
||||
path = PurePosixPath(args.path)
|
||||
|
||||
if args.to_windows:
|
||||
out = str(PureWindowsPath(path))
|
||||
else:
|
||||
out = path.as_posix()
|
||||
|
||||
if args.escape_backslashes:
|
||||
out = out.replace('\\', '\\\\')
|
||||
|
||||
sys.stdout.write(out)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run_main(main)
|
|
@ -15,11 +15,15 @@
|
|||
|
||||
void gles_init(RendererBackend *gles_backend, int major, int minor) {
|
||||
#ifdef TAISEI_BUILDCONF_HAVE_ANGLE
|
||||
// for loading ANGLE libraries
|
||||
// Load ANGLE by default by setting up some SDL-specific environment vars.
|
||||
// These are not overwritten if they are already set in the environment, so
|
||||
// you can still override this behavior as usual.
|
||||
|
||||
#ifdef TAISEI_BUILDCONF_RELOCATABLE_INSTALL
|
||||
// In a relocatable build, paths are relative to SDL_GetBasePath
|
||||
char *basepath = SDL_GetBasePath();
|
||||
char buf[128];
|
||||
|
||||
// SDL_*_DRIVER are SDL-specific env vars
|
||||
char buf[strlen(basepath) + sizeof(TAISEI_BUILDCONF_ANGLE_GLES_PATH) + sizeof(TAISEI_BUILDCONF_ANGLE_EGL_PATH)];
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s%s", basepath, TAISEI_BUILDCONF_ANGLE_GLES_PATH);
|
||||
env_set("SDL_VIDEO_GL_DRIVER", buf, false);
|
||||
|
||||
|
@ -27,10 +31,14 @@ void gles_init(RendererBackend *gles_backend, int major, int minor) {
|
|||
env_set("SDL_VIDEO_EGL_DRIVER", buf, false);
|
||||
|
||||
SDL_free(basepath);
|
||||
#else
|
||||
// Static absolute paths
|
||||
env_set("SDL_VIDEO_GL_DRIVER", TAISEI_BUILDCONF_ANGLE_GLES_PATH, false);
|
||||
env_set("SDL_VIDEO_EGL_DRIVER", TAISEI_BUILDCONF_ANGLE_EGL_PATH, false);
|
||||
#endif
|
||||
|
||||
env_set("SDL_OPENGL_ES_DRIVER", 1, false);
|
||||
|
||||
#endif
|
||||
#endif // TAISEI_BUILDCONF_HAVE_ANGLE
|
||||
|
||||
_r_backend_inherit(gles_backend, &_r_backend_gl33);
|
||||
glcommon_setup_attributes(SDL_GL_CONTEXT_PROFILE_ES, major, minor, 0);
|
||||
|
|
|
@ -63,9 +63,8 @@ config.set('TAISEI_BUILDCONF_RENDERER_BACKENDS', r_macro)
|
|||
config.set_quoted('TAISEI_BUILDCONF_RENDERER_DEFAULT', default_renderer)
|
||||
|
||||
if angle_enabled
|
||||
if enabled_renderers.contains('gles30') or enabled_renderers.contains('gles20')
|
||||
config.set('TAISEI_BUILDCONF_HAVE_ANGLE', 1)
|
||||
else
|
||||
error('you should enable gles30 and/or gles20 with ANGLE')
|
||||
endif
|
||||
assert(
|
||||
enabled_renderers.contains('gles30') or enabled_renderers.contains('gles20'),
|
||||
'An OpenGL ES renderer is required to use ANGLE. Enable r_gles30 or r_gles20, or disable install_angle.'
|
||||
)
|
||||
endif
|
||||
|
|
|
@ -14,10 +14,10 @@
|
|||
#include "util.h"
|
||||
#include "loadpacks.h"
|
||||
|
||||
static char* get_default_res_path(void) {
|
||||
static char *get_default_res_path(void) {
|
||||
char *res;
|
||||
|
||||
#ifdef TAISEI_BUILDCONF_RELATIVE_DATA_PATH
|
||||
#ifdef TAISEI_BUILDCONF_RELOCATABLE_INSTALL
|
||||
res = SDL_GetBasePath();
|
||||
strappend(&res, TAISEI_BUILDCONF_DATA_PATH);
|
||||
#else
|
||||
|
|
Loading…
Reference in a new issue