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
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ else()
string(APPEND mxl_VERSION ".0")
endif()

option(BUILD_TESTS "Build the tests" ON)
option(BUILD_TOOLS "Build the tools" ON)

project(mxl
VERSION ${mxl_VERSION}
LANGUAGES CXX C
Expand Down Expand Up @@ -54,8 +57,10 @@ if(APPLE)
endif()

add_subdirectory(lib)
add_subdirectory(tools)
add_subdirectory(utils)
if (BUILD_TOOLS)
add_subdirectory(tools)
endif()

find_package(Doxygen)

Expand Down Expand Up @@ -132,4 +137,4 @@ set(CPACK_PACKAGE_CONTACT "DMF MXL <mxl@ebu.ch>")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")

# Include CPack
include(CPack)
include(CPack)
6 changes: 4 additions & 2 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ target_link_libraries(mxl
# Alias trace to libtrace::libtrace so that this library can be used
# in lieu of a module from the local source tree
add_library(${PROJECT_NAME}::mxl ALIAS mxl)
add_subdirectory(tests)
if (BUILD_TESTS)
add_subdirectory(tests)
endif()

# Install targets
install(TARGETS mxl EXPORT ${PROJECT_NAME}-targets
Expand Down Expand Up @@ -162,4 +164,4 @@ install(EXPORT ${PROJECT_NAME}-targets
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${MXL_CMAKE_CONFIG_DESTINATION}
COMPONENT ${PROJECT_NAME}-dev
)
)
19 changes: 19 additions & 0 deletions rust/Cargo.lock

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

Empty file added rust/flake.lock
Empty file.
70 changes: 70 additions & 0 deletions rust/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
description = "Flake for MXL dev";

inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/*.tar.gz";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = {
self,
nixpkgs,
rust-overlay
}: let
overlays = [
(import rust-overlay)
(self: super: {
rustStable = super.rust-bin.stable."1.88.0".default;
rustNightly = super.rust-bin.nightly."2025-06-26".default;
})
];

allSystems = [
"x86_64-linux" # 64-bit Intel/AMD Linux
"aarch64-linux" # 64-bit ARM Linux
"x86_64-darwin" # 64-bit Intel macOS
"aarch64-darwin" # 64-bit ARM macOS
];

forAllSystems = f:
nixpkgs.lib.genAttrs allSystems (system:
f {
pkgs = import nixpkgs {
inherit overlays system;
};
}
);
in {
devShells = forAllSystems ({pkgs}: {
default = pkgs.mkShell {
LIBCLANG_PATH = pkgs.lib.makeLibraryPath [pkgs.llvmPackages_latest.libclang.lib];
packages =
(with pkgs; [
rustStable
rust-analyzer
clang
cmake
pkg-config
]);
};
}
);
nightly = forAllSystems ({pkgs}: {
default = pkgs.mkShell {
LIBCLANG_PATH = pkgs.lib.makeLibraryPath [pkgs.llvmPackages_latest.libclang.lib];
packages =
(with pkgs; [
rustNightly
rust-analyzer
clang
cmake
pkg-config
]);
};
}
);
};
}
1 change: 1 addition & 0 deletions rust/mxl-sys/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mxl/version.h
1 change: 1 addition & 0 deletions rust/mxl-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ version.workspace = true

[build-dependencies]
bindgen.workspace = true
cmake = "0.1.54"

[features]
mxl-not-built = []
32 changes: 30 additions & 2 deletions rust/mxl-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::env;
use std::fs;
use std::path::PathBuf;

#[cfg(debug_assertions)]
Expand Down Expand Up @@ -27,8 +28,7 @@ fn get_bindgen_specs() -> BindgenSpecs {
.to_string_lossy()
.to_string(),
];
#[cfg(not(feature = "mxl-not-built"))]
{
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")
Expand All @@ -37,6 +37,34 @@ fn get_bindgen_specs() -> BindgenSpecs {
.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?

let dst = cmake::Config::new(repo_root)
.out_dir(build_dir)
.generator("Unix Makefiles")
.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-lib=mxl");
}

BindgenSpecs {
Expand Down
Loading