dv 0.2.0

Core Rust library for DimensionalVariable, a multi-language library for handling physical quantities with units.
Documentation
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test", "rust_doc", "rust_shared_library", "rust_static_library")
load("@rules_python//python:defs.bzl", "py_binary")

package(default_visibility = ["//visibility:public"])

exports_files(["Cargo.toml"])  # Expose root version file to other packages

# ==============================================================================
# Rust Library
# ==============================================================================

rust_library(
    name = "dv_rs",
    srcs = ["src/lib.rs", "src/units.rs"],
    compile_data = ["DOCS.md"],
    edition = "2021",
)

# ==============================================================================
# Documentation
# ==============================================================================

# Documentation target (equivalent to `cargo doc` for this crate)
rust_doc(
    name = "docs",
    crate = ":dv_rs",
)

# Simple Python HTTP server to serve the generated docs
py_binary(
    name = "serve_docs",
    srcs = ["serve_docs.py"],
    data = [":docs"],
)

# ==============================================================================
# Tests
# ==============================================================================

rust_test(
    name = "unit_tests",
    # Reuse the library crate so compile_data (DOCS.md) is available; no need to recompile sources under a new crate name
    crate = ":dv_rs",
    deps = [":dv_rs"],
)

rust_test(
    name = "units_tests",
    srcs = ["tests/units_tests.rs"],
    deps = [":dv_rs"],
)

rust_test(
    name = "operator_tests",
    srcs = ["tests/operator_tests.rs"],
    deps = [":dv_rs"],
)

# Aggregate suite to match the original //core:integration_tests target name
test_suite(
    name = "integration_tests",
    tests = [
        ":units_tests",
        ":operator_tests",
    ],
)

filegroup(
    name = "rust_sources",
    srcs = glob(["**/*.rs", "**/*.toml", "**/*.md"]),
    visibility = ["//python:__pkg__"],
)