0%

meson自定义Visual Studio Backend的调试器参数

Visual Studio C/C++解决方案的<项目名>[email protected]文件可以存储调试器的配置,可以利用configure_file,在meson执行configure时输出自定义的vcxproj.user文件。

meson configure_file()

这里以使用Python本机调试器为例子:

[email protected]文件:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug|Win32'">
<DebuggerFlavor>PythonDebugLaunchProvider</DebuggerFlavor>
<LocalDebuggerCommandArguments>-i -c "print('&gt;&gt;&gt; import FooBar'); import FooBar"</LocalDebuggerCommandArguments>
<LocalDebuggerCommand>@PYTHON_FULL_PATH@</LocalDebuggerCommand>
<LocalDebuggerWorkingDirectory>$(OutDirFullPath)</LocalDebuggerWorkingDirectory>
<LocalDebuggerEnvironment>PYTHONPATH=$(OutDirFullPath)</LocalDebuggerEnvironment>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|Win32'">
<DebuggerFlavor>PythonDebugLaunchProvider</DebuggerFlavor>
<LocalDebuggerCommandArguments>-i -c "print('&gt;&gt;&gt; import FooBar'); import FooBar"</LocalDebuggerCommandArguments>
<LocalDebuggerCommand>@PYTHON_FULL_PATH@</LocalDebuggerCommand>
<LocalDebuggerWorkingDirectory>$(OutDirFullPath)</LocalDebuggerWorkingDirectory>
<LocalDebuggerEnvironment>PYTHONPATH=$(OutDirFullPath)</LocalDebuggerEnvironment>
</PropertyGroup>
</Project>

上面的DebuggerFlavor也可以改为WindowsLocalDebugger

meson.build部分内容:

1
2
3
4
5
6
7
configure_file(
input: '@0@@sha.vcxproj.user.in'.format(meson.project_name()),
output: '@0@@sha.vcxproj.user'.format(meson.project_name()),
configuration : configuration_data({
'PYTHON_FULL_PATH': find_program('python').full_path()
})
)
请我喝瓶肥仔快乐水?

欢迎关注我的其它发布渠道