Skip to content

Commit 13171b6

Browse files
committed
fix(pkg/driverbuilder): use a single constant for the Cmake command.
Moreover, add back some now unused cmake variables, ie: * PROBE_NAME * PROBE_VERSION * PROBE_DEVICE_NAME Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
1 parent cb2c45b commit 13171b6

18 files changed

+46
-18
lines changed

pkg/driverbuilder/builder/builders.go

+29-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,25 @@ import (
3131
)
3232

3333
// DriverDirectory is the directory the processor uses to store the driver.
34-
const DriverDirectory = "/tmp/driver"
34+
const (
35+
DriverDirectory = "/tmp/driver"
36+
cmakeCmdFmt = `cmake -Wno-dev \
37+
-DUSE_BUNDLED_DEPS=On \
38+
-DCREATE_TEST_TARGETS=Off \
39+
-DBUILD_LIBSCAP_GVISOR=Off \
40+
-DBUILD_LIBSCAP_MODERN_BPF=Off \
41+
-DENABLE_DRIVERS_TESTS=Off \
42+
-DDRIVER_NAME=%s \
43+
-DPROBE_NAME=%s \
44+
-DBUILD_BPF=On \
45+
-DDRIVER_VERSION=%s \
46+
-DPROBE_VERSION=%s \
47+
-DGIT_COMMIT=%s \
48+
-DDRIVER_DEVICE_NAME=%s \
49+
-DPROBE_DEVICE_NAME=%s \
50+
.. && \
51+
sed -i s/'DRIVER_COMMIT ""'/'DRIVER_COMMIT "%s"'/g driver/src/driver_config.h`
52+
)
3553

3654
var HeadersNotFoundErr = errors.New("kernel headers not found")
3755

@@ -59,6 +77,7 @@ type commonTemplateData struct {
5977
BuildModule bool
6078
BuildProbe bool
6179
GCCVersion string
80+
CmakeCmd string
6281
}
6382

6483
// Builder represents a builder capable of generating a script for a driverkit target.
@@ -293,6 +312,15 @@ func (c Config) toTemplateData(b Builder, kr kernelrelease.KernelRelease) common
293312
BuildModule: len(c.ModuleFilePath) > 0,
294313
BuildProbe: len(c.ProbeFilePath) > 0,
295314
GCCVersion: c.GCCVersion,
315+
CmakeCmd: fmt.Sprintf(cmakeCmdFmt,
316+
c.DriverName,
317+
c.DriverName,
318+
c.DriverVersion,
319+
c.DriverVersion,
320+
c.DriverVersion,
321+
c.DeviceName,
322+
c.DeviceName,
323+
c.DriverVersion),
296324
}
297325
}
298326

pkg/driverbuilder/builder/templates/alinux.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ mv usr/src/kernels/*/* /tmp/kernel
4141

4242
cd {{ .DriverBuildDir }}
4343
mkdir -p build && cd build
44-
cmake -DUSE_BUNDLED_DEPS=On -DCREATE_TEST_TARGETS=Off -DBUILD_LIBSCAP_GVISOR=Off -DBUILD_LIBSCAP_MODERN_BPF=Off -DENABLE_DRIVERS_TESTS=Off -DDRIVER_NAME={{ .ModuleDriverName }} -DBUILD_BPF=On ..
44+
{{ .CmakeCmd }}
4545

4646
{{ if .BuildModule }}
4747
# Build the module

pkg/driverbuilder/builder/templates/almalinux.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ mv usr/src/kernels/*/* /tmp/kernel
4141

4242
cd {{ .DriverBuildDir }}
4343
mkdir -p build && cd build
44-
cmake -DUSE_BUNDLED_DEPS=On -DCREATE_TEST_TARGETS=Off -DBUILD_LIBSCAP_GVISOR=Off -DBUILD_LIBSCAP_MODERN_BPF=Off -DENABLE_DRIVERS_TESTS=Off -DDRIVER_NAME={{ .ModuleDriverName }} -DBUILD_BPF=On ..
44+
{{ .CmakeCmd }}
4545

4646
{{ if .BuildModule }}
4747
# Build the module

