cossin_table: fix build script usage

This commit is contained in:
Robert Jördens 2020-12-10 17:17:09 +01:00
parent 18ea94298b
commit 7fa4b76e4d
3 changed files with 8 additions and 7 deletions

View File

@ -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!(

View File

@ -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;

View File

@ -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)