{"id":23189085,"url":"https://github.com/kubasejdak-org/platform","last_synced_at":"2026-05-06T22:04:11.655Z","repository":{"id":241406023,"uuid":"806245389","full_name":"kubasejdak-org/platform","owner":"kubasejdak-org","description":"C/C++ application bootstrap layer for various hardware/OS platforms","archived":false,"fork":false,"pushed_at":"2026-05-01T21:41:10.000Z","size":3484,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-01T23:27:35.742Z","etag":null,"topics":["arm","baremetal","c","cpp","embedded","freertos","linux","toolchain","toolchain-cmake","toolchain-file"],"latest_commit_sha":null,"homepage":"","language":"C","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/kubasejdak-org.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2024-05-26T19:15:34.000Z","updated_at":"2026-04-23T20:16:35.000Z","dependencies_parsed_at":"2024-07-28T12:05:16.207Z","dependency_job_id":"115dc002-4b20-4074-a641-5aba70356d4f","html_url":"https://github.com/kubasejdak-org/platform","commit_stats":null,"previous_names":["kubasejdak-org/platform"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/kubasejdak-org/platform","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubasejdak-org%2Fplatform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubasejdak-org%2Fplatform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubasejdak-org%2Fplatform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubasejdak-org%2Fplatform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kubasejdak-org","download_url":"https://codeload.github.com/kubasejdak-org/platform/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubasejdak-org%2Fplatform/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32713820,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-06T19:35:05.142Z","status":"ssl_error","status_checked_at":"2026-05-06T19:35:03.996Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["arm","baremetal","c","cpp","embedded","freertos","linux","toolchain","toolchain-cmake","toolchain-file"],"created_at":"2024-12-18T11:17:13.445Z","updated_at":"2026-05-06T22:04:11.648Z","avatar_url":"https://github.com/kubasejdak-org.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# platform\n\nA CMake-based bootstrap framework that enables building C/C++ projects for Linux and baremetal platforms (with or\nwithout RTOS) from a single codebase. It provides toolchain configuration via CMake variables and platform-specific\nentry point abstraction through a unified `appMain()` interface.\n\nMain features:\n\n- **toolchain setup**: configures compiler, architecture flags, and build settings for target platform via CMake\n  toolchain files,\n- **unified main()**: provides platform-specific `main()` implementations that invoke application-defined `appMain()`\n  function.\n\n\u003e [!IMPORTANT]\n\u003e\n\u003e `platform` requires target project to use CMake.\n\n## Architecture\n\n### Components\n\n- **`toolchain`**:\n    - Configures compiler and architecture flags via `PLATFORM` + `TOOLCHAIN` CMake variables from the list of supported\n      ones.\n    - On Linux, additionally allows enabling sanitizers (`asan`, `lsan`, `tsan`, `ubsan`) and code coverage support.\n- **`main`**:\n    - Provides platform-specific `main()` that calls application-defined `appMain()`.\n    - On Linux, an optional `platform::main-paths` target exposes API for getting install, config, and data root paths.\n- **`package`**:\n    - Exposes build-time metadata (compiler, build type) and git metadata (e.g. tag, branch, commit), regenerated at\n      every CMake reconfiguration.\n\n\u003e [!IMPORTANT]\n\u003e\n\u003e Only components explicitly referenced by `find_package(platform COMPONENTS ...)` are processed by CMake and those\n\u003e referenced by `target_link_libraries()` are actually built.\n\n#### `main`\n\nThe `main` component abstracts the entry-point dispatch across all supported platforms:\n\n```mermaid\nflowchart TD\n    main[\"main()\"] --\u003e Platform{platform}\n\n    Platform --\u003e|Linux| AppMainLinux[\"appMain()\"]\n    Platform --\u003e|Baremetal| AppMainBaremetal[\"appMain()\"]\n    Platform --\u003e|RTOS| CreateThread[Create thread]\n    CreateThread --\u003e Scheduler[Run scheduler]\n    Scheduler e1@--\u003e|new thread| AppMainRTOS[\"appMain()\"]\n\n    e1@{ animation: fast }\n\n    classDef mainStyle stroke:#ff6600\n    classDef appMainStyle stroke:#00ff00\n\n    class main mainStyle\n    class AppMainLinux,AppMainBaremetal,AppMainRTOS appMainStyle\n```\n\n### Technologies\n\n- **Language**: C++23, C17\n- **Build System**: CMake (minimum version 3.28)\n- **Documentation**: MkDocs with Material theme\n- **Static Analysis**: clang-format, clang-tidy\n- **CI/CD**: GitHub Actions\n\n### Repository Structure\n\n`platform` follows standard `kubasejdak-org` repository layout for C++ library:\n\n```bash\nplatform/\n├── cmake/                          # CMake build system\n│   ├── compilation-flags.cmake     # Internal compilation flags\n│   ├── components.cmake            # Helper component loader (FetchContent helper)\n│   ├── modules/                    # CMake Find*.cmake modules for dependencies\n│   └── presets/                    # Internal presets helpers\n├── lib/                            # Core components\n│   ├── main/                       # appMain() entrypoint for given platform\n│   │   ├── linux/                  # Entrypoint for Linux\n│   │   ├── baremetal-arm/          # Entrypoint for baremetal on ARM\n│   │   └── freertos-arm/           # Entrypoint for FreeRTOS on ARM\n│   ├── package/                    # Component with repo build, version and git info\n│   └── toolchain/                  # Toolchain configurations\n│       ├── linux/                  # Toolchain configs for Linux\n│       ├── baremetal-arm/          # Toolchain configs for baremetal on ARM\n│       └── freertos-arm/           # Toolchain configs for FreeRTOS on ARM\n├── examples/                       # Examples of platform usage\n├── tools/                          # Internal tools and scripts\n├── .devcontainer/                  # Devcontainers configs\n├── .github/workflows/              # GitHub Actions configs\n└── CMakePresets.json               # Development CMake presets\n```\n\n## Usage\n\n### CMake Integration\n\nCreate a `Findplatform.cmake` module (typically in `cmake/modules` directory):\n\n```cmake\ninclude(FetchContent)\nFetchContent_Declare(platform\n    GIT_REPOSITORY  https://github.com/kubasejdak-org/platform.git\n    GIT_TAG         \u003ccommit-sha|branch|tag\u003e\n    SOURCE_SUBDIR   lib\n)\n\nFetchContent_MakeAvailable(platform)\ninclude(${platform_SOURCE_DIR}/cmake/components.cmake)\n```\n\n\u003e [!NOTE]\n\u003e\n\u003e `GIT_TAG` accepts any ref recognized by CMake FetchContent: a full commit SHA, a branch name, or a tag.\n\nThis will allow defining which `platform` version should be used. It will also automatically download repo into build\ndirectory.\n\nThen, add directory containing that file to CMake search paths and use required components:\n\n```cmake\nlist(APPEND CMAKE_MODULE_PATH \"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules\")\n\n...\n\nfind_package(platform COMPONENTS toolchain)     # Must be requested before project()\n\nproject(myproject)\n\n...\n\nfind_package(platform COMPONENTS main package)  # Other components can be requested after project()\n```\n\n### Configuration\n\nControl platform selection via CMake variables (typically in `CMakePresets.json`):\n\n| Variable           | Purpose                                       | Examples                                 |\n| ------------------ | --------------------------------------------- | ---------------------------------------- |\n| `PLATFORM`         | Target platform                               | `linux`, `baremetal-arm`, `freertos-arm` |\n| `TOOLCHAIN`        | Compiler toolchain                            | `gcc`, `clang`, `arm-none-eabi-gcc`      |\n| `FREERTOS_VERSION` | FreeRTOS kernel version (`freertos-arm` only) | `freertos-10.2.1`                        |\n\n### Implementing `appMain()`\n\nImplement `appMain()` instead of `main()` in the application:\n\n```cpp\n#include \u003ccstdlib\u003e\n\nint appMain(int argc, char* argv[])\n{\n    // Application code\n    return EXIT_SUCCESS;\n}\n```\n\n### Linking\n\n```cmake\ntarget_link_libraries(my-app\n    PRIVATE\n        platform::main          # Provides main() → appMain() dispatch\n)\n```\n\n\u003e [!TIP]\n\u003e\n\u003e See [examples/](examples/) for complete, per-platform integration examples.\n\n## Development\n\n\u003e [!NOTE]\n\u003e\n\u003e This section is relevant when working with `platform` itself, in standalone way. However presets used to build\n\u003e `platform` tests and examples can be used as a reference for dependent projects.\n\n### Commands\n\n- **Configure**: `cmake --preset \u003cpreset-name\u003e . -B out/build/\u003cpreset-name\u003e`\n- **Build**: `cmake --build out/build/\u003cpreset-name\u003e --parallel`\n- **Run tests**: `cd out/build/\u003cpreset-name\u003e/bin; ./\u003cbinary-name\u003e`\n- **Reformat code**: `tools/check-clang-format.sh`\n- **Run linter**: `cd out/build/\u003cpreset-name\u003e; ../../../tools/check-clang-tidy.sh`\n    - Must be launched with clang preset (usually in clang devcontainer)\n\n### Available CMake Presets\n\n- **Native Linux**:\n    - **Dependencies provided by target system**: `linux-native-{gcc,clang}-{debug,release}`\n- **Cross-compilation**:\n    - **Generic ARM64**: `linux-arm64-{gcc,clang}-{debug,release}`\n    - **Yocto (via SDK)**: `yocto-sdk-{gcc,clang}-{debug,release}`\n    - **Baremetal ARMv7**: `baremetal-armv7-*-{gcc,clang}-{debug,release}`\n    - **FreeRTOS ARMv7**: `freertos-armv7-*-{gcc,clang}-{debug,release}`\n- **Sanitizers**: `*-{asan,lsan,tsan,ubsan}` variants\n\n\u003e [!NOTE]\n\u003e\n\u003e For local development use `linux-native-conan-gcc-debug` preset.\n\n### Code Quality\n\n- **Zero Warning Policy**: All warnings treated as errors\n- **Code Formatting**: clang-format with project-specific style checked\n- **Static Analysis**: clang-tidy configuration checked\n- **Coverage**: Code coverage reports generated\n- **Valgrind**: Tests and examples run under valgrind\n- **Sanitizers**: Address, leak, thread, and undefined behavior sanitizers checked\n\n### Important Notes\n\n1. **Component Structure**: Each component is a separate, reusable module in `lib/` with the following structure:\n    - `\u003ccomponent\u003e/include/platform/\u003ccomponent\u003e/`: public headers\n    - `\u003ccomponent\u003e/`: private implementation files\n    - `\u003ccomponent\u003e/CMakeLists.txt`: component configuration\n    - optionally: `\u003ccomponent\u003e/\u003cmodule\u003e/` with the same structure if it form a separate smaller part within component\n2. **Testing**: Always run tests when making changes. Test fixtures are well-established.\n3. **Dependencies**: Be careful with dependency management. This project has specific version requirements.\n4. **Code Style**: Follow the established patterns. The project has strict formatting and static analysis rules.\n5. **Error Handling**: Always use `std::error_code` for error reporting, never exceptions.\n6. **Documentation**: Update documentation when adding new components or changing APIs.\n7. **Namespace**: All code should be in the `platform::` namespace hierarchy.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkubasejdak-org%2Fplatform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkubasejdak-org%2Fplatform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkubasejdak-org%2Fplatform/lists"}