{"id":16120625,"url":"https://github.com/a-cordier/bpk","last_synced_at":"2025-10-20T12:50:13.609Z","repository":{"id":80951024,"uuid":"189106614","full_name":"a-cordier/bpk","owner":"a-cordier","description":":construction_worker: bpk packages files as binary resources availables in your C++ project","archived":false,"fork":false,"pushed_at":"2019-06-09T09:11:09.000Z","size":24,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-12T16:18:55.614Z","etag":null,"topics":["build-tool","cpp"],"latest_commit_sha":null,"homepage":"","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/a-cordier.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}},"created_at":"2019-05-28T21:35:17.000Z","updated_at":"2023-03-05T05:49:24.000Z","dependencies_parsed_at":"2023-03-12T08:46:55.210Z","dependency_job_id":null,"html_url":"https://github.com/a-cordier/bpk","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-cordier%2Fbpk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-cordier%2Fbpk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-cordier%2Fbpk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/a-cordier%2Fbpk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/a-cordier","download_url":"https://codeload.github.com/a-cordier/bpk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247471287,"owners_count":20944153,"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-tool","cpp"],"created_at":"2024-10-09T20:58:52.291Z","updated_at":"2025-10-20T12:50:08.589Z","avatar_url":"https://github.com/a-cordier.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"## bpk\n\nbpk packages files as binary resources availables in your project\n\n### Requirements\n\n  - [cmake](https://cmake.org/install/)\n  - [conan](https://docs.conan.io/en/latest/installation.html)\n\n### Download \u0026 Build\n\n```sh\ngit clone --recursive https://github.com/a-cordier/bpk.git\ncd bpk\nmkdir build\ncd build\ncmake ..\nmake\n```\n\n### Package your files\n\n```sh\nbpk -d \u003csrc_dir\u003e -o \u003cfile_name\u003e.h -n \u003cnamespace\u003e\n```\n\n### Use in your project\n\n  - Add the output file to your project\n  - Use `\u003cnamespace\u003e::getResource(const char* key)` to get access to your file\n\nFiles are named after their relative path inside their resource directory\n\n### Example\n\n  - Assuming the following resource directory\n\n```\nresources\n└── svg\n    ├── next.svg\n    ├── pause.svg\n    ├── play.svg\n    ├── previous.svg\n    └── stop.svg\n```\n\nRunning:\n\n```sh\nbpk -d ./resources -o resources.h -n resources\n```\n\n  - Will generate the following `resources.h` file\n\n```cpp\n#include \u003ciostream\u003e\n#include \u003cvector\u003e\n#include \u003cmap\u003e\n#include \u003cutility\u003e\n\nnamespace resources {\n\n\tnamespace {\n\n\t\tstd::map\u003cstd::string, std::vector\u003cchar\u003e \u003e data = {\n\t\t\t{ \"svg/previous.svg\", { /* Data chunks */ } },\n\t\t\t{ \"svg/pause.svg\", { /* Data chunks */ } },\n\t\t\t{ \"svg/play.svg\", { /* Data chunks */ } },\n\t\t\t{ \"svg/next.svg\", { /* Data chunks */ } },\n\t\t};\n\t}\n\n\tinline char* get(const char* name) {\n    \t\tauto it = data.find(name);\n    \t\treturn it == data.end() ? nullptr : it-\u003esecond.data();\n    \t}\n    \n    inline std::vector\u003cchar\u003e::size_type size(const char* name) {\n        auto it = data.find(name);\n        return it == data.end() ? 0 : it-\u003esecond.size();\n    }\n}\n```\n\n  - Resources being accessed the following way\n\n```cpp\n#include \"resources.h\"\n\nauto data = resources::get(\"svg/play.svg\")\n```\n\n### Integrating with CMAKE\n\nIntegration with CMAKE for automating generation at build time may be achieved using the \n[ExternalProject](https://cmake.org/cmake/help/latest/module/ExternalProject.html) module\n\n#### CMAKE integration sample\n\n```cmake\ninclude(ExternalProject)\n\nExternalProject_Add(\n        bpk\n\tGIT_REPOSITORY    \"https://github.com/a-cordier/bpk.git\"\n        GIT_TAG           \"v1.0.0\"\n        SOURCE_DIR        \"${CMAKE_CURRENT_BINARY_DIR}/bpk-src\"\n        BINARY_DIR        \"${CMAKE_CURRENT_BINARY_DIR}/bpk-build\"\n        INSTALL_COMMAND   \"\"\n)\n\nset(RESOURCES_DIR \"${CMAKE_CURRENT_SOURCE_DIR}/resources\")\nset(RESOURCES_FILE \"${CMAKE_CURRENT_SOURCE_DIR}/src/resources.h\")\n\nadd_custom_command(\n        TARGET bpk\n        POST_BUILD\n        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}\n        COMMAND \"${CMAKE_CURRENT_BINARY_DIR}/bpk-build/bin/bpk\" \n\t        \"-o\" \"${RESOURCES_FILE}\" \n\t\t\"-d\" \"${RESOURCES_DIR}\" \n\t\t\"-n\" \"resources\"\n        COMMENT \"Running bpk to generate resources file\"\n)\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa-cordier%2Fbpk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fa-cordier%2Fbpk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fa-cordier%2Fbpk/lists"}