diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index b4af3604..8437333d 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -86,4 +86,5 @@ RUN git clone https://github.com/microsoft/vcpkg \ ENV VCPKG_ROOT="/home/${USERNAME}/vcpkg" -RUN rustup default 1.88.0 +COPY ./scripts/ /tmp/scripts/ +RUN /tmp/scripts/common/rust/install-rust.sh diff --git a/.devcontainer/Dockerfile.almalinux b/.devcontainer/Dockerfile.almalinux index 4b1b378e..19c274f7 100644 --- a/.devcontainer/Dockerfile.almalinux +++ b/.devcontainer/Dockerfile.almalinux @@ -73,4 +73,5 @@ RUN git clone https://github.com/microsoft/vcpkg \ ENV VCPKG_ROOT=/home/$USERNAME/vcpkg -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=1.88.0 +COPY ./scripts/ /tmp/scripts/ +RUN /tmp/scripts/common/rust/install-rust.sh diff --git a/.devcontainer/Dockerfile.amazonlinux b/.devcontainer/Dockerfile.amazonlinux index e5ce400b..134763dc 100644 --- a/.devcontainer/Dockerfile.amazonlinux +++ b/.devcontainer/Dockerfile.amazonlinux @@ -66,4 +66,5 @@ RUN git clone https://github.com/microsoft/vcpkg \ ENV VCPKG_ROOT=/home/$USERNAME/vcpkg -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=1.88.0 +COPY ./scripts/ /tmp/scripts/ +RUN /tmp/scripts/common/rust/install-rust.sh diff --git a/.devcontainer/Dockerfile.debiantrixie b/.devcontainer/Dockerfile.debiantrixie index 923648c5..ba0d76d9 100644 --- a/.devcontainer/Dockerfile.debiantrixie +++ b/.devcontainer/Dockerfile.debiantrixie @@ -81,4 +81,5 @@ RUN git clone https://github.com/microsoft/vcpkg \ ENV VCPKG_ROOT="/home/${USERNAME}/vcpkg" -RUN rustup default 1.88.0 +COPY ./scripts/ /tmp/scripts/ +RUN /tmp/scripts/common/rust/install-rust.sh diff --git a/.devcontainer/Dockerfile.ubuntu-legacy b/.devcontainer/Dockerfile.ubuntu-legacy index 69ba26e8..4ca0677c 100644 --- a/.devcontainer/Dockerfile.ubuntu-legacy +++ b/.devcontainer/Dockerfile.ubuntu-legacy @@ -100,4 +100,5 @@ ENV VCPKG_ROOT=/home/$USERNAME/vcpkg COPY register-clang-version.sh /home/$USERNAME/register-clang-version.sh RUN sudo /home/$USERNAME/register-clang-version.sh ${CLANG_VERSION} 100 && rm /home/$USERNAME/register-clang-version.sh -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=1.88.0 +COPY ./scripts/ /tmp/scripts/ +RUN /tmp/scripts/common/rust/install-rust.sh diff --git a/.devcontainer/almalinux/devcontainer.json b/.devcontainer/almalinux/devcontainer.json index c80d44b2..252bbf68 100644 --- a/.devcontainer/almalinux/devcontainer.json +++ b/.devcontainer/almalinux/devcontainer.json @@ -28,7 +28,8 @@ "matepek.vscode-catch2-test-adapter", "llvm-vs-code-extensions.vscode-clangd", "xaver.clang-format", - "bierner.markdown-mermaid" + "bierner.markdown-mermaid", + "rust-lang.rust-analyzer" ], "settings": { "C_Cpp.intelliSenseEngine": "disabled", @@ -50,4 +51,4 @@ "gpu": "optional" }, "remoteUser": "devcontainer" -} \ No newline at end of file +} diff --git a/.devcontainer/amazonlinux/devcontainer.json b/.devcontainer/amazonlinux/devcontainer.json index 7d456894..2610a3e6 100644 --- a/.devcontainer/amazonlinux/devcontainer.json +++ b/.devcontainer/amazonlinux/devcontainer.json @@ -32,7 +32,8 @@ "matepek.vscode-catch2-test-adapter", "llvm-vs-code-extensions.vscode-clangd", "xaver.clang-format", - "bierner.markdown-mermaid" + "bierner.markdown-mermaid", + "rust-lang.rust-analyzer" ], "settings": { "C_Cpp.intelliSenseEngine": "disabled", @@ -51,4 +52,4 @@ "DISPLAY": "${localEnv:DISPLAY}" }, "remoteUser": "devcontainer" -} \ No newline at end of file +} diff --git a/.devcontainer/debiantrixie/devcontainer.json b/.devcontainer/debiantrixie/devcontainer.json index bb5b17b3..684157d1 100644 --- a/.devcontainer/debiantrixie/devcontainer.json +++ b/.devcontainer/debiantrixie/devcontainer.json @@ -28,7 +28,8 @@ "matepek.vscode-catch2-test-adapter", "llvm-vs-code-extensions.vscode-clangd", "xaver.clang-format", - "bierner.markdown-mermaid" + "bierner.markdown-mermaid", + "rust-lang.rust-analyzer" ], "settings": { "C_Cpp.intelliSenseEngine": "disabled", @@ -50,4 +51,4 @@ "gpu": "optional" }, "remoteUser": "devcontainer" -} \ No newline at end of file +} diff --git a/.devcontainer/scripts/common/rust/install-rust.sh b/.devcontainer/scripts/common/rust/install-rust.sh new file mode 100755 index 00000000..fbab8779 --- /dev/null +++ b/.devcontainer/scripts/common/rust/install-rust.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# SPDX-FileCopyrightText: 2025 Contributors to the Media eXchange Layer project. +# SPDX-License-Identifier: Apache-2.0 + +set -eu + +RUST_VERSION=1.90.0 + +if command -v rustup > /dev/null 2>&1; then + rustup default $RUST_VERSION +else + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain=$RUST_VERSION + . "$HOME/.cargo/env" +fi + +# Install cargo binstall +curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash + +cargo binstall cargo-audit --locked +cargo binstall cargo-outdated --locked + +# udeps requires the nightly compiler, so using machete (at least for now) +# cargo binstall cargo-udeps --locked +cargo binstall cargo-machete --locked + +cargo binstall cargo-deny --locked +cargo binstall cargo-audit --locked +cargo binstall cargo-nextest --locked diff --git a/.devcontainer/ubuntu20/devcontainer.json b/.devcontainer/ubuntu20/devcontainer.json index b3321a83..e7783184 100644 --- a/.devcontainer/ubuntu20/devcontainer.json +++ b/.devcontainer/ubuntu20/devcontainer.json @@ -30,7 +30,8 @@ "matepek.vscode-catch2-test-adapter", "llvm-vs-code-extensions.vscode-clangd", "xaver.clang-format", - "bierner.markdown-mermaid" + "bierner.markdown-mermaid", + "rust-lang.rust-analyzer" ], "settings": { "C_Cpp.intelliSenseEngine": "disabled", @@ -52,4 +53,4 @@ "gpu": "optional" }, "remoteUser": "devcontainer" -} \ No newline at end of file +} diff --git a/.devcontainer/ubuntu22/devcontainer.json b/.devcontainer/ubuntu22/devcontainer.json index 57c7dbd3..02c77d4d 100644 --- a/.devcontainer/ubuntu22/devcontainer.json +++ b/.devcontainer/ubuntu22/devcontainer.json @@ -30,7 +30,8 @@ "matepek.vscode-catch2-test-adapter", "llvm-vs-code-extensions.vscode-clangd", "xaver.clang-format", - "bierner.markdown-mermaid" + "bierner.markdown-mermaid", + "rust-lang.rust-analyzer" ], "settings": { "C_Cpp.intelliSenseEngine": "disabled", @@ -52,4 +53,4 @@ "gpu": "optional" }, "remoteUser": "devcontainer" -} \ No newline at end of file +} diff --git a/.devcontainer/ubuntu24/devcontainer.json b/.devcontainer/ubuntu24/devcontainer.json index 9777cf7f..52f08331 100644 --- a/.devcontainer/ubuntu24/devcontainer.json +++ b/.devcontainer/ubuntu24/devcontainer.json @@ -30,7 +30,8 @@ "matepek.vscode-catch2-test-adapter", "llvm-vs-code-extensions.vscode-clangd", "xaver.clang-format", - "bierner.markdown-mermaid" + "bierner.markdown-mermaid", + "rust-lang.rust-analyzer" ], "settings": { "C_Cpp.intelliSenseEngine": "disabled", @@ -52,4 +53,4 @@ "gpu": "optional" }, "remoteUser": "devcontainer" -} \ No newline at end of file +} diff --git a/.devcontainer/ubuntu25/devcontainer.json b/.devcontainer/ubuntu25/devcontainer.json index 1343790e..87ea80b5 100644 --- a/.devcontainer/ubuntu25/devcontainer.json +++ b/.devcontainer/ubuntu25/devcontainer.json @@ -30,7 +30,8 @@ "matepek.vscode-catch2-test-adapter", "llvm-vs-code-extensions.vscode-clangd", "xaver.clang-format", - "bierner.markdown-mermaid" + "bierner.markdown-mermaid", + "rust-lang.rust-analyzer" ], "settings": { "C_Cpp.intelliSenseEngine": "disabled", @@ -52,4 +53,4 @@ "gpu": "optional" }, "remoteUser": "devcontainer" -} \ No newline at end of file +} diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bbacba38..a2fa3889 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2025 Contributors to the Media eXchange Layer project. +# SPDX-License-Identifier: Apache-2.0 + name: Test the rust bindings on: diff --git a/CMakeLists.txt b/CMakeLists.txt index 72b11e1c..e4f66480 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ else() string(APPEND mxl_VERSION ".0") endif() +option(BUILD_DOCS "Build the docs" ON) option(BUILD_TESTS "Build the tests" ON) option(BUILD_TOOLS "Build the tools" ON) @@ -62,39 +63,41 @@ if (BUILD_TOOLS) add_subdirectory(tools) endif() -find_package(Doxygen) +if(BUILD_DOCS) + find_package(Doxygen) -if(DOXYGEN_FOUND) - include(FetchContent) + if(DOXYGEN_FOUND) + include(FetchContent) - FetchContent_Declare( - doxygen-awesome-css - URL https://github.com/jothepro/doxygen-awesome-css/archive/refs/heads/main.zip - ) - FetchContent_MakeAvailable(doxygen-awesome-css) + FetchContent_Declare( + doxygen-awesome-css + URL https://github.com/jothepro/doxygen-awesome-css/archive/refs/heads/main.zip + ) + FetchContent_MakeAvailable(doxygen-awesome-css) - # Save the location the files were cloned into - # This allows us to get the path to doxygen-awesome.css - FetchContent_GetProperties(doxygen-awesome-css SOURCE_DIR AWESOME_CSS_DIR) + # Save the location the files were cloned into + # This allows us to get the path to doxygen-awesome.css + FetchContent_GetProperties(doxygen-awesome-css SOURCE_DIR AWESOME_CSS_DIR) - # Generate the Doxyfile - set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) - set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) - configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY) + # Generate the Doxyfile + set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in) + set(DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile) + configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT} @ONLY) - set(DOXYGEN_OUTPUT_DIR "${CMAKE_BINARY_DIR}/docs") + set(DOXYGEN_OUTPUT_DIR "${CMAKE_BINARY_DIR}/docs") - add_custom_target(doc - COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Generating API documentation with Doxygen" - BYPRODUCTS "${DOXYGEN_OUTPUT_DIR}/html/index.html" - VERBATIM - ) + add_custom_target(doc + COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generating API documentation with Doxygen" + BYPRODUCTS "${DOXYGEN_OUTPUT_DIR}/html/index.html" + VERBATIM + ) - install(DIRECTORY "${CMAKE_BINARY_DIR}/docs/html" - DESTINATION share/doc/mxl - FILES_MATCHING PATTERN "*") + install(DIRECTORY "${CMAKE_BINARY_DIR}/docs/html" + DESTINATION share/doc/mxl + FILES_MATCHING PATTERN "*") + endif() endif() if(EXISTS "/etc/os-release") diff --git a/rust/.config/nextest.toml b/rust/.config/nextest.toml new file mode 100644 index 00000000..6a109e17 --- /dev/null +++ b/rust/.config/nextest.toml @@ -0,0 +1,5 @@ +[profile.ci] +fail-fast = false + +[profile.ci.junit] +path = "junit.xml" diff --git a/rust/.gitattributes b/rust/.gitattributes index 383338e0..265e6dd7 100644 --- a/rust/.gitattributes +++ b/rust/.gitattributes @@ -1 +1,4 @@ +# SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +# SPDX-License-Identifier: Apache-2.0 + Cargo.lock -diff diff --git a/rust/.gitignore b/rust/.gitignore index 09c22a05..91712988 100644 --- a/rust/.gitignore +++ b/rust/.gitignore @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +# SPDX-License-Identifier: Apache-2.0 + .DS_Store .idea .vscode diff --git a/rust/Cargo.lock.license b/rust/Cargo.lock.license new file mode 100644 index 00000000..e8d14bb3 --- /dev/null +++ b/rust/Cargo.lock.license @@ -0,0 +1,2 @@ +# SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +# SPDX-License-Identifier: Apache-2.0 diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 65ca6f08..d986b3aa 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +# SPDX-License-Identifier: Apache-2.0 + [workspace] members = ["mxl", "mxl-sys"] diff --git a/rust/README.md b/rust/README.md index 8dcb8a22..d2e6bc81 100644 --- a/rust/README.md +++ b/rust/README.md @@ -1,3 +1,8 @@ + + # Rust bindings for DMF MXL ## Goals diff --git a/rust/flake.nix b/rust/flake.nix index a219b532..eab9efe9 100644 --- a/rust/flake.nix +++ b/rust/flake.nix @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2025 Contributors to the Media eXchange Layer project. +# SPDX-License-Identifier: Apache-2.0 + { description = "Flake for MXL dev"; diff --git a/rust/mxl-sys/.gitignore b/rust/mxl-sys/.gitignore index 8d6e3400..bbf8a55d 100644 --- a/rust/mxl-sys/.gitignore +++ b/rust/mxl-sys/.gitignore @@ -1 +1,4 @@ +# SPDX-FileCopyrightText: 2025 Contributors to the Media eXchange Layer project. +# SPDX-License-Identifier: Apache-2.0 + mxl/version.h diff --git a/rust/mxl-sys/Cargo.toml b/rust/mxl-sys/Cargo.toml index 0e4fa65a..58e1dbf1 100644 --- a/rust/mxl-sys/Cargo.toml +++ b/rust/mxl-sys/Cargo.toml @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +# SPDX-License-Identifier: Apache-2.0 + [package] name = "mxl-sys" edition.workspace = true diff --git a/rust/mxl-sys/build.rs b/rust/mxl-sys/build.rs index 390ce970..4154ed03 100644 --- a/rust/mxl-sys/build.rs +++ b/rust/mxl-sys/build.rs @@ -1,5 +1,7 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + use std::env; -use std::fs; use std::path::PathBuf; #[cfg(debug_assertions)] @@ -29,41 +31,27 @@ fn get_bindgen_specs() -> BindgenSpecs { .to_string(), ]; if cfg!(not(feature = "mxl-not-built")) { - let build_dir = repo_root.join("build").join(BUILD_VARIANT); - let build_version_dir = build_dir - .join("lib") - .join("include") - .to_string_lossy() - .to_string(); + let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap()); + let build_version_dir = out_dir.join("include").to_string_lossy().to_string(); includes_dirs.push(build_version_dir); - let mxl_version_out_path = manifest_dir.join("mxl"); - if !fs::exists(&mxl_version_out_path) - .expect("Error checking if out path for version header file exists") - { - fs::create_dir(&mxl_version_out_path) - .expect("Failed to create out path for version header file"); - } - let mxl_version_header = mxl_version_out_path.join("version.h"); - println!("cargo:rerun-if-changed={}", mxl_version_header.display()); - // TODO: re-run on build_dir changing? + // Rebuild if any file in lib/ changes + let lib_root = repo_root.join("lib"); + println!("cargo:rerun-if-changed={}", lib_root.display()); let dst = cmake::Config::new(repo_root) - .out_dir(build_dir) - .generator("Unix Makefiles") + .generator("Ninja") + .configure_arg("--preset") + .configure_arg(BUILD_VARIANT) + .configure_arg("-B") + .configure_arg(out_dir.join("build")) + .define("BUILD_DOCS", "OFF") .define("BUILD_TESTS", "OFF") .define("BUILD_TOOLS", "OFF") - // .configure_arg(format!("--preset={BUILD_VARIANT}")) .build(); - let mxl_version_location = dst.join("include").join("mxl").join("version.h"); - assert!(matches!(std::fs::exists(&mxl_version_location), Ok(true))); - - fs::copy(&mxl_version_location, &mxl_version_header) - .expect("Could copy mxl version header"); - - println!("cargo:rustc-link-search={}", dst.join("lib64").display()); + println!("cargo:rustc-link-search={}", dst.join("lib").display()); println!("cargo:rustc-link-lib=mxl"); } diff --git a/rust/mxl-sys/src/lib.rs b/rust/mxl-sys/src/lib.rs index 666331b0..d82df112 100644 --- a/rust/mxl-sys/src/lib.rs +++ b/rust/mxl-sys/src/lib.rs @@ -1,7 +1,12 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(missing_docs)] +#![allow(rustdoc::broken_intra_doc_links)] +#![allow(rustdoc::invalid_html_tags)] // Suppress expected warnings from bindgen-generated code. // See https://github.com/rust-lang/rust-bindgen/issues/1651. #![allow(deref_nullptr)] diff --git a/rust/mxl-sys/tests/simple_test.rs b/rust/mxl-sys/tests/simple_test.rs index c617fe56..d0357dc4 100644 --- a/rust/mxl-sys/tests/simple_test.rs +++ b/rust/mxl-sys/tests/simple_test.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + #[test] fn there_is_bindgen_generated_code() { let mxl_version = mxl_sys::mxlVersionType { diff --git a/rust/mxl-sys/wrapper-with-version-h.h b/rust/mxl-sys/wrapper-with-version-h.h index 80c5254f..44b4bd77 100644 --- a/rust/mxl-sys/wrapper-with-version-h.h +++ b/rust/mxl-sys/wrapper-with-version-h.h @@ -1,2 +1,5 @@ +// SPDX-FileCopyrightText: 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + #include "wrapper-without-version-h.h" #include "mxl/version.h" diff --git a/rust/mxl-sys/wrapper-without-version-h.h b/rust/mxl-sys/wrapper-without-version-h.h index 5248f1e1..e6fb4216 100644 --- a/rust/mxl-sys/wrapper-without-version-h.h +++ b/rust/mxl-sys/wrapper-without-version-h.h @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + #include "mxl/dataformat.h" #include "mxl/flow.h" #include "mxl/flowinfo.h" diff --git a/rust/mxl/Cargo.toml b/rust/mxl/Cargo.toml index 447c4998..325c59ec 100644 --- a/rust/mxl/Cargo.toml +++ b/rust/mxl/Cargo.toml @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +# SPDX-License-Identifier: Apache-2.0 + [package] name = "mxl" edition.workspace = true diff --git a/rust/mxl/build.rs b/rust/mxl/build.rs index 382d75e1..4451cc68 100644 --- a/rust/mxl/build.rs +++ b/rust/mxl/build.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + use std::env; use std::path::PathBuf; diff --git a/rust/mxl/examples/common/mod.rs b/rust/mxl/examples/common/mod.rs index 221a4629..e37eb881 100644 --- a/rust/mxl/examples/common/mod.rs +++ b/rust/mxl/examples/common/mod.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + pub fn setup_logging() { tracing_subscriber::fmt() .with_env_filter( diff --git a/rust/mxl/examples/flow-reader.rs b/rust/mxl/examples/flow-reader.rs index 98bd2a2c..60987c87 100644 --- a/rust/mxl/examples/flow-reader.rs +++ b/rust/mxl/examples/flow-reader.rs @@ -1,9 +1,12 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + mod common; use std::time::Duration; use clap::Parser; -use mxl::config::get_mxf_so_path; +use mxl::config::get_mxl_so_path; use tracing::{info, warn}; const READ_TIMEOUT: Duration = Duration::from_secs(5); @@ -30,7 +33,7 @@ fn main() -> Result<(), mxl::Error> { common::setup_logging(); let opts: Opts = Opts::parse(); - let mxl_api = mxl::load_api(get_mxf_so_path())?; + let mxl_api = mxl::load_api(get_mxl_so_path())?; let mxl_instance = mxl::MxlInstance::new(mxl_api, &opts.mxl_domain, "")?; let reader = mxl_instance.create_flow_reader(&opts.flow_id)?; let flow_info = reader.get_info()?; diff --git a/rust/mxl/examples/flow-writer.rs b/rust/mxl/examples/flow-writer.rs index 7fe5ba13..67ca8b09 100644 --- a/rust/mxl/examples/flow-writer.rs +++ b/rust/mxl/examples/flow-writer.rs @@ -1,9 +1,12 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + mod common; use clap::Parser; use tracing::info; -use mxl::config::get_mxf_so_path; +use mxl::config::get_mxl_so_path; #[derive(Debug, Parser)] #[command(version = clap::crate_version!(), author = clap::crate_authors!())] @@ -30,7 +33,7 @@ fn main() -> Result<(), mxl::Error> { common::setup_logging(); let opts: Opts = Opts::parse(); - let mxl_api = mxl::load_api(get_mxf_so_path())?; + let mxl_api = mxl::load_api(get_mxl_so_path())?; let mxl_instance = mxl::MxlInstance::new(mxl_api, &opts.mxl_domain, "")?; let flow_def = mxl::tools::read_file(opts.flow_config_file.as_str()).map_err(|error| { mxl::Error::Other(format!( diff --git a/rust/mxl/src/api.rs b/rust/mxl/src/api.rs index 5cf81e9f..2c9ab3f9 100644 --- a/rust/mxl/src/api.rs +++ b/rust/mxl/src/api.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + use std::path::Path; use dlopen2::wrapper::{Container, WrapperApi}; diff --git a/rust/mxl/src/config.rs b/rust/mxl/src/config.rs index f89891ae..69295d47 100644 --- a/rust/mxl/src/config.rs +++ b/rust/mxl/src/config.rs @@ -1,12 +1,14 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + use std::str::FromStr; include!(concat!(env!("OUT_DIR"), "/constants.rs")); -pub fn get_mxf_so_path() -> std::path::PathBuf { - std::path::PathBuf::from_str(MXL_BUILD_DIR) - .expect("build error: 'MXL_BUILD_DIR' is invalid") - .join("lib") - .join("libmxl.so") +pub fn get_mxl_so_path() -> std::path::PathBuf { + // The mxl-sys build script ensures that the build directory is in the library path + // so we can just return the library name here. + "libmxl.so".into() } pub fn get_mxl_repo_root() -> std::path::PathBuf { diff --git a/rust/mxl/src/error.rs b/rust/mxl/src/error.rs index a56a4aad..d5372feb 100644 --- a/rust/mxl/src/error.rs +++ b/rust/mxl/src/error.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + pub type Result = core::result::Result; #[derive(Debug, thiserror::Error)] diff --git a/rust/mxl/src/flow.rs b/rust/mxl/src/flow.rs index d82e0eca..d0b3f753 100644 --- a/rust/mxl/src/flow.rs +++ b/rust/mxl/src/flow.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + pub mod reader; pub mod writer; diff --git a/rust/mxl/src/flow/reader.rs b/rust/mxl/src/flow/reader.rs index a5bfd678..82aa123a 100644 --- a/rust/mxl/src/flow/reader.rs +++ b/rust/mxl/src/flow/reader.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + use std::sync::Arc; use crate::{ diff --git a/rust/mxl/src/flow/writer.rs b/rust/mxl/src/flow/writer.rs index 250578db..b1234073 100644 --- a/rust/mxl/src/flow/writer.rs +++ b/rust/mxl/src/flow/writer.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + use std::sync::Arc; use crate::{ diff --git a/rust/mxl/src/grain.rs b/rust/mxl/src/grain.rs index 9bfae8f0..2205933c 100644 --- a/rust/mxl/src/grain.rs +++ b/rust/mxl/src/grain.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + pub mod data; pub mod reader; pub mod write_access; diff --git a/rust/mxl/src/grain/data.rs b/rust/mxl/src/grain/data.rs index fabdd135..d8cd9879 100644 --- a/rust/mxl/src/grain/data.rs +++ b/rust/mxl/src/grain/data.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + pub struct GrainData<'a> { pub user_data: &'a [u8], pub payload: &'a [u8], diff --git a/rust/mxl/src/grain/reader.rs b/rust/mxl/src/grain/reader.rs index 227e3e8a..8ecdec7f 100644 --- a/rust/mxl/src/grain/reader.rs +++ b/rust/mxl/src/grain/reader.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + use std::{sync::Arc, time::Duration}; use crate::{ diff --git a/rust/mxl/src/grain/write_access.rs b/rust/mxl/src/grain/write_access.rs index 04447aef..69657eb9 100644 --- a/rust/mxl/src/grain/write_access.rs +++ b/rust/mxl/src/grain/write_access.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + use std::{marker::PhantomData, sync::Arc}; use tracing::error; diff --git a/rust/mxl/src/grain/writer.rs b/rust/mxl/src/grain/writer.rs index a2399e0b..2c06b708 100644 --- a/rust/mxl/src/grain/writer.rs +++ b/rust/mxl/src/grain/writer.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + use std::sync::Arc; use super::write_access::GrainWriteAccess; diff --git a/rust/mxl/src/instance.rs b/rust/mxl/src/instance.rs index 95861b5e..8e703cd1 100644 --- a/rust/mxl/src/instance.rs +++ b/rust/mxl/src/instance.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + use std::{ffi::CString, sync::Arc}; use dlopen2::wrapper::Container; diff --git a/rust/mxl/src/lib.rs b/rust/mxl/src/lib.rs index b2ce1e5e..723739d7 100644 --- a/rust/mxl/src/lib.rs +++ b/rust/mxl/src/lib.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + mod api; mod error; mod flow; diff --git a/rust/mxl/src/samples.rs b/rust/mxl/src/samples.rs index 9bfae8f0..2205933c 100644 --- a/rust/mxl/src/samples.rs +++ b/rust/mxl/src/samples.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + pub mod data; pub mod reader; pub mod write_access; diff --git a/rust/mxl/src/samples/data.rs b/rust/mxl/src/samples/data.rs index 4c079690..ef7797d9 100644 --- a/rust/mxl/src/samples/data.rs +++ b/rust/mxl/src/samples/data.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + use std::marker::PhantomData; use crate::Error; diff --git a/rust/mxl/src/samples/reader.rs b/rust/mxl/src/samples/reader.rs index e6f75dcd..5612f319 100644 --- a/rust/mxl/src/samples/reader.rs +++ b/rust/mxl/src/samples/reader.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + use std::sync::Arc; use crate::{ diff --git a/rust/mxl/src/samples/write_access.rs b/rust/mxl/src/samples/write_access.rs index bbb57ce1..08fe9632 100644 --- a/rust/mxl/src/samples/write_access.rs +++ b/rust/mxl/src/samples/write_access.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + use std::{marker::PhantomData, sync::Arc}; use tracing::error; diff --git a/rust/mxl/src/samples/writer.rs b/rust/mxl/src/samples/writer.rs index 4c0193f5..f1e9ac37 100644 --- a/rust/mxl/src/samples/writer.rs +++ b/rust/mxl/src/samples/writer.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + use std::sync::Arc; use crate::{Error, Result, SamplesWriteAccess, instance::InstanceContext}; diff --git a/rust/mxl/src/tools.rs b/rust/mxl/src/tools.rs index 312af218..156e6593 100644 --- a/rust/mxl/src/tools.rs +++ b/rust/mxl/src/tools.rs @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + pub fn read_file(file_path: impl AsRef) -> Result { use std::io::Read; diff --git a/rust/mxl/tests/basic_tests.rs b/rust/mxl/tests/basic_tests.rs index 7242077c..544f8c0d 100644 --- a/rust/mxl/tests/basic_tests.rs +++ b/rust/mxl/tests/basic_tests.rs @@ -1,10 +1,13 @@ +// SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project. +// SPDX-License-Identifier: Apache-2.0 + /// Tests of the basic low level synchronous API. /// /// The tests now require an MXL library of a specific name to be present in the system. This should /// change in the future. For now, feel free to just edit the path to your library. use std::time::Duration; -use mxl::{MxlInstance, OwnedGrainData, OwnedSamplesData, config::get_mxf_so_path}; +use mxl::{MxlInstance, OwnedGrainData, OwnedSamplesData, config::get_mxl_so_path}; use tracing::info; static LOG_ONCE: std::sync::Once = std::sync::Once::new(); @@ -32,7 +35,7 @@ fn setup_test(test: &str) -> mxl::MxlInstance { .init(); }); - let mxl_api = mxl::load_api(get_mxf_so_path()).unwrap(); + let mxl_api = mxl::load_api(get_mxl_so_path()).unwrap(); let domain = setup_empty_domain(test); mxl::MxlInstance::new(mxl_api, &domain, "").unwrap() }