summaryrefslogtreecommitdiff
path: root/examples
AgeCommit message (Collapse)Author
2018-03-25merge_config.py: Clean up name_and_loc_str()Ulf Magnusson
- Rename to name_and_loc(), to be consistent with the kconfiglib.py version - Use a comment instead of a docstring. Shorten the description a bit too. - Piggyback a missing # in conf3 in the module docstring. Typo.
2018-03-18Add print_config_tree.py example script (#42)Ricardo F
Works like menuconfig.py, but just dumps the tree, with a specified .config file as base. Handy for diffing.
2018-02-25menuconfig.py: More style and comment nitsUlf Magnusson
- Use generator expression rather than list comprehension - Fix dubious English
2018-02-25menuconfig.py: Style and comment nitsUlf Magnusson
2018-02-23menuconfig.py: Remove unused STR_TO_TRI importUlf Magnusson
Piggyback a small note to clarify that symbols defined without a type are pretty obscure.
2018-02-09oldconfig.py style nitsUlf Magnusson
2018-02-09Simplify tri_value_str() in oldconfig.pyUlf Magnusson
2018-02-08oldconfig.py comment nitUlf Magnusson
2018-02-08oldconfig.py comment nitUlf Magnusson
2018-02-08Prompt for choices with new visible symbols in oldconfig.pyUlf Magnusson
It makes sense to prompt for a choice during oldconfig if it contains new visible symbols, even if there is already an old visible user selection.
2018-02-07Give symbol locations in merge_config.py warningsUlf Magnusson
Helpful for debugging. Piggyback some small fixes: - Don't imply that merge_config.py is an executable file or that it only runs under Python 3. Remove the hashbang line and fix the example in the overview. - Add some #'s to the overview .config files that had accidentally been left out. - Fix a questionable sentence in oldconfig.py's name_and_loc_str() docstring.
2018-02-07Allow "n"/"m"/"y" as aliases for 0/1/2 in set_value()Ulf Magnusson
More experience working with the API convinced me that it's worth it. Gets rid of ugly conversions in the menuconfig.py and oldconfig.py examples, and streamlines some things internally as well. Include two other small fixes as well: - Make warnings generated by Choice.set_value() match those generated by Symbol.set_value(). - Get rid of the input stripping in menuconfig.py. It's not like the interface is usable as-is anyway, and it just complicates the example.
2018-02-06Add help text display feature to oldconfig.pyUlf Magnusson
Typing '??' displays the help text of the current item.
2018-02-06Refactor do_oldconfig() slightlyUlf Magnusson
Not sure why anyone would want to oldconfig just a part of the configuration tree, especially as there might be dependencies pointing outside of it. Take a Kconfig object instead of a node.
2018-02-06Account for earlier symbols depending on later ones in oldconfig.pyUlf Magnusson
The oldnoconfig operation needs to be rerun if the value of any symbol changes, to catch cases where symbols depend on symbols defined after them. Otherwise the earlier symbols will just get their default value instead of being prompted for.
2018-02-06Consistently use 'kconf' instead of 'conf'Ulf Magnusson
The examples had some leftovers from Kconfiglib 1.
2018-02-06Add oldconfig.py example scriptUlf Magnusson
Implements the standard 'make oldconfig' functionality, prompting the user for the values of new symbols to update an old .config file. This came up in https://github.com/zephyrproject-rtos/zephyr/issues/5426.
2018-02-03Add example that finds references to undefined symbolsUlf Magnusson
Does a global search over all architectures in the kernel, which should avoid false positives. Referencing an undefined symbol in a particular architecture can be fine in a Kconfig file that's shared by multiple architectures, but if the symbol isn't defined by any architecture, it's likely to be an error (or a potential cleanup).
2017-12-30Add merge_config.py exampleUlf Magnusson
Functions similarly to scripts/kconfig/merge_config.sh from the kernel. Came up in https://github.com/zephyrproject-rtos/zephyr/pull/5417.
2017-11-27eval_expr.py: Fix missing argument error messageUlf Magnusson
Copy-paste error. Piggyback error message consistency nit for help_grep.py.
2017-11-26menuconfig.py: indent_print() style nitUlf Magnusson
2017-11-26print_tree.py: Style nitsUlf Magnusson
- Remove redundant parentheses in indent_print(). - Use unnumbered replacement fields with format().
2017-11-20allno/yesconfig.py: Remove unused STR_TO_TRI importsUlf Magnusson
Leftovers
2017-11-20Simplify menuconfig.py's value_str() a bitUlf Magnusson
No need to use a dictionary.
2017-11-10eval_expr.py: s/syms["MODULES"]/modules/Ulf Magnusson
Preferred method, should 'option modules' be properly supported later.
2017-11-10Fix a few typosUlf Magnusson
Clean up some formatting a bit too.
2017-11-09allnoconfig.py: s/while 1/while True/Ulf Magnusson
Pointless as an optimization here. Should restrict obfuscating micro-optimization to the library code too even where it helps.
2017-11-08Add a release test scriptUlf Magnusson
Confirms that all the examples that aren't tested in the test suite at least run. Easy to miss brokenness there. Output can be inspected manually (it'll vary depending on the kernel version). Fix defconfig_oldconfig.py, which hadn't been properly updated for the new API.
2017-11-07Test for m, y assignability in a more readable wayUlf Magnusson
2017-11-06Refer to kconfiglib.py for iterative tree walkingUlf Magnusson
Turns out to be kinda awkward to implement print_tree.py iteratively, because the indent.
2017-11-06Clean up examples a bitUlf Magnusson
conf -> kconf, for consistency, plus various nits.
2017-11-06Simplify allyesconfig.pyUlf Magnusson
Can be implemented in a simpler/better way with Choice.assignable. Also rename 'conf' to 'kconf' in allnoconfig.py for consistency.
2017-11-05Simplify redundant 'is (not) None' tests in examplesUlf Magnusson
2017-11-05Simplify allnoconfig.py choice handlingUlf Magnusson
Don't need to handle them at all now that .assignable doesn't claim that choice symbols in y-mode choices can be set to n. 20/20 hindsight.
2017-11-05Fix find_symbol.py typoUlf Magnusson
Argument must be "X86" to get that output. "x86" just returns some constant symbols.
2017-11-05Add example that finds references to a symbolUlf Magnusson
Demonstrates expression fetching and walking. Basically a much better version of get_ref_locations() from Kconfiglib 1, now that the user API is flexible enough to implement it. Should be it for new examples before release.
2017-11-05Get rid of some more tristate quotesUlf Magnusson
2017-11-04Add symbolic ../kconfiglib.py link to examples/Ulf Magnusson
Handy for running menuconfig.py
2017-11-04Fix some menuconfig.py typosUlf Magnusson
2017-11-04Add documentation for menuconfig exampleUlf Magnusson
Also avoid printing (None) as the name for unnamed (normal) choices.
2017-11-04Add menuconfig example/proof of conceptUlf Magnusson
Still needs documentation and some cleanup. Interface deliberately kept super simple/clunky to focus on the concepts. Not something you'd actually want to use. Sample session: $ python Kconfiglib/examples/menuconfig.py Kconfiglib/examples/Kmenuconfig ======== Example Kconfig configuration ======== [*] Enable loadable module support (MODULES) Bool and tristate symbols [*] Bool symbol (BOOL) [ ] Dependent bool symbol (BOOL_DEP) < > Dependent tristate symbol (TRI_DEP) [ ] First prompt (TWO_MENU_NODES) < > Tristate symbol (TRI) [ ] Second prompt (TWO_MENU_NODES) *** These are selected by TRI_DEP *** < > Tristate selected by TRI_DEP (SELECTED_BY_TRI_DEP) < > Tristate implied by TRI_DEP (IMPLIED_BY_TRI_DEP) String, int, and hex symbols (foo) String symbol (STRING) (747) Int symbol (INT) (0xABC) Hex symbol (HEX) Various choices -*- Bool choice (BOOL_CHOICE) --> Bool choice sym 1 (BOOL_CHOICE_SYM_1) Bool choice sym 2 (BOOL_CHOICE_SYM_2) {M} Tristate choice (TRI_CHOICE) < > Tristate choice sym 1 (TRI_CHOICE_SYM_1) < > Tristate choice sym 2 (TRI_CHOICE_SYM_2) [ ] Optional bool choice (OPT_BOOL_CHOICE) Enter a symbol/choice name, "load_config", or "write_config" (or press CTRL+D to exit): BOOL Value for BOOL (available: n, y): n ======== Example Kconfig configuration ======== [*] Enable loadable module support (MODULES) Bool and tristate symbols [ ] Bool symbol (BOOL) < > Tristate symbol (TRI) [ ] Second prompt (TWO_MENU_NODES) *** These are selected by TRI_DEP *** < > Tristate selected by TRI_DEP (SELECTED_BY_TRI_DEP) < > Tristate implied by TRI_DEP (IMPLIED_BY_TRI_DEP) String, int, and hex symbols (foo) String symbol (STRING) (747) Int symbol (INT) (0xABC) Hex symbol (HEX) Various choices -*- Bool choice (BOOL_CHOICE) --> Bool choice sym 1 (BOOL_CHOICE_SYM_1) Bool choice sym 2 (BOOL_CHOICE_SYM_2) {M} Tristate choice (TRI_CHOICE) < > Tristate choice sym 1 (TRI_CHOICE_SYM_1) < > Tristate choice sym 2 (TRI_CHOICE_SYM_2) [ ] Optional bool choice (OPT_BOOL_CHOICE) Enter a symbol/choice name, "load_config", or "write_config" (or press CTRL+D to exit): MODULES Value for MODULES (available: n, y): n ======== Example Kconfig configuration ======== [ ] Enable loadable module support (MODULES) Bool and tristate symbols [ ] Bool symbol (BOOL) [ ] Tristate symbol (TRI) [ ] Second prompt (TWO_MENU_NODES) *** These are selected by TRI_DEP *** [ ] Tristate selected by TRI_DEP (SELECTED_BY_TRI_DEP) [ ] Tristate implied by TRI_DEP (IMPLIED_BY_TRI_DEP) String, int, and hex symbols (foo) String symbol (STRING) (747) Int symbol (INT) (0xABC) Hex symbol (HEX) Various choices -*- Bool choice (BOOL_CHOICE) --> Bool choice sym 1 (BOOL_CHOICE_SYM_1) Bool choice sym 2 (BOOL_CHOICE_SYM_2) -*- Tristate choice (TRI_CHOICE) --> Tristate choice sym 1 (TRI_CHOICE_SYM_1) Tristate choice sym 2 (TRI_CHOICE_SYM_2) [ ] Optional bool choice (OPT_BOOL_CHOICE) Enter a symbol/choice name, "load_config", or "write_config" (or press CTRL+D to exit): ^D Unsetting modules demonstrates one reason why it makes sense to have .type be magic and change from TRISTATE to BOOL without modules (<> = tristate, [] = bool). The C implementation uses the same trick. (The original type is still available in .orig_type though.) Piggyback printing of tristates as n, m, y in the warning for invalid values in set_value().
2017-11-01Switch to a much faster invalidation algorithmUlf Magnusson
_cached_vis is always calculated as a side effect of calculating any other cached value, and so doubles as a flag for whether an item (symbol or choice) has any cached values. If _cached_vis is None for some item, it also indirectly means that no other item can have any cached values that (actually) depend on the item, because _cached_vis would have gotten calculated as a side effect of calculating any such cached value. Therefore, it's safe to stop recursive invalidation at an item that has _cached_vis None. Huge speedup for the allyes/noconfig*.py scripts. allnoconfig_simpler.py went from 2.671 seconds to 1.067 seconds. The dependency selftests need to be updated too now that _get_dependent() is gone. The kernel defconfig tests pass even if all global invalidation is disabled at least (except for the few defconfigs that don't set MODULES=y), and that's a huge invalidation test. Seems pretty speedy too, even though there's some redundant work, so maybe things could be simplified a bit...
2017-10-31Handle choices more like the C implementationUlf Magnusson
Choice symbols get the choice itself propagated to the conditions of their properties. This works since the Symbol/Choice value interfaces are compatible now. Simplifies value calculations and makes .assignable work automagically for choice symbols in choices in any mode. One drawback is that a '&& <choice>' now shows up on conditions when printing choice symbols, which is not valid Kconfig. That should be easy to work around if needed at least.
2017-10-30Merge user_str/tri_value into user_valueUlf Magnusson
user_str_value isn't justified any more with the other API improvements. user_value now stores 0, 1, 2 for bool/tristate symbols, and a string for other symbol types. Much simpler and more intuitive. Also avoid printing quotes around tristate values in __repr__(). This was inconsistent too as it was only done for the value and user value. Should be getting close to final API.
2017-10-30Consistently use 0/1/2 for tristate valuesUlf Magnusson
Easier to work with, allowing e.g. direct comparisons with < and >. Make set_value() take 0, 1, 2 for bool and tristate symbols, and fix other APIs to match. Also: - Add introductions to various concepts in the module docstring. Document some more attributes. Still TODOs. - Rename the Config class to Kconfig. - Escape " and \ in the name of constant symbols when printing them. Also make the (un)escaping 100% consistent with how the C tools do it (\ before non-magic character should be unescaped too). - Clean up the escaping/unescaping code and provide two public escape()/unescape() functions. - Export the original MODULES-independent type in orig_type. It's needed for printing symbols in the reparsable __str__() Kconfig format with just public APIs. - Lots of other minor reorganizing and nits all over.
2017-10-28Nearly finalize APIUlf Magnusson
Probably just some usability tweaks left. Having to do STR_TO_TRI[] for comparisons against 'assignable' values is kinda ugly and confusing.
2017-10-25BackupUlf Magnusson
2017-10-24Kconfiglib 2 backupUlf Magnusson
WIP
2015-06-20Make all examples Python 3-friendly.Ulf Magnusson
print -> print(). Skip 'from __future__ import print_function' by only having a single argument (to avoid interpretation as tuples in Python 2). Keeps the examples simple.
2015-05-24Add example that mirrors defconfig and oldconfig.Ulf Magnusson
From https://github.com/ulfalizer/Kconfiglib/issues/15. Getting the output to match up exactly requires emulating each step, due to Kconfig subtleties related to which symbols have been assigned values by the user. The output might differ with other approaches, but this is not a bug.