Merge pull request #117 from gsora/gsora/ci-hosted-native

Compile for hosted and real hardware on main push
This commit is contained in:
Sean Cross 2022-03-18 22:56:51 +08:00 committed by GitHub
commit 5604d6aa1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 47 additions and 2 deletions

37
.github/workflows/build.yml vendored Normal file
View file

@ -0,0 +1,37 @@
on:
push:
branches:
- main
name: Build xous-core
jobs:
build:
name: Setup Rust
runs-on: ubuntu-latest
strategy:
matrix:
task: ["hosted-ci", "renode-image"]
steps:
- name: Install Ubuntu dependencies
run: |
sudo apt update
sudo apt install -y libxkbcommon-dev
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: "1.59.0"
default: true
- name: Checkout sources
uses: actions/checkout@v2
- uses: Swatinem/rust-cache@v1
- name: Install RISC-V toolkit
run: cargo xtask install-toolkit
- name: Build hosted-ci
run: cargo xtask ${{ matrix.task }}

View file

@ -165,6 +165,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let lkey = args.nth(3);
let kkey = args.nth(4);
match task.as_deref() {
Some("install-toolkit") => {
ensure_compiler(&Some(PROGRAM_TARGET), true)?
}
Some("renode-image") => {
let mut args = env::args();
args.nth(1);
@ -602,6 +605,7 @@ Various debug configurations:
pddb-ci PDDB config for CI testing (eg: TRNG->deterministic for reproducible errors)
ffi-test builds an image for testing C-FFI bindings and integration
tts builds an image with text to speech support via externally linked C executable
install-toolkit installs Xous toolkit with no prompt, useful in CI
"
)
}
@ -1015,7 +1019,7 @@ static DONE_COMPILER_CHECK: std::sync::atomic::AtomicBool =
/// Ensure we have a compatible compiler toolchain. We use a new Target,
/// and we want to give the user a friendly way of installing the latest
/// Rust toolchain.
fn ensure_compiler(target: &Option<&str>) -> Result<(), String> {
fn ensure_compiler(target: &Option<&str>, force_install: bool) -> Result<(), String> {
use std::process::Stdio;
if DONE_COMPILER_CHECK.load(std::sync::atomic::Ordering::SeqCst) {
return Ok(());
@ -1108,6 +1112,10 @@ fn ensure_compiler(target: &Option<&str>) -> Result<(), String> {
target
);
loop {
if force_install {
break;
}
print!("Would you like this program to attempt to download and install it? [Y/n] ");
stdout.flush().unwrap();
buffer.clear();
@ -1251,7 +1259,7 @@ fn build(
extra_args: Option<&[&str]>,
features: Option<&[&str]>,
) -> Result<PathBuf, DynError> {
ensure_compiler(&target)?;
ensure_compiler(&target, false)?;
let stream = if debug { "debug" } else { "release" };
let mut args = vec!["build"];
print!("Building");