YoctoでRust②〜cargo-bitbake〜
はじめに
組込みLinuxでRustする場合、普通にホストマシンで開発して、普通にホストマシンのRustコンパイラでクロスビルドしたものをターゲットに持って行っています。 これで事足りているのですが、前々から興味があったため、YoctoでRustアプリケーションをビルドします。
今回は、CargoプロジェクトからYoctoのレシピを生成してくれるcargo-bitbakeを試してみます。
cargo-bitbakeのインストール
libssl-dev
が必要なのでインストールします。
$ sudo apt install libssl-dev
$ cargo install cargo-bitbake
ripgrepでお試し
ripgrepをYoctoでビルドしてみます。 構築している環境のRustのバージョンが1.24.0なので、そのコンパイラでビルド可能なbranchを引っ張ってきます。
なんかそんな感じでしたねw
— みつきん (@yusuke_mitsuki) 2019年4月30日
どうやらmasterブランチを使うのが正解のようです。
こっちもぼちぼち書きます。
meta-rustはmaster branchを使うのが良いらしいです。確かに、1.33まで対応されていました。
$ git clone https://github.com/BurntSushi/ripgrep.git -b 0.9.0 $ ripgrep $ cargo bitbake $ ls *.bb ripgrep_0.9.0.bb
レシピができました。
$ cat ripgrep_0.9.0.bb # Auto-Generated by cargo-bitbake 0.3.10 # inherit cargo # If this is git based prefer versioned ones if they exist # DEFAULT_PREFERENCE = "-1" # how to get ripgrep could be as easy as but default to a git checkout: # SRC_URI += "crate://crates.io/ripgrep/0.9.0" SRC_URI += "git://github.com/BurntSushi/ripgrep.git;protocol=https" SRCREV = "6799dcfc0ee63d741cd721c3311852a1b01449d8" S = "${WORKDIR}/git" CARGO_SRC_DIR="" # please note if you have entries that do not begin with crate:// # you must change them to how that package can be fetched SRC_URI += " \ crate://crates.io/aho-corasick/0.6.6 \ crate://crates.io/ansi_term/0.11.0 \ crate://crates.io/atty/0.2.11 \ crate://crates.io/bitflags/1.0.3 \ crate://crates.io/bytecount/0.3.1 \ crate://crates.io/cfg-if/0.1.4 \ crate://crates.io/clap/2.32.0 \ crate://crates.io/crossbeam/0.3.2 \ crate://crates.io/encoding_rs/0.8.4 \ crate://crates.io/encoding_rs_io/0.1.1 \ crate://crates.io/fnv/1.0.6 \ crate://crates.io/fuchsia-zircon-sys/0.3.3 \ crate://crates.io/fuchsia-zircon/0.3.3 \ crate://crates.io/glob/0.2.11 \ crate://crates.io/lazy_static/1.0.2 \ crate://crates.io/libc/0.2.42 \ crate://crates.io/log/0.4.3 \ crate://crates.io/memchr/2.0.1 \ crate://crates.io/memmap/0.6.2 \ crate://crates.io/num_cpus/1.8.0 \ crate://crates.io/rand/0.4.2 \ crate://crates.io/redox_syscall/0.1.40 \ crate://crates.io/redox_termios/0.1.1 \ crate://crates.io/regex-syntax/0.6.2 \ crate://crates.io/regex/1.0.2 \ crate://crates.io/remove_dir_all/0.5.1 \ crate://crates.io/same-file/1.0.2 \ crate://crates.io/simd/0.2.2 \ crate://crates.io/strsim/0.7.0 \ crate://crates.io/tempdir/0.3.7 \ crate://crates.io/termcolor/1.0.1 \ crate://crates.io/termion/1.5.1 \ crate://crates.io/textwrap/0.10.0 \ crate://crates.io/thread_local/0.3.5 \ crate://crates.io/ucd-util/0.1.1 \ crate://crates.io/unicode-width/0.1.5 \ crate://crates.io/unreachable/1.0.0 \ crate://crates.io/utf8-ranges/1.0.0 \ crate://crates.io/void/1.0.2 \ crate://crates.io/walkdir/2.1.4 \ crate://crates.io/winapi-i686-pc-windows-gnu/0.4.0 \ crate://crates.io/winapi-x86_64-pc-windows-gnu/0.4.0 \ crate://crates.io/winapi/0.3.5 \ crate://crates.io/wincolor/1.0.0 \ " # FIXME: update generateme with the real MD5 of the license file LIC_FILES_CHKSUM=" \ file://Unlicense OR MIT;md5=generateme \ " SUMMARY = "ripgrep is a line-oriented search tool that recursively searches your current directory for a regex pattern while respecting your gitignore rules. ripgrep has first class support on Windows, macOS and Linux" HOMEPAGE = "https://github.com/BurntSushi/ripgrep" LICENSE = "Unlicense OR MIT" # includes this file if it exists but does not fail # this is useful for anything you may want to override from # what cargo-bitbake generates. include ripgrep-${PV}.inc include ripgrep.inc
なんかライセンス関連のところが変、というかFIXME
と書いてありますね。
ということで、ちょろっと直しておきます。
LIC_FILES_CHKSUM=" \ file://COPYING;md5=034e2d49ef70c35b64be514bef39415a \ "
ビルドしてみる
面倒くさいので、meta-rustのrecipes-exampleに生成されたレシピを突っ込みます。
meta-rust/recipes-example/ripgrep$ ls ripgrep_0.9.0.bb
$ bitbake ripgrep ERROR: ParseError at /home/tomoyuki/others/01.rust/yocto/layers/meta-rust/recipes-example/ripgrep/ripgrep_0.9.0.bb:103: unparsed line: 'SUMMARY = "ripgrep is a line-oriented search tool that recursively searches your current'
サマリの説明部分でエラーが出ます。レシピを確認してみます。
SUMMARY = "ripgrep is a line-oriented search tool that recursively searches your current directory for a regex pattern while respecting your gitignore rules. ripgrep has first class support on Windows, macOS and Linux"
改行入ってます。
SUMMARY = "ripgrep is a line-oriented search tool that recursively searches your current directory for a regex pattern while respecting your gitignore rules. ripgrep has first class support on Windows, macOS and Linux"
改行をなくします。
$ bitbake ripgrep WARNING: Host distribution "ubuntu-18.04" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution. Loading cache: 100% |############################################| Time: 0:00:00 Loaded 2785 entries from dependency cache. NOTE: There are 1 recipes to be removed from sysroot cortexa7hf-neon-vfpv4, removing... NOTE: Resolving any missing task queue dependencies Build Configuration: BB_VERSION = "1.36.0" BUILD_SYS = "x86_64-linux" NATIVELSBSTRING = "universal" TARGET_SYS = "arm-poky-linux-gnueabi" MACHINE = "raspberrypi3" DISTRO = "poky" DISTRO_VERSION = "2.4.4" TUNE_FEATURES = "arm armv7ve vfp thumb neon vfpv4 callconvention-hard cortexa7" TARGET_FPU = "hard" meta meta-poky meta-yocto-bsp = "rocko:5f660914cd7eec8117efccdf1eb29c466b4e74f7" meta-oe meta-python meta-networking = "rocko:eae996301d9c097bcbeb8046f08041dc82bb62f8" meta-raspberrypi = "rocko:8e4c537d84fdde8e3b4642d0dda2c0f4af76d52f" meta-rust = "rocko:a4797129e2ab7f11671f817653b11ed876c2b43c" Initialising tasks: 100% |#######################################| Time: 0:00:00 NOTE: Executing SetScene Tasks NOTE: Executing RunQueue Tasks WARNING: ripgrep-0.9.0-r0 do_populate_lic: ripgrep: No generic license file exists for: Unlicense in any provider NOTE: Tasks Summary: Attempted 564 tasks of which 549 didn't need to be rerun and all succeeded. Summary: There were 2 WARNING messages shown.
はい、OKです。