文学编程:一次性从源代码中提取并运行脚本的工具?
我刚刚开始阅读有关文学编程和 noweb
- 我找到了它很有趣。据我了解,“notangle”步骤是从文字编程(源)文件中提取(机器)源代码(文件)的步骤。
在这里,我对一个特定方面感兴趣:我希望能够一次性提取多个源文件(在 notangle
步骤中),包括一个执行脚本 - 并在同一步骤中运行执行脚本!
bash 中的示例如下所示:
#!/usr/bin/env bash
# file: test.c.gdb.sh
# generate C source file
cat > test.c <<"EOF"
#include "stdio.h"
int main(void) {
return 0;
}
EOF
# generate gdb script file
cat > test.gdb <<"EOF"
break main
run
EOF
# run the 'execution script'
gcc -g -Wall test.c -o test.exe
chmod +x test.exe
gdb -x test.gdb -se test.exe
重点在于,我可以从 shell 调用 './test.c.gdb.sh
',然后我就可以获得源代码生成文件,然后编译,然后让调试器自动启动。
是否有一个有文字的编程工具,可以在 notangle
步骤中允许类似的事情?
预先感谢您的任何答复,
干杯!
I just started reading about literate programming and noweb
- and I find it quite interesting. As far as I understand it, the 'notangle
' step is the one that extracts (machine) source code (file), from the literal programming (source) file.
Here, I'm interested in one specific aspect: I would like to be able to extract multiple source files in one pass (in the notangle
step) , including an execution script - and run the execution script in the same step!
An example in bash would look something like this:
#!/usr/bin/env bash
# file: test.c.gdb.sh
# generate C source file
cat > test.c <<"EOF"
#include "stdio.h"
int main(void) {
return 0;
}
EOF
# generate gdb script file
cat > test.gdb <<"EOF"
break main
run
EOF
# run the 'execution script'
gcc -g -Wall test.c -o test.exe
chmod +x test.exe
gdb -x test.gdb -se test.exe
The point in this, is that I can just call './test.c.gdb.sh
' from the shell, and I'll have the source files generated, then compiled, and then have the debugger started automatically.
Is there a literate programming tool, that would allow something like this in the notangle
step?
Thanks in advance for any answers,
Cheers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
人们有时会使用 make、ant、scons 或 maven 来处理此类事情。
“单一”魔法命令无法很好地覆盖很多基地。因此,这需要外部工具来完成。
通常,最终报告或文档需要通过各种 LaTeX 工具进行复杂的多步骤处理。这也可能需要一个简单的构建脚本或工具设置。
Folks sometimes use make, ant, scons or maven for this kind of thing.
A "single" magical command can't cover very many bases very well. So it's left to external tools to do this.
Often, the final report or document requires complex, multi-step processing through various LaTeX tools. This, too, may require a simple build script or tool setup.