{"id":21904651,"url":"https://github.com/outpost-os/outpost-kconfig","last_synced_at":"2025-03-22T06:46:36.966Z","repository":{"id":263442341,"uuid":"835630527","full_name":"outpost-os/outpost-kconfig","owner":"outpost-os","description":"Kconfig-related glue for build systems","archived":false,"fork":false,"pushed_at":"2024-11-18T14:54:04.000Z","size":38,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-01-27T07:23:05.314Z","etag":null,"topics":["kconfig","meson"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/outpost-os.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-30T08:15:04.000Z","updated_at":"2024-11-18T14:54:14.000Z","dependencies_parsed_at":"2024-11-19T04:59:17.788Z","dependency_job_id":null,"html_url":"https://github.com/outpost-os/outpost-kconfig","commit_stats":null,"previous_names":["outpost-os/outpost-kconfig"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outpost-os%2Foutpost-kconfig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outpost-os%2Foutpost-kconfig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outpost-os%2Foutpost-kconfig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/outpost-os%2Foutpost-kconfig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/outpost-os","download_url":"https://codeload.github.com/outpost-os/outpost-kconfig/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244918583,"owners_count":20531686,"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":["kconfig","meson"],"created_at":"2024-11-28T16:18:03.282Z","updated_at":"2025-03-22T06:46:36.948Z","avatar_url":"https://github.com/outpost-os.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\nSPDX-FileCopyrightText: 2024 Ledger SAS\nSPDX-License-Identifier: Apache-2.0\n--\u003e\n\n# Outpost-Kconfig\n\n`Outpost-Kconfig` provides build system recipes for Meson and Cargo that handles `kconfig` and/or `.config` file.\nThe aim is to ease `kconfig` usage across different languages and build systems.\n\n## Table of Contents\n1. [Meson Build System](#meson-build-system)\n2. [Cargo](#cargo)\n3. [License](#license)\n\n# Meson Build system\n\nMeson Buildsystem recipe collection that handles `Kconfig` and `.config` files.\n\nThis meson project can be used as a sub-project for every meson based project which uses `Kconfig` as configuration system. The top level `Kconfig` is parsed at configure time (i.e. during meson setup), the `config` file is checked and a build specific `.config` file is generated using `oldconfig` policy for missing `Kconfig` entry.\nDuring project configuration, two dependencies file are generated, one which listed all `Kconfig` files that are parsed, and the `.config` itself. Thus, if any of those file change (Kconfig new options and/or a manually run menuconfig), the project is automatically reconfigure by `Meson`. This project provides a meson `configuration_data` object containing all `.config` entries (field to `y` are converted to `1/0` boolean) and a `config.h` is generated using meson `configure_file` feature.\n\nThe provided `configuration_data` can be reused for Meson `source_set`configuration.\n\n## Options\n - `kconfig`: Top level `Kconfig` file.\n - `config`: input config file.\n\u003e **NOTE:** This is up to the user to provide the input config file (e.g. from a `defconfig`, and/or after `config fragment` merge operation). This can be done w/ `scripts/kconfig.py` but this is out of scope of the meson configuration step.\n\n\u003e Options got `yield` attribute and thus can be defined at top-level project and forwarded to sub projects seamlessly\n\n## Environment\n`Kconfig` can use environment variables substitution in `kconfig` file and/or `dotconfig`. This recipe export a meson variable named `kconfig_env` to be used as `env` keyword argument value for meson function (see: https://mesonbuild.com/Reference-manual_returned_env.html).\n\n### Exported environment variables\n - `srctree`: standard kconfig variable for top level source directory  (a.k.a. meson global source tree).\n - `subprojects`: helper to path to top level subprojects directory. This ease subprojects `Kconfig` files source from top level `Kconfig`` file.\n - `KCONFIG_CONFIG`: Outputted dotconfig file path.\n\n### meson devenv\n`kconfig_env` is also added to the meson devenv. Meson devenv is a python-virtual-env-like feature that allowed developers to enable the required variables for the project. Using this, one can activate the project devenv and directly use `menuconfig`  from `kconfiglib` w/o the need of any helper or custom command.\n\ne.g.\n\n```console\nmeson devenv -C builddir\nmenuconfig\n```\n\n## Targets (deprecated)\nThere is a helper target called `menuconfig` for users who wants to edit the configuration during development. This target handles the path of top-level `Kconfig` and output `.config`.\n\n - `menuconfig`: runs menuconfig inside the given `builddir`\n \u003e **TODO:**  Add oldconfig, savedefconfig targets\n\n## Meson variables\nThe following variables can be use by top level project to use `Kconfig` features. (see: https://mesonbuild.com/Reference-manual_returned_subproject.html)\n\n- kconfig_env: [environment variables set](#environment)\n- kconfig_data: kconfig meson `configure_data` w/ entry set to `y` converted as `1/0 boolean`\n- kconfig_h: C header generated at configure time by meson from processed `kconfig_data`\n- kconfig_rustargs: Rust flags generated at configure time by meson from processed `kconfig_data`\n\n## Prerequisit\nThis project uses kconfiglib python package as Kconfig frontend. One could install it with the following:\n```console\npip3 install --user kconfiglib\n```\n\n# Cargo\n\nFor Cargo build system, there is no handling of Kconfig itself nor any graphical frontend.\nWe assumed that the `.config` file is well-formed.\n\nAs a pre requisite, we stated that kconfig entries must be build time evaluated in order to\nfail as soon as possible, and especially, not at runtime. Moreover, no external crates and\nno dead code are mandatory requirements too.\n\nThus, 2 crates are needed:\n - kconfig_import: import and parse `.config` from a build script, i.e. `build.rs`.\n - kconfig: provide helper getter macro\n\n ## crate kconfig_import\n\nThis crate allows user to import a `.config` file, the file path is given through an environment\nvariable `config` in order to stay coherent w/ meson option.\n\nBlank lines and comments are trimmed and then, each kconfig entry is pushed in cargo config as boolean.\nThis allows users to use conditional compile with `#[cfg]` attribute or `cfg!` macro using only\nthe config entry name, i.e. means that the config is defined, whatever is type or value.\n\nEntries w/ a specific value (i.e. `int`, `hex` and `string`) are pushed to the cargo environment.\nDue to some const limitation on string view manipulation, `hex` are converted to decimal integer at\nbuild time and an extra entry w/ `_HEX_STR` suffix is added, holding the original hexadecimal value\n(w/ `0x` prefix) as string.\n\n## crate kconfig\n\nThis crate provide macro helper in order to get value (and converted to the right type) from Rust code\n**at build time**. As all environment variables are text, the `get!` macro takes a required parameter\nthat is the config entry name and an optional parameter that is the integer type in which user wants\nto convert config entry. If no optional parameter, the raw string is accessed.\n\nAt build time, if the config entry does not exist, compiling process will panic.\nAt build time, if the string to integer conversion fails, compiling process will panic.\n\nFor boolean value, rust `#[cfg]` and `cfg!` can be used.\n\n## usage\n\nCargo.toml\n```toml\n[dependencies]\nkconfig\n\n[build-dependencies]\nkconfig_import\n```\n\nbuild.rs\n```rust\nfn main() {\n    kconfig_import::import_dotconfig_from_script();\n}\n```\n\nany.rs\n```rust\nuse kconfig:\n\n[...]\n\n// conditional function compilation\n#[cfg(CONFIG_EXTRA_UBER_FEATURE)]\nfn my_extra_uber_function(...) {\n    [...]\n}\n\n// u16 array size from KConfig `.config` file\nconst SOME_ARRAY_SIZE: u16 = kconfig::get!(\"CONFIG_SOME_ARRAY_SIZE\", u16);\n\n// string from KConfig `.config` file\nconst MOTD_BANNER: \u0026str = kconfig::get!(\"CONFIG_MOTD\");\n```\n\n# LICENSE\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n\u003e**NOTE:** This project bundles a modified version `kconfig.py` from [Zephyr project](https://www.zephyrproject.org/), licensed under `ISC`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutpost-os%2Foutpost-kconfig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foutpost-os%2Foutpost-kconfig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foutpost-os%2Foutpost-kconfig/lists"}