| Message ID | 20251010075258.2161972-5-hongxu.jia@windriver.com |
|---|---|
| State | New |
| Headers | show |
| Series | [v5,1/5] distro/include: Add debug_build.inc when DEBUG_BUILD is enabled | expand |
On Fri, 2025-10-10 at 15:52 +0800, hongxu via lists.openembedded.org wrote: > The debug_build.inc is used to collect debug build configuration, > override BUILD_MODE and BUILD_DIR for cargo.bbclass when DEBUG_BUILD is enabled > > Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> > --- > meta/classes-recipe/cargo.bbclass | 4 ++-- > meta/conf/distro/include/debug_build.inc | 4 ++++ > 2 files changed, 6 insertions(+), 2 deletions(-) > > diff --git a/meta/classes-recipe/cargo.bbclass b/meta/classes-recipe/cargo.bbclass > index 2dd28e95d3..c90b8c18f0 100644 > --- a/meta/classes-recipe/cargo.bbclass > +++ b/meta/classes-recipe/cargo.bbclass > @@ -31,7 +31,7 @@ B = "${WORKDIR}/build" > export RUST_BACKTRACE = "1" > > RUSTFLAGS ??= "" > -BUILD_MODE = "${@['--release', ''][d.getVar('DEBUG_BUILD') == '1']}" > +BUILD_MODE ??= "--release" > # --frozen flag will prevent network access (which is required since only > # the do_fetch step is authorized to access network) > # and will require an up to date Cargo.lock file. > @@ -41,7 +41,7 @@ CARGO_BUILD_FLAGS = "-v --frozen --target ${RUST_HOST_SYS} ${BUILD_MODE} --manif > > # This is based on the content of CARGO_BUILD_FLAGS and generally will need to > # change if CARGO_BUILD_FLAGS changes. > -BUILD_DIR = "${@['release', 'debug'][d.getVar('DEBUG_BUILD') == '1']}" > +BUILD_DIR ??= "release" > CARGO_TARGET_SUBDIR = "${RUST_HOST_SYS}/${BUILD_DIR}" > oe_cargo_build () { > export RUSTFLAGS="${RUSTFLAGS}" > diff --git a/meta/conf/distro/include/debug_build.inc b/meta/conf/distro/include/debug_build.inc > index c8e2cf90cf..1b399b6f65 100644 > --- a/meta/conf/distro/include/debug_build.inc > +++ b/meta/conf/distro/include/debug_build.inc > @@ -47,3 +47,7 @@ INHIBIT_SYSROOT_STRIP:class-native ?= "1" > > # For meson.bbclass > MESON_BUILDTYPE ?= "debug" > + > +# For cargo.bbclass > +BUILD_MODE ?= "" > +BUILD_DIR ?= "debug" These worry me as they are generic names not specific to cargo. I'd really like to see a more cargo specific name if we're going to call this from generic code so we may need to do some renaming. Cheers, Richard
On 12/15/25 20:04, Richard Purdie wrote: > CAUTION: This email comes from a non Wind River email account! > Do not click links or open attachments unless you recognize the sender and know the content is safe. > > On Fri, 2025-10-10 at 15:52 +0800, hongxu via lists.openembedded.org wrote: >> The debug_build.inc is used to collect debug build configuration, >> override BUILD_MODE and BUILD_DIR for cargo.bbclass when DEBUG_BUILD is enabled >> >> Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> >> --- >> meta/classes-recipe/cargo.bbclass | 4 ++-- >> meta/conf/distro/include/debug_build.inc | 4 ++++ >> 2 files changed, 6 insertions(+), 2 deletions(-) >> >> diff --git a/meta/classes-recipe/cargo.bbclass b/meta/classes-recipe/cargo.bbclass >> index 2dd28e95d3..c90b8c18f0 100644 >> --- a/meta/classes-recipe/cargo.bbclass >> +++ b/meta/classes-recipe/cargo.bbclass >> @@ -31,7 +31,7 @@ B = "${WORKDIR}/build" >> export RUST_BACKTRACE = "1" >> >> RUSTFLAGS ??= "" >> -BUILD_MODE = "${@['--release', ''][d.getVar('DEBUG_BUILD') == '1']}" >> +BUILD_MODE ??= "--release" >> # --frozen flag will prevent network access (which is required since only >> # the do_fetch step is authorized to access network) >> # and will require an up to date Cargo.lock file. >> @@ -41,7 +41,7 @@ CARGO_BUILD_FLAGS = "-v --frozen --target ${RUST_HOST_SYS} ${BUILD_MODE} --manif >> >> # This is based on the content of CARGO_BUILD_FLAGS and generally will need to >> # change if CARGO_BUILD_FLAGS changes. >> -BUILD_DIR = "${@['release', 'debug'][d.getVar('DEBUG_BUILD') == '1']}" >> +BUILD_DIR ??= "release" >> CARGO_TARGET_SUBDIR = "${RUST_HOST_SYS}/${BUILD_DIR}" >> oe_cargo_build () { >> export RUSTFLAGS="${RUSTFLAGS}" >> diff --git a/meta/conf/distro/include/debug_build.inc b/meta/conf/distro/include/debug_build.inc >> index c8e2cf90cf..1b399b6f65 100644 >> --- a/meta/conf/distro/include/debug_build.inc >> +++ b/meta/conf/distro/include/debug_build.inc >> @@ -47,3 +47,7 @@ INHIBIT_SYSROOT_STRIP:class-native ?= "1" >> >> # For meson.bbclass >> MESON_BUILDTYPE ?= "debug" >> + >> +# For cargo.bbclass >> +BUILD_MODE ?= "" >> +BUILD_DIR ?= "debug" > These worry me as they are generic names not specific to cargo. I'd > really like to see a more cargo specific name if we're going to call > this from generic code so we may need to do some renaming. Copy, and do it for target only //Hongxu > Cheers, > > Richard
diff --git a/meta/classes-recipe/cargo.bbclass b/meta/classes-recipe/cargo.bbclass index 2dd28e95d3..c90b8c18f0 100644 --- a/meta/classes-recipe/cargo.bbclass +++ b/meta/classes-recipe/cargo.bbclass @@ -31,7 +31,7 @@ B = "${WORKDIR}/build" export RUST_BACKTRACE = "1" RUSTFLAGS ??= "" -BUILD_MODE = "${@['--release', ''][d.getVar('DEBUG_BUILD') == '1']}" +BUILD_MODE ??= "--release" # --frozen flag will prevent network access (which is required since only # the do_fetch step is authorized to access network) # and will require an up to date Cargo.lock file. @@ -41,7 +41,7 @@ CARGO_BUILD_FLAGS = "-v --frozen --target ${RUST_HOST_SYS} ${BUILD_MODE} --manif # This is based on the content of CARGO_BUILD_FLAGS and generally will need to # change if CARGO_BUILD_FLAGS changes. -BUILD_DIR = "${@['release', 'debug'][d.getVar('DEBUG_BUILD') == '1']}" +BUILD_DIR ??= "release" CARGO_TARGET_SUBDIR = "${RUST_HOST_SYS}/${BUILD_DIR}" oe_cargo_build () { export RUSTFLAGS="${RUSTFLAGS}" diff --git a/meta/conf/distro/include/debug_build.inc b/meta/conf/distro/include/debug_build.inc index c8e2cf90cf..1b399b6f65 100644 --- a/meta/conf/distro/include/debug_build.inc +++ b/meta/conf/distro/include/debug_build.inc @@ -47,3 +47,7 @@ INHIBIT_SYSROOT_STRIP:class-native ?= "1" # For meson.bbclass MESON_BUILDTYPE ?= "debug" + +# For cargo.bbclass +BUILD_MODE ?= "" +BUILD_DIR ?= "debug"
The debug_build.inc is used to collect debug build configuration, override BUILD_MODE and BUILD_DIR for cargo.bbclass when DEBUG_BUILD is enabled Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> --- meta/classes-recipe/cargo.bbclass | 4 ++-- meta/conf/distro/include/debug_build.inc | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-)