wrap OBJDIR creation in prevent gmake warning#2038
wrap OBJDIR creation in prevent gmake warning#2038thomashope wants to merge 1 commit intopremake:masterfrom
Conversation
|
I believe Visual Studio may actually have an issue with the intermediate and target directories being the same. We may want to do this at a core level, rather than a per-exporter level. |
|
Hmm I thought I'd had a VS project setup in the past that put them in the same place and it didn't mind, although I didn't test when investigating this issue. Just tried on Xcode and it seemed happy to use the same dir for both |
|
It's very possible I'm thinking of another quirk with intermediate and target paths. |
|
If I get a chance to later I will dust off my PC and give it a try. If you want to try in the meantime though this is the test script I've been using. Just supply your own main.cpp. local project_name = "test"
workspace (project_name)
configurations {"Debug", "Release"}
location ("build/" .. _ACTION)
project (project_name)
kind "ConsoleApp"
location ("build/" .. _ACTION)
language "C++"
cppdialect "C++11"
architecture "x86_64"
files {
"main.cpp",
}
-- Reproducing a bug where setting targetdir and objdir to be the same directory
-- causes makefiles to emit a warning due to two rules having the same name
--
-- github issue #726 https://github.com/premake/premake-core/issues/726
targetdir ("bin/" .. _ACTION .. "/%{cfg.buildcfg}")
objdir ("bin/" .. _ACTION .. "/%{cfg.buildcfg}")
-- objdir ("obj/" .. _ACTION .. "/%{cfg.buildcfg}") |
|
(deprecated) gmake can have similar fix. Question, why not have something like following instead |
Wrap OBJDIR creation in conditional to prevent defining two rules with the same name
What does this PR do?
Make doesn't want you to create two rules with the same name and will emit a warning if you do (unless they are double colon rules which have some caveats?).
If you set the
targetdirandobjdirto the same location in Premake two rules are produced with the same name, as described in #726, causing make to complain.How does this PR change Premake's behavior?
Wraps the
OBJDIRrule in a conditional so it is not run ifOBJDIRandTARGETDIRare the same.closes #726
Anything else we should know?
I'm not an expert on makefiles but in my research I saw two possible solutions to this issue.
Change the rules to double colon rules which did work but possibly has some caveats.
Wrap a conditional around one of the rules. Apparently make has the concept of immediate and deferred contexts which I looked into a bit but seems to not be an issue for this case. I was reading about the concepts here.
I selected option 2 because as far as I could tell I didn't have any relevant caveats and seemed the least surprising for someone reading the makefile / Lua code.
Tests were not included because the warning was only visible when you run the makefile and I wasn't sure how / if it was worthing testing that.
Did you check all the boxes?
closes #XXXXin comment to auto-close issue when PR is merged)You can now support Premake on our OpenCollective. Your contributions help us spend more time responding to requests like these!