refactor: workspace layout — crates/, app at root, legacy C++ removed

Single mechanical restructure commit:
- root Cargo.toml = oakapp bin + workspace; one cargo build produces
  oakapp, oak-cli, oak-worker, liboakengine.dylib
- app/rust/src -> src/ (app at repo root, no rust/ nesting)
- src/<mod>/rust -> crates/oak<mod>; src/oakcore-rs -> crates/oakcore;
  src/bindings/oakotio -> crates/oakotio; src/engine/rust ->
  crates/oakengine (keeps cdylib+staticlib+rlib)
- public C headers include/<mod>/ -> crates/oakengine/include/<mod>/
- OFX SDK headers vendored into crates/oakplugin/ofx/ (HostSupport gone)
- legacy deleted: old src/ C++ modules, engine/, core/, ffmpeg_bridge/,
  app/ (Qt), cli/worker C++, root CMakeLists, third_party/KDDockWidgets
  submodule, otio-install, all build-* output (~40GB)
- oakstorage kept but excluded from the workspace (skeleton w/ todos);
  gpui excluded (own workspace)
- verified: cargo build green, cargo test --workspace 1845/0
  (with the documented OCIO_RS_* env override for the homebrew OCIO)
This commit is contained in:
2026-08-10 20:24:25 +08:00
parent f8540e3892
commit 013a175707
4212 changed files with 8331 additions and 2274987 deletions
+44
View File
@@ -0,0 +1,44 @@
// 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/>.
//! `oak-cli info <project.ove>` — print the project name, its sequences and
//! its footage (port of `cmd_info()` in cli/main.cpp).
use crate::cmd::{port_not_wired, require_or, EXIT_ERROR};
/// Run `info`. `project` is the .ove path from the command line.
pub fn run(project: String) -> i32 {
if let Err(code) = require_or(
"info",
&[
&crate::deferred::INIT,
&crate::deferred::NODE,
&crate::deferred::TIMELINE,
],
EXIT_ERROR,
) {
return code;
}
// Facade port (unreachable while the families above are deferred):
// oakengine_init(OAKENGINE_INIT_HEADLESS)
// project_create + project_load(project, ...)
// name/filename/is_modified/sequence_count/sequence_at(...) +
// fmt::sequence() / fmt::footage_entry() for each
// project_free + oakengine_shutdown()
// The formatters already exist in crate::fmt and are golden-tested.
let _ = &project;
port_not_wired("info", EXIT_ERROR)
}
+71
View File
@@ -0,0 +1,71 @@
// 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/>.
//! Subcommand implementations.
//!
//! Each subcommand is a faithful port of its `cli/main.cpp` counterpart:
//! the argument validation is real (same messages, same usage-error code),
//! and the facade work gates on [`crate::deferred::require`] — while the
//! families a subcommand needs are deferred, it prints the "not yet
//! available" error with the reasons and exits with the C++-compatible code
//! (1 for info/probe, 2 for render/transcode), never crashing.
pub mod info;
pub mod probe;
pub mod render;
pub mod transcode;
use crate::deferred::DeferredFamily;
/// 0 — success.
pub const EXIT_OK: i32 = 0;
/// 1 — general error (bad project/media file, no sequence, I/O failure).
pub const EXIT_ERROR: i32 = 1;
/// 2 — rendering unavailable or failed (e.g. no GL render backend).
pub const EXIT_RENDER_UNAVAILABLE: i32 = 2;
/// 64 — usage error.
pub const EXIT_USAGE: i32 = 64;
/// Gate a subcommand on its facade families.
///
/// When every family is wrapped this returns `Ok(())` and the subcommand's
/// port runs; when any is deferred it prints the composed "not yet
/// available" message to stderr and returns `Err(unavailable_code)` — the
/// code the C++ binary would exit with when that family's work is
/// impossible (1 for info/probe, 2 for render/transcode).
pub fn require_or(
cmd: &str,
families: &[&DeferredFamily],
unavailable_code: i32,
) -> Result<(), i32> {
match crate::deferred::require(families) {
Ok(()) => Ok(()),
Err(msg) => {
eprintln!("error: {cmd}: {msg}");
Err(unavailable_code)
}
}
}
/// Fallback for the (today unreachable) success arm of `require_or`: the
/// gate reported the families available, but the call-through port is not
/// wired yet. Never panics; reports an internal error and returns `code`.
pub fn port_not_wired(cmd: &str, code: i32) -> i32 {
eprintln!(
"error: {cmd}: internal error: facade families reported available but no port is wired yet"
);
code
}
+39
View File
@@ -0,0 +1,39 @@
// 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/>.
//! `oak-cli probe <mediafile>` — probe a media file and print its decoder,
//! duration and video/audio/subtitle streams (port of `cmd_probe()` in
//! cli/main.cpp).
use crate::cmd::{port_not_wired, require_or, EXIT_ERROR};
/// Run `probe`. `mediafile` is the media path from the command line.
pub fn run(mediafile: String) -> i32 {
if let Err(code) = require_or(
"probe",
&[&crate::deferred::INIT, &crate::deferred::NODE],
EXIT_ERROR,
) {
return code;
}
// Facade port (unreachable while the families above are deferred):
// oakengine_init(OAKENGINE_INIT_HEADLESS)
// footage_probe(mediafile) -> decoder_name/duration/stream infos,
// formatted with the fmt::* lines (golden-tested)
// footage_free + oakengine_shutdown()
let _ = &mediafile;
port_not_wired("probe", EXIT_ERROR)
}
+69
View File
@@ -0,0 +1,69 @@
// 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/>.
//! `oak-cli render <project.ove> <start_seconds> <end_seconds> <out_dir>` —
//! render the first sequence to PPM frames plus a PCM s16 WAV (port of
//! `cmd_render()` in cli/main.cpp).
use crate::cmd::{port_not_wired, require_or, EXIT_RENDER_UNAVAILABLE, EXIT_USAGE};
/// Run `render` with the validated (or rejected) seconds arguments.
///
/// The seconds are validated exactly like the C++ `strtod` checks before any
/// facade work; the facade work itself (init + project + sequence + renderer,
/// then [`crate::ppm::write_ppm`] / [`crate::wav::write_wav`] per frame) is
/// gated on the deferred families below.
pub fn run(project: String, start_seconds: &str, end_seconds: &str, out_dir: &str) -> i32 {
let start: f64 = match start_seconds.parse() {
Ok(v) => v,
Err(_) => {
eprintln!("error: invalid start seconds \"{start_seconds}\"");
return EXIT_USAGE;
}
};
let end: f64 = match end_seconds.parse() {
Ok(v) => v,
Err(_) => {
eprintln!("error: invalid end seconds \"{end_seconds}\"");
return EXIT_USAGE;
}
};
if end <= start {
eprintln!("error: invalid end seconds \"{end_seconds}\"");
return EXIT_USAGE;
}
if let Err(code) = require_or(
"render",
&[
&crate::deferred::INIT,
&crate::deferred::NODE,
&crate::deferred::TIMELINE,
&crate::deferred::RENDER,
],
EXIT_RENDER_UNAVAILABLE,
) {
return code;
}
// Facade port (unreachable while the families above are deferred):
// oakengine_init(HEADLESS | RENDER), chdir to the project dir,
// project_load, sequence 0 frame rate -> start_ts/end_ts,
// renderer_create(f32, fr_num, fr_den), then for each timestamp
// render_frame -> ppm::write_ppm (progress on stderr), then
// render_audio -> wav::write_wav. Both writers are golden-tested.
let _ = (&project, &start, &end, &out_dir);
port_not_wired("render", EXIT_RENDER_UNAVAILABLE)
}
+70
View File
@@ -0,0 +1,70 @@
// 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/>.
//! `oak-cli transcode <input_media> <out> [width] [--format ppm|mp4]` —
//! "media in, renders out" round trip (port of `cmd_transcode()` in
//! cli/main.cpp).
use crate::cmd::{port_not_wired, require_or, EXIT_RENDER_UNAVAILABLE, EXIT_USAGE};
/// Run `transcode`. `width`/`format` are validated exactly like the C++ loop
/// over `argv[4..]`; the facade work is gated on the deferred families below.
pub fn run(
input_media: String,
out: String,
width: Option<String>,
format: Option<String>,
) -> i32 {
if let Some(w) = &width {
match w.parse::<i64>() {
Ok(n) if n > 0 => {}
_ => {
eprintln!("error: invalid width \"{w}\"");
return EXIT_USAGE;
}
}
}
if let Some(f) = &format {
if f != "ppm" && f != "mp4" {
eprintln!("error: unknown --format \"{f}\" (ppm|mp4)");
return EXIT_USAGE;
}
}
if let Err(code) = require_or(
"transcode",
&[
&crate::deferred::INIT,
&crate::deferred::NODE,
&crate::deferred::TIMELINE,
&crate::deferred::RENDER,
&crate::deferred::EXPORT,
],
EXIT_RENDER_UNAVAILABLE,
) {
return code;
}
// Facade port (unreachable while the families above are deferred):
// probe the source for geometry/fps/duration, build a temporary
// project (new + import_footage + sequence_new + add_track x2 +
// add_footage_clip x2), then either the ppm path (render_frame /
// render_audio -> ppm::write_ppm / wav::write_wav) or the mp4 path
// (oakengine_export_render with H.264/AAC options + progress
// callback). The C++ exits 2 when the render/export backend is
// unavailable, which is also the code used here.
let _ = (&input_media, &out, &width, &format);
port_not_wired("transcode", EXIT_RENDER_UNAVAILABLE)
}