RFC: Support for CMake `codegen` target

Abierto
#284 6 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Necesita aclaración
Estado de actividad
Tranquilo
Stack tecnológico
cmake, cpp
Área
build-system

Línea de trabajo

Comienza leyendo cmake/TargetCapnpSources.cmake, especialmente target_capnp_sources y su add_custom_command; después, inspecciona CMakeLists.txt en la llamada a capnp_generate_cpp alrededor de las líneas 137-138. Revisa el comportamiento de generación de código de CMake y las rutas de generación disponibles. Se considerará terminado cuando exista un enfoque acordado que pueda generar todos los headers y fuentes necesarios antes de que IWYU procese la base de datos de compilación.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

CMake allows different approaches for running static analysis tools over a codebase: co-compiling and using a compilation database.

Bitcoin Core uses the latter. This approach has many benefits: for example, the ability to filter entries, which allows us to maintain a list of sources where IWYU warnings are enforced. When processing the compilation database, IWYU expects to find every source and header. This is not the case when the database is generated solely during the configuration step, as it lacks the headers and sources that will be generated during the subsequent build step.

Modern CMake provides a way to generate expected headers and sources beforehand using the built-in codegen target. This approach is currently used in the Bitcoin Core IWYU CI job.

However, the Libmultiprocess project seems inherently incapable of supporting the codegen target. While it is almost trivial to amend add_custom_command in the target_capnp_sources function with the conditional CODEGEN option, doing so is not possible for the capnp_generate_cpp function shipped by libcapnp-dev or similar packages.

There are several ways we could tackle this issue:

  1. Execute a normal build step: This guarantees that all files will be generated without relying on codegen at all.

  2. Introduce a custom target: We could create a custom target to generate all files beforehand, though this might be challenging.

  3. Use CMake's co-compilation: Switch to the co-compiling approach, though I am unsure about the usability of this method for the CI job.

  4. Alternative solutions: Open to other ideas.

I am hoping to gather my colleagues' opinions on the best way forward.

Lenguaje dominante
C++
Estrellas
62
Forks
58
Merge medio
6 d 11 h
PR fusionados (30 d)
7

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de bitcoin-core/libmultiprocess

Todos los issues de bitcoin-core/libmultiprocess

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.