-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
CMake build directories with "unconventional" names are undiscovered #120
Comments
Oh I didn't know about I'm working on "v2" that greatly increases the flexibility of the internal logic, here is an example. I think it would be possible to support searching subdirectories for Do you think this API would fully support that use-case? Ideally we could determine the directory from CMakeLists but it's not a common format that's easy to parse. kondo/kondo-lib/src/project/rust.rs Lines 28 to 37 in 658cd96
|
A top-level As for artifacts, the build dir is not set in # Minimal CMake config.
touch CMakeLists.txt
# All of these are valid ways to configure the project, even simultaneously.
(mkdir build && cd build && cmake ..) # 1. Currently supported.
(mkdir _ && cd _ && cmake ..) # 2. Unsupported.
(mkdir build/config1 && cd build/config1 && cmake ../..) # 3. Unsupported.
(mkdir /tmp/build && cd /tmp/build && cmake /project/) # 4. Unsupported, assumes project tree in `/project/`.
cmake . # 5. Unsupported. (1) and (2) can be supported by looking for a subdirectory with This approach breaks down for (4) where One can detect (5) ( The current interface sketch for For all these reasons a better implementation might be to instead in a first implementation treat the build directory (directory with |
Thank you for the detailed breakdown, I haven't personally user CMake before so this is helpful. I've fixed the naming of
I've added that assumption to the docstring of the methods, thanks for pointing that out. There may be a way to enforce this at a type level so it's impossible to not have a found project before you check artifacts etc. For example Lines 124 to 127 in 415cd33
I'm still thinking over your last couple paragraphs :) |
Thanks! I am certainly open to helping with this (e.g., by looking over PRs), or even contributing an implementation myself once your new API has become clearer. Feel free to ping me. |
I noticed while reading the Is this commonly used? Perhaps the binary path could be retrieved |
Option 1 ✅(mkdir build && cd build && cmake ..) # 1. Currently supported. Already supported. Option 2 ✅(mkdir _ && cd _ && cmake ..) # 2. Unsupported. This shouldn't be a problem to implement. Requires recursive searching for Option 3 👍(mkdir build/config1 && cd build/config1 && cmake ../..) # 3. Unsupported. It seems based on your 3rd option that only supporting artifacts at the root of the project is insufficient. I'll have a think how to address that. Perhaps Option 4
|
Do you know if there is a preference/rough order of which options tends to be most common for cmake projects? |
I have added option 1 support for the rework in 9b48edb. |
This is typically use to construct paths to artifacts (e.g., to reference generated sources or headers). A similar variable is I have never worked on a project which sets these as opposed to read the values set by CMake.
I'd say that building in a subdirectory is pretty typical (variations of (1) or (2)), but I also know people who e.g., keep their build directories on a different partition, i.e., (4). For quick and dirty stuff people also use (3). Re: (4) (external build directory):
This would be really unfortunate. I am not exactly sure what you tried, but as far as kondo is concerned the directory with
Re: (5) (build in source directory):
The presence of that file seems to depend on the build system used (CMake supports generating for an open-ended zoo of build systems), e.g., I do not see it for the Ninja generator. As far as I know there is also no standard CMake command to clean up the build directory including the build directory itself (equivalent of e.g., Another issue with defaulting to the build tools for #122 is that it would require the build tool to be present on the system which might not be the case. CMake projects might reconfigure when running
Autotools would behave similarly. |
Currently
kondo
hardcodes a list of possible CMake build directories. This often works well enough, but since the name of a CMake build directory is merely convention it can fail for directories with other names.A more reliable way to discover CMake build directories would be to search for subdirectories with a generated file
CMakeCache.txt
, but this cannot be supported in the current impl. Most of the infrastructure around artifact dirs assumes a static list of directories where instead a possible approach to address this would be to e.g., compute a (set of) globs forartifact_dirs
and then have consumers of that API dynamically check for glob matches in the file system (e.g., here). It might make sense to also centralize glob matching to reduce slow repeated and identical hits of the filesystem.The text was updated successfully, but these errors were encountered: