-
Notifications
You must be signed in to change notification settings - Fork 421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Declare extra dependencies of Lean files #2762
Comments
How would this help? Lake needs to know the dependencies of files before it elaborates them to see if they have changed in order to determine whether to rebuild the dependent. I do not see what good learning about them afterwards would do. |
Shake can do that. The standard example of compiling a C file looks like this: "_build//*.o" %> \out -> do
let c = dropDirectory1 $ out -<.> "c"
let m = out -<.> "m"
cmd_ "gcc -c" [c] "-o" [out] "-MMD -MF" [m]
neededMakefileDependencies m That is, Shake only learns of the dependencies after building. Just like |
@gebner I'm not saying it is impossible to record such information. I am just not sure what the use of doing so is. That is, what would you like Lake to do with this information? |
I think the ultimate goal is clear: One option, which the submitter of leanprover/lake#58 probably had in mind, is to record the referenced files while Lean is running. And then have Lake check those recorded dependencies when running There are of course also other options, like to manually list the dependencies in the lakefile. |
Ah, are you saying that if I didn't realize that! I think I was mistakenly thinking that the goal was to determine the dependency chain without ever elaborating |
I would also find this feature very useful. We are using |
Yes, this is precisely what I meant. |
Btw, while it would great if the Lean file itself could declare its extra dependencies in elaborators, for widgets it would be a sufficient stopgap if we could specify in the |
@Vtec234, I should note that your need and @gebner's feature request are actually different. In your example, you need to specify dependencies to build before the library's modules are elaborated. The feature request here is to specify additional dependencies after the module has been elaborated. Both of these can be accomplished in a relatively straightforward manner in a custom target. A pre-build dependencies is done use |
@tydeu thank you for looking into this! The two feature requests you point out roughly correspond to my two messages above, which are indeed different. For widgets, specifying dependencies before elaborating the library suffices, although doing so after would be nice and convenient, since we could do it in the relevant Lean file rather than in the I am afraid I don't understand your proposed solution though. In my example, I am not sure how to "get hold" (I mean obtain a variable) for the |
And thank you for your reply!
I am sorry, but I do not understand what you are saying here at all. |
In short, I'd like to tell Lake somehow that the target for |
Ah, I was suggesting new features, not ones present in Lake at the moment (at least outside fully custom targets). The only declarative example at the moment is the |
Lean files can use elaborators that read files at compile time. For example
include_str
in doc-gen4 reads the specified file during compilation and inserts the file's contents as a string literal. TheBase.lean
file contains this:If
static/style.css
changes, thenBase.lean
needs to be recompiled.leanprover/lake#58 suggested adding an environment extension which stores the referenced files. Then
include_str
would add the filename to the environment extension. Lake could then read the referenced files from the.olean
file, which contains the serialized environment extension.The text was updated successfully, but these errors were encountered: