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

CMake metadata badges #9823

Open
LecrisUT opened this issue Dec 20, 2023 · 4 comments
Open

CMake metadata badges #9823

LecrisUT opened this issue Dec 20, 2023 · 4 comments
Labels
service-badge Accepted and actionable changes, features, and bugs

Comments

@LecrisUT
Copy link

There are two useful informations that can be extracted from a CMake project

  • cmake_minimum_required
  • project(VERSION)

Unfortunately it would not be possible to extract them via json/yaml/toml, but if regex is an option, here are the regex to extract the information:

  • cmake_minimum_required\([\n\r\s]*VERSION[\n\r\s]*(?P<version>[\d\.]+)[^\)]*\)
  • project\([^\)]*VERSION[\n\r\s]*(?P<version>[\d\.]+)[^\)]*\)

This can simply be run on the top-level file CMakeLists.txt or wherever the root is redirected.

Let me know if this is appropriate to implement, and if I should make a PR for it.

@chris48s chris48s added the service-badge Accepted and actionable changes, features, and bugs label Dec 20, 2023
@chris48s
Copy link
Member

chris48s commented Dec 20, 2023

We do have a handful of badges that extend BaseService directly and just parse text (or headers) rather than json/xml/other structured data.

You could look at

for examples of that sort of thing.

We do have to be a bit more manual with the error handling because we can't apply a schema to ensure the response matches an expected format.

@LecrisUT
Copy link
Author

Great, so having regex opperations is not considered too computationally expensive. Is there also an example that navigates git repo?

Also where should these 2 badges be located?

@chris48s
Copy link
Member

Yeah reasonable questions.

I think make the "service" name cmake. So the files live in services/cmake and the route base is /cmake. Then follow the docs for the 'noun' part of the route.

We do have some badges that assume GitHub, but I think the direction we're going in this days is trying to make this type of badges work for projects hosted on GitLab/BitBucket/etc So I reckon we have the badges accept a required query param which is a URL to the file we're going to parse. That makes it host-agnostic.

So then an example call for the version badge with the file https://raw.githubusercontent.com/apiaryio/drafter/master/CMakeLists.txt would be like

/cmake/v?cmakelists=https%3A//raw.githubusercontent.com/apiaryio/drafter/master/CMakeLists.txt

Does that help?

@LecrisUT
Copy link
Author

Very much, thank you. I will see what I can do around this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service-badge Accepted and actionable changes, features, and bugs
Projects
None yet
Development

No branches or pull requests

2 participants