pkg/driverbuilder/builder/templates/amazonlinux.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ mv usr/src/kernels/*/* /tmp/kernel
4444

4545
cd {{ .DriverBuildDir }}
4646
mkdir -p build && cd build
47-
cmake -DUSE_BUNDLED_DEPS=On -DCREATE_TEST_TARGETS=Off -DBUILD_LIBSCAP_GVISOR=Off -DBUILD_LIBSCAP_MODERN_BPF=Off -DENABLE_DRIVERS_TESTS=Off -DDRIVER_NAME={{ .ModuleDriverName }} -DBUILD_BPF=On ..
47+
{{ .CmakeCmd }}
4848

4949
{{ if .BuildModule }}
5050
# Build the module

pkg/driverbuilder/builder/templates/archlinux.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ mv usr/lib/modules/*/build/* /tmp/kernel
4141

4242
cd {{ .DriverBuildDir }}
4343
mkdir -p build && cd build
44-
cmake -DUSE_BUNDLED_DEPS=On -DCREATE_TEST_TARGETS=Off -DBUILD_LIBSCAP_GVISOR=Off -DBUILD_LIBSCAP_MODERN_BPF=Off -DENABLE_DRIVERS_TESTS=Off -DDRIVER_NAME={{ .ModuleDriverName }} -DBUILD_BPF=On ..
44+
{{ .CmakeCmd }}
4545

4646
{{ if .BuildModule }}
4747
# Build the module

pkg/driverbuilder/builder/templates/centos.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ mv usr/src/kernels/*/* /tmp/kernel
4242
cd {{ .DriverBuildDir }}
4343
sed -i 's/$(MAKE) -C $(KERNELDIR)/$(MAKE) KCFLAGS="-Wno-incompatible-pointer-types" -C $(KERNELDIR)/g' driver/Makefile.in
4444
mkdir -p build && cd build
45-
cmake -DUSE_BUNDLED_DEPS=On -DCREATE_TEST_TARGETS=Off -DBUILD_LIBSCAP_GVISOR=Off -DBUILD_LIBSCAP_MODERN_BPF=Off -DENABLE_DRIVERS_TESTS=Off -DDRIVER_NAME={{ .ModuleDriverName }} -DBUILD_BPF=On ..
45+
{{ .CmakeCmd }}
4646

4747
{{ if .BuildModule }}
4848
# Build the module

