CI / Build & test (Windows) (push) Failing after 7s
All crates take the oak-* kebab-case naming (oak-audio, oak-codec, oak-common, oak-core, oak-ffmpeg-link, oak-node, oak-otio, oak-plugin, oak-render, oak-storage, oak-task, oak-timeline, oak-undo), with the lib identifiers rewritten (oakrender:: -> oak_render::, oakcore_rs:: -> oak_core::, ...) across all 226 referencing files. The GUI application moves from the workspace root into crates/oak-app/: src/, build.rs (paths fixed for the new location) and tests/ travel with it, the root Cargo.toml becomes workspace-only ([workspace] + workspace.package + profiles), and the app package inherits the workspace version. The screenshots example becomes a standalone crate examples/simple_player/ with its own Cargo.toml. Every crate now inherits the single workspace version (version.workspace = true), and the workflows' crate paths and the build docs follow the renames. Validated with a clean cargo check --workspace.
88 lines
3.2 KiB
Rust
88 lines
3.2 KiB
Rust
// Oak Video Editor - Non-Linear Video Editor
|
|
// Copyright (C) 2026 Oak Team
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
//! oakcommon helpers (config, file functions) — direct Rust calls into
|
|
//! the oakcommon crate (single-lib unification; the former
|
|
//! `bridge/common.rs`). The configuration-location and disk-cache
|
|
//! helpers delegate to oakcommon's own implementation.
|
|
|
|
use std::sync::Mutex;
|
|
|
|
/// Read a config string via the domain store
|
|
/// (`ConfigStore::get(group, key)`); `None` when missing or empty.
|
|
pub fn config_get_string(group: Option<&str>, key: &str) -> Option<String> {
|
|
oak_common::configstore::ConfigStore::instance()
|
|
.get(group, key)
|
|
.ok()
|
|
.filter(|s| !s.is_empty())
|
|
}
|
|
|
|
/// `oakcommon_config_get_int(group, key, default)`.
|
|
pub fn config_get_int(group: Option<&str>, key: &str, default: i32) -> i32 {
|
|
oak_common::configstore::ConfigStore::instance().get_int(group, key, default)
|
|
}
|
|
|
|
/// The configuration directory — oakcommon's implementation
|
|
/// (`FileFunctions::get_configuration_location`, honoring `OAK_CONFIG_DIR`
|
|
/// and the platform fallbacks).
|
|
pub fn configuration_location() -> String {
|
|
oak_common::filefunctions::FileFunctions::new()
|
|
.get_configuration_location()
|
|
.unwrap_or_default()
|
|
}
|
|
|
|
/// Serializes tests that mutate `OAK_CONFIG_DIR` / `OAK_RENDER_BACKEND`
|
|
/// (env is process-global; the manager tests share this lock too).
|
|
pub static ENV_TEST_LOCK: Mutex<()> = Mutex::new(());
|
|
|
|
/// The default disk cache directory (C++ `DiskManager::
|
|
/// get_default_disk_cache_path`): `<configuration_location>/mediacache`.
|
|
pub fn default_disk_cache_path() -> String {
|
|
oak_common::filefunctions::default_disk_cache_path()
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn config_missing_key_falls_back() {
|
|
// The real config store is empty under cargo test: defaults apply.
|
|
assert_eq!(config_get_int(None, "GraphicsBackend", 7), 7);
|
|
assert_eq!(config_get_string(None, "missing"), None);
|
|
}
|
|
|
|
#[test]
|
|
fn configuration_location_uses_env_override() {
|
|
let _guard = ENV_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner());
|
|
let dir = std::env::temp_dir().join("oakrender-config-test");
|
|
std::env::set_var("OAK_CONFIG_DIR", &dir);
|
|
let loc = configuration_location();
|
|
assert_eq!(loc, dir.to_string_lossy());
|
|
std::env::remove_var("OAK_CONFIG_DIR");
|
|
}
|
|
|
|
#[test]
|
|
fn default_disk_cache_path_is_under_config() {
|
|
let _guard = ENV_TEST_LOCK.lock().unwrap_or_else(|e| e.into_inner());
|
|
let dir = std::env::temp_dir().join("oakrender-cache-test");
|
|
std::env::set_var("OAK_CONFIG_DIR", &dir);
|
|
let p = default_disk_cache_path();
|
|
assert!(p.ends_with("/mediacache") || p.ends_with("\\mediacache"));
|
|
std::env::remove_var("OAK_CONFIG_DIR");
|
|
}
|
|
}
|