xmake-io / xmake

🔥 A cross-platform build utility based on Lua
https://xmake.io
Apache License 2.0
9.87k stars 776 forks source link

Allow wildcards in target:add("files", ...) #5452

Closed Raildex closed 1 month ago

Raildex commented 1 month ago

Is your feature request related to a problem? Please describe.

Depending on the platform and architecture, I want to configure it differently using on_load and on_config. I have many files depending on the platform and I would like to use wildcards. However, xmake does not support adding files using a wildcard using target:add('files',...)

add_files("specific/windows/*.c") -- works!
on_config("windows", function(target)
    target:add("files","specific/windows/*.c") -- does not work!
end)

xmake.lua:34: cannot match add_files("specific\windows\*.c") in target(...)

Describe the solution you'd like

Allowing wildcards in target:add('files', ...)

Describe alternatives you've considered

I am aware of

if(is_plat("windows")) then
    add_files("specific/windows/*.c")
end

but I would like to add the files during config time only, because it lets me neatly distinguish between platform and architecture without nesting if-then-else chains.

Additional context

No response

Raildex commented 1 month ago

this issue is solved by using $(scriptdir) in the path!

on_config("windows", function(target)
    target:add("files", "$(scriptdir)/specific/windows/*.c")
end)