pkg/driverbuilder/builder/templates/debian.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ sourcedir=$(find . -type d -name "{{ .KernelHeadersPattern }}" | head -n 1 | xar
4949

5050
cd {{ .DriverBuildDir }}
5151
mkdir -p build && cd build
52-
cmake -DUSE_BUNDLED_DEPS=On -DCREATE_TEST_TARGETS=Off -DBUILD_LIBSCAP_GVISOR=Off -DBUILD_LIBSCAP_MODERN_BPF=Off -DENABLE_DRIVERS_TESTS=Off -DDRIVER_NAME={{ .ModuleDriverName }} -DBUILD_BPF=On ..
52+
{{ .CmakeCmd }}
5353

5454
{{ if .BuildModule }}
5555
# Build the module

pkg/driverbuilder/builder/templates/fedora.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ mv usr/src/kernels/*/* /tmp/kernel
4141

4242
cd {{ .DriverBuildDir }}
4343
mkdir -p build && cd build
44-
cmake -DUSE_BUNDLED_DEPS=On -DCREATE_TEST_TARGETS=Off -DBUILD_LIBSCAP_GVISOR=Off -DBUILD_LIBSCAP_MODERN_BPF=Off -DENABLE_DRIVERS_TESTS=Off -DDRIVER_NAME={{ .ModuleDriverName }} -DBUILD_BPF=On ..
44+
{{ .CmakeCmd }}
4545

4646
{{ if .BuildModule }}
4747
# Build the module

pkg/driverbuilder/builder/templates/flatcar.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ make KCONFIG_CONFIG=/tmp/kernel.config modules_prepare
4848

4949
cd {{ .DriverBuildDir }}
5050
mkdir -p build && cd build
51-
cmake -DUSE_BUNDLED_DEPS=On -DCREATE_TEST_TARGETS=Off -DBUILD_LIBSCAP_GVISOR=Off -DBUILD_LIBSCAP_MODERN_BPF=Off -DENABLE_DRIVERS_TESTS=Off -DDRIVER_NAME={{ .ModuleDriverName }} -DBUILD_BPF=On ..
51+
{{ .CmakeCmd }}
5252

5353
{{ if .BuildModule }}
5454
# Build the module

pkg/driverbuilder/builder/templates/local.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ cd {{ .DriverBuildDir }}
3838
{{ if .DownloadSrc }}
3939
echo "* Configuring sources with cmake"
4040
mkdir -p build && cd build
41-
cmake -DUSE_BUNDLED_DEPS=On -DCREATE_TEST_TARGETS=Off -DBUILD_LIBSCAP_GVISOR=Off -DBUILD_LIBSCAP_MODERN_BPF=Off -DENABLE_DRIVERS_TESTS=Off -DDRIVER_NAME={{ .ModuleDriverName }} -DBUILD_BPF=On ..
41+
{{ .CmakeCmd }}
4242
{{ end }}
4343
{{ end }}
4444

pkg/driverbuilder/builder/templates/opensuse.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ sourcedir="$(find . -type d -name "linux-*-obj" | head -n 1 | xargs readlink -f)
4444

4545
cd {{ .DriverBuildDir }}
4646
mkdir -p build && cd build
47-
cmake -DUSE_BUNDLED_DEPS=On -DCREATE_TEST_TARGETS=Off -DBUILD_LIBSCAP_GVISOR=Off -DBUILD_LIBSCAP_MODERN_BPF=Off -DENABLE_DRIVERS_TESTS=Off -DDRIVER_NAME={{ .ModuleDriverName }} -DBUILD_BPF=On ..
47+
{{ .CmakeCmd }}
4848

4949
{{ if .BuildModule }}
5050
# Build the module

pkg/driverbuilder/builder/templates/oracle.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ mv usr/src/kernels/*/* /tmp/kernel
4141

4242
cd {{ .DriverBuildDir }}
4343
mkdir -p build && cd build
44-
cmake -DUSE_BUNDLED_DEPS=On -DCREATE_TEST_TARGETS=Off -DBUILD_LIBSCAP_GVISOR=Off -DBUILD_LIBSCAP_MODERN_BPF=Off -DENABLE_DRIVERS_TESTS=Off -DDRIVER_NAME={{ .ModuleDriverName }} -DBUILD_BPF=On ..
44+
{{ .CmakeCmd }}
4545

4646
{{ if .BuildModule }}
4747
# Build the module

pkg/driverbuilder/builder/templates/photonos.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ mv usr/src/linux-*headers-*/* /tmp/kernel
4444

4545
cd {{ .DriverBuildDir }}
4646
mkdir -p build && cd build
47-
cmake -DUSE_BUNDLED_DEPS=On -DCREATE_TEST_TARGETS=Off -DBUILD_LIBSCAP_GVISOR=Off -DBUILD_LIBSCAP_MODERN_BPF=Off -DENABLE_DRIVERS_TESTS=Off -DDRIVER_NAME={{ .ModuleDriverName }} -DBUILD_BPF=On ..
47+
{{ .CmakeCmd }}
4848

4949
{{ if .BuildModule }}
5050
# Build the module

pkg/driverbuilder/builder/templates/redhat.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ mv usr/src/kernels/*/* /tmp/kernel
4343

4444
cd {{ .DriverBuildDir }}
4545
mkdir -p build && cd build
46-
cmake -DUSE_BUNDLED_DEPS=On -DCREATE_TEST_TARGETS=Off -DBUILD_LIBSCAP_GVISOR=Off -DBUILD_LIBSCAP_MODERN_BPF=Off -DENABLE_DRIVERS_TESTS=Off -DDRIVER_NAME={{ .ModuleDriverName }} -DBUILD_BPF=On ..
46+
{{ .CmakeCmd }}
4747

4848
{{ if .BuildModule }}
4949
# Build the module

pkg/driverbuilder/builder/templates/rocky.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ mv usr/src/kernels/*/* /tmp/kernel
4141

4242
cd {{ .DriverBuildDir }}
4343
mkdir -p build && cd build
44-
cmake -DUSE_BUNDLED_DEPS=On -DCREATE_TEST_TARGETS=Off -DBUILD_LIBSCAP_GVISOR=Off -DBUILD_LIBSCAP_MODERN_BPF=Off -DENABLE_DRIVERS_TESTS=Off -DDRIVER_NAME={{ .ModuleDriverName }} -DBUILD_BPF=On ..
44+
{{ .CmakeCmd }}
4545

4646
{{ if .BuildModule }}
4747
# Build the module

pkg/driverbuilder/builder/templates/sles.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ sourcedir="$(find . -type d -name "linux-*-obj" | head -n 1 | xargs readlink -f)
4646

4747
cd {{ .DriverBuildDir }}
4848
mkdir -p build && cd build
49-
cmake -DUSE_BUNDLED_DEPS=On -DCREATE_TEST_TARGETS=Off -DBUILD_LIBSCAP_GVISOR=Off -DBUILD_LIBSCAP_MODERN_BPF=Off -DENABLE_DRIVERS_TESTS=Off -DDRIVER_NAME={{ .ModuleDriverName }} -DBUILD_BPF=On ..
49+
{{ .CmakeCmd }}
5050

5151
{{ if .BuildModule }}
5252
# Build the module

pkg/driverbuilder/builder/templates/ubuntu.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ sourcedir=$(find . -type d -name "{{ .KernelHeadersPattern }}" | head -n 1 | xar
4545

4646
cd {{ .DriverBuildDir }}
4747
mkdir -p build && cd build
48-
cmake -DUSE_BUNDLED_DEPS=On -DCREATE_TEST_TARGETS=Off -DBUILD_LIBSCAP_GVISOR=Off -DBUILD_LIBSCAP_MODERN_BPF=Off -DENABLE_DRIVERS_TESTS=Off -DDRIVER_NAME={{ .ModuleDriverName }} -DBUILD_BPF=On ..
48+
{{ .CmakeCmd }}
4949

5050
{{ if .BuildModule }}
5151
# Build the module

pkg/driverbuilder/builder/templates/vanilla.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export KBUILD_MODPOST_WARN=1
5858

5959
cd {{ .DriverBuildDir }}
6060
mkdir -p build && cd build
61-
cmake -DUSE_BUNDLED_DEPS=On -DCREATE_TEST_TARGETS=Off -DBUILD_LIBSCAP_GVISOR=Off -DBUILD_LIBSCAP_MODERN_BPF=Off -DENABLE_DRIVERS_TESTS=Off -DDRIVER_NAME={{ .ModuleDriverName }} -DBUILD_BPF=On ..
61+
{{ .CmakeCmd }}
6262

6363
{{ if .BuildModule }}
6464
# Build the module

0 commit comments

Comments
 (0)