#207 Only write out files when they've changed

4.0
closed
nobody
Code (121)
5
2013-12-09
2012-03-07
Anonymous
No

Currently running premake twice on the same input will cause the project/solution files to be written twice. It would be nice if these files were only written if they'd changed since they were last generated.

This should help when using Visual Studio as it doesn't always cope with reloading solutions correctly (in my experience it mostly just crashes). This means I have to remember to close it before running premake, which is a bit of a pain if only a single project has changed (VS can usually cope with reloading projects better than it can cope with reloading solutions).

Discussion

  • dmail
    dmail
    2012-03-07

    How would you propose premake decides on if the premake file has changed? It could simply do a md5 (or another algorithm) on the source; yet the file may have changed but not for the configuration you are running.

    I would think a better solution would be to implement [1] for deterministic GUIDS if that solves the problem. I have seen a number of people who have said this is a problem when using VS10 yet I have still not seen it myself, maybe you could attach a premake script which shows this problem?

    [1] https://sourceforge.net/tracker/?func=detail&aid=3494262&group_id=71616&atid=531881

     

  • Anonymous
    2012-03-09

    I already specify GUIDs for my projects so that my user settings are correctly preserved when regenerating projects.

    I'm a little confused by your comment about whether you're talking about the premake file (the input premake.lua file), or the output files generated by premake. I was referring to the output files in my original report.

    How do you check if an output file has changed? Well as you said, you could use an MD5 but that would require you to store the MD5 somewhere so you could compare it the next time premake was run. An even simpler solution would just be to compare the data you were going to write to the file against the current state of the file to see if they match, so just:

    1) Generate the new data for the file
    2) Read in the current contents of the file
    3) If the current contents match the new contents, do nothing; otherwise if the contents don't match, or the file doesn't yet exist, write out the new file.

    That would mean that Visual Studio would only have to reload the projects that had changed, rather than always having to reload everything.

     
  • dmail
    dmail
    2012-03-09

    "I'm a little confused by your comment about whether you're talking about
    the premake file (the input premake.lua file), or the output files
    generated by premake. I was referring to the output files in my original
    report."

    I was thinking about the input files yet I suppose the output would work if generated projects are not changed by loading into VS (I do not know if this is the current situation).

    "That would mean that Visual Studio would only have to reload the projects
    that had changed, rather than always having to reload everything."
    As I have said previously I have never seen this error but it would seem you are suggesting that projects changing is the problem not solution files?
    Can you attach a simple premake script and what change is needed to generate the error, as I would think Starkos would find that helpful?

     

  • Anonymous
    2012-03-09

    Any premake script would exhibit this behaviour. I should point out that because I use file globbing, when I want to regenerate my projects I run premake externally to Visual Studio.

    1) Run premake.
    2) Open the generated solution in Visual Studio.
    3) Run premake again.
    4) Visual Studio will reload all projects and solutions despite the fact that premake should have produced identical output both times it was run.

    As Visual Studio responds to files being changed on disk (even if they're the same), the only way to stop Visual Studio pointlessly reloading things that haven't changed is to not overwrite the files on disk if the new and old contents are the same.

    I realise this is a bit of an esoteric request as I could just not run premake when I know things haven't changed, but I have a script that syncs various things, and then generates some C++ code, before finally running premake. I'm currently unable to run this script (to do the syncing part) while Visual Studio is debugging my application as the premake step would cause Visual Studio to try and reload stuff, which is a pretty fatal thing for it to try and do whilst debugging.

    So as I said, I could just not run premake in this case, but the fact that it always regenerates everything when it's run has been bugging me for ages, so I figured I'd raise it as a bug anyway.

     
    Last edit: Anonymous 2014-08-06
  • starkos
    starkos
    2013-12-09

    • status: open --> closed
    • Group: --> 4.0