2012-04-11 1043 views

回答

2

the 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. 

所以我想嘗試

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

感謝他response.I會嘗試, – 2012-04-11 23:32:58

2

您需要捕捉環境變量的值,在使用「選項ENV」一個配置的象徵,就像如下:

 
config ENV_VAR 
    string 
    option env="ENV_VAR" 

if ENV_VAR = "foo" 
source "foo_file" 
endif 

作爲一個附註,'源'語句中的$參考引用co nfig變量,而不是環境變量。你不能這樣做

 
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的配置系統工作庫的作者。)