{"id":17241974,"url":"https://github.com/mtkennerly/realia","last_synced_at":"2025-10-05T01:03:51.501Z","repository":{"id":62443784,"uuid":"278835453","full_name":"mtkennerly/realia","owner":"mtkennerly","description":"Extra conditional compilation macros for Rust","archived":false,"fork":false,"pushed_at":"2024-03-16T15:22:41.000Z","size":37,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T03:04:23.344Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mtkennerly.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-07-11T10:05:00.000Z","updated_at":"2023-02-23T15:43:00.000Z","dependencies_parsed_at":"2022-11-01T23:18:14.950Z","dependency_job_id":null,"html_url":"https://github.com/mtkennerly/realia","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtkennerly%2Frealia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtkennerly%2Frealia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtkennerly%2Frealia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mtkennerly%2Frealia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mtkennerly","download_url":"https://codeload.github.com/mtkennerly/realia/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248814034,"owners_count":21165664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T06:11:56.597Z","updated_at":"2025-10-05T01:03:51.404Z","avatar_url":"https://github.com/mtkennerly.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Realia\n\nThis crate provides macros for conditional compilation based on various checks.\nThese macros are analogous to `#[cfg(...)]` and `#[cfg_attr(...)]`.\n\nRealia is inspired by and heavily based on [rustversion](https://crates.io/crates/rustversion).\n\n## Attributes\nPrimary:\n\n* Environment variables:\n  * `#[realia::env(\"FOO\")]`\n    * Checks if the `FOO` environment variable exists.\n  * `#[realia::env(\"FOO\", \"bar\")]`\n    * Checks if the `FOO` environment variable has the value `bar`.\n* Executables:\n  * `#[realia::cmd(\"foo\")]`\n    * Checks if the executable `foo` exists in the `PATH` environment variable.\n* Dependencies (accounts for target-specific ones, but not optional ones currently):\n  * `#[realia::dep(\"your-crate\", \"foo\")]`\n    * Checks if your crate uses any version of the `foo` crate.\n  * `#[realia::dep(\"your-crate\", \"foo\", \"1.2.3\")]`\n    * Checks if your crate uses the `foo` crate with exactly version 1.2.3.\n  * `#[realia::dep_since(\"your-crate\", \"foo\", \"1.2.3\")]`\n    * Checks if your crate uses the `foo` crate with version 1.2.3 or newer.\n  * `#[realia::dep_before(\"your-crate\", \"foo\", \"1.2.3\")]`\n    * Checks if your crate uses the `foo` crate with a version before 1.2.3.\n  * `#[realia::dep_from_registry(\"your-crate\", \"foo\")]`\n    * Checks if your crate uses the `foo` crate from the registry (as opposed to\n      being a `git` or `path` dependency). This is useful if you have\n      [publishing fallbacks](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#multiple-locations).\n\nThe above can be refined or augmented by these additional attributes:\n\n* `#[realia::not(env(\"FOO\"))]`\n  * Inverts the condition.\n* `#[realia::any(env(\"FOO\"), env(\"bar\"))]`\n  * Checks if any of the conditions are met.\n* `#[realia::all(env(\"FOO\"), env(\"bar\"))]`\n  * Checks if all of the conditions are met.\n* `#[realia::attr(env(\"FOO\"), some_attr)]`\n  * Applies `#[some_attr]` if the condition is met.\n    You can also specify `const` this way.\n\n## Triggering build on changed conditions\nIf you use the `env` or `cmd` attributes,you'll need to include a `build.rs`\nin your project with any environment variables you check.\n\n```rust\nfn main() {\n    // Necessary when using #[realia::env(\"FOO\")]\n    println!(\"cargo:rerun-if-env-changed=FOO\");\n\n    // Necessary when using #[realia::cmd(...)]\n    println!(\"cargo:rerun-if-env-changed=PATH\");\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtkennerly%2Frealia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmtkennerly%2Frealia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmtkennerly%2Frealia/lists"}