Help debugging version hierarchies
A problem occurs when 2 versions of a package are included in a build tree (as can be seen by vimports).
When the bridge runs (or any function the model file places into dot), it can be hard to debug which version of the package is running.
(KenSchalk) I think the right answer to this is an SDL debugger.
To help debug these situations, how about the following. Starting with the .main.ves file, every level adds an entry to a hierarchy_comment binding, creating a reverse record of the hierarchy.
.main.ves
import some_file = some_file.ves; { # init . ++= [ hierarchy_comment = [ $(slash_to_under(_model_name(_self))) = 1 ] ]; }
bridge_wrapper.ves
from /vesta/xyz.com/some/path import bridges = mybridge/1; from /vesta/xyz.com/other/path import other_model/1; { . ++= hierarchy_comment = [ $(slash_to_under(_model_name(_self))) = ./hierarchy_comment ] ]; # descend the hier, passing ./hierarchy_comment res = other_model(); bridge_params = [ mybridge = [ command = "/my/path/tool", root = <"thing">, [ hierarchy_comment_bridge_wrapper = ./hierarchy_comment ], ] ]; // ... return [ bridges, bridge_params, component_models, ]; }
mybridge/build.ves
{ command = ./command; root = ./root; hierarchy_comment_bridge_wrapper = ./hierarchy_comment_bridge_wrapper; . ++= [ hierarchy_comment = [ $(slash_to_under(_model_name(_self))) = ./hierarchy_comment ] ]; mybridge(args){ _=if .!flags && ./flags!dbg_hier && ./flags/dbg_hier then { _=_print(["bridge imported via hierarchy" = ./hierarchy_comment]); _=_print(["bridge_loader imported via hierarchy" = hierarchy_comment_bridge_wrapper]); return -1; } else -1; // ... rest of bridge ... }; return [ mybridge, ]; }
Now the env_build() will create a ./mybridge/mybridge() function as it does normally, and setting . ++= [ flags/dbg_hier = TRUE]; will make that function print where it came from.
*NOTE* that this prints the invocation hierarchy, not the import hierarchy, which you can already get from vimports. Just because it gets imported doesnt mean it ever gets evaluated.
slash_to_under() is necessary because binding names which contain slashes are not handled correctly. Under the right circumstances (adding a cache entry which depends on them), they cause the evaluator to die with an assertion failure. There's a bug in the tracker about this.
slash_to_under() is left as an exerciser for the reader :)