{"id":26368766,"url":"https://github.com/bindreams/syringe","last_synced_at":"2025-09-04T18:05:33.429Z","repository":{"id":50540920,"uuid":"514859331","full_name":"bindreams/syringe","owner":"bindreams","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-07T15:30:34.000Z","size":7681,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-24T15:02:26.758Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bindreams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"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,"zenodo":null}},"created_at":"2022-07-17T14:00:54.000Z","updated_at":"2025-03-07T15:30:41.000Z","dependencies_parsed_at":"2025-06-16T12:45:47.176Z","dependency_job_id":null,"html_url":"https://github.com/bindreams/syringe","commit_stats":null,"previous_names":["bindreams/syringe"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/bindreams/syringe","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bindreams%2Fsyringe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bindreams%2Fsyringe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bindreams%2Fsyringe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bindreams%2Fsyringe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bindreams","download_url":"https://codeload.github.com/bindreams/syringe/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bindreams%2Fsyringe/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273649505,"owners_count":25143652,"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","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-03-16T22:48:59.665Z","updated_at":"2025-09-04T18:05:33.385Z","avatar_url":"https://github.com/bindreams.png","language":"C","readme":"# Syringe 💉\nA cmake-based tool for crossplatform file embedding into C++ sources. A constexpr interface allows for zero-overhead file retrieval from a simple map-like interface.\n\n## Installation\nPre-built binaries of Syringe are available on the \"Releases\" page. Copy the binary file to a directory where it can be found by CMake. We recommend placing it in `~/.local/bin` on all systems, creating the directory and adding it to PATH, if necessary. Alternatively, you can build and install the binary manually.\n\n### Manual build\nPrerequesites:\n - A C++ compiler with support for C++20, such as [Clang](https://clang.llvm.org/);\n - An up-to-date version of [CMake](https://cmake.org/) (minimum 3.17, recommended 3.23);\n - [Ninja](https://ninja-build.org/) build system is recommended.\n\nClone or download this project. For your convenience, Syringe provides a CMakepresets file, which already specifies the settings for building the project. Open the root folder in terminal, conifure, build and install the project by running these commands:\n```sh\ncmake --preset default\ncmake --build build     # Add \"--config Release\" for Visual Studio.\ncmake --install build   # Add \"--prefix \u003cdir\u003e\" for a custom directory.\n```\nOn Windows, add the install directory to PATH.\n\n## Usage\nAlthough the syringe binary has a simple interface that can be use from the command line, if your project uses CMake, we recommend the CMake interface.\n\n### CMake interface\nCopy the `syringe.cmake` file into your project, and include it in your CMakeLists:\n```cmake\ninclude(syringe.cmake)\n```\nThis file provides two functions: `inject_files` and `target_inject_files`. Either one can be used depending on which one is more convenient for your project.\n\n```\ntarget_inject_files(\u003ctarget\u003e\n    FILES [files...]\n\tOUTPUT \u003coutput\u003e\n\t[VARIABLE \u003cvariable\u003e]\n\t[PREFIX \u003cprefix\u003e]\n\t[RELATIVE \u003crelative\u003e]\t\n)\n```\n`target_inject_files` adds a pre-build step for `\u003ctarget\u003e`. Files specified in `\u003cfiles\u003e` are embedded into a header file specified by `\u003coutput\u003e`. The output file is automatically added as a source dependency of the target, and can be included by the path that was specified in the parameter (including any directories, if they were specified).\n\nOptional parameter `\u003cvariable\u003e` overrides the default variable name for the compile-time map that stores the embedded files (default is `resources`). This parameter can be a nested name (e.g. `my_namespace::assets`), in which the necessary namespaces will be created. `\u003cprefix\u003e` and `\u003crelative\u003e` add and remove common prefixes from embedded files\\` names.\n\n\nSee the `examples` folder for example usage of this function.\n```\ninject_files(\n    FILES [files...]\n\tOUTPUT \u003coutput\u003e\n\t[VARIABLE \u003cvariable\u003e]\n\t[PREFIX \u003cprefix\u003e]\n\t[RELATIVE \u003crelative\u003e]\t\n)\n```\n`inject_files` has an interface almost exactly the same as `target_inject_files`, but the generated embedding command does not automatically bind to any target. This has the following implications:\n1. Since no target depends on the existence of the output, this command may run after the build step of your target. Add the output as a dependency using [`target_sources`](https://cmake.org/cmake/help/latest/command/target_sources.html).\n2. For the same reason the user is responsible for adding the output file to the search path of the compiler. This can be done using [`target_include_directories`](https://cmake.org/cmake/help/latest/command/target_include_directories.html).\n3. Unlike `target_inject_files` which places files in a predetermined directory, `inject_files` accepts an absolute path to the output. A relative path will be interpreted as relative to [`CMAKE_CURRENT_BINARY_DIR`](https://cmake.org/cmake/help/latest/variable/CMAKE_CURRENT_BINARY_DIR.html).\n\nIn summary, `inject_files` is the \"raw\" version of `target_inject_files`, which gives greater control of the targets to the user.\n\n### Commandline interface\nWhen not using CMake, you can directly call the `syringe` binary to create the header file. The options are similar to CMake, and can be inspected with `syringe --help`.\n\n## C++ interface\nAfter embedding the files, a header file with their binary contents is created. To use these files you need to include the header from anywhere in your project and access the object you specified during injecting (default is `resources`). This object has a map-like interface. You can iterate over it, call `size()`, and retrieve file contents with `operator[]`.\n```c++\n#include \u003cresources.hpp\u003e\n\nconstexpr span\u003cconst uint8_t\u003e pic_of_a_dog = resources[\"dog.jpg\"];\n```\nA `span\u003cconst uint8_t\u003e` can be easily transformed to `const unsigned char*`, `std::byte` span or any other format of binary data that you prefer.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbindreams%2Fsyringe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbindreams%2Fsyringe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbindreams%2Fsyringe/lists"}