diff options
| author | rottedfm <rottedfm@proton.me> | 2026-08-19 11:24:55 -0400 |
|---|---|---|
| committer | rottedfm <rottedfm@proton.me> | 2026-08-19 11:24:55 -0400 |
| commit | 8e16347b0eb329e84892af8ece36886324c95f62 (patch) | |
| tree | be1267972b5de2f1ae592577dfabce67f1fe6e87 /build.rs | |
| parent | c6ae4660d1cc2414b22c492c5e819d009c8187c2 (diff) | |
| parent | ea0bd36167b684c0accdb5ce2b2e21b8d84aeb25 (diff) | |
Establishes the first working baseline: moji <file> opens a file into a
ropey rope and edits it with Helix selection-first modal editing, under a
DO-178C DAL-C requirements and traceability process.
Prior to this, main tracked four files and src/main.rs was still
println!("Hello, world!") — there was no buildable state to build on.
Verified on a fresh clone of the branch with no untracked files:
cargo build; clippy --all-targets -D warnings clean; 294 tests passing;
scripts/check-trace.sh reports 98/98 requirements traced in both
directions.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'build.rs')
| -rw-r--r-- | build.rs | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..20c813a --- /dev/null +++ b/build.rs @@ -0,0 +1,37 @@ +use anyhow::Result; +use vergen_gix::{Build, Cargo, Emitter, Gix}; + +/// Fallback used when the crate is built outside a git checkout (e.g. from a +/// packaged `.crate` file), so `env!("VERGEN_GIT_REMOTE_URL")` always resolves. +const UNKNOWN_REMOTE: &str = "unknown"; + +fn main() -> Result<()> { + let build = Build::all_build(); + let gix = Gix::all_git(); + let cargo = Cargo::all_cargo(); + Emitter::default() + .default_on_error() + .add_instructions(&build)? + .add_instructions(&gix)? + .add_instructions(&cargo)? + .emit()?; + + emit_git_remote_url(); + Ok(()) +} + +/// vergen only reports the local checkout (sha, branch, describe...), so read the +/// `origin` remote out of the same repository and expose it alongside the rest of +/// the `VERGEN_GIT_*` variables. +fn emit_git_remote_url() { + let url = git_remote_url().unwrap_or_else(|| UNKNOWN_REMOTE.to_string()); + println!("cargo:rustc-env=VERGEN_GIT_REMOTE_URL={url}"); + println!("cargo:rerun-if-changed=.git/config"); +} + +fn git_remote_url() -> Option<String> { + let repo = gix::discover(env!("CARGO_MANIFEST_DIR")).ok()?; + let remote = repo.find_remote("origin").ok()?; + let url = remote.url(gix::remote::Direction::Fetch)?; + Some(url.to_bstring().to_string()) +} |
