Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add target.del_headerfiles #1939

Closed
SirLynix opened this issue Dec 23, 2021 · 12 comments
Closed

Add target.del_headerfiles #1939

SirLynix opened this issue Dec 23, 2021 · 12 comments

Comments

@SirLynix
Copy link
Member

SirLynix commented Dec 23, 2021

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

I'm using add_files then del_files to remove some files which shouldn't be part of it, and now I would like to add headerfiles (and remove some which shouldn't be part of it).

To be clear, here's what I have:

-- Common config
set_group("Tests")
set_kind("binary")

add_deps("NazaraCore", "NazaraNetwork", "NazaraPhysics2D", "NazaraShader")
add_packages("catch2", "spirv-tools")
add_headerfiles("Engine/**.hpp")
add_files("resources.cpp")
add_files("Engine/**.cpp")

target("NazaraClientUnitTests")
	add_deps("NazaraAudio")

	add_files("main_client.cpp")

target("NazaraUnitTests")
	add_files("main.cpp")

	-- del_headerfiles("Engine/Shader/**") :(
	del_files("Engine/Audio/**")

Describe the solution you'd like

Since add_files has del_files, it would be logical to have del_headerfiles too.

I tried to add it myself to make a PR (it doesn't seem very complicated) but I'm not comfortable enough yet with xmake internals.

Describe alternatives you've considered

Add every header subfolder myself except those I don't wan't, but since del_files exists it seems del_headerfiles would be a nice addition

@waruqi
Copy link
Member

waruqi commented Dec 23, 2021

you can use add_headerfiles("**.h|excluded/*.h")

@SirLynix
Copy link
Member Author

It won't work with my code (and when I'll have multiples subfolder I guess), since I add files for both targets but want to remove files for only one

@waruqi
Copy link
Member

waruqi commented Dec 23, 2021

At present, I am not very satisfied with the naming convention of del_files, so I have not added other interfaces.
But I might consider changing to other naming conventions later. For example, remove_files, remove_headerfiles, rm_files, rm_headerfiles ...

@SirLynix
Copy link
Member Author

For reference:
Premake uses removefiles
CMake uses REMOVE_ITEM
Maven seems to use "delete"
Gradle seems to use "delete" as well
Meson seems to have a "delete" command

So it seems delete and remove are the two common keywords for this, since delete may seems ambiguous (since "delete file" may mean deleting it from the filesystem, same for rm since it's an unix command), I can suggest using remove, remove_files, remove_headerfiles and such.

@SirLynix
Copy link
Member Author

Also thinking about it, a word that I haven't seen in other build tools is, but may be more clear, is "exclude" (exclude_files, exclude_headerfiles)

@waruqi
Copy link
Member

waruqi commented Dec 23, 2021

Thank you, I think remove_files and remove_headerfiles are better.

@eli-schwartz
Copy link

meson's "delete" command is for the scriptable tool to edit the build definition files.

I think the concept you are working with here has more to do with inheritance, and specifically partial inheritance? i.e. targets seem to have sub-targets that inherit the list of associated source files, and you can restrict that by later on by removing some of those files from the target node.

This is definitely not something meson has an equivalent to, since meson supports neither globs nor target inheritance. Instead, one would simply create two meson arrays, and add one set of files to one target and both sets of files to the other target.

Also meson's rewriter uses delete to delete attributes, and remove to remove array elements from an attribute value.

@waruqi
Copy link
Member

waruqi commented Dec 24, 2021

I have added remove_files and remove_headerfiles on remove branch. you can try it. xmake update -s github:xmake-io/xmake#remove

@waruqi
Copy link
Member

waruqi commented Dec 24, 2021

It has been merge into dev now.

@SirLynix
Copy link
Member Author

I get errors

error: @programdir\core\main.lua:280: @programdir\core\project\target.lua:1515: bad argument #1 to 'remove' (position out of bounds)
stack traceback:
    [C]: in function 'remove'
    [@programdir\core\project\target.lua:1515]: in function 'pred'
    [@programdir\core\base\table.lua:458]: in function 'remove_if'
    [@programdir\core\project\target.lua:1507]: in function 'headerfiles'
    [@programdir\plugins\project\vstudio\impl\vs201x.lua:572]: in function 'make'
    [@programdir\plugins\project\vstudio\vs.lua:50]: in function '?'
    [@programdir\plugins\project\main.lua:79]: in function '_make'
    [@programdir\plugins\project\main.lua:89]:
    [C]: in function 'xpcall'
    [@programdir\core\base\utils.lua:280]:
    [@programdir\core\base\task.lua:519]: in function 'run'
    [@programdir\core\main.lua:278]: in function 'cotask'
    [@programdir\core\base\scheduler.lua:371]:

stack traceback:
        [C]: in function 'error'
        @programdir\core\base\os.lua:827: in function 'base/os.raiselevel'
        (...tail calls...)
        @programdir\core\main.lua:280: in upvalue 'cotask'
        @programdir\core\base\scheduler.lua:371: in function <@programdir\core\base\scheduler.lua:368>

@waruqi
Copy link
Member

waruqi commented Dec 24, 2021

Try it again.

@waruqi waruqi added this to the v2.6.3 milestone Dec 24, 2021
@SirLynix
Copy link
Member Author

It works well, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants