Syntax for getting the value of an environment variable in a Kconfig file

Can someone provide me with the syntax for getting the value of an environment variable in a Kconfig file?

Based on the value of the environment variable, I need to conditionally specify a different Kconfig file.

+5
source share
2 answers

By kconfig docs :

<expr> ::= <symbol>                             (1)
           <symbol> '=' <symbol>                (2)
           <symbol> '!=' <symbol>               (3)
           '(' <expr> ')'                       (4)
           '!' <expr>                           (5)
           <expr> '&&' <expr>                   (6)
           <expr> '||' <expr>                   (7)


- misc options: "option" <symbol>[=<value>]

  - "env"=<value>
  This imports the environment variable into Kconfig.

if:

    "if" <expr>
    <if block>
    "endif"

This defines an if block. The dependency expression <expr> is appended
to all enclosed menu entries.

source:

    "source" <prompt>

This reads the specified configuration file. This file is always parsed.

So i will try

option env="YOURVAR"
if YOURVAR=foo
    source "somefile"
endif
if YOURVAR!=foo
    source "someotherfile"
endif
+2
source

You will need to display the value of the environment variable in the configuration symbol using the "env" option, as shown below:

config ENV_VAR
    string
    option env = "ENV_VAR"

if ENV_VAR = "foo"
source "foo_file"
endif

, $- 'source' , . -

source "foo/$ENV_VAR/Kconfig"

config ENV_VAR_SYM
    string
    option env="ENV_VAR"

source "foo/$ENV_VAR_SYM/Kconfig"

(ENV_VAR_SYM, , ENV_VAR, , .)

. Kconfig .

( Kconfiglib Kconfiglib, Kconfig.)

+2

All Articles