Skip to content

Commit

Permalink
fox: fixed cargo doc build
Browse files Browse the repository at this point in the history
  • Loading branch information
istvan-fodor committed Oct 1, 2024
1 parent d86b2dc commit 4c1aed5
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
18 changes: 13 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "r2a"
version = "0.1.2"
version = "0.1.3"
edition = "2021"
description = "A Rust library that provides a typesafe way to convert ROS2 messages into Apache Arrow format"
homepage = "https://github.com/istvan-fodor/r2a"
Expand All @@ -9,14 +9,18 @@ license = "Apache-2.0"
readme = "README.md"
keywords = ["ROS", "ROS2", "Humble", "Jazzy", "Arrow"]

[features]
doc-only = []
default = ["r2r", "r2r_common"]


[dependencies]
arrow-schema = ">=50"
arrow-array = ">=50"
r2r = ">=0.9.0"
r2r = { version = ">=0.9.0", optional = true }
anyhow = ">=1"
log = ">=0.4"


[dev-dependencies]
futures = "0.3"
tokio = { version = "1.40.0", features = ["rt-multi-thread", "full"] }
Expand All @@ -25,11 +29,15 @@ rand = "0.8"

[build-dependencies]
walkdir = "2"
r2r = ">=0.9.0"
r2r_common = ">=0.9.0"
r2r = { version = ">=0.9.0", optional = true }
r2r_common = { version = ">=0.9.0", optional = true }
anyhow = "1"
proc-macro2 = "1.0.78"
quote = "1.0.35"
syn = { version = "2", features = ["full", "visit"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"

[package.metadata.docs.rs]
no-default-features = true
features = ["doc-only"]
15 changes: 10 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use proc_macro2::TokenStream;
use quote::quote;
use r2r_common::get_env_hash;


use anyhow::Result;
use std::collections::BTreeMap;
Expand Down Expand Up @@ -273,7 +273,6 @@ fn generate_imports() -> TokenStream {
fn generate_arrow_imports() -> TokenStream {
quote! {
use arrow_schema::{DataType, Field, Fields, Schema};
use std::sync::Arc;
use r2r::{WrappedTypesupport};
}
}
Expand Down Expand Up @@ -1546,8 +1545,15 @@ fn generate_arrow_rowbuilders(
gen_function
}

#[cfg(feature = "doc-only")]
fn main() -> Result<()> {
Ok(())
}

#[cfg(not(feature = "doc-only"))]
fn main() -> Result<()> {
// Parse the source code as a syn file
use r2r_common::get_env_hash;
let out_dir = env::var("OUT_DIR").unwrap();
let out_dir_path = Path::new(&out_dir);

Expand All @@ -1572,16 +1578,15 @@ fn main() -> Result<()> {
let (structs_by_schema, structs_by_type) =
find_structs_by_schema_and_type(deps_dir, env_hash.as_str(), &implementing_structs);

//let map_function = generate_map_function(&structs_by_schema);
//let map_function = generate_map_function(&structs_by_schema);s
generate_schema(
out_dir_path,
&structs_by_schema,
// &structs_by_type,
// &structs_by_type,
&mut log_file,
)?;

generate_arrow_mappers(out_dir, structs_by_schema, structs_by_type, &mut log_file)?;

Ok(())
}

Expand Down
2 changes: 2 additions & 0 deletions src/ros_mapper.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use anyhow::Result;
use arrow_array::builder::ArrayBuilder;
use arrow_array::Array;
use std::sync::Arc;

/// The `RowBuilder` trait is implemented for each ROS2 message type by a code generator.
/// It serves as an accumulator that collects records and converts them into a collection
Expand Down Expand Up @@ -152,6 +153,7 @@ pub trait ArrowSupport<'a> {
fn arrow_schema() -> arrow_schema::Schema;
}

#[cfg(feature = "default")]
include!(concat!(env!("OUT_DIR"), "/generated_arrow_mappers.rs"));

#[cfg(test)]
Expand Down
4 changes: 4 additions & 0 deletions src/schema.rs
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
#[cfg(feature = "default")]
include!(concat!(env!("OUT_DIR"), "/generated_schema.rs"));

#[cfg(feature = "doc-only")]
pub static SUPPORTED_SCHEMAS: &'static [&'static str] = &[];

0 comments on commit 4c1aed5

Please sign in to comment.