{"id":15032595,"url":"https://github.com/alinuxperson/build_script","last_synced_at":"2025-04-09T21:23:42.025Z","repository":{"id":57529681,"uuid":"336477890","full_name":"ALinuxPerson/build_script","owner":"ALinuxPerson","description":"A wrapper for build.rs instructions","archived":false,"fork":false,"pushed_at":"2023-05-25T20:26:52.000Z","size":94,"stargazers_count":16,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T23:16:22.101Z","etag":null,"topics":["build","build-script","build-scripts","build-tool","build-tools","rust","rustlang"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/build_script","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/ALinuxPerson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-02-06T07:07:51.000Z","updated_at":"2023-05-25T20:13:34.000Z","dependencies_parsed_at":"2024-09-28T21:10:31.857Z","dependency_job_id":null,"html_url":"https://github.com/ALinuxPerson/build_script","commit_stats":{"total_commits":62,"total_committers":1,"mean_commits":62.0,"dds":0.0,"last_synced_commit":"18f9c5a849c786679cefc61de0c179245269157a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ALinuxPerson%2Fbuild_script","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ALinuxPerson%2Fbuild_script/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ALinuxPerson%2Fbuild_script/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ALinuxPerson%2Fbuild_script/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ALinuxPerson","download_url":"https://codeload.github.com/ALinuxPerson/build_script/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248113163,"owners_count":21049795,"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":["build","build-script","build-scripts","build-tool","build-tools","rust","rustlang"],"created_at":"2024-09-24T20:18:48.864Z","updated_at":"2025-04-09T21:23:42.007Z","avatar_url":"https://github.com/ALinuxPerson.png","language":"Rust","readme":"\u003cdiv align=\"center\"\u003e\n    \u003ch1\u003e\u003cb\u003eBuild Script\u003c/b\u003e\u003c/h1\u003e\n    \u003ca href=\"https://www.crates.io/crates/build_script\"\u003e\n        \u003cimg src=\"https://img.shields.io/crates/v/build_script.svg\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://www.docs.rs/build_script\"\u003e\n        \u003cimg src=\"https://docs.rs/build_script/badge.svg\"\u003e\n    \u003c/a\u003e\n    \u003cp\u003eA wrapper for build.rs instructions\u003c/p\u003e\n\u003c/div\u003e\n\n# Why?\nI made this because I felt like the way you pass instructions to `build.rs` makes it very easy to make mistakes \n(especially when using strings) and it just felt odd that rust doesn't provide an api or an official external crate \n(like [`rand`](https://crates.io/crates/rand)).\n\n# Installation\nAdd this to your `Cargo.toml`:\n```toml\n[build-dependencies]\nbuild_script = \"0.2.0\"\n```\n\n# Examples\n```rust\nuse build_script::{cargo_rustc_link_lib, cargo_rustc_link_search, BuildScript, Instruction, Value};\n\nfn main() {\n    // basic instructions    \n    build_script::cargo_rerun_if_changed(\"something.txt\");\n    build_script::cargo_rerun_if_env_changed(\"PKG_CONFIG\");\n    build_script::cargo_rustc_link_lib(\"somelibrary\");\n    build_script::cargo_rustc_link_lib_mapping(cargo_rustc_link_lib::Kind::DynamicLibrary, \"somelibrary\");\n    build_script::cargo_rustc_link_search(\"something-else.txt\");\n    build_script::cargo_rustc_link_search_mapping(cargo_rustc_link_search::Kind::Crate, \"something-else.txt\");\n    build_script::cargo_rustc_flags(\"-l ffi\");\n    build_script::cargo_rustc_cfg(\"key\");\n    build_script::cargo_rustc_cfg_mapping(\"key\", \"value\");\n    build_script::cargo_rustc_env(\"var\", \"value\");\n    build_script::cargo_rustc_cdylib_link_arg(\"flag\");\n    build_script::cargo_mapping(\"key\", \"value\");\n\n    // other, advanced instructions    \n    let mut build_script = BuildScript::default();\n    let instruction = {\n        let value = Value::Singular(\"something\".into());\n        Instruction::new(\"instruction\", value)\n    };\n\n    // add a custom instruction to the instruction stack    \n    build_script.custom_instruction(instruction);\n\n    // write all instructions to something (for this scenario, and also usually, its stdout)    \n    build_script.build();\n}\n```\n\nFor more information see the documentation.\n\n# Terminology\n## Instruction\nThe instruction is what is passed to cargo. An example would be `cargo:rerun-if-env-changed=ENV`. This example will\nalso be dissected below.\n\nThe instruction is split into three parts:\n### Prefix\nThe prefix is the string before the delimiter `:`: `cargo`.\n\nUsually the prefix is `cargo`, however in this crate other, custom prefixes can be used for future compatibility in case\nanother prefix is added.\n\n### Name\nThe name is the string in between the delimiters `:` and `=`: `rerun-if-env-changed`.\n\nIf the name is unknown, the instruction will automatically be a mapping (see below).\n### Value\nThe value is the string after the delimiter `=`: `ENV`.\n\nThis represents the value of the instruction.\n## Mapping\nThere is a type of instruction which is a mapping: `cargo:KEY=VALUE`.\n\nThis is, verbatim:\n\n\u003e Metadata, used by `links` scripts.\n\nThe source can be found [here](https://doc.rust-lang.org/cargo/reference/build-scripts.html).\n\nThis is used when an instruction name is unknown.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falinuxperson%2Fbuild_script","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falinuxperson%2Fbuild_script","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falinuxperson%2Fbuild_script/lists"}