-
Notifications
You must be signed in to change notification settings - Fork 63
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
FileConfig cleanups #978
FileConfig cleanups #978
Conversation
This enables removing the dependency on context from FileConfig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not check this thoroughly, but on a spot check, all looked good to me. It's a big improvement! Except that it looks like there is a compile error with packaging Epoch... Also, this seems to be causing test failures with serialization (again, they look like compile errors).
I didn't notice the test failures. These need to be fixed before merging.
As far as I can see, this should be ready to be merged. I also added this PR to the 0.1.0 milestone. Given that there are no major concerns by reviewers, we should be able to merge this for 0.1.0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a sensible choice to factor out all the static methods of FileConfig
into a separate FileUtil
class. There are some methods that ended up in CUtil
, however, which seem out of place there.
* @param directory String representation of the director to search in. | ||
* @return A Java file or null if not found | ||
*/ | ||
public static Path findFile(String fileName, Path directory) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this moved to CUtil
? I don't see what's C-specific about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method is only used by the C generator and the file lookup strategy seems to be very specific to the assumptions that the C generator makes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What assumptions are those? The employed strategy seems rather generic.
* version do not accidentally get executed. | ||
* @param fileConfig | ||
*/ | ||
public static void deleteBinFiles(FileConfig fileConfig) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This, too, doesn't look C-specific to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this function is only used by the C-generator. Honestly, I don't quite understand what it does, but it seems to make various assumptions as to where files are placed and how they are named. Hence, I figure it will not be easily applicable to other targets. I also don't quite understand why it is needed since we have methods for cleaning up the entire bin dir.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the function is "quarantined" here with the eventual goal of eliminating it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also see my comment in the main thread. I don't know the C Generator well enough to understand what this method does, why it is needed, and whether it can be eliminated. I only know that the other generators don't use it ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method implements a simple functionality that all targets should implement: If a code generation or compilation fails for a program Foo.lf, then there should be no binary file bin/Foo. If there is, it is a bug. If the other targets don't implement this, then it is a bug.
My goal is to make FileConfig and FileUtil classes focus on one specific task each. FileConfig provides details about where certain files should be located and is meant to configure the generators. FileUtil provides generic static methods for file system access (including access to files and directories in jars or bundles). By generic FS access I mean operations like writing a file, deleting a file/directory or copying a file/directory. The two methods in CUtil don't fit the scope of either of those classes. They are not configuration related, and they don't provide generic filesystem access. Instead, they implement very specific algorithms. These algorithms are intervened with the code generation process (delete bin in fact analysis the resource contents and deletes files where it assumes the generator has placed them, findFile makes assumptions as to where the source files for the compilation are located). Therefore, I argue that the methods should be placed in |
Yes, I'm fully on board with this.
I understand. We can leave them in |
I think currently we don't support the files property outside the C-based targets. I am not sure how useful it would be for the other targets. For C++, it only adds redundancy but no new functionality. But yes, we can and should discuss this elsewhere. |
This PR cleans up FileConfig which currently seems to mix a variety of concerns. Despite some other simplifications and cleanups, it factors out functions that are purely related to file system access to a new static class FileUtils.
Note that this branch is based on #971 and hence include it's changes. The diff should clear up once #971 is merged.