From 7fa4b76e4d05a3a8d0474196248808006cb17e5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Thu, 10 Dec 2020 17:17:09 +0100 Subject: [PATCH] cossin_table: fix build script usage --- dsp/build.rs | 7 +++++-- dsp/src/lib.rs | 1 - dsp/src/trig.rs | 7 +++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dsp/build.rs b/dsp/build.rs index 07a4c2f..e8c9f99 100644 --- a/dsp/build.rs +++ b/dsp/build.rs @@ -1,3 +1,4 @@ +use std::env; use std::f64::consts::PI; use std::fs::File; use std::io::prelude::*; @@ -6,8 +7,10 @@ use std::path::Path; fn write_cossin_table() { const DEPTH: usize = 7; - let mut file = - File::create(Path::new("src").join("cossin_table.rs")).unwrap(); + let out_dir = env::var_os("OUT_DIR").unwrap(); + let dest_path = Path::new(&out_dir).join("cossin_table.rs"); + let mut file = File::create(dest_path).unwrap(); + writeln!(file, "pub(crate) const COSSIN_DEPTH: usize = {};", DEPTH) .unwrap(); write!( diff --git a/dsp/src/lib.rs b/dsp/src/lib.rs index 98bd661..6dd20f7 100644 --- a/dsp/src/lib.rs +++ b/dsp/src/lib.rs @@ -18,7 +18,6 @@ pub fn shift_round(x: i32, shift: usize) -> i32 { (x + (1 << (shift - 1))) >> shift } -mod cossin_table; pub mod iir; pub mod lockin; pub mod pll; diff --git a/dsp/src/trig.rs b/dsp/src/trig.rs index cdded60..ecef4d4 100644 --- a/dsp/src/trig.rs +++ b/dsp/src/trig.rs @@ -1,9 +1,8 @@ -use super::{ - cossin_table::{COSSIN, COSSIN_DEPTH}, - Complex, -}; +use super::Complex; use core::f64::consts::PI; +include!(concat!(env!("OUT_DIR"), "/cossin_table.rs")); + /// Compute the cosine and sine of an angle. /// This is ported from the MiSoC cossin core. /// (https://github.com/m-labs/misoc/blob/master/misoc/cores/cossin.py)