Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion .devcontainer/Dockerfile.almalinux
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion .devcontainer/Dockerfile.amazonlinux
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion .devcontainer/Dockerfile.debiantrixie
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion .devcontainer/Dockerfile.ubuntu-legacy
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions .devcontainer/almalinux/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -50,4 +51,4 @@
"gpu": "optional"
},
"remoteUser": "devcontainer"
}
}
5 changes: 3 additions & 2 deletions .devcontainer/amazonlinux/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -51,4 +52,4 @@
"DISPLAY": "${localEnv:DISPLAY}"
},
"remoteUser": "devcontainer"
}
}
5 changes: 3 additions & 2 deletions .devcontainer/debiantrixie/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -50,4 +51,4 @@
"gpu": "optional"
},
"remoteUser": "devcontainer"
}
}
29 changes: 29 additions & 0 deletions .devcontainer/scripts/common/rust/install-rust.sh
Original file line number Diff line number Diff line change
@@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor detail, cargo audit is 2x here in this list.

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
5 changes: 3 additions & 2 deletions .devcontainer/ubuntu20/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -52,4 +53,4 @@
"gpu": "optional"
},
"remoteUser": "devcontainer"
}
}
5 changes: 3 additions & 2 deletions .devcontainer/ubuntu22/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -52,4 +53,4 @@
"gpu": "optional"
},
"remoteUser": "devcontainer"
}
}
5 changes: 3 additions & 2 deletions .devcontainer/ubuntu24/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -52,4 +53,4 @@
"gpu": "optional"
},
"remoteUser": "devcontainer"
}
}
5 changes: 3 additions & 2 deletions .devcontainer/ubuntu25/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -52,4 +53,4 @@
"gpu": "optional"
},
"remoteUser": "devcontainer"
}
}
3 changes: 3 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
55 changes: 29 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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")
Expand Down
5 changes: 5 additions & 0 deletions rust/.config/nextest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[profile.ci]
fail-fast = false

[profile.ci.junit]
path = "junit.xml"
3 changes: 3 additions & 0 deletions rust/.gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project.
# SPDX-License-Identifier: Apache-2.0

Cargo.lock -diff
3 changes: 3 additions & 0 deletions rust/.gitignore
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions rust/Cargo.lock.license

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"]

Expand Down
5 changes: 5 additions & 0 deletions rust/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<!--
SPDX-FileCopyrightText: 2025 2025 Contributors to the Media eXchange Layer project.
SPDX-License-Identifier: Apache-2.0
-->

# Rust bindings for DMF MXL

## Goals
Expand Down
3 changes: 3 additions & 0 deletions rust/flake.nix
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
3 changes: 3 additions & 0 deletions rust/mxl-sys/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# SPDX-FileCopyrightText: 2025 Contributors to the Media eXchange Layer project.
# SPDX-License-Identifier: Apache-2.0

mxl/version.h
3 changes: 3 additions & 0 deletions rust/mxl-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
42 changes: 15 additions & 27 deletions rust/mxl-sys/build.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down Expand Up @@ -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");
}

Expand Down
5 changes: 5 additions & 0 deletions rust/mxl-sys/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
Loading
Loading