No practical way to create a package for a cc_binary with runfiles
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
- Bastante claro
- Estado de actividad
- Tranquilo
- Área
- build-system
Línea de trabajo
Empieza reproduciendo los ejemplos pkg_zip y pkg_files con include_runfiles habilitado y, a continuación, compara el contenido de los archivos generados y los errores de colisión de prefijos notificados. El trabajo estará terminado cuando un cc_binary con shared libraries u otros runfiles pueda empaquetarse como el contenido del directorio runfiles sin el binario raíz defectuoso, destinos duplicados ni un archivo vacío, en todos los sistemas operativos.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Maybe I'm missing something here, but it seems there's no practical way to just cleanly package a cc_binary that requires shared libraries or other runfiles.
This is the most obvious solution:
pkg_zip(
name = "release_package",
srcs = ["//:mytool"],
include_runfiles = True,
)
But then you end up with the following structure:
mytool.exe
mytool.runfiles/mytool.exe
mytool.runfiles/libfoo.dll
The fundamental problem here is that the mytool.exe at the root of the package is broken, since it's just the raw artifact of the cc_binary rule with none of the required runfiles. What I want is a zip file that just contains the contents of the generated runfiles directory. I used Windows extensions here for illustrative purposes (since it's the clearest about file types), but this is a problem on ALL operating systems.
Here's what I've tried:
Strip the runfiles prefix
pkg_files(
name = "my_tool_runfiles",
strip_prefix = strip_prefix.from_pkg() + "mytool.runfiles",
include_runfiles = True,
srcs = ["//:mytool"],
)
pkg_zip(
name = "release_package",
srcs = [":my_tool_runfiles"],
)
This fails because the tool I'm trying to drop can't have its prefix stripped:
Error in fail: Could not strip prefix 'mytool.runfiles' from file <generated file mytool> (@@//:mytool)
Create a shim filegroup
# Just present just_the_runfiles as runfiles.
filegroup(
name = "just_the_runfiles",
data = ["//:mytool"],
)
pkg_files(
name = "my_tool_runfiles",
strip_prefix = strip_prefix.from_pkg() + "mytool.runfiles",
include_runfiles = True,
srcs = [":just_the_runfiles"],
)
pkg_zip(
name = "release_package",
srcs = [":my_tool_runfiles"],
)
This doesn't work either; it produces an empty zip file.
Try to explicitly exclude just the binary
filegroup(
name = "just_the_binary",
srcs = ["//:mytool"],
)
pkg_files(
name = "my_tool_runfiles",
strip_prefix = strip_prefix.from_pkg() + "mytool.runfiles",
include_runfiles = True,
excludes = [":just_the_binary"],
srcs = ["//:mytool"],
)
pkg_zip(
name = "release_package",
srcs = [":my_tool_runfiles"],
)
This doesn't work either; it produces an empty zip file.
Try to create an intermediate pkg_files
pkg_files(
name = "my_tool_runfiles",
include_runfiles = True,
srcs = ["//:mytool"],
)
pkg_files(
name = "tool_bin_wrapper",
prefix = "bin",
srcs = [":my_tool_runfiles"],
)
pkg_zip(
name = "release_package",
srcs = [":tool_bin_wrapper"],
)
Fails with:
Error in fail: After renames, multiple sources (at least bazel-out/darwin_x86_64-fastbuild/bin/external/libfoo/libfoo.dylib, bazel-out/darwin_x86_64-fastbuild/bin/_solib_darwin_x86_64/_Uexternal_Slibfoo_Usources/libfoo.dylib) map to the same destination. Consider adjusting strip_prefix and/or renames
I've spent a lot of time messing around with prefixes to try and get that error to go away. No matter what I do, I can't get pkg_files to work if it references another thing that specifies include_runfiles. This means that any hope for renaming/stripping prefixes/excluding files using an intermediate is gone.
filter_directory
This is just fundamentally incompatible:
in src attribute of filter_directory rule //bazel:strip_redundant_binary: '//bazel:bins' must produce a single file
- Lenguaje dominante
- Starlark
- Estrellas
- 254
- Forks
- 225
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 3
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de bazelbuild/rules_pkg
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
bazelbuild/rules_pkg#1093 ·
Los mantenedores suelen responder en 1 día
-
Targets rely on implicit `__init__.py` creation, causing rules_python deprecation warningsPosiblemente ocupada @onnosteenbergen-samotics la tomó hace 32 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
bazelbuild/rules_pkg#1081 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
design feature-request
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
bazelbuild/rules_pkg#1080 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
bazelbuild/rules_pkg#1075 · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
bazelbuild/rules_pkg#1066 · 1 reacción ·
Los mantenedores suelen responder en 1 día
Todos los issues de bazelbuild/rules_pkg
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
aws/context-ontology-accelerator#325 ·
Los mantenedores suelen responder en 1 día
-
agent-butler-finding chore
Dificultad 1/5 Menos de una hora Aptitud para principiantes 84/100
jordansmall/spindrift#6210 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
objectionary/jeo-maven-plugin#1926 ·
Los mantenedores suelen responder en 2 días
-
orchestration.migration.data.tasks.retry values are ignored by the 8.8 data migration jobPosiblemente ocupada @irisfield la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
camunda/camunda-platform-helm#7773 ·
Los mantenedores suelen responder en 1 día
-
0.kind: enhancement 6.topic: reproducible builds
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
NixOS/nixpkgs#580765 · 1 comentario ·
Los mantenedores suelen responder en 1 día