premake / premake-core

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

Adding custom Property Group properties to my project file #1469

Closed gabrielmaneru closed 3 years ago

gabrielmaneru commented 4 years ago

What are you trying to do? I want to add some specific configuration into the Property Group.

What problem are you having? I don't know how to develop new content for premake.

What have you tried so far? I tried adding a new action. I also tried to inspect the src files of premake to understand their framework but didn't get it.

What version of Premake are you using? 5.0

Anything else we should know? The property I want to add: PropertyGroup DisableFastUpToDateCheck true /DisableFastUpToDateCheck /PropertyGroup

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

starkos commented 4 years ago

I'm not familiar with that one, I'll try to take a look later. In the meantime, does this answer help at all?

gabrielmaneru commented 4 years ago

Thanks to @L4ZZA 's post on your linked issue which gave an example for this problem by dropping everything at the top of the file:

if os.istarget "Windows" then
    require "vstudio"
    local p = premake;
    local vc = p.vstudio.vc2010;

    function disableFastUpToDateCheck(prj, cfg)
        vc.element("DisableFastUpToDateCheck", nil, "true")
    end

    p.override(vc.elements, "globalsCondition",
            function(oldfn, prj, cfg)
                local elements = oldfn(prj, cfg)
                elements = table.join(elements, {disableFastUpToDateCheck})
                return elements
            end)
end

It works perfect as a patch for my personal projects, however I do think there should be an easier and cleaner way to add a new specific flag. I don't know if that's even possible but something like:

filter "system:windows"
    systemversion "latest"
    propconfig ("DisableFastUpToDateCheck", "true")
starkos commented 4 years ago

That is not (easily) possible, but this is:

filter "system:windows"
   systemversion "latest"
   fastUpToDateCheck "off"

You just need to register the new field in src/_premake_init.lua, and then find the right spot to add the element in modules/vstudio/vc2010_vcxproj.lua. Lots of examples to copy from in those files; feel free to ask any questions here. You can put the changes in your own project or system script, or submit a pull request and we'll get it merged into core ASAP.

ddobrev commented 3 years ago

Would a maintainer be willing to reopen and fix this? The setting is crucial for projects with generated code as it causes them to rebuild every time.

ddobrev commented 3 years ago

Until this is fixed, how can I edit the patch to only apply to specified projects? Regardless of where I put it, it changes all of them.

starkos commented 3 years ago

Why not fix it and submit a PR?

samsinsane commented 3 years ago

I'm going to close this off in favour of #1443.