- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
这是 my project在 github 上。
这是我的 SConstruct 文件:
SConscript('main.scons', variant_dir = 'build', duplicate = 0)
这是我的 main.scons 文件:
import sys
import os
import fnmatch
def find_source_files(directory, ext = "cpp"):
matches = []
for root, dirnames, filenames in os.walk(directory):
for filename in fnmatch.filter(filenames, '*.' + ext):
matches.append(os.path.join(root, filename))
return matches
if __name__ == '__main__':
for f in find_source_files('src'):
print f
else:
Program(target = 'main.bin', source = find_source_files('src'))
这是我运行时得到的结果:
bitcycle @ cypher ~/git/IeiuniumTela $ find $(pwd) -name "*.bin" -or -name "*.o" -exec rm {} \;; scons; find $(pwd) -name "*.bin" -or -name "*.o"
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
scons: building associated VariantDir targets: build
gcc -o build/main.bin
gcc: fatal error: no input files
compilation terminated.
scons: *** [build/main.bin] Error 4
scons: building terminated because of errors.
这是当我运行 `python main.scons' 来测试它时发生的事情:
bitcycle @ cypher ~/git/IeiuniumTela $ python main.scons
src/main.cpp
我很难理解为什么它找不到我的源文件。这里有什么建议或想法吗?
[更新] 从邮件列表中获得一些好的指导后,我发现这对我来说“足够好”。
/SConstruct:SConscript('src/main.scons', variant_dir = 'build', duplicate = 0)
/src/main.scons: 程序(target = 'main.bin', source = Glob('*.cpp'))
请参阅 github 存储库以获取完整的源代码树。为了完整起见,我还在 repo 中添加了一个空的构建目录。我觉得有趣的是:
一个。在这个用于发现源的构建工具的上下文中,SCons 的 Glob 版本不是递归的。我希望递归发现选项是首选。 :(
我需要将 scons 文件放在与源文件相同的目录中(这很烦人)。
打印语句显然有效,但 sys.stdout.write 无效(来自 python 模块)。
最佳答案
会不会是因为你的main.scons
文件已经在src
目录下了,而你的find_source_file
其实是在搜索src/源
?当我将 scons 文件移动到顶级目录时,它为我找到了源代码。
更新:经过调查,variant_dir
将工作目录设置为 build
,因此您的 find_source_files
会在 build/src
中查找文件,并且什么也没找到。从 SConstruct 文件调用 find_source_files
或在 main.scons 中使用 VariantDir()
可能会更好。
关于c++ - 为什么scons找不到我项目的源文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15328995/
我正在为 scons 扩展一个命令,但来源不完整。一些 xml pdf 文档不存在。 根据 scons wiki,我可以使用scons -i (--ignore-errors,忽略为重建文件而执行的命
在构建我的程序时,区分不存在的文件和空文件很重要。但是,scons 似乎对它们一视同仁,并且在源文件从这些状态之一更改为另一种状态时忽略了重建目标。 逐步示例: 第 0 步: 构造 foo = Com
我正在使用 scons 构建两个项目。一个效果很好,而另一个(更复杂的)项目非常令人沮丧。这是我在为第二个项目运行 scons 时看到的: S time scons scons: Reading SC
我最近从 make 转换为 SCons。我通常在 make 中做的一件事是有一个从源文件生成预处理源的方法,其中包含将应用于正常构建的所有编译器选项。这对于确定 header 的包含方式很有用。 在
我有一个使用 scons 构建的大型 C++ 项目。 它的构建速度很慢,我想进行一些更改以使其构建速度更快。 现在我想集中我的时间来加速构建中最慢的部分。 如何确定哪些文件需要最长的编译时间? 最佳答
我想对所有 .o 做一些后期处理文件(例如由 Object 或 StaticObject Builders 生成的文件),无论用户使用什么 Builder。 我试图像这样“覆盖”或“ Hook ”基础
更新作为构建一部分的文件内容的正确 SCONS 方法是什么? 我使用 SCONS 来构建一个相当大的项目。但是为了一个简单的问题,假设它看起来像这样: env.Program("foo", ["foo
我不想使用 scons --n,我想看看某些东西是如何构建的,而不是现在如何构建。 我认为它可以以某种方式使用 .sconsdblite。 有人做过吗? 最佳答案 SCons man pages解释了
我正在尝试让 SCons 检查我需要的 git 存储库(并希望使该存储库保持最新状态)。问题是我必须告诉它 git repo 包含哪些文件才能在构建中使用它们,如果我这样做,SCons 将在尝试克隆它
我需要作为自定义构建器的一部分按顺序运行两个程序。 其中一个程序我被困住了,无法处理绝对/相对路径,因此我必须使用构建器的 chdir=1 选项才能运行其操作与目标位于同一目录中。 第二个是位于项目的
我正在尝试建立一个涉及代码生成器的构建系统。在生成器运行之前,生成的确切文件是未知的,但我希望能够通过模式匹配运行进一步的构建步骤(在具有某些扩展名的所有文件上运行一些程序)。这可能吗? 这里涉及代码
我有一个简单的项目构建系统,我使用SCons将其组合在一起。 。该项目有相当多的源文件,我认为在构建过程中显示某种进度信息将是用户友好的。 SCons 提供了诸如 CXXCOMSTR 之类的构造变量,
我正在为不同的编译器使用 scons。vc10 和瑞萨编译器。如果我使用 env.program(---) 编译程序,我得到的链接标志为 “链接/nologo/subsystem:console/pd
我有一个分层构建,它使用 SConscript 递归地声明构建目标;所以我事先不知道目标。每个构建都会产生一些额外的文件,比如 *.err *.out ,这些文件不在目标中。当我运行 scons -c
我正在使用 scons 来构建一个项目。效果很好。但是我们的构建命令只是将结果输出到标准输出,我需要让它对我们的软件团队更有用一点。 以下是我想要的行为,按优先顺序排列。有人可以帮我实现它们吗? 没有
我的团队正在创建一个基于 SCons 的构建系统。我们在自己的 site_scons/site_tools 文件夹中创建了一堆辅助类。 我的任务是使用 pyunit 在我们的代码上创建和运行测试。测试
我有一个自定义构建器如下 my_builder = Builder(action = ['mytool' + env['TESTFLAG'] + ' $SOURCE -o $TARGET')],
我有一个仅包含头文件的库,其中包含一个文件夹层次结构和一堆 .hpp我想安装的文件。我的问题是,该 scons 不会将该文件夹复制到构建文件夹中。 这是我的目录布局的样子: root SConst
我正在使用 scons 为一个较大的软件项目实现构建系统。有一个目录结构将各个库和程序的代码分离到它们自己的目录中。使用我们现有的 make 系统,我可以在单个程序目录中执行“make clean”,
默认情况下,SCons 似乎会查看用于构建程序的“配方”并从中提取隐式依赖项。例如假设我的 SConstruct 包含: Command('foo', 'foocreator.py', '/usr/b
我是一名优秀的程序员,十分优秀!