mirror of
https://git.yoctoproject.org/poky
synced 2026-03-12 10:19:44 +01:00
* use 4 spaces
* avoid trailing space
* add CARGO_LOCK_SRC_DIR to allow searching outside ${S}
* use BPN in output filename
* First I've used CARGO_LOCK_SRC_DIR as relative to ${S}, because that's what CARGO_SRC_DIR
in cargo.bbclass is using:
meta/classes-recipe/cargo.bbclass:CARGO_SRC_DIR ??= ""
meta/classes-recipe/cargo.bbclass:MANIFEST_PATH ??= "${S}/${CARGO_SRC_DIR}/Cargo.toml"
but change to absolute path (defaulting to ${S}) as requested by Alex:
11:44 < kanavin> JaMa, would prefer CARGO_LOCK_SRC_DIR ??= "${S}"
11:46 < kanavin> otherwise looks good
* I've resolved my usecase for CARGO_LOCK_SRC_DIR by changing
S back to ${WORKDIR}/git and using CARGO_SRC_DIR to select
the right subdirectory to be built, because the Cargo.toml
in this subdirectory was also referencing other subdirectories
with relative path:
88b147506d/token/cli/Cargo.toml (L30)
so including all Cargo.lock files in whole ${WORKDIR}/git
seems like reasonable approach
(From OE-Core rev: 7636a2b8080521ed2ad54b0edce47a8742a12d58)
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
46 lines
1.3 KiB
Plaintext
46 lines
1.3 KiB
Plaintext
#
|
|
# Copyright OpenEmbedded Contributors
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
|
|
##
|
|
## Purpose:
|
|
## This class is used to update the list of crates in SRC_URI
|
|
## by reading Cargo.lock in the source tree.
|
|
##
|
|
## See meta/recipes-devtools/python/python3-bcrypt_*.bb for an example
|
|
##
|
|
## To perform the update: bitbake -c update_crates recipe-name
|
|
|
|
addtask do_update_crates after do_patch
|
|
do_update_crates[depends] = "python3-native:do_populate_sysroot"
|
|
|
|
# The directory where to search for Cargo.lock files
|
|
CARGO_LOCK_SRC_DIR ??= "${S}"
|
|
|
|
do_update_crates() {
|
|
nativepython3 - <<EOF
|
|
|
|
def get_crates(f):
|
|
import tomllib
|
|
c_list = '# from %s' % os.path.relpath(f, '${CARGO_LOCK_SRC_DIR}')
|
|
c_list += '\nSRC_URI += " \\\'
|
|
crates = tomllib.load(open(f, 'rb'))
|
|
for c in crates['package']:
|
|
if 'source' in c and 'crates.io' in c['source']:
|
|
c_list += '\n crate://crates.io/%s/%s \\\' % (c['name'], c['version'])
|
|
c_list += '\n"\n'
|
|
return c_list
|
|
|
|
import os
|
|
crates = "# Autogenerated with 'bitbake -c update_crates ${PN}'\n\n"
|
|
for root, dirs, files in os.walk('${CARGO_LOCK_SRC_DIR}'):
|
|
for file in files:
|
|
if file == 'Cargo.lock':
|
|
crates += get_crates(os.path.join(root, file))
|
|
open(os.path.join('${THISDIR}', '${BPN}'+"-crates.inc"), 'w').write(crates)
|
|
|
|
EOF
|
|
}
|