The make generate commands currently starts by compiling build tools in the .tools folder, then it go installs mdatagen globally for use in go:generate. Unfortunately, go install does not take into account the version of mdatagen referenced in internal/tools/go.mod. This means it isn't possible to generate using the local version of mdatagen for testing, even with replace statements.
This PR fixes this by prepending .tools to the $PATH before running the generate command, which makes go:generate use the version of mdatagen in that folder instead of a global one.
(Originally, this PR also added a new modgenerate target in Makefile.Common, to allow running generate commands on a specific group of modules instead of all of them for efficiency reasons. After discussing it with @mx-psi, we decided to hold off on that change for a later PR, as it warrants further discussion.)
Description
This PR is in the context of this PR on the core Collector modifying
make check-contrib
to use the latest version ofmdatagen
.The
make generate
commands currently starts by compiling build tools in the.tools
folder, then itgo install
s mdatagen globally for use ingo:generate
. Unfortunately,go install
does not take into account the version ofmdatagen
referenced ininternal/tools/go.mod
. This means it isn't possible to generate using the local version ofmdatagen
for testing, even withreplace
statements.This PR fixes this by prepending
.tools
to the$PATH
before running the generate command, which makesgo:generate
use the version ofmdatagen
in that folder instead of a global one.(Originally, this PR also added a new
modgenerate
target inMakefile.Common
, to allow running generate commands on a specific group of modules instead of all of them for efficiency reasons. After discussing it with @mx-psi, we decided to hold off on that change for a later PR, as it warrants further discussion.)