summaryrefslogtreecommitdiff
path: root/examples
AgeCommit message (Collapse)Author
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.
2015-03-13Fix examples/allnoconfig.py testsuite hang with v4.0-rc3.Ulf Magnusson
Settings the user value to 'y' does not guarantee that the (actual) value will become 'y', as the symbol's visibility still acts as an upper bound on the value.
2015-03-12Use Symbol.is_allnoconfig_y() in the examplesPhilip Craig
This is required for the 'make allnoconfig' tests.
2012-12-13Rename some APIs to be more consistent and intuitive.Ulf Magnusson
2012-12-12Re-enable set_user_value() warning for symbols with no prompts.Ulf Magnusson
Disable warnings in allnoconfig_simpler.py instead.
2012-12-11Rename APIs to be more consistent and intuitive.Ulf Magnusson
2012-12-11Add a grep'ing example.Ulf Magnusson
2012-12-11Include allnoconfig_simpler.py in test suite.Ulf Magnusson
Also update some comments to reflect optimizations.
2012-12-08Add a simpler allnoconfig example.Ulf Magnusson
2012-12-08Clarify allno/yesconfig.py.Ulf Magnusson
2012-12-06Move examples into separate directory.Ulf Magnusson