Message ID | fde568774cf2bd9174d1ecb4d9378a362a254f29.1692099121.git.frederic.martinsons@gmail.com |
---|---|
State | New |
Headers | show |
Series | [PATHCH,V3,1/4] rust: add cargo-c native recipe | expand |
> -----Original Message----- > From: openembedded-core@lists.openembedded.org <openembedded-core@lists.openembedded.org> On Behalf Of Frederic Martinsons > Sent: den 15 augusti 2023 17:36 > To: openembedded-core@lists.openembedded.org > Subject: [OE-core] [PATHCH V3 2/4] classes-recipe: add cargo_c.bbclass > > From: Frederic Martinsons <frederic.martinsons@gmail.com> > > This class can be used inside rust recipe to generate > a rust library that can be called by C/C++ code. > > The rust recipe which uses this class has to only replace > "inherit cargo" by "inherit cargo-c". Typo: cargo-c -> cargo_c > > Signed-off-by: Frederic Martinsons <frederic.martinsons@gmail.com> > --- > meta/classes-recipe/cargo_c.bbclass | 41 +++++++++++++++++++++++++++++ > 1 file changed, 41 insertions(+) > create mode 100644 meta/classes-recipe/cargo_c.bbclass > > diff --git a/meta/classes-recipe/cargo_c.bbclass b/meta/classes-recipe/cargo_c.bbclass > new file mode 100644 > index 0000000000..c083f69c08 > --- /dev/null > +++ b/meta/classes-recipe/cargo_c.bbclass > @@ -0,0 +1,41 @@ > +# > +# Copyright OpenEmbedded Contributors > +# > +# SPDX-License-Identifier: MIT > +# > + > +## > +## Purpose: > +## This class is used by any recipes that want to compile a C ABI compatible > +## library with header and pkg config file > + > +inherit cargo pkgconfig > + > +# the binaries we will use > +CARGO_C_BUILD = "cargo-cbuild" > +CARGO_C_INSTALL = "cargo-cinstall" > + > +# We need cargo-c to compile for the target > +BASEDEPENDS:append = " cargo-c-native" > + > +do_compile[progress] = "outof:\s+(\d+)/(\d+)" > +cargo_c_do_compile() { > + oe_cargo_fix_env > + export RUSTFLAGS="${RUSTFLAGS}" > + bbnote "Using rust targets from ${RUST_TARGET_PATH}" > + bbnote "cargo-cbuild = $(which ${CARGO_C_BUILD})" > + bbnote "${CARGO_C_BUILD} cbuild ${CARGO_BUILD_FLAGS}" > + "${CARGO_C_BUILD}" cbuild ${CARGO_BUILD_FLAGS} > +} > + > +cargo_c_do_install() { > + oe_cargo_fix_env > + export RUSTFLAGS="${RUSTFLAGS}" > + bbnote "cargo-cinstall = $(which ${CARGO_C_INSTALL})" > + "${CARGO_C_INSTALL}" cinstall ${CARGO_BUILD_FLAGS} \ > + --destdir ${D} \ > + --prefix /usr \ Shouldn't that be "${prefix}" rather than "/usr"? > + --library-type cdylib > +} > + > +EXPORT_FUNCTIONS do_compile do_install > -- > 2.34.1 //Peter
Le mer. 16 août 2023, 01:11, Peter Kjellerstedt <peter.kjellerstedt@axis.com> a écrit : > > -----Original Message----- > > From: openembedded-core@lists.openembedded.org < > openembedded-core@lists.openembedded.org> On Behalf Of Frederic Martinsons > > Sent: den 15 augusti 2023 17:36 > > To: openembedded-core@lists.openembedded.org > > Subject: [OE-core] [PATHCH V3 2/4] classes-recipe: add cargo_c.bbclass > > > > From: Frederic Martinsons <frederic.martinsons@gmail.com> > > > > This class can be used inside rust recipe to generate > > a rust library that can be called by C/C++ code. > > > > The rust recipe which uses this class has to only replace > > "inherit cargo" by "inherit cargo-c". > > Typo: cargo-c -> cargo_c > > > > > Signed-off-by: Frederic Martinsons <frederic.martinsons@gmail.com> > > --- > > meta/classes-recipe/cargo_c.bbclass | 41 +++++++++++++++++++++++++++++ > > 1 file changed, 41 insertions(+) > > create mode 100644 meta/classes-recipe/cargo_c.bbclass > > > > diff --git a/meta/classes-recipe/cargo_c.bbclass > b/meta/classes-recipe/cargo_c.bbclass > > new file mode 100644 > > index 0000000000..c083f69c08 > > --- /dev/null > > +++ b/meta/classes-recipe/cargo_c.bbclass > > @@ -0,0 +1,41 @@ > > +# > > +# Copyright OpenEmbedded Contributors > > +# > > +# SPDX-License-Identifier: MIT > > +# > > + > > +## > > +## Purpose: > > +## This class is used by any recipes that want to compile a C ABI > compatible > > +## library with header and pkg config file > > + > > +inherit cargo pkgconfig > > + > > +# the binaries we will use > > +CARGO_C_BUILD = "cargo-cbuild" > > +CARGO_C_INSTALL = "cargo-cinstall" > > + > > +# We need cargo-c to compile for the target > > +BASEDEPENDS:append = " cargo-c-native" > > + > > +do_compile[progress] = "outof:\s+(\d+)/(\d+)" > > +cargo_c_do_compile() { > > + oe_cargo_fix_env > > + export RUSTFLAGS="${RUSTFLAGS}" > > + bbnote "Using rust targets from ${RUST_TARGET_PATH}" > > + bbnote "cargo-cbuild = $(which ${CARGO_C_BUILD})" > > + bbnote "${CARGO_C_BUILD} cbuild ${CARGO_BUILD_FLAGS}" > > + "${CARGO_C_BUILD}" cbuild ${CARGO_BUILD_FLAGS} > > +} > > + > > +cargo_c_do_install() { > > + oe_cargo_fix_env > > + export RUSTFLAGS="${RUSTFLAGS}" > > + bbnote "cargo-cinstall = $(which ${CARGO_C_INSTALL})" > > + "${CARGO_C_INSTALL}" cinstall ${CARGO_BUILD_FLAGS} \ > > + --destdir ${D} \ > > + --prefix /usr \ > > Shouldn't that be "${prefix}" rather than "/usr"? > Yes you're right. I'll send a v4 with that correction and fix the typo you mentioned. Thanks. > > > + --library-type cdylib > > +} > > + > > +EXPORT_FUNCTIONS do_compile do_install > > -- > > 2.34.1 > > //Peter >
diff --git a/meta/classes-recipe/cargo_c.bbclass b/meta/classes-recipe/cargo_c.bbclass new file mode 100644 index 0000000000..c083f69c08 --- /dev/null +++ b/meta/classes-recipe/cargo_c.bbclass @@ -0,0 +1,41 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +## +## Purpose: +## This class is used by any recipes that want to compile a C ABI compatible +## library with header and pkg config file + +inherit cargo pkgconfig + +# the binaries we will use +CARGO_C_BUILD = "cargo-cbuild" +CARGO_C_INSTALL = "cargo-cinstall" + +# We need cargo-c to compile for the target +BASEDEPENDS:append = " cargo-c-native" + +do_compile[progress] = "outof:\s+(\d+)/(\d+)" +cargo_c_do_compile() { + oe_cargo_fix_env + export RUSTFLAGS="${RUSTFLAGS}" + bbnote "Using rust targets from ${RUST_TARGET_PATH}" + bbnote "cargo-cbuild = $(which ${CARGO_C_BUILD})" + bbnote "${CARGO_C_BUILD} cbuild ${CARGO_BUILD_FLAGS}" + "${CARGO_C_BUILD}" cbuild ${CARGO_BUILD_FLAGS} +} + +cargo_c_do_install() { + oe_cargo_fix_env + export RUSTFLAGS="${RUSTFLAGS}" + bbnote "cargo-cinstall = $(which ${CARGO_C_INSTALL})" + "${CARGO_C_INSTALL}" cinstall ${CARGO_BUILD_FLAGS} \ + --destdir ${D} \ + --prefix /usr \ + --library-type cdylib +} + +EXPORT_FUNCTIONS do_compile do_install