我正在尝试使用travis-ci构建rust二进制文件。我设法使Windows和osx构建正常工作,但是linux构建不断失败。
似乎“alsa-sys” crate (依赖项之一)无法在linux-vm中找到alsa.pc。
.travis.yml:
language: rust
cache: cargo
rust:
- stable
matrix:
allow_failures:
- rust: nightly
fast_finish: true
os:
- osx
- windows
- linux
script:
- cargo build --verbose --release
before_deploy:
- if [[ -f target/release/soundsense-rs ]]; then mv target/release/soundsense-rs "target/release/soundsense-rs-$TRAVIS_TAG-$TRAVIS_OS_NAME"; fi
- if [[ -f target/release/soundsense-rs.exe ]]; then mv target/release/soundsense-rs.exe "target/release/soundsense-rs-$TRAVIS_TAG-$TRAVIS_OS_NAME.exe"; fi
deploy:
- provider: releases
skip_cleanup: true
on:
tags: true
condition: "$TRAVIS_RUST_VERSION = stable"
branch: release
file_glob: true
file:
- target/release/soundsense-rs-*
api_key:
secure: IRdsT0enLWr2qaa63GPnITLaYdar4vDKcKfo9Fm1PlDoWi1gigTZ2elegApdBQmWzcgdHEtiEayg9KtQw76R/l7bH2Yst3kvZPyd635g6Cwj9XUp70opApLeKdVGQhnvGA2fMehYXNfcLi8wn65th3katabvJhuU26C1ICAFt1ExVu2iDbIjUYPmg5O4f3BAvHYlGe5BNyA3C20sakD25ocp+Z/KaI1gfRdYvm3cwVuci63N2O0c+j2IHkaUg/bfA7XHRUqzxO1U4MNrRyYAwRRiIJ+wgKVh9qISt4N0Uw8IZR8ZmBkeK4OPkh+ggb05ONoOpCuOVDGKqMzbEG0SNKbDpwXdxfCkmbtNeXrORX6ZSlNPJOGaPhrD36WYZdRGOZMNC4lSgev/O2lZ/TfJc1Qj9kXlD7kbmG/vKrSkQYs4i/5p4a93E0zgBfyWiK1wiUYCc01PF5YKjbc0n7aymSO3z3CzGijwykH6MKFnInk1JtJ2aUjBM722oKVuCaW/JDikN4wMgPrlIMUY+dLrXBJZLXra89B/RS6un1NsTO0IPyMDQYKRgp6yTkvWJHux0m0Gwexnc+S/dPhb9Z023UDA0pb504XNc7ggpo9xtb5sUa/z/xQRoX3fKFSUEOoNLI3Kw/DE4QwHmnvVSdOGF4+s3Kj2JqnKSZusq3yycnw=
错误信息:
Running `/home/travis/build/prixt/soundsense-rs/target/release/build/alsa-sys-9e3efef5874a428f/build-script-build`
error: failed to run custom build command for `alsa-sys v0.1.2`
Caused by:
process didn't exit successfully: `/home/travis/build/prixt/soundsense-rs/target/release/build/alsa-sys-9e3efef5874a428f/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "`\"pkg-config\" \"--libs\" \"--cflags\" \"alsa\"` did not exit successfully: exit code: 1\n--- stderr\nPackage alsa was not found in the pkg-config search path.\nPerhaps you should add the directory containing `alsa.pc\'\nto the PKG_CONFIG_PATH environment variable\nNo package \'alsa\' found\n"', src/libcore/result.rs:999:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
warning: build failed, waiting for other jobs to finish...
error: build failed
The command "cargo build --verbose --release" exited with 101.
我需要添加哪些命令来解决此问题?
最佳答案
遵循@Jmb的建议,我在before_install步骤中添加了一些软件包安装命令:
before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -y libasound2-dev ; sudo apt-get install -y libwebkit2gtk-4.0 ; fi
(我还需要安装libwebkit2gtk软件包以获得另一个依赖关系)
这解决了问题。
关于linux - 将 'alsa-sys'包装箱构建为依赖项时,如何安装和连接alsa.pc?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57727066/