Skip to content
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

Remove generated files before build and detect modified files #48

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

salkinium
Copy link
Member

This enhances the lbuild build and lbuild clean commands to detect modified generated files before deletion, via modified timestamp comparison (and content hash as backup) in the buildlog. The commands fail if a modification is detected and users can lbuild clean --force to clear them by force.

TODO:

  • Implement content change detection in buildlog
  • Clean before building to remove files from previous configuration
  • Testing

Fixes #33.

cc @dergraaf @WasabiFan

@salkinium
Copy link
Member Author

Example errors:

Screenshot 2019-10-24 at 15 58 21

Screenshot 2019-10-24 at 15 58 42

@WasabiFan
Copy link

Nice!

If I am using source control and don't check in the build log, how will this behave?

@salkinium
Copy link
Member Author

If I am using source control and don't check in the build log, how will this behave?

Screenshot 2019-10-24 at 19 18 32

There used to be an option to generate a buildlog via silently simulating a build on the current config and then use that for deletion. However, that cannot detect any content changes and it's a fragile solution anyways.

@salkinium
Copy link
Member Author

If there is no build log, then lbuild build will simply overwrite your files again, but it cannot remove the unnecessary ones. It's best to commit the build log too, but perhaps it could be made a little slimmer? This is currently not using source and module file hashes or build time.

@WasabiFan
Copy link

My initial reaction is to oppose checking in the build log. That being said, it isn't an educated opinion, it's rather just based on patterns I usually follow. My main reasoning is that the build log would be a single point of failure for collaboration, as if multiple people added modules when implementing their own features then tried to merge together, I imagine it would be easy to "break" the file (i.e., either render it unparsable or make it not match reality).

For my project at least, I'd probably prefer to wipe out the generated files and regenerate them all from scratch each time, but I also don't yet have any custom modifications to modm and don't know how that would work. In the past, the way I've preferred autogen systems to work is that they're a pure map of config -> code without any state, so it's harder to mess it up or get into an inconsistent state.

@salkinium
Copy link
Member Author

multiple people added modules when implementing their own features then tried to merge together, I imagine it would be easy to "break" the file

Hm, though you may have merge conflicts in the generated code too, since wildly different modules/options can still change the same code location. But I get your point, one less file to worry about.

a pure map of config -> code without any state

That's a good point. It is possible to simulate the build and get the buildlog from that, however, only if the config still corresponds to config used for generating the files.

I'm kinda just looking for a "build receipt" of sorts, simply copying the project.xml config to project.xml.backup would suffice, however, you'd need to simulate a full build everytime you call, which can be annoying. I think I'll wait until I've implemented #37 and then see what the resulting capabilities of lbuild are and what information is really required, and what is derivable from config.

@WasabiFan
Copy link

I'm kinda just looking for a "build receipt" of sorts, simply copying the project.xml config to project.xml.backup would suffice, however, you'd need to simulate a full build everytime you call, which can be annoying

You could view this a bit differently -- think of it as including an inventory in the build output. Rather than a backup, it's the same information encoded as part of the output rather than the input.


Separately...

The build log has a strange mix of stuff. Some of it is like a manifest of the module contents, while other parts are actual log info (such as the build time). It would be helpful if it were made into just the former, so it was more conducive to version control if that's the goal. If it were both small and deterministic/consistent, that would make versioning it better.

Something to think about: as far as I can tell, most of this is about trying to support modifications to generated code. Some possible larger changes to the design/model which you could consider:

  • Replace the build log with a module-level hash of the contents. Check the contents against the hashes to know what must be re-built. This would a) shrink that file and b) make it less weird.
  • You could have a new way to mark (in the project file) modules or individual files which shouldn't be auto-generated. Overwrite everything else.

@salkinium salkinium force-pushed the develop branch 2 times, most recently from 843ad2b to 5a8d54f Compare July 10, 2021 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Remove previously build files when configuration changes
2 participants