ipbus / ipbb

IPbus Builder Tool
GNU General Public License v3.0
12 stars 12 forks source link

Fail dependency parsing in case of undefined variables #208

Open jhegeman opened 2 days ago

jhegeman commented 2 days ago

In case an undefined variable is used in a dependency file, the current implementation of generate-project stumbles on, after showing a somewhat cryptic warning message.

This fix makes sure that parsing fails, and ipbb aborts with a clear message about parsing errors, showing the exact lines, as well as a message about which variable is undefined.

I discovered this, because I had a bug in my dependency files that led to an undefined variable being used in a conditional in a dependency file. IPBB's generate-project step produced a somewhat cryptic warning:

[13:04:28] WARNING: components/tcds2_link/firmware/cfg/tcds2_link_speed_select_10g.d3:4                                                                                                                                              _fileparser.py:312
           'tcds2_link_speed' is already defined with value '{}'. New value will not be applied ("10g").

and then stumbled on (with some missing dependencies, indeed).

This fix changes the behaviour into:

$ ipbb vivado generate-project
WARNING: dep parsing errors detected
ERROR: Project 'dth400_p1v1_tcds_nodeemu' contains 2 parsing errors.
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ dep file                                                                  ┃ line                                                                   ┃ error                                                            ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ cms-tcds2-firmware/components/tcds2_link/firmware/cfg/tcds2_link_pkg.d3:6 │ '? tcds2_link_speed == "5g" ? src tcds2_link_speed_choice_pkg_5g.vhd'  │ Parsing directive failed: name 'tcds2_link_speed' is not defined │
│ cms-tcds2-firmware/components/tcds2_link/firmware/cfg/tcds2_link_pkg.d3:7 │ '? tcds2_link_speed != "5g" ? src tcds2_link_speed_choice_pkg_10g.vhd' │ Parsing directive failed: name 'tcds2_link_speed' is not defined │
└───────────────────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────────────────────┴──────────────────────────────────────────────────────────────────┘
Aborted!