CompileAll uses alphabetical ordering only?
Hello.
We're trying to create a script that compiles everything on a certain namespace, for that we are depending on CompileAll. However it seems that this method doesn't check for a dependency tree even when using flags like: curb.
Due to its apparent alphabetical nature, classes that come first but depend upon classes that come later fail to compile because their object still doesn't exists. Example:
Suppose we have to compile a class in which its name starts with A and it has a Parameter which contains an expression that calls for B.
In this case, A would fail to compile because B is not compiled.
We only found one way to bypass this issue, that's providing each package by using CompilePackage instead. This method allows us to not only selectively provide which packages to compile, but also the ordering. However we wanted to use CompileAll due to its flexibility.
So my question is: is there a way to force the CompileAll to respect the dependency tree?
Compiler does build dependency tree. If you encounter some kind of the issue where your classes are not compiled in a correct order you might open a WRC ticket.
Use DependsOn keyword to provide hints to compiler.
Other hint is CompileAfter keyword.
From the docs
so I always use DependsOn.
In addition to already mentioned options, System will help to organize compilation order. You can prioritize some kind of system classes, which by any case have to be compiled first. By using System, DependsOn, or CompileAfter, you can correctly organize your compilation order, CompileAll should work correctly with flags `ck-u`.
Examples where System is useful include when you have a set of classes that are used in compile-time tasks such as method generators and projection classes, as used by several InterSystems components such as BI cube definitions and NLP domain definitions. The Class Parameter expression example you describe is probably another example in the same category.
Thanks for everyone's suggestions. But we have opted for using CompilePackage while providing the method the argument dynamically by using envs.