premake / premake-core

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

Files filter only seems to work on source files or header files #2157

Open AceKiron opened 8 months ago

AceKiron commented 8 months ago

What are you trying to do? I'm trying to add an .ico file with buildaction ResourceCompile.

What problem are you having? I honestly have no idea how to do this, the files filter only seems to work when it has a .cpp or .h extension.

What have you tried so far?

files {
    "%{prj.location}/src/**.h",
    "%{prj.location}/src/**.cpp",

    "%{prj.location}/assets/**.ico"
}

filter "files:%{prj.location}/assets/**.ico"
    buildaction "ResourceCompile"

What version of Premake are you using? premake5 (Premake Build Script Generator) 5.0.0-beta2

Anything else we should know? Add any other context about the problem here. Right now, .ico files have the buildaction set to None in the .vcxproj file.

Jarod42 commented 8 months ago

Tokens cannot be used in filter. So use:

filter "files:assets/**.ico"
    buildaction "ResourceCompile"
AceKiron commented 8 months ago

Tokens cannot be used in filter. So use:

filter "files:assets/**.ico"
    buildaction "ResourceCompile"

@Jarod42 that doesn't seem to make a difference.

Jarod42 commented 8 months ago

Which generator do you use? I bet than buildaction "ResourceCompile" is only supported by vs* action.

AceKiron commented 8 months ago

The command I use to generate project files is premake5 vs2022.

Jarod42 commented 8 months ago

Is project location at the same place than premake5.lua? (else path in filter "files:assets/**.ico" should be fixed).

Just did a quick test, and in visual, property of the ico file is set properly...

AceKiron commented 8 months ago

premake5.lua:

outputdir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"

workspace "Imagination Game Engine"
    startproject "Editor"

    architecture "x64"

    configurations {
        "Debug",
        "Release"
    }

    flags {
        "MultiProcessorCompile"
    }

    language "C++"
    cppdialect "C++20"

    staticruntime "off"

    targetdir ("%{wks.location}/bin/" .. outputdir .. "/%{prj.name}")
    objdir ("%{wks.location}/bin-int/" .. outputdir .. "/%{prj.name}")

    includedirs {
        "%{prj.location}/src"
    }

    files {
        "%{prj.location}/src/**.h",
        "%{prj.location}/src/**.cpp",

        "%{prj.location}/assets/**.ico"
    }

    filter "files:assets/**.ico"
        buildaction "ResourceCompile"

    filter "system:windows"
        systemversion "latest"

        defines "SYSTEM=0"

    filter "configurations:Debug"
        runtime "Debug"
        symbols "on"

        defines "CONFIGURATION=0"

    filter "configurations:Release"
        runtime "Release"
        optimize "on"

        defines "CONFIGURATION=1"

include "Editor"
include "Engine"

Engine/premake5.lua:

project "Engine"
    location "%{wks.location}/%{prj.name}"
    kind "StaticLib"

    pchsource "src/impch.cpp"
    pchheader "impch.h"

And then there's the Engine/assets/icons/Imagination.ico file. All the other files should be irrelevant.

AceKiron commented 8 months ago

Eventually, it seemed putting the files filter in the project scope fixed it..

AceKiron commented 8 months ago

Nevermind. It may be marked as ResourceCompile, but there are still no resource.h, Engine.rc, or Engine.aps files.

AceKiron commented 8 months ago

And it's broken again?...

Jarod42 commented 8 months ago

Nevermind. It may be marked as ResourceCompile, but there are still no resource.h, Engine.rc, or Engine.aps files.

Project with resource I work on doesn't use buildaction "ResourceCompile" for the .ico, but have .rc files (which is handled directly with files "**.rc" and supported by all generators)...