unity-solution-generator 0.1.1

Regenerates Unity .csproj/.sln files from asmdef/asmref layout without launching the Unity editor.
Documentation
//! Unity Solution Generator core library.
//!
//! Ported from the Swift `SolutionGeneratorCore` target.

/// Version of the user-visible `csproj.lock` format. Bump only on intentional
/// schema changes; `csproj.lock` may be checked in, so a bump means consumers
/// re-lock against possibly different Unity installs. See [[architecture.md]].
pub const LOCKFILE_VERSION: u32 = 1;

/// Version of the dev-local cache files (`scan-cache`, `lock-fingerprint`,
/// `.fingerprints/<hash>`). Bumping invalidates ALL three caches wholesale —
/// no migrations. These files are gitignored under `Library/`, so cold-rebuild
/// on bump is harmless. Cargo / Bazel idiom.
pub const CACHE_VERSION: u32 = 1;

pub mod defines;
pub mod error;
pub(crate) mod generate_cache;
pub mod io;
pub(crate) mod lock_cache;
pub mod lockfile;
pub mod lockfile_scanner;
pub(crate) mod package_cache;
pub mod paths;
pub mod profile;
pub mod project_scanner;
pub mod solution_generator;
pub mod typecheck;
pub(crate) mod walk;
pub mod xml;

pub use defines::{generate_version_defines, parse_scripting_defines};
pub use error::{GeneratorError, LockfileError, Result};
pub use lockfile::{DllRef, Lockfile, LockfileIO, RefCategory};
pub use lockfile_scanner::LockfileScanner;
pub use paths::{
    DEFAULT_GENERATOR_ROOT, lockfile_path, parent_directory, resolve_project_root, resolve_real_path,
};
pub use project_scanner::{AsmDefRecord, ProjectCategory, ProjectScanner, ScanResult, VersionDefine};
pub use solution_generator::{
    BuildConfig, BuildPlatform, GenerateOptions, GenerateResult, SolutionGenerator,
};
pub use typecheck::{TypecheckOptions, TypecheckResult};
/// Test-only re-exports of internal helpers. Not part of the stable public API.
#[doc(hidden)]
pub mod __test_only {
    pub use crate::lock_cache::{build_entries, is_valid};
    pub use crate::typecheck::__test_only_build_rsp as build_rsp;
}

/// High-level convenience: parse string args + run the full generate pipeline.
///
/// Used by the CLI and by external FFI hosts (see meow-tower's BoxcatBridge).
/// `platform` accepts `ios|android|osx`; `config` accepts `prod|dev|editor`.
/// `extra_refs` is a comma-separated list of DLL paths (see `DllRef::parse_list`).
/// Loads or scans the lockfile as needed.
pub fn generate(
    project_root: &str,
    platform: &str,
    config: &str,
    output_dir: Option<&str>,
    extra_refs: Option<&str>,
) -> Result<()> {
    let build_platform = BuildPlatform::parse(platform).ok_or_else(|| {
        GeneratorError::Other(format!(
            "Unknown platform '{platform}'. Use 'ios', 'android', or 'osx'."
        ))
    })?;
    let build_config = BuildConfig::parse(config).ok_or_else(|| {
        GeneratorError::Other(format!(
            "Unknown config '{config}'. Use 'prod', 'dev', or 'editor'."
        ))
    })?;
    let resolved = resolve_project_root(project_root);
    let extra_refs_vec: Vec<DllRef> = extra_refs.map(DllRef::parse_list).unwrap_or_default();
    let options = GenerateOptions::new(resolved.clone(), build_platform)
        .with_build_config(build_config)
        .with_output_dir(output_dir)
        .with_extra_refs(extra_refs_vec);
    let lockfile = LockfileIO::load_or_scan(&resolved, DEFAULT_GENERATOR_ROOT)?;
    SolutionGenerator::new().generate_from_lockfile(&options, &lockfile)?;
    Ok(())
}