Skip to content

Add to_list() method to include_directories objects #14488

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

WillAyd
Copy link
Contributor

@WillAyd WillAyd commented Apr 17, 2025

This revives PR #13035 while retaining authorship to @gabeblack

I did not see any outstanding comments so it is the same code as before. I am happy to make any edits that are required

clean up

fix tests for windows paths mimicing what was done in other unit tests (e.g., test case 74)

Update mesonbuild/interpreter/interpreterobjects.py

Co-authored-by: Charles Brunet <[email protected]>

Update docs/markdown/snippets/include_directories_to_list.md

Co-authored-by: Charles Brunet <[email protected]>

Update mesonbuild/interpreter/interpreterobjects.py

Co-authored-by: Charles Brunet <[email protected]>

Update docs/yaml/objects/inc.yaml

Co-authored-by: Charles Brunet <[email protected]>

Fix comment language
@WillAyd WillAyd requested a review from jpakkane as a code owner April 17, 2025 15:48
@bonzini bonzini added this to the 1.9 milestone Apr 17, 2025
@bonzini
Copy link
Collaborator

bonzini commented Apr 24, 2025

Fixes #5468

@joukewitteveen
Copy link
Contributor

joukewitteveen commented May 21, 2025

I think to_list methods should take two optional arguments: start and stop. Since subscripting does not support any form of slicing, the additional methods enable a use-case not otherwise supported. Implementation shouldn't be too hard. For custom_target it could be something like

        start = kwargs.get('start')  # defaults to 0
        stop = kwargs.get('stop', len(self.held_object.outputs))
        selection = range(start, stop)
        return [x for i, x in enumerate(self.held_object) if i in selection]

edit: or simply return list(self.held_object)[kwargs.get('start'):kwargs.get('stop')].

This would enable

headers = ['multiple', 'files']
sources = ['several', 'sources']
custom_outputs = custom_target('example', ..., output : [headers, sources])
just_headers = custom_outputs.to_list(stop=headers.length())

For include_directories, there is a weird quirk in that every input results in two outputs, so you'd need to multiply the start/stop arguments by 2 either in meson.build or in the specific to_list implementation.

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

Successfully merging this pull request may close these issues.

3 participants