premake-core icon indicating copy to clipboard operation
premake-core copied to clipboard

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

Open AceKiron opened this issue 1 year ago • 10 comments

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.

AceKiron avatar Nov 05 '23 06:11 AceKiron

Tokens cannot be used in filter. So use:

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

Jarod42 avatar Nov 05 '23 07:11 Jarod42

Tokens cannot be used in filter. So use:

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

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

AceKiron avatar Nov 05 '23 07:11 AceKiron

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

Jarod42 avatar Nov 05 '23 07:11 Jarod42

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

AceKiron avatar Nov 05 '23 07:11 AceKiron

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...

Jarod42 avatar Nov 05 '23 07:11 Jarod42

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 avatar Nov 05 '23 07:11 AceKiron

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

AceKiron avatar Nov 05 '23 09:11 AceKiron

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

AceKiron avatar Nov 05 '23 09:11 AceKiron

And it's broken again?...

AceKiron avatar Nov 05 '23 10:11 AceKiron

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)...

Jarod42 avatar Nov 05 '23 14:11 Jarod42