Skip to content

Conversation

@samsinsane
Copy link
Member

What does this PR do?

Adds ability for toolsets to specify tool output extensions.

How does this PR change Premake's behavior?

The gmake generator will now correctly use .obj when using the msc toolset.

Anything else we should know?

N/A

Did you check all the boxes?

  • Focus on a single fix or feature; remove any unrelated formatting or code changes
  • Add unit tests showing fix or feature works; all tests pass
  • Mention any related issues (put closes #XXXX in comment to auto-close issue when PR is merged)
  • Follow our coding conventions
  • Minimize the number of commits
  • Align documentation to your changes

You can now support Premake on our OpenCollective. Your contributions help us spend more time responding to requests like these!

global(nil)
end

function cpp.gettooloutputext(tool, cfg)
Copy link
Contributor

@Jarod42 Jarod42 Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why gcc/clang don't provide it too?

Or move that function as helper method (usable by other toolset (as ninja))

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why gcc/clang don't provide it too?

I couldn't decide if I should or not, but I'm leaning towards I should now.

This function needs to exist though with the fallback, otherwise all modules that introduce C and C++ toolsets won't use extensions on their files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

--

function msc.gettooloutputext(tool)
return iif(tool == "rc", "res", "obj")
Copy link
Contributor

@Jarod42 Jarod42 Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.getextension (as several programming languages (C++, python)) returns the dot too, seems more coherent to return '.res'/'.obj'.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I considered this but I opted for this as the the usage would look weird otherwise - %{}%{} instead of %{}.%{}.

I don't really feel that strongly either way, and it does look like we have precedent to include the dot. @nickclark2016 thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically speaking, the extension does not include the dot. I would honestly prefer we "break" existing code to fix that, but that's probably not viable. Let's just aim for consistency, so include the ".".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@samsinsane samsinsane force-pushed the ssurtees/gmake_output_extensions branch from f0f2f8a to b5cf5fb Compare September 26, 2025 12:17
buildoutputs { "$(OBJDIR)/%{file.objname}.o" }
buildoutputs { "$(OBJDIR)/%{file.objname}%{premake.modules.gmake.cpp.gettooloutputext('cxx', cfg)}" }
buildmessage '$(notdir $<)'
buildcommands {'$(CXX) %{premake.modules.gmake.cpp.fileFlags(cfg, file)} $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<"'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't that .o also be changed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

???

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"$(@:%.o=%.d)" hardcode .o, should it be "$(@:%%%{premake.modules.gmake.cpp.gettooloutputext('cxx', cfg)}=%.d)"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the line you've commented on here.

@nickclark2016 nickclark2016 merged commit 9a6f7f7 into premake:master Oct 1, 2025
49 checks passed
@samsinsane samsinsane deleted the ssurtees/gmake_output_extensions branch October 1, 2025 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants