如何强制 scons 生成扩展名为 .bin 的二进制文件? [英] How to force scons to generate binary file with .bin extension?

查看:81
本文介绍了如何强制 scons 生成扩展名为 .bin 的二进制文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下 sconstruct

import glob
import os
for file in glob.glob("*.cpp"):
    Program([file])

我在 *nix 平台上使用它,所以 scons 会自动生成与源文件同名的同名可执行文件.我只是想知道如何强制它生成带有 exebin 扩展名的可执行文件?谢谢!

I am using this on a *nix platform so scons automatically generate executable file with the same name from the same name as the source file. I am just wondering how can I force it to generate executable files with a exe or a bin extension? Thanks!

推荐答案

附加到每个已创建程序的扩展名存储在环境变量PROGSUFFIX"中.您可以使用以下命令覆盖 Posix 系统下 "" 的默认设置:

The extension that gets appended to each created program is stored in the environment variable "PROGSUFFIX". You can override the default setting of "" under Posix systems with:

env = Environment()
env['PROGSUFFIX'] = '.bin'    # or env.Replace(PROGSUFFIX='.bin')
for file in Glob('*.cpp'):
    env.Program([file])

注意,我在这里不使用 Python glob.glob(),而是使用 SCons 版本的 Glob().后者的优点是它也会找到生成的 CPP 文件,这些文件可能在物理上尚不存在.

Note, how I don't use the Python glob.glob() here, but the SCons version Glob(). The latter has the advantage that it will find generated CPP files too, which might not exist yet physically.

这篇关于如何强制 scons 生成扩展名为 .bin 的二进制文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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