Skip to content

Conversation

@dcbaker
Copy link
Member

@dcbaker dcbaker commented Oct 28, 2025

This is built on top of #15178

As I hurtle onward to getting dependencies in ready for having split compile arguments, I've stopped to work on splitting include directories out of compile args. To that purpose I've been working on making the IncludeDirs object more flexible, and this is the first leg of that work.

There is some just generic cleanups here, but also a lot of fixes for handling extra_build_dirs. To that point I've attempted to replace all (although one unique instance remains in the VS backend) conversion from IncludeDirs to List[str] to use methods built into the object itself, and which correctly handle those cases.

@dcbaker dcbaker added the refactoring No behavior changes label Oct 28, 2025
# -Ipath will add to begin of array. And without reverse
# flags will be added in reversed order.
args: T.List[str] = []
for p in inc.rel_string_list(self.build_to_src, self.build_dir):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing reverse=True?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That causes the test_internal_include_order test to fail, so I think I ported the comment over incorrectly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which doesn't make sense.

I need to think about this one more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, after a lot of head scratching and confusion, I have an answer: rel_string_list returns the stringlist in the order that this code expects already, so no reversing required. The reason the previous code reversed the iteration was to get build directory before source directory, which this does by default.

This is really class constant for all dependencies, and by taking it out
of the initializer we make the `__init__` call have a more consistent
interface.
So we don't create a default name that is overwritten except in the case
of appleframeworks. This allows for some cleanup, including
deleting some initializers that were only setting the name.
We have type checking that ensures this is a string list already.
It's allowed in the `DependencyKeywordArguments` TypeDict already, so we
now have two sources of truth. Additionally, it's often populated by
reading from that dict, so we're just doing useless work.
…Dependency

It's read out of the `kwargs`, then passed along with the kwargs. We can
just get it in the class initializer for no cost
This is always derived from kwargs, so now we have two sources of truth
that can go out of sync.
This simplifies a bunch of cases, and likely fixes some annoying bugs
in cross compile situations where should have been passing this and
weren't.
The goal is to have a single type for candidates that replaces having a
mixture of class initializers, partials, and factories with a single
wrapper class.
This makes the type checking more reasonable (including fixing an issue
that newer mypy is pointing out to us), consolidating special cases, and
improving code readability.
Avoid extra method calls and repeating ourselves.
It's now only used to populate the DependencyCandidate, so we can remove
it and just calculate the same information from the `type_name`
parameter. This reduces code and the number of method calls.
This includes some cleanup to remove unused calculations.
@dcbaker dcbaker force-pushed the submit/cleanup-build-includedirs branch from 16eb3ef to 295fed3 Compare November 5, 2025 17:22
@dcbaker dcbaker marked this pull request as draft November 5, 2025 17:22
@dcbaker dcbaker force-pushed the submit/cleanup-build-includedirs branch from 295fed3 to edc117e Compare November 5, 2025 17:25
This allows us to clean up many instances of the same pattern
implemented elsewhere, by consolidating into one.
This adds the ability to remove build directories that don't exist.

This doesn't require a second call to reverse() because that was being
used to switch the order of the build and src directories, but
`rel_string_list` returns them in the expected order already.
@dcbaker dcbaker force-pushed the submit/cleanup-build-includedirs branch from edc117e to 8a38912 Compare November 5, 2025 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring No behavior changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants