I'm working on getting out-of-tree linux kernel modules to build. One of the challenges I face is in passing the kernel tree directory path to the Kbuild system.
In my WORKSPACE file I have:
new_local_repository(
name = "kernel_source_host",
path = "/storage/infra/kernel_release/linux-4.14.173-src/",
build_file = "BUILD.generic-kernel",
)
In the BUILD.generic-kernel file I have:
name = "whole_kernel_tree",
srcs = glob(["**/*"],
exclude = [".git/**"]),
)
filegroup(
name = "config_file",
srcs = [".config"],
)
My BUILD file then looks like this:
load("@bazel_skylib//lib:paths.bzl", "paths")
load("@rules_foreign_cc//foreign_cc:defs.bzl", "make")
filegroup(
name="nfnetmap_queue_src",
srcs = [
"nfnetmap_queue.c",
"nfnetmap_queue_meta.h",
"Kbuild",
"Makefile",
],
)
make(
name = "nfnetmap_queue",
data = [
"@kernel_source_host//:whole_kernel_tree",
"@kernel_source_host//:config_file",
],
targets = ["default"],
env = {
"KERNELDIR": MYSTERY_GOES_HERE
},
lib_source = ":nfnetmap_queue_src",
out_binaries = ["nfnetmap_queue.ko"],
)
I'd like the mystery text to be the execpath of my copied kernel source tree.
I've come up with several variations on a theme which fail.
The closest is "$(execpath @kernel_source_host//:config_file)" which gets me the correct execpath of the config file, but not the containing directory.
paths.dirname("$(execpath @kernel_source_host//:config_file)")
seems like it should work, but I end up with complaints of "unterminated $(execpath) expression". Attempts to quote around this haven't gotten me anywhere.
"$(execpath paths.dirname(@kernel_source_host//:config_file))"
seems even less likely to work, and it ends up with invalid target name 'paths.dirname(@kernel_source_host//:config_file': target names may not contain '//' path separators
This seems like something which should be straight-forward to do, but I haven't found any good references.
- Garrett