Setting Up PyCharm for Debugging Waf
Setting Up PyCharm for Debugging Waf
AZ Code Generator is in preview release and is subject to change. |
PyCharm is an integrated development environment for Python which includes a graphical debugger that is useful for debugging Waf.
To set up PyCharm and Waf for debugging
Download PyCharm Community Edition .
Start PyCharm.
At the welcome screen, choose Open Directory.
Navigate to the
lumberyard_version\dev
directory. There should be a file calledwscript
andwaf_branch_spec.py
under this folder.Configure the Python interpreter.
Choose File, Settings, Project:dev, Project Interpreter to open the project interpreter page.
Click the gear
icon on the right of the Project Interpreter and choose Add....
Select the Existing environment radio button, and then click the ellipsis (...) icon to the right of it.
Navigate to the folder containing the
python
executable. The executable will be contained under the pathlumberyard_version\dev\Tools\Python\3.7.5\platform
, with the exact path depending on your platform. The Python executable file must be in the same folder as the project or you may have issues running Waf.
Set up a debugging profile for Waf.
To set up Waf for debugging, use the project explorer in the left pane. If you don’t see the project explorer, press Alt+1). Navigate to the
\dev\Tools\Build\waf-<version>
node and expand it. You should see a file calledlmbr_waf
inside this node.Right-click lmbr_waf and choose Create lmbr_waf Note
The Indexing... operation must finish before the option appears. You can verify status in the bar at the bottom.In the Create Run/Debug Configuration dialog, ensure that the following values are configured correctly:
- Allow parallel run should be unselected.
- Parameters is the command to use to run Waf for the run/debug session.
- Python Interpreter should be the interpreter that you specified earlier.
- The Working directory must be the
dev
directory.
Set up
wscript
files as debuggable Python files. Waf uses files calledwscript
to define the build rules per project. These are dynamically loaded Python modules that can be debugged like any other Python module.Choose File, Settings, Editor, File Types.
Choose Python in Recognized File Types. Select the + icon to the right of the Registered patterns section to add a new file type.
Under Registered Patterns, click the green plus sign (+).
In the Add Wildcard dialog box, enter wscript.
Turn off IncrediBuild.
Open the
_WAF_/usersettings.options
file.Verify that
use_incredibuild = False
(Optional) Enable file outlining. This feature makes it easier to navigate source files.
To enable file outlining, right-click the Project tab and choose Show Members.