diff options
author | Frederic Martinsons <frederic.martinsons@gmail.com> | 2023-08-17 07:04:15 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-08-21 16:15:35 +0100 |
commit | 5116f2b2cf3d00fc2c9f41f8ce3661ed7bb4975e (patch) | |
tree | 6aa9a1a1267e7229afe8f969c4fa4548c94cfdb7 /meta-selftest/recipes-devtools | |
parent | c318d1914e0b65e04b945f67651a56c2699eb969 (diff) | |
download | poky-5116f2b2cf3d00fc2c9f41f8ce3661ed7bb4975e.tar.gz |
rust: provide examples for C library generation in rust
rust-c-lib-example is a little rust code which provide
a single function to print a formatted date (via the chrono crate)
from an input timestamp in millisecond. It has the necessary FFI
annotation and inherit cargo_c class for the C ABI compatible
library generation.
rust-c-lib-example is meson project for the C code which
will call the print_date function from rust-c-lib-example
if no argument is provided, if any argument is provided
it will print "Hello world in rust from C!"
add a runtime test case to check if all went well.
(From OE-Core rev: bb177c7764b1bc47157d57d7a34930e59a7acef3)
Signed-off-by: Frederic Martinsons <frederic.martinsons@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta-selftest/recipes-devtools')
3 files changed, 110 insertions, 0 deletions
diff --git a/meta-selftest/recipes-devtools/rust/rust-c-lib-example-bin_git.bb b/meta-selftest/recipes-devtools/rust/rust-c-lib-example-bin_git.bb new file mode 100644 index 0000000000..47d878597a --- /dev/null +++ b/meta-selftest/recipes-devtools/rust/rust-c-lib-example-bin_git.bb | |||
@@ -0,0 +1,16 @@ | |||
1 | DESCRIPTION = "A simple example for C wrapper around a rust library" | ||
2 | HOMEPAGE = "https://gitlab.com/fmartinsonsHome/rust-c-lib-example" | ||
3 | LICENSE = "MIT" | ||
4 | LIC_FILES_CHKSUM = "file://LICENSE;md5=cb9c441273ed8a029701a086befbfc63" | ||
5 | |||
6 | SRC_URI = " \ | ||
7 | git://gitlab.com/fmartinsonsHome/rust-c-lib-example.git;branch=main;protocol=https \ | ||
8 | " | ||
9 | |||
10 | SRCREV = "fc53c457f69aa5221ec1f8619a007e8150db5e60" | ||
11 | S = "${WORKDIR}/git" | ||
12 | |||
13 | DEPENDS = "rust-c-lib-example" | ||
14 | |||
15 | inherit meson pkgconfig | ||
16 | |||
diff --git a/meta-selftest/recipes-devtools/rust/rust-c-lib-example-crates.inc b/meta-selftest/recipes-devtools/rust/rust-c-lib-example-crates.inc new file mode 100644 index 0000000000..05f5949203 --- /dev/null +++ b/meta-selftest/recipes-devtools/rust/rust-c-lib-example-crates.inc | |||
@@ -0,0 +1,79 @@ | |||
1 | SRC_URI += " \ | ||
2 | crate://crates.io/android-tzdata/0.1.1 \ | ||
3 | crate://crates.io/android_system_properties/0.1.5 \ | ||
4 | crate://crates.io/autocfg/1.1.0 \ | ||
5 | crate://crates.io/bumpalo/3.13.0 \ | ||
6 | crate://crates.io/cc/1.0.82 \ | ||
7 | crate://crates.io/cfg-if/1.0.0 \ | ||
8 | crate://crates.io/chrono/0.4.26 \ | ||
9 | crate://crates.io/core-foundation-sys/0.8.4 \ | ||
10 | crate://crates.io/iana-time-zone/0.1.57 \ | ||
11 | crate://crates.io/iana-time-zone-haiku/0.1.2 \ | ||
12 | crate://crates.io/js-sys/0.3.64 \ | ||
13 | crate://crates.io/libc/0.2.147 \ | ||
14 | crate://crates.io/log/0.4.19 \ | ||
15 | crate://crates.io/num-traits/0.2.16 \ | ||
16 | crate://crates.io/once_cell/1.18.0 \ | ||
17 | crate://crates.io/proc-macro2/1.0.66 \ | ||
18 | crate://crates.io/quote/1.0.32 \ | ||
19 | crate://crates.io/syn/2.0.28 \ | ||
20 | crate://crates.io/time/0.1.45 \ | ||
21 | crate://crates.io/unicode-ident/1.0.11 \ | ||
22 | crate://crates.io/wasi/0.10.0+wasi-snapshot-preview1 \ | ||
23 | crate://crates.io/wasm-bindgen/0.2.87 \ | ||
24 | crate://crates.io/wasm-bindgen-backend/0.2.87 \ | ||
25 | crate://crates.io/wasm-bindgen-macro/0.2.87 \ | ||
26 | crate://crates.io/wasm-bindgen-macro-support/0.2.87 \ | ||
27 | crate://crates.io/wasm-bindgen-shared/0.2.87 \ | ||
28 | crate://crates.io/winapi/0.3.9 \ | ||
29 | crate://crates.io/winapi-i686-pc-windows-gnu/0.4.0 \ | ||
30 | crate://crates.io/winapi-x86_64-pc-windows-gnu/0.4.0 \ | ||
31 | crate://crates.io/windows/0.48.0 \ | ||
32 | crate://crates.io/windows-targets/0.48.1 \ | ||
33 | crate://crates.io/windows_aarch64_gnullvm/0.48.0 \ | ||
34 | crate://crates.io/windows_aarch64_msvc/0.48.0 \ | ||
35 | crate://crates.io/windows_i686_gnu/0.48.0 \ | ||
36 | crate://crates.io/windows_i686_msvc/0.48.0 \ | ||
37 | crate://crates.io/windows_x86_64_gnu/0.48.0 \ | ||
38 | crate://crates.io/windows_x86_64_gnullvm/0.48.0 \ | ||
39 | crate://crates.io/windows_x86_64_msvc/0.48.0 \ | ||
40 | " | ||
41 | |||
42 | SRC_URI[android-tzdata-0.1.1.sha256sum] = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" | ||
43 | SRC_URI[android_system_properties-0.1.5.sha256sum] = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" | ||
44 | SRC_URI[autocfg-1.1.0.sha256sum] = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" | ||
45 | SRC_URI[bumpalo-3.13.0.sha256sum] = "a3e2c3daef883ecc1b5d58c15adae93470a91d425f3532ba1695849656af3fc1" | ||
46 | SRC_URI[cc-1.0.82.sha256sum] = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01" | ||
47 | SRC_URI[cfg-if-1.0.0.sha256sum] = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" | ||
48 | SRC_URI[chrono-0.4.26.sha256sum] = "ec837a71355b28f6556dbd569b37b3f363091c0bd4b2e735674521b4c5fd9bc5" | ||
49 | SRC_URI[core-foundation-sys-0.8.4.sha256sum] = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" | ||
50 | SRC_URI[iana-time-zone-0.1.57.sha256sum] = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" | ||
51 | SRC_URI[iana-time-zone-haiku-0.1.2.sha256sum] = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" | ||
52 | SRC_URI[js-sys-0.3.64.sha256sum] = "c5f195fe497f702db0f318b07fdd68edb16955aed830df8363d837542f8f935a" | ||
53 | SRC_URI[libc-0.2.147.sha256sum] = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" | ||
54 | SRC_URI[log-0.4.19.sha256sum] = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" | ||
55 | SRC_URI[num-traits-0.2.16.sha256sum] = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" | ||
56 | SRC_URI[once_cell-1.18.0.sha256sum] = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" | ||
57 | SRC_URI[proc-macro2-1.0.66.sha256sum] = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" | ||
58 | SRC_URI[quote-1.0.32.sha256sum] = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" | ||
59 | SRC_URI[syn-2.0.28.sha256sum] = "04361975b3f5e348b2189d8dc55bc942f278b2d482a6a0365de5bdd62d351567" | ||
60 | SRC_URI[time-0.1.45.sha256sum] = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" | ||
61 | SRC_URI[unicode-ident-1.0.11.sha256sum] = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" | ||
62 | SRC_URI[wasi-0.10.0+wasi-snapshot-preview1.sha256sum] = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" | ||
63 | SRC_URI[wasm-bindgen-0.2.87.sha256sum] = "7706a72ab36d8cb1f80ffbf0e071533974a60d0a308d01a5d0375bf60499a342" | ||
64 | SRC_URI[wasm-bindgen-backend-0.2.87.sha256sum] = "5ef2b6d3c510e9625e5fe6f509ab07d66a760f0885d858736483c32ed7809abd" | ||
65 | SRC_URI[wasm-bindgen-macro-0.2.87.sha256sum] = "dee495e55982a3bd48105a7b947fd2a9b4a8ae3010041b9e0faab3f9cd028f1d" | ||
66 | SRC_URI[wasm-bindgen-macro-support-0.2.87.sha256sum] = "54681b18a46765f095758388f2d0cf16eb8d4169b639ab575a8f5693af210c7b" | ||
67 | SRC_URI[wasm-bindgen-shared-0.2.87.sha256sum] = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" | ||
68 | SRC_URI[winapi-0.3.9.sha256sum] = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" | ||
69 | SRC_URI[winapi-i686-pc-windows-gnu-0.4.0.sha256sum] = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" | ||
70 | SRC_URI[winapi-x86_64-pc-windows-gnu-0.4.0.sha256sum] = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" | ||
71 | SRC_URI[windows-0.48.0.sha256sum] = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" | ||
72 | SRC_URI[windows-targets-0.48.1.sha256sum] = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" | ||
73 | SRC_URI[windows_aarch64_gnullvm-0.48.0.sha256sum] = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" | ||
74 | SRC_URI[windows_aarch64_msvc-0.48.0.sha256sum] = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" | ||
75 | SRC_URI[windows_i686_gnu-0.48.0.sha256sum] = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" | ||
76 | SRC_URI[windows_i686_msvc-0.48.0.sha256sum] = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" | ||
77 | SRC_URI[windows_x86_64_gnu-0.48.0.sha256sum] = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" | ||
78 | SRC_URI[windows_x86_64_gnullvm-0.48.0.sha256sum] = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" | ||
79 | SRC_URI[windows_x86_64_msvc-0.48.0.sha256sum] = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" | ||
diff --git a/meta-selftest/recipes-devtools/rust/rust-c-lib-example_git.bb b/meta-selftest/recipes-devtools/rust/rust-c-lib-example_git.bb new file mode 100644 index 0000000000..6e7c250b92 --- /dev/null +++ b/meta-selftest/recipes-devtools/rust/rust-c-lib-example_git.bb | |||
@@ -0,0 +1,15 @@ | |||
1 | DESCRIPTION = "A simple example for rust C library" | ||
2 | HOMEPAGE = "https://gitlab.com/fmartinsonsHome/rust-c-lib-example" | ||
3 | LICENSE = "MIT" | ||
4 | LIC_FILES_CHKSUM = "file://LICENSE;md5=cb9c441273ed8a029701a086befbfc63" | ||
5 | |||
6 | SRC_URI = " \ | ||
7 | git://gitlab.com/fmartinsonsHome/rust-c-lib-example.git;branch=main;protocol=https \ | ||
8 | " | ||
9 | |||
10 | SRCREV = "fc53c457f69aa5221ec1f8619a007e8150db5e60" | ||
11 | S = "${WORKDIR}/git" | ||
12 | |||
13 | inherit cargo_c | ||
14 | |||
15 | require ${BPN}-crates.inc | ||