diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 967b0169..4e27f9a6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -73,6 +73,8 @@ jobs: clippy: name: Clippy Lints runs-on: ubuntu-18.04 + env: + AF_VER: 3.8.0 steps: - name: Checkout Repository uses: actions/checkout@master @@ -83,7 +85,29 @@ jobs: toolchain: stable override: true components: clippy + + - name: Cache ArrayFire + uses: actions/cache@v1 + id: arrayfire + with: + path: afbin + key: ${{ runner.os }}-af-${{ env.AF_VER }} + + - name: Download ArrayFire + # Only download and cache arrayfire if already not found + if: steps.arrayfire.outputs.cache-hit != 'true' + run: | + wget --quiet http://arrayfire.s3.amazonaws.com/${AF_VER}/ArrayFire-v${AF_VER}_Linux_x86_64.sh + chmod +x ./ArrayFire-v${AF_VER}_Linux_x86_64.sh + mkdir afbin + ./ArrayFire-v${AF_VER}_Linux_x86_64.sh --skip-license --exclude-subdir --prefix=./afbin + rm ./afbin/lib64/libcu*.so* + rm ./afbin/lib64/libafcuda*.so* + rm ./ArrayFire-v${AF_VER}_Linux_x86_64.sh + - name: Run clippy tool + env: + AF_PATH: ${{ github.workspace }}/afbin uses: actions-rs/cargo@v1 with: command: clippy diff --git a/build.rs b/build.rs index 5b55757a..c1fca518 100644 --- a/build.rs +++ b/build.rs @@ -58,21 +58,32 @@ struct Config { win_vs_toolset: String, } -fn fail(s: &str) -> ! { - panic!("\n{}\n\nbuild script failed, must exit now", s) +fn fail(msg: &str) -> ! { + eprintln!("ERROR: {}", msg); + std::process::exit(1); } fn dir_exists(location: &str) -> bool { match fs::metadata(location) { Ok(f) => f.is_dir(), - Err(_) => false, + Err(err) => { + if err.kind() != ErrorKind::NotFound { + eprintln!("WARNING: failed to access `{}`: {}", location, err); + } + false + } } } fn file_exists(location: &str) -> bool { match fs::metadata(location) { Ok(f) => f.is_file(), - Err(_) => false, + Err(err) => { + if err.kind() != ErrorKind::NotFound { + eprintln!("WARNING: failed to access `{}`: {}", location, err); + } + false + } } } @@ -291,13 +302,9 @@ fn blob_backends(conf: &Config, build_dir: &std::path::Path) -> (Vec, Ve let afpath = match env::var("AF_PATH") { Ok(af_path) => PathBuf::from(&af_path), Err(_) => { - println!( - "WARNING! USE_LIB is defined, - but AF_PATH is not found," - ); - println!( - "Trying to find libraries from - known default locations" + eprintln!( + "WARNING: USE_LIB is defined, but AF_PATH is not found. Trying to find \ + libraries from known default locations." ); if cfg!(target_os = "windows") { PathBuf::from("C:\\Program Files\\ArrayFire\\v3\\") @@ -449,6 +456,11 @@ fn main() { } let (backends, backend_dirs) = blob_backends(&conf, &build_dir); + + if backends.is_empty() { + fail("no arrayfire backends found"); + } + for backend in backends.iter() { println!("cargo:rustc-link-lib=dylib={}", backend); }