aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/backend/ninjabackend.py
diff options
context:
space:
mode:
authorAndrei Alexeyev <0x416b617269@gmail.com>2019-02-17 21:25:00 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2019-02-18 22:08:36 +0200
commit2d0841c62423eb8316749476c2d2eac9db25de55 (patch)
treec09abf14fff0ad98575111aa451c60dc1163fb04 /mesonbuild/backend/ninjabackend.py
parent80f16cac8fd4ef7d0ab31ab8b6d94e3b6f3495ff (diff)
downloadmeson-2d0841c62423eb8316749476c2d2eac9db25de55.zip
meson-2d0841c62423eb8316749476c2d2eac9db25de55.tar.gz
meson-2d0841c62423eb8316749476c2d2eac9db25de55.tar.bz2
Improve handling of gui_app
This does two things: * On windows GCC-like compilers, the subsystem is always explicitly specified (either -mwindows or -mconsole). MSVC is already explicit. * The gui_app linker flags are now added after those mandated by external dependencies. This is because some misguided libraries (such as SDL) think that hijacking `main()` and forcing `-mwindows` in link flags is clever. We must unconditionally override such misuses to let gui_app work as intended.
Diffstat (limited to 'mesonbuild/backend/ninjabackend.py')
-rw-r--r--mesonbuild/backend/ninjabackend.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 2466fac..16962a4 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -2327,8 +2327,6 @@ rule FORTRAN_DEP_HACK%s
if isinstance(target, build.Executable):
# Currently only used with the Swift compiler to add '-emit-executable'
commands += linker.get_std_exe_link_args()
- # If gui_app is significant on this platform, add the appropriate linker arguments
- commands += linker.get_gui_app_args(target.gui_app)
# If export_dynamic, add the appropriate linker arguments
if target.export_dynamic:
commands += linker.gen_export_dynamic_link_args(self.environment)
@@ -2361,6 +2359,15 @@ rule FORTRAN_DEP_HACK%s
raise RuntimeError('Unknown build target type.')
return commands
+ def get_target_type_link_args_post_dependencies(self, target, linker):
+ commands = []
+ if isinstance(target, build.Executable):
+ # If gui_app is significant on this platform, add the appropriate linker arguments.
+ # Unfortunately this can't be done in get_target_type_link_args, because some misguided
+ # libraries (such as SDL2) add -mwindows to their link flags.
+ commands += linker.get_gui_app_args(target.gui_app)
+ return commands
+
def get_link_whole_args(self, linker, target):
target_args = self.build_target_link_arguments(linker, target.link_whole_targets)
return linker.get_link_whole_for(target_args) if len(target_args) else []
@@ -2539,6 +2546,9 @@ rule FORTRAN_DEP_HACK%s
if need_threads:
commands += linker.thread_link_flags(self.environment)
+ # Add link args specific to this BuildTarget type that must not be overridden by dependencies
+ commands += self.get_target_type_link_args_post_dependencies(target, linker)
+
# Add link args for c_* or cpp_* build options. Currently this only
# adds c_winlibs and cpp_winlibs when building for Windows. This needs
# to be after all internal and external libraries so that unresolved