ID:1575742
 
(See the best response by DarkCampainger.)
Problem description:

So basically, there is this event scheduling library floating about https://github.com/BYOND/event-scheduling that's basically aimed at allowing more flexible versions of spawn(), where you can cancel them, repeat tasks neatly etc.

There is also a fairly nice logging library from Keeth and Koil https://github.com/BYOND/log4dm that splits logs into levels, log4j style.

What I'd essentially like to do, is use the log4dm library in the event-scheduling library, as it's useful for debugging and offers that debugging forward to the library's userbase.

However I don't particularly want to /mandate/ the dependency. It seems fairly reasonable to me that you'd be entirely not bothered by log4dm, and just want the event scheduling. As BYOND doesn't seem to download dependencies for libraries (or for the 5th year running, I've overlooked this feature, which is a great possibility also), you kind of end up needing to download a dependency yourself, that you don't especially want or need.

So what I'm looking for, is some means of making that dependency optional, making the library usable out of the box, as it were.

My current thoughts are, the log4dm library is such that you could define an empty set of objects matching the types seen in the library, and this would satisfy the compile-time dependencies event-scheduling would have. However, I think DreamMaker would still complain about being unable to resolve the log4dm import, so you'd need some way of resolving that, that ... didn't also just stop the actual library being imported if present.

Thoughts?

This should be able to be satisfied by pre-processors. You can make the calls to these functions wrapped in pre-proccssors causing them not to be added, or you can create the empty set of objects if you would rather.

#define logActions 0

#if logActions != 0
#include <user\libary\project.dme>
#endif
The issue there is that it's very dependent on library naming to work, I think? Or are what you are suggesting is the user of event-scheduling "turns on" logging in their DME, essentially?

What I would've preferred, is the simple inclusion of log4dm in their project enables that functionality. Which basically implies log4dm provides the #define. The issue with that though, is in the user of event-scheduling's DME, log4dm would need to come before, I think?
I was indeed suggesting off by default, on by user preference.

You're correct, it would be very order dependent for compile time. Sounds like what we would need is a warn only option for include, which I don't believe is possible right now.
Best response
Stephen001 wrote:
As BYOND doesn't seem to download dependencies for libraries (or for the 5th year running, I've overlooked this feature, which is a great possibility also), you kind of end up needing to download a dependency yourself, that you don't especially want or need.

I'm not sure if it's documented anywhere, but if you include a file named "include.txt" in the base directory of your library, with the names and versions of the dependencies, BYOND will automatically download them. I'm not sure if the versioning does anything, or is just for documentation, though (it's not like it could download the older version?).

You can see this in a lot of Deadron's libs. Here's an example from his PathFinding library:

include.txt:
Deadron.BaseCamp version=23
Deadron.EventLoop version=9
Deadron.Geography version=1
That mythical incantation will work for me, I think.

The bulk of the reasoning for making the dependency optional was purely to resolve that apparent lack of automatic download. I'll have to try it out, see how it goes.

Cheers.