Skip to content

Properly filter .NET build events for configuration #2215

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

Merged

Conversation

mendsley
Copy link
Contributor

closes #2214

What does this PR do?

This change properly generates per-configuration conditions for build events with .NET projects rather than pulling build events from the project's "first" configuration

How does this PR change Premake's behavior?

Allows configuration filters to work as expected with .NET project generation

@mendsley
Copy link
Contributor Author

It looks like the CI workflow failed due to a network issue. Is there a way to re-run it?

https://github.com/premake/premake-core/actions/runs/9273887065/job/25514966115?pr=2215

@nickclark2016
Copy link
Member

To keep parity in support between C# and C++ projects, would you mind adding support there and adding the corresponding unit tests?

@mendsley
Copy link
Contributor Author

Hi @nickclark2016! I guess I was under the assumption this only affected C# project file generation. What did you have in mind for the C++ side?

@nickclark2016
Copy link
Member

I'm not 100% sure that C++ has the problem, but I'd expect the same behavior (allowing per config steps).

@jsmrcina
Copy link

It looks like C++ does not have this problem. The post build events are properly filtered. Minimal example is below using the same version of premake:

premake.lua

workspace "premaketest"
   configurations { "Debug", "Release" }
   platforms { "x64" }

project "premaketest"
   kind "ConsoleApp"
   language "C++"
   cppdialect "C++17"

   files { "*.h", "*.hpp", "*.cpp" }

   architecture "x86_64"

   filter "configurations:Debug"
      defines { "DEBUG" }

      postbuildcommands {
         "{ECHO} Debug",
      }

   filter "configurations:Release"
      defines { "NDEBUG", "__OPENCV_BUILD" }
      optimize "On"

      postbuildcommands {
         "{ECHO} Release",
      }

premaketest.vcxproj

   ... snip ...
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <PreprocessorDefinitions>DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <Optimization>Disabled</Optimization>
      <LanguageStandard>stdcpp17</LanguageStandard>
      <ExternalWarningLevel>Level3</ExternalWarningLevel>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
    </Link>
    <PostBuildEvent>
      <Command>echo Debug</Command>
    </PostBuildEvent>
  </ItemDefinitionGroup>
  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <ClCompile>
      <PrecompiledHeader>NotUsing</PrecompiledHeader>
      <WarningLevel>Level3</WarningLevel>
      <PreprocessorDefinitions>NDEBUG;__OPENCV_BUILD;%(PreprocessorDefinitions)</PreprocessorDefinitions>
      <Optimization>Full</Optimization>
      <FunctionLevelLinking>true</FunctionLevelLinking>
      <IntrinsicFunctions>true</IntrinsicFunctions>
      <MinimalRebuild>false</MinimalRebuild>
      <StringPooling>true</StringPooling>
      <LanguageStandard>stdcpp17</LanguageStandard>
      <ExternalWarningLevel>Level3</ExternalWarningLevel>
    </ClCompile>
    <Link>
      <SubSystem>Console</SubSystem>
      <EnableCOMDATFolding>true</EnableCOMDATFolding>
      <OptimizeReferences>true</OptimizeReferences>
    </Link>
    <PostBuildEvent>
      <Command>echo Release</Command>
    </PostBuildEvent>
  </ItemDefinitionGroup>
   ... snip ...

Thanks!

@mendsley
Copy link
Contributor Author

Just checking back in to see if there is anything remaining to be actioned on this

@mendsley
Copy link
Contributor Author

Bump

@nickclark2016 nickclark2016 merged commit fa2405d into premake:master Jul 27, 2024
11 of 12 checks passed
@mendsley mendsley deleted the mendsley/cs_configs_build_events branch September 28, 2024 20:17
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.

Configuration filters don't work correctly for postbuildcommands in C# projects
3 participants