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

Build outputs are infinitely recursively processed #1940

Open
1 of 13 tasks
artemking4 opened this issue Sep 2, 2022 · 9 comments
Open
1 of 13 tasks

Build outputs are infinitely recursively processed #1940

artemking4 opened this issue Sep 2, 2022 · 9 comments
Assignees
Labels

Comments

@artemking4
Copy link

What seems to be the problem?
When using custom rules, if a buildoutput happens to use the same file extension as the rule itself, premake gets into an infinite recursion loop and later dies with stack smashing(?).

What did you expect to happen?
I had expected premake not to compile already compiled files again. Though, something like that can be by design, i.e. you do .bmp>.png>.jpg, but not .png>.png>... (unless specified so)

What have you tried so far?
A dirty hack: create a file with a different extension and then copy it to the output directory.

How can we reproduce this?

rule "sampleRule"
    fileextension ".txt"

    -- buildmessage and buildcommands dont seem to matter
    buildmessage 'Copying %{file.relpath}'
    buildcommands 'cp %{file.relpath} new_%{file.relpath}'
    buildoutputs '%{file.basename}.txt'

workspace "sample"
    configurations { "Debug", "Release" }

project "sample"
    kind "Utility"
    rules { "sampleRule" }

    files { "**.txt" }

Keep in mind that for order for this to work you need to first have #1939 installed.
My premake script uses a required script and overrides the gmake utility project generator, so the version is still relevant, nothing is touched except that.

  • Visual Studio 2022 (vs2022)
  • Visual Studio 2019 (vs2019)
  • Visual Studio 2017 (vs2017)
  • Visual Studio 2015 (vs2015)
  • Visual Studio 2012 (vs2012)
  • Visual Studio 2010 (vs2010)
  • Visual Studio 2008 (vs2008)
  • Visual Studio 2005 (vs2005)
  • GNU Makefile (gmake)
  • GNU Makefile 2 (gmake2)
  • XCode (xcode)
  • Codelite
  • Other (Please list below)

What version of Premake are you using?
5.0.0-beta1

@artemking4 artemking4 added the bug label Sep 2, 2022
@nickclark2016
Copy link
Member

I mean, if it requires #1939 to be installed and it's currently not in master, I don't consider it a bug. That's an issue that should be worked out in #1939. If you can show it's an issue in other exporters, then that'll make sense for us to work it as a bug.

@artemking4
Copy link
Author

It is an issue in all exporters though, you can just change the project kind to ConsoleApp or similar to observe said behavior.

@nickclark2016
Copy link
Member

That is a project type. An exporter is Visual Studio, Gmake (not gmake2), xcode, etc.

@artemking4
Copy link
Author

Well, my pull request does not modify anything other than gmake2's utility project type. And as i said, this can be observed in gmake2's cpp project type too. I can create a minimal reproducible example if you need that

@nickclark2016
Copy link
Member

Ahh got it. Yes, please go ahead and attach a minimum premake5.lua file that can reproduce it (and any supporting files needed).

@artemking4
Copy link
Author

premake5.lua:

rule "sampleRule"
    fileextension ".txt"

    -- buildmessage and buildcommands dont seem to matter
    buildmessage 'Copying %{file.relpath}'
    buildcommands 'cp %{file.relpath} new_%{file.relpath}'
    buildoutputs '%{file.basename}.txt'

workspace "sample"
    configurations { "Debug", "Release" }

project "sample"
    kind "ConsoleApp"
    rules { "sampleRule" }

    files { "**.txt" }

alongside with an empty sample.txt file

$ premake5 --version
premake5 (Premake Build Script Generator) 5.0.0-beta1
$ premake5 gmake2
Building configurations...
Running action 'gmake2'...
Error: [string "src/base/string.lua"]:27: stack overflow in token: file.basename

@nickclark2016
Copy link
Member

So just to follow up, would you expect the generated files to not be included in the rule's outputs?

@artemking4
Copy link
Author

Not really, i dont think that this is by any means good. Because then if you have 2 rules, i.e. one for .cpp>.so and the other one for .so, it will not pass it through the second rule, which im pretty sure isnt what someone would want. What im saying is that the rule's outputs should not be fed to itself again.

@nickclark2016
Copy link
Member

Completely following now. I'll try to have a fix out this weekend, as I see where this needs to go.

@nickclark2016 nickclark2016 self-assigned this Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants