简体   繁体   English

调试Sconscript文件蚀

[英]Debug Sconscript file eclipse

I have python project that is already built based on Scons. 我有已经基于Scons构建的python项目。

I am trying to use Eclipse IDE and Pydev to fix some bugs in the source code. 我正在尝试使用Eclipse IDE和Pydev修复源代码中的一些错误。

I have installed Eclispe Sconsolidator plugin. 我已经安装了Eclispe Sconsolidator插件。

My project is like below Project A all source codes including Sconscript file which defines all the tager, environmet etc. 我的项目就像项目A下的所有源代码一样,包括定义所有标记,环境等的Sconscript文件。

Eclipse provide me with Add Scons nature to the project. Eclipse为我提供了项目的Add Scons性质。 Once added the Scons automatically picks up my Sconscript file and executes. 添加后,Scons会自动获取我的Sconscript文件并执行。

== Running SCons at 10/28/13 1:59 PM ==

Command line: /opt/gcdistro/app/scons/2.3.0/bin/scons -u --jobs=16

scons: Reading SConscript files.

I want to know how can I place breakpoints in some of the .py files that is a part of my project which Scons is executing. 我想知道如何在Scons正在执行的项目的一部分.py文件中放置断点。

It may be difficult to debug a SCons project. 调试SCons项目可能很困难。 What you have in a SConstruct or SConscript python script is only one part of a bigger picture. 您在SConstruct或SConscript python脚本中所拥有的只是大局的一部分。 SCons builds in a multi-step manner, first it reads the scripts and builds its trees, then it analyzes those trees and only builds what is necessary to build. SCons以多步骤的方式构建,首先读取脚本并构建其树,然后分析这些树,然后仅构建需要构建的树。 So, you'll probably only be able to debug the declarative part that is the reading of the python scripts. 因此,您可能只能调试声明部分,即读取python脚本。

Try debugging it like you would any other python program, but I doubt you'll get very far. 像其他任何python程序一样尝试调试它,但是我怀疑您会走得很远。

After a bit of struggle I was able to find answer to my question. 经过一番挣扎,我能够找到问题的答案。 Since SCons is a python module by itself, it is possible to debug it in eclipse using PyDev. 由于SCons本身就是一个python模块,因此可以使用PyDev在eclipse中对其进行调试。 This is not the most optimal solution I wanted but was the closest. 这不是我想要的最佳解决方案,而是最近的解决方案。

Step 1: I disabled the Eclipse SCons nature of the project. 步骤1:我禁用了项目的Eclipse SCons特性。

Step 2: Created a main file that will do the same function of SCons but instantiate the python object of the SCons main function. 步骤2:创建一个主文件,该文件将执行SCons的相同功能,但实例化SCons主函数的python对象。

Step 3: Set the breakpoints in my script where wanted and it was able to execute it. 步骤3:在脚本中的所需位置设置断点,并且该断点能够执行该断点。

import os
import sys

if __name__ == '__main__':
    sys.path.append('/gpfs02/gcdistro/app/scons/2.3.0/engine/')
    sys.path.append('/gpfs02/gcdistro/app/scons/2.3.0/bin/')
    sys.path.append('/gpfs02/gcdistro/app/scons/2.3.0/engine/SCons/')
    import SCons
    from SCons import Script
    Script.main()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM