How to force scons to generate binary file with .bin extension?

让人想犯罪 __ 提交于 2020-01-17 03:05:13

问题


I have the following sconstruct

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

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!


回答1:


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])

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.



来源:https://stackoverflow.com/questions/26833937/how-to-force-scons-to-generate-binary-file-with-bin-extension

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!