Skip to content

Commit

Permalink
Revert "WIP"
Browse files Browse the repository at this point in the history
This reverts commit 2cd74b3dd03be1d9509d90d57be93cdd409c5b55.
  • Loading branch information
douglas-raillard-arm committed Jan 10, 2024
1 parent 15d8bee commit 1d28daa
Show file tree
Hide file tree
Showing 40 changed files with 21,579 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tools/analysis/analysis/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[package]
name = "analysis"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]

futures-async-stream = "0.2"
futures = "0.3"
pin-project = "1.0"

serde = { version = "1.0", features = ["derive", "alloc"] }

smartstring = { version = "1.0", features = ["serde"]}

# JSON
serde_json = { version = "1.0", default-features = false, features = ["alloc"]}
erased-serde = {version = "0.3"}
schemars = {version = "0.8"}

# Arrow
arrow2_convert = "0.3.2"
arrow2 = {version = "0.14.2", features=["io_ipc", "io_ipc_compression"]}
macro_rules_attribute = "0.1.3"
# uuid = {version = "1.2.2", features = [
# "v4", # Lets you generate random UUIDs
# "fast-rng", # Use a faster (but still sufficiently random) RNG
# ]}
paste = "1.0"

# For WASM
# TODO: avoid depending on lz4-sys for WASM
# arrow2 = {version = "0.14.2", features=["io_ipc"]}
# [lib]
# crate-type = ["cdylib"]


[build-dependencies]
regex = "1"
glob = "0.3"
56 changes: 56 additions & 0 deletions tools/analysis/analysis/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#![feature(iter_intersperse)]

use std::{env, fs, path::Path};

use glob::glob;
use regex::Regex;

fn main() -> Result<(), String> {
let out_dir = env::var_os("OUT_DIR").unwrap();
let src_dir = env::var_os("CARGO_MANIFEST_DIR").unwrap();
let src_path = Path::new(&src_dir).join("src");

let pattern = src_path
.join("**/*.rs")
.to_str()
.ok_or("Could not convert source path to string".to_string())?
.to_string();

let rx = Regex::new(r"(?s)\banalysis!\s*[({\[]\s*name\s*:\s*(?P<name>.*?),").unwrap();

let mut funcs = Vec::new();

for entry in glob(&pattern).expect("Could not glob") {
let path = entry.map_err(|_e| "could not glob".to_string())?;
let rel_path = path
.strip_prefix(src_path.clone())
.map_err(|_e| "Could not rebase path".to_string())?;

let content = fs::read_to_string(path.clone()).expect("Could not read file");

let mod_: String = rel_path
.components()
.map(|x| {
Path::new(&x)
.file_stem()
.unwrap()
.to_str()
.unwrap()
.to_string()
})
.intersperse("::".to_string())
.collect();

funcs.extend(
rx.captures_iter(&content)
.map(|c| "crate::".to_owned() + &mod_ + "::" + &c["name"].trim()),
);
}

let dest_path = Path::new(&out_dir).join("analyses_list.rs");
// let content = format!("build_analyses_descriptors!{{ {} }}", funcs.join(", "));
let content = format!("build_analyses_descriptors!{{ {} }}", funcs.join(", "));
// println!("generated: {}", content);
fs::write(dest_path, content).unwrap();
Ok(())
}
Loading

0 comments on commit 1d28daa

Please sign in to comment.