[vala/meson-msvc] meson: Delay-load valacodegen.dll for valac on MSVC-like




commit 281c33d473b1e2a65d9294ba44dc0161c14846bb
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Thu Jan 27 12:43:45 2022 +0800

    meson: Delay-load valacodegen.dll for valac on MSVC-like
    
    If we are building Vala as shared builds, we must delay-load valacodegen.dll so
    that valac will run when installed, as valacodegen.dll is not installed
    together with valac-x.y.exe, under $(bindir), when building with Visual Studio-
    like compilers.
    
    Otherwise, when running valac, one will be greeted with a Windows error dialog
    indicating that valacodegen.dll could not be found.

 compiler/meson.build | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
---
diff --git a/compiler/meson.build b/compiler/meson.build
index a07330f69..0c3a569ef 100644
--- a/compiler/meson.build
+++ b/compiler/meson.build
@@ -5,16 +5,25 @@ valac_sources = files(
 valac_name = 'valac@0@'.format(vala_version_suffix)
 
 extra_compiler_include_dirs = []
+extra_compiler_linker_args = []
+extra_compiler_libs = []
 
+# We must delay-load valacodegen.dll for Visual Studio-like builds,
+# otherwise the installed valac-x.y.exe won't run
 if cc.get_argument_syntax() == 'msvc'
        extra_compiler_include_dirs += include_directories('../msvc')
+       if get_option('default_library') == 'shared'
+               extra_compiler_linker_args += '/delayload:@0@.dll'.format(valacodegen_lib.name())
+               extra_compiler_libs += cc.find_library('delayimp')
+       endif
 endif
 
 valac_exe = executable(
        valac_name,
        valac_sources,
        include_directories: extra_compiler_include_dirs,
-       dependencies: [glib_dep, valacodegen_dep],
+       link_args: extra_compiler_linker_args,
+       dependencies: [glib_dep, valacodegen_dep] + extra_compiler_libs,
        install: true,
 )
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]