premake / premake-core

Premake
https://premake.github.io/
BSD 3-Clause "New" or "Revised" License
3.21k stars 618 forks source link

removefiles state affected by filter , includedirs or links #848

Closed RicoP closed 7 years ago

RicoP commented 7 years ago

I had one project configured like that

  project "bez"
    defines { "NOMINMAX" } --http://stackoverflow.com/a/2561377
    kind "ConsoleApp"
    --warnings "Extra"
    buildoptions { "/Wall" } -- VS only
    language "C++"
    location "../build/projects"
    targetdir "../build/bin/%{cfg.buildcfg}"
    links { "un", "gainput" }
    includedirs { ".", "../external/sfml/include", "../external/gainput/include", "../external/dirent" }
    libdirs { "../external/sfml/lib" }
    files { "bez/**.h", "bez/**.cpp" }
    links { "bgfx", "bimg", "bx", "bgfxcommon" }
    includedirs { ".", "../external/", "../external/bx/include", "../external/bimg/include", "../external/bgfx/include" }
    includedirs { "../external/bx/include/compat/msvc" }
    includedirs { "../external/bgfxcommon" }
    includedirs { "../external/bgfx/3rdparty" }
    filter "configurations:Debug"
      links ( { "opengl32", "xinput9_1_0", "sfml-system-d", "sfml-window-d", "sfml-graphics-d" } )
    filter "configurations:Release"
      links ( { "opengl32", "xinput9_1_0", "sfml-system", "sfml-window", "sfml-graphics" } )

I wanted to remove the files "bez/systems/menusystem.h" and "bez/systems/menusystem.cpp" so I added

        removefiles { "bez/systems/menusystem.h", "bez/systems/menusystem.cpp" }

to the end of the project, but the two files where still there.

After some tinkering I added the removefiles command right after the files command which then removed the two files as I wanted it to be.

Correct code:

  project "bez"
    defines { "NOMINMAX" } --http://stackoverflow.com/a/2561377
    kind "ConsoleApp"
    --warnings "Extra"
    buildoptions { "/Wall" } -- VS only
    language "C++"
    location "../build/projects"
    targetdir "../build/bin/%{cfg.buildcfg}"
    links { "un", "gainput" }
    includedirs { ".", "../external/sfml/include", "../external/gainput/include", "../external/dirent" }
    libdirs { "../external/sfml/lib" }
    files { "bez/**.h", "bez/**.cpp" }
    removefiles { "bez/systems/menusystem.h", "bez/systems/menusystem.cpp" } -- <== ONLY HERE, NOT AT THE BOTTOM!
    links { "bgfx", "bimg", "bx", "bgfxcommon" }
    includedirs { ".", "../external/", "../external/bx/include", "../external/bimg/include", "../external/bgfx/include" }
    includedirs { "../external/bx/include/compat/msvc" }
    includedirs { "../external/bgfxcommon" }
    includedirs { "../external/bgfx/3rdparty" }
    filter "configurations:Debug"
      links ( { "opengl32", "xinput9_1_0", "sfml-system-d", "sfml-window-d", "sfml-graphics-d" } )
    filter "configurations:Release"
      links ( { "opengl32", "xinput9_1_0", "sfml-system", "sfml-window", "sfml-graphics" } )

so apparently filter , includedirs or links affect the state of removefiles. Is that the intended behaviour or is this a bug?

samsinsane commented 7 years ago

filter does affect the state of removefiles, as it does with almost all API calls. filter will remain active until you call filter, configuration (not configurations), project or workspace/solution. You can read more about the filter command here and here.

As for resolving your issue, either specify the removefiles before filter or add filter {} once you no longer wish to filter. For example:

filter "configurations:Release"
  links ( { "opengl32", "xinput9_1_0", "sfml-system", "sfml-window", "sfml-graphics" } )
filter {}
RicoP commented 7 years ago

Ok, thank you very much.