cargo: Rename MANIFEST_PATH -> CARGO_MANIFEST_PATH
PATCH 1/3 cargo: Rename MANIFEST_PATH -> CARGO_MANIFEST_PATH
This variable is a piece of recipe configurable interface, scope it with the class name to make that clear.
---
meta/classes-recipe/cargo.bbclass | 4 ++-- meta/classes-recipe/cargo_common.bbclass | 2 +- meta/classes-recipe/ptest-cargo.bbclass | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
meta/classes-recipe/cargo.bbclass +2 -2
@@ -35,7 +35,7 @@ export RUST_BACKTRACE = "1" CARGO_SRC_DIR ??= "" # The actual path to the Cargo.toml -MANIFEST_PATH ??= "${S}/${CARGO_SRC_DIR}/Cargo.toml" +CARGO_MANIFEST_PATH ??= "${S}/${CARGO_SRC_DIR}/Cargo.toml" RUSTFLAGS ??= "" BUILD_MODE = "${@['--release', ''][d.getVar('DEBUG_BUILD') == '1']}"
@@ -44,7 +44,7 @@ BUILD_MODE = "${@['--release', ''][d.getVar('DEBUG_BUILD') == '1']}" # and will require an up to date Cargo.lock file. # This force the package being built to already ship a Cargo.lock, in the end # this is what we want, at least, for reproducibility of the build. -CARGO_BUILD_FLAGS = "-v --frozen --target ${RUST_HOST_SYS} ${BUILD_MODE} --manifest-path=${MANIFEST_PATH}" +CARGO_BUILD_FLAGS = "-v --frozen --target ${RUST_HOST_SYS} ${BUILD_MODE} --manifest-path=${CARGO_MANIFEST_PATH}" # This is based on the content of CARGO_BUILD_FLAGS and generally will need to # change if CARGO_BUILD_FLAGS changes.
meta/classes-recipe/cargo_common.bbclass +1 -1
@@ -161,7 +161,7 @@ python cargo_common_do_patch_paths() { # here is better than letting cargo tell (in case the file is missing) # "Cargo.lock should be modified but --frozen was given" - manifest_path = d.getVar("MANIFEST_PATH", True) + manifest_path = d.getVar("CARGO_MANIFEST_PATH", True) lockfile = os.path.join(os.path.dirname(manifest_path), "Cargo.lock") if not os.path.exists(lockfile): bb.fatal(f"{lockfile} file doesn't exist")
meta/classes-recipe/ptest-cargo.bbclass +1 -1
@@ -15,7 +15,7 @@ python do_compile_ptest_cargo() { cargo = bb.utils.which(d.getVar("PATH"), d.getVar("CARGO", True)) cargo_build_flags = d.getVar("CARGO_BUILD_FLAGS", True) rust_flags = d.getVar("RUSTFLAGS", True) - manifest_path = d.getVar("MANIFEST_PATH", True) + manifest_path = d.getVar("CARGO_MANIFEST_PATH", True) project_manifest_path = os.path.normpath(manifest_path) manifest_dir = os.path.dirname(manifest_path)
Signature · 1 line
2.39.0
PATCH 2/3 cargo: Move CARGO_MANIFEST_PATH/CARGO_SRC_DIR to cargo_common
cargo_common_do_configure uses CARGO_MANIFEST_PATH (which depends on CARGO_SRC_DIR), but their definition was in cargo.bbclass.
Match the other variables here and change to default values, rather than weak defaults.
---
meta/classes-recipe/cargo.bbclass | 7 ------- meta/classes-recipe/cargo_common.bbclass | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-)
meta/classes-recipe/cargo.bbclass +0 -7
@@ -30,13 +30,6 @@ B = "${WORKDIR}/build" # where the issue occured export RUST_BACKTRACE = "1" -# The directory of the Cargo.toml relative to the root directory, per default -# assume there's a Cargo.toml directly in the root directory -CARGO_SRC_DIR ??= "" - -# The actual path to the Cargo.toml -CARGO_MANIFEST_PATH ??= "${S}/${CARGO_SRC_DIR}/Cargo.toml" - RUSTFLAGS ??= "" BUILD_MODE = "${@['--release', ''][d.getVar('DEBUG_BUILD') == '1']}" # --frozen flag will prevent network access (which is required since only
meta/classes-recipe/cargo_common.bbclass +7 -0
@@ -33,6 +33,13 @@ CARGO_DISABLE_BITBAKE_VENDORING ?= "0" # Used by libstd-rs to point to the vendor dir included in rustc src CARGO_VENDORING_DIRECTORY ?= "${CARGO_HOME}/bitbake" +# The directory of the Cargo.toml relative to the root directory, per default +# assume there's a Cargo.toml directly in the root directory +CARGO_SRC_DIR ?= "" + +# The actual path to the Cargo.toml +CARGO_MANIFEST_PATH ?= "${S}/${CARGO_SRC_DIR}/Cargo.toml" + CARGO_RUST_TARGET_CCLD ?= "${RUST_TARGET_CCLD}" cargo_common_do_configure () { mkdir -p ${CARGO_HOME}/bitbake
Signature · 1 line
2.39.0
Re: [OE-Core][PATCH 2/3] cargo: Move CARGO_MANIFEST_PATH/CARGO_SRC_DIR to cargo_common
Quoted 5 lines · Alex Kiernan
cargo_common_do_configureusesCARGO_MANIFEST_PATH(which depends onCARGO_SRC_DIR), but their definition was in cargo.bbclass.Match the other variables here and change to default values, rather than weak defaults.
FWIW "single value" class variables tend to work much better as ??= (which I'd call default value) since than it doesn't matter if the recipe setting comes before or after the inherit and the inherit position in the recipe doesn't matter.
I'd call ?= a weak assignment or weak default.
Thanks for working on cleaning some of these things up. I got so far with it originally and then ran out of time (and too frustrated with the long build/test cycles!).
Cheers,
Richard
Quoted 52 lines
Signed-off-by Alex Kiernan <[email protected]>---
meta/classes-recipe/cargo.bbclass | 7 ------- meta/classes-recipe/cargo_common.bbclass | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-)meta/classes-recipe/cargo.bbclass +0
-7@@ -30,13 +30,6 @@ B = "${WORKDIR}/build" # where the issue occured export RUST_BACKTRACE = "1" -# The directory of the Cargo.toml relative to the root directory, per default -# assume there's a Cargo.toml directly in the root directory -CARGO_SRC_DIR ??= "" - -# The actual path to the Cargo.toml -CARGO_MANIFEST_PATH ??= "${S}/${CARGO_SRC_DIR}/Cargo.toml" - RUSTFLAGS ??= "" BUILD_MODE = "${@['--release', ''][d.getVar('DEBUG_BUILD') == '1']}" # --frozen flag will prevent network access (which is required since onlymeta/classes-recipe/cargo_common.bbclass +7
-1@@ -33,6 +33,13 @@ CARGO_DISABLE_BITBAKE_VENDORING ?= "0" # Used by libstd-rs to point to the vendor dir included in rustc src CARGO_VENDORING_DIRECTORY ?= "${CARGO_HOME}/bitbake" +# The directory of the Cargo.toml relative to the root directory, per default +# assume there's a Cargo.toml directly in the root directory +CARGO_SRC_DIR ?= "" + +# The actual path to the Cargo.toml +CARGO_MANIFEST_PATH ?= "${S}/${CARGO_SRC_DIR}/Cargo.toml" + CARGO_RUST_TARGET_CCLD ?= "${RUST_TARGET_CCLD}" cargo_common_do_configure () { mkdir -p ${CARGO_HOME}/bitbake -=-=-=-=-=-=-=-=-=-=-=-Links: You receive all messages sent to this group.
View/Reply Online (#191955): https://lists.openembedded.org/g/openembedded-core/message/191955
Mute This Topic: https://lists.openembedded.org/mt/103034028/1686473
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [OE-Core][PATCH 2/3] cargo: Move CARGO_MANIFEST_PATH/CARGO_SRC_DIR to cargo_common
Quoted 5 lines · Richard Purdie
Quoted 3 lines · Alex Kiernan
cargo_common_do_configureusesCARGO_MANIFEST_PATH(which depends onCARGO_SRC_DIR), but their definition was in cargo.bbclass.
Quoted 8 lines
Quoted 2 lines
Match the other variables here and change to default values, rather than weak defaults.
FWIW "single value" class variables tend to work much better as ??= (which I'd call default value) since than it doesn't matter if the recipe setting comes before or after the inherit and the inherit position in the recipe doesn't matter.
Ah, I guess that makes sense - for "single value" :append/:remove aren't really useful, so leaving the actual assignment as late as possible works?
TBH I've never really been very clear what the "right" thing to use is between ?= and ??=
Quoted 6 lines
I'd call ?= a weak assignment or weak default.
Thanks for working on cleaning some of these things up. I got so far with it originally and then ran out of time (and too frustrated with the long build/test cycles!).
I'll go back and do the opposite cleanup and send a v2.
Quoted 57 lines
Cheers,
Richard
Quoted 52 lines
Signed-off-by Alex Kiernan <[email protected]>---
meta/classes-recipe/cargo.bbclass | 7 ------- meta/classes-recipe/cargo_common.bbclass | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-)meta/classes-recipe/cargo.bbclass +0
-7@@ -30,13 +30,6 @@ B = "${WORKDIR}/build" # where the issue occured export RUST_BACKTRACE = "1" -# The directory of the Cargo.toml relative to the root directory, per default -# assume there's a Cargo.toml directly in the root directory -CARGO_SRC_DIR ??= "" - -# The actual path to the Cargo.toml -CARGO_MANIFEST_PATH ??= "${S}/${CARGO_SRC_DIR}/Cargo.toml" - RUSTFLAGS ??= "" BUILD_MODE = "${@['--release', ''][d.getVar('DEBUG_BUILD') == '1']}" # --frozen flag will prevent network access (which is required since onlymeta/classes-recipe/cargo_common.bbclass +7
-1@@ -33,6 +33,13 @@ CARGO_DISABLE_BITBAKE_VENDORING ?= "0" # Used by libstd-rs to point to the vendor dir included in rustc src CARGO_VENDORING_DIRECTORY ?= "${CARGO_HOME}/bitbake" +# The directory of the Cargo.toml relative to the root directory, per default +# assume there's a Cargo.toml directly in the root directory +CARGO_SRC_DIR ?= "" + +# The actual path to the Cargo.toml +CARGO_MANIFEST_PATH ?= "${S}/${CARGO_SRC_DIR}/Cargo.toml" + CARGO_RUST_TARGET_CCLD ?= "${RUST_TARGET_CCLD}" cargo_common_do_configure () { mkdir -p ${CARGO_HOME}/bitbake -=-=-=-=-=-=-=-=-=-=-=-Links: You receive all messages sent to this group.
View/Reply Online (#191955): https://lists.openembedded.org/g/openembedded-core/message/191955
Mute This Topic: https://lists.openembedded.org/mt/103034028/1686473
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Signature · 1 line
Alex Kiernan
Re: [OE-Core][PATCH 2/3] cargo: Move CARGO_MANIFEST_PATH/CARGO_SRC_DIR to cargo_common
Quoted 16 lines · Alex Kiernan
Quoted 5 lines · Richard Purdie
Quoted 3 lines · Alex Kiernan
cargo_common_do_configureusesCARGO_MANIFEST_PATH(which depends onCARGO_SRC_DIR), but their definition was in cargo.bbclass.Quoted 8 lines
Quoted 2 lines
Match the other variables here and change to default values, rather than weak defaults.
FWIW "single value" class variables tend to work much better as ??= (which I'd call default value) since than it doesn't matter if the recipe setting comes before or after the inherit and the inherit position in the recipe doesn't matter.
Quoted 3 lines
Ah, I guess that makes sense - for "single value" :append/:remove aren't really useful, so leaving the actual assignment as late as possible works?
??= means "fall back to this value if nothing else is ever set".
For a single value, append or += never makes sense so the fallback is probably what we want from a class regardless of order.
If you use ?= it just adds some ordering constraints.
Quoted 2 lines
TBH I've never really been very clear what the "right" thing to use is between ?= and ??=
For the above case it is one of the few "clearer" cases. As soon as you have multiple values, it becomes fuzzy sadly. I'm not sure how we improve things either.
Cheers,
Richard
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [OE-Core][PATCH 2/3] cargo: Move CARGO_MANIFEST_PATH/CARGO_SRC_DIR to cargo_common
Quoted 17 lines · Alex Kiernan via lists.openembedded.org
Quoted 5 lines · Richard Purdie
Quoted 3 lines · Alex Kiernan
cargo_common_do_configureusesCARGO_MANIFEST_PATH(which depends onCARGO_SRC_DIR), but their definition was in cargo.bbclass.Quoted 8 lines
Quoted 2 lines
Match the other variables here and change to default values, rather than weak defaults.
FWIW "single value" class variables tend to work much better as ??= (which I'd call default value) since than it doesn't matter if the recipe setting comes before or after the inherit and the inherit position in the recipe doesn't matter.
Quoted 4 lines
Ah, I guess that makes sense - for "single value" :append/:remove aren't really useful, so leaving the actual assignment as late as possible works?
And I've just read the bitbake docs and I clearly still don't really understand... its += / -= rather than append/remove which are the things which are important here.
Quoted 76 lines
TBH I've never really been very clear what the "right" thing to use is between ?= and ??=
Quoted 6 lines
I'd call ?= a weak assignment or weak default.
Thanks for working on cleaning some of these things up. I got so far with it originally and then ran out of time (and too frustrated with the long build/test cycles!).
I'll go back and do the opposite cleanup and send a v2.
Quoted 38 lines
Cheers,
Richard
Quoted 34 lines
Signed-off-by Alex Kiernan <[email protected]>---
meta/classes-recipe/cargo.bbclass | 7 ------- meta/classes-recipe/cargo_common.bbclass | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-)meta/classes-recipe/cargo.bbclass +0
-7@@ -30,13 +30,6 @@ B = "${WORKDIR}/build" # where the issue occured export RUST_BACKTRACE = "1" -# The directory of the Cargo.toml relative to the root directory, per default -# assume there's a Cargo.toml directly in the root directory -CARGO_SRC_DIR ??= "" - -# The actual path to the Cargo.toml -CARGO_MANIFEST_PATH ??= "${S}/${CARGO_SRC_DIR}/Cargo.toml" - RUSTFLAGS ??= "" BUILD_MODE = "${@['--release', ''][d.getVar('DEBUG_BUILD') == '1']}" # --frozen flag will prevent network access (which is required since onlymeta/classes-recipe/cargo_common.bbclass +0
-0@@ -33,6 +33,13 @@ CARGO_DISABLE_BITBAKE_VENDORING ?= "0" # Used by libstd-rs to point to the vendor dir included in rustc src CARGO_VENDORING_DIRECTORY ?= "${CARGO_HOME}/bitbake"Quoted 13 lines
meta/classes-recipe/cargo_common.bbclass CARGO_DISABLE_BITBAKE_VENDORING ?= "0" · line 45
Quoted 12 lines
meta/classes-recipe/cargo_common.bbclass +7
-0+# The directory of the Cargo.toml relative to the root directory, per default +# assume there's a Cargo.toml directly in the root directory +CARGO_SRC_DIR ?= "" + +# The actual path to the Cargo.toml +CARGO_MANIFEST_PATH ?= "${S}/${CARGO_SRC_DIR}/Cargo.toml" + CARGO_RUST_TARGET_CCLD ?= "${RUST_TARGET_CCLD}" cargo_common_do_configure () { mkdir -p ${CARGO_HOME}/bitbake--
Alex Kiernan-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#192014): https://lists.openembedded.org/g/openembedded-core/message/192014
Mute This Topic: https://lists.openembedded.org/mt/103034028/3618097
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Signature · 1 line
Alex Kiernan
Re: [OE-Core][PATCH 2/3] cargo: Move CARGO_MANIFEST_PATH/CARGO_SRC_DIR to cargo_common
Quoted 19 lines · Alex Kiernan
Quoted 17 lines · Alex Kiernan via lists.openembedded.org
Quoted 13 lines · Richard Purdie
Quoted 5 lines · Alex Kiernan
cargo_common_do_configureusesCARGO_MANIFEST_PATH(which depends onCARGO_SRC_DIR), but their definition was in cargo.bbclass.Match the other variables here and change to default values, rather than weak defaults.
FWIW "single value" class variables tend to work much better as ??= (which I'd call default value) since than it doesn't matter if the recipe setting comes before or after the inherit and the inherit position in the recipe doesn't matter.
Quoted 11 lines
Quoted 4 lines
Ah, I guess that makes sense - for "single value" :append/:remove aren't really useful, so leaving the actual assignment as late as possible works?
And I've just read the bitbake docs and I clearly still don't really understand... its += / -= rather than append/remove which are the things which are important here.
Quoted 2 lines
TBH I've never really been very clear what the "right" thing to use is between ?= and ??=
For something which isn't a single value, you'd need to use += or append and that gets much more unclear. My comments were only for single value variables as we don't have a good answer for the rest, much as I wish we had.
Cheers,
Richard
PATCH 3/3 cargo: Add CARGO_LOCK_PATH for path to Cargo.lock
In reply to Alex KiernanWhen building a workspace enabled project, the Cargo.lock is found at the root of the project, not alongside the Cargo.toml. Expose CARGO_LOCK_PATH so it can be explicitly configured.
---
meta/classes-recipe/cargo_common.bbclass | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
meta/classes-recipe/cargo_common.bbclass +4 -2
@@ -40,6 +40,9 @@ CARGO_SRC_DIR ?= "" # The actual path to the Cargo.toml CARGO_MANIFEST_PATH ?= "${S}/${CARGO_SRC_DIR}/Cargo.toml" +# Path to Cargo.lock +CARGO_LOCK_PATH ?= "${@ os.path.join(os.path.dirname(d.getVar('CARGO_MANIFEST_PATH', True)), 'Cargo.lock')}" + CARGO_RUST_TARGET_CCLD ?= "${RUST_TARGET_CCLD}" cargo_common_do_configure () { mkdir -p ${CARGO_HOME}/bitbake
@@ -168,8 +171,7 @@ python cargo_common_do_patch_paths() { # here is better than letting cargo tell (in case the file is missing) # "Cargo.lock should be modified but --frozen was given" - manifest_path = d.getVar("CARGO_MANIFEST_PATH", True) - lockfile = os.path.join(os.path.dirname(manifest_path), "Cargo.lock") + lockfile = d.getVar("CARGO_LOCK_PATH", True) if not os.path.exists(lockfile): bb.fatal(f"{lockfile} file doesn't exist")
Signature · 1 line
2.39.0