骗局使用Clang -MJ选项 [英] Scons to use Clang -MJ option

查看:143
本文介绍了骗局使用Clang -MJ选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Scons构建系统在Windows上构建compile_commands.json,所有其他可能性均失败了。

Hi I am trying to build a compile_commands.json on windows with Scons build system and all other possibilities have failed.

我决定使用Clang -MJ选项为此,因为这似乎是最简单的解决方案。

I decided to use the Clang -MJ option to do this as this seems the easiest solution available.

问题在于,尚不清楚我将如何使用Scons构建系统来完成此任务;基本上,我必须在每个构建命令中添加 -MJ myfilename.o.json 。我目前正在建立一个包含多个源文件的图书馆:
library = env.StaticLibrary(target = result_path +'/'+ result_name,source = sources)

The issue is that it isnt clear how I would go about doing this with the Scons build system; Basically I have to add -MJ myfilename.o.json to every build command. I am currently building a Library with multiple sources files like this : library = env.StaticLibrary(target=result_path + '/' + result_name, source=sources)

基本上到最后我应该拥有: clang ++ -target x86_64-pc-windows-gnu - MJ AABB.o.json -o src / core / AABB.o -c -m64 -g -O3 -std = c ++ 14 -Wwrite-strings -I。 -I / c / GodotLibraries / godot_headers -Iinclude -Iinclude / core src / core / AABB.cpp

Essentially at the end I should have : clang++ -target x86_64-pc-windows-gnu -MJ AABB.o.json -o src/core/AABB.o -c -m64 -g -O3 -std=c++14 -Wwrite-strings -I. -I/c/GodotLibraries/godot_headers -Iinclude -Iinclude/core src/core/AABB.cpp

在此先感谢,

`

推荐答案

您正在尝试为当前构建环境。这是通过将新标志附加到正确的 environment变量来完成的。根据要使用的构建过程(= Builder ),相应的单个构建操作(= Actions )可能使用不同的变量。 用户指南包含附录A构造变量,其中列出了默认变量及其提要。

You are trying to set special compiler flags for your current build environment. This is done by appending the new flags to the correct environment variable. Depending on what build process (=Builder) you want to use, the corresponding single build actions (=Actions) might use different variables. The User Guide contains an Appendix A "Construction Variables", listing the default variables and their synopsis.

在您的情况下, CCFLAGS 是相关的,可以这样使用:

In your case the CCFLAGS is relevant and can be used like this:

env = Environment()
env.Append(CCFLAGS=['-MJ','AAB.o.json','-m64','-g','-O3'])

env.Program(...)

以同样的方式,通过设置<$,可以使 SCons 使用 clang 编译器c $ c> CXX 变量:

In the same way you can make SCons use the clang compiler, by setting the CXX variable accordingly:

env = Environment()
env['CXX']='clang'
env.Append(CCFLAGS=['-MJ','AAB.o.json','-m64','-g','-O3'])

env.Program(...)

我希望这能让您获得 SCons Builder / Action 设置背后的一般思想:每个 Build的已执行命令的基本结构始终相同er ,但是您可以通过设置和覆盖已扩展的环境变量来影响最终输出。

I hope this lets you get the general idea behind the Builder/Action setup in SCons: The basic structure of the executed command is always the same for each Builder, but you can influence the final output by setting and overwriting those environment variables that get expanded.

这篇关于骗局使用Clang -MJ选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