防止SCons寻找标准工具 [英] Prevent SCons from looking for standard tools

查看:97
本文介绍了防止SCons寻找标准工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在设置SCons以与Windows作为主机OS进行交叉编译。我正在为交叉编译器构建自定义的 Environment ,但是SCons每次启动时都坚持要查找Visual Studio(并打印一条警告,指出找不到它,因为我没有安装)。我可以阻止它寻找我不打算使用的标准工具吗?

I am currently setting up SCons for cross-compilation with Windows as the host OS. I am building a custom Environment for the cross-compiler, but SCons insists on looking for Visual Studio each time I start it up (and prints a warning that it cannot find it, because I don't have it installed). Can I prevent it from looking for standard tools I know I am not going to use?

推荐答案

至少有两种方法可以执行此操作,第一种是最简单的方法,尝试创建指定编译器的环境,如下所示:

There are at least 2 ways to do this, the first way is the easiest, try creating the environment specifying the compiler, as follows:

env = Environment(CC = '/path/to/the/compiler')

您可能还需要为链接器和其他工具添加路径。然后SCons不应该搜索它们。

You'll probably need to add paths for the linker and other tools as well. Then SCons shouldnt search for them.

另一种方法是使用 tools为交叉编译器创建工具定义CONFIGURATION FILE REFERENCE /www.scons.org/doc/HTML/scons-man.html rel = nofollow> SCons手册页,其中提到了以下内容:

Another way to do it would be to create a tool definition for the cross-compiler using the tools argument on the Environment() function as mentioned in the CONFIGURATION FILE REFERENCE section of the SCons man page, where the following is mentioned:

此外,可以使用一组特定的工具来初始化
环境作为可选的关键字参数:

Additionally, a specific set of tools with which to initialize the environment may be specified as an optional keyword argument:

env = Environment(tools = ['msvc','lex'])

非内置工具可以使用toolpath参数指定:

Non-built-in tools may be specified using the toolpath argument:

env = Environment(tools = ['default','foo'],toolpath = ['tools '])

...

工具列表的各个元素本身也可能是
两元素列表的形式(工具名kw_dict)。 SCons如上所述搜索工具名称规范文件
,并将
kw_dict(必须是字典)作为
工具的generate函数的关键字参数传递。生成函数可以使用参数
通过以不同方式设置
的环境或更改其初始化来修改工具的行为。

The individual elements of the tools list may also themselves be two-element lists of the form (toolname, kw_dict). SCons searches for the toolname specification file as described above, and passes kw_dict, which must be a dictionary, as keyword arguments to the tool's generate function. The generate function can use the arguments to modify the tool's behavior by setting up the environment in different ways or otherwise changing its initialization.

tools / my_tool.py:

def generate(env, **kw):
  # Sets MY_TOOL to the value of keyword argument 'arg1' or 1.
  env['MY_TOOL'] = kw.get('arg1', '1')
def exists(env):
  return 1

SConstruct:

env = Environment(tools = ['default', ('my_tool', {'arg1': 'abc'})],
                  toolpath=['tools'])

这篇关于防止SCons寻找标准工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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