crosvm: Fix cross-compile in dev container

- Fix devcontainer.json to be used by vscode correctly
- Fix wayland-protocols path finding
- Add missing SYSROOT env for pkg_config
- Add missing linker settings

TEST=native/armv7/aarch64 targets compile in dev container

Change-Id: Id6fc43b2fd63d09bc46169d996387d5417ada93e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3766822
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
This commit is contained in:
Zihan Chen 2022-07-18 18:07:53 -07:00 committed by crosvm LUCI
parent 6385eee278
commit e2f7c0c24b
3 changed files with 16 additions and 6 deletions

View file

@ -43,5 +43,13 @@ rustflags = [
[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
[target.x86_64-pc-windows-gnu]
runner = "wine64"
[env]
PKG_CONFIG_SYSROOT_DIR_armv7-unknown-linux-gnueabihf = "/usr/arm-linux-gnueabihf"
PKG_CONFIG_SYSROOT_DIR_aarch64-unknown-linux-gnu = "/usr/aarch64_linux_gnu"
PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-gnu = "/usr/x86_64-w64-mingw32"

View file

@ -1,7 +1,7 @@
{
"image": "gcr.io/crosvm-packages/crosvm_dev:latest",
"image": "gcr.io/crosvm-packages/crosvm_dev:r0012",
"extensions": [
"matklad.rust-analyzer",
"rust-lang.rust-analyzer",
"bungcip.better-toml",
"esbenp.prettier-vscode",
"ms-python.vscode-pylance",

View file

@ -32,15 +32,17 @@ cfg_if::cfg_if! {
// Searches for the given protocol in both the system wide and bundles protocols path.
fn find_protocol(name: &str) -> PathBuf {
let protocols_path = pkg_config::get_variable("wayland-protocols", "pkgdatadir")
.unwrap_or_else(|_| "/usr/share/wayland-protocols".to_owned());
let protocol_file_name = PathBuf::from(format!("{}.xml", name));
// Prioritize the systems wayland protocols before using the bundled ones.
if let Ok(protocols_path) = pkg_config::get_variable("wayland-protocols", "pkgdatadir") {
if let Some(found) = scan_path(protocols_path, &protocol_file_name) {
return found;
}
}
let protocols_path = format!("/usr/share/wayland-protocols/stable/{}", name);
if let Some(found) = scan_path(protocols_path, &protocol_file_name) {
return found;
}
// Use bundled protocols as a fallback.
let protocol_path = Path::new("protocol").join(protocol_file_name);
assert!(