vivi情景分析(一): 配置管理(四)

上一篇 / 下一篇  2008-06-13 16:47:47 / 个人分类:arm

bool函数的实现在scrīpts/Configure内,从arch/config.in中摘出bool 函数的典型用法:
bool '    Support OS Switching' CONFIG_S3C2400_GAMEPARK_OSSWITCH

第一个参数为选项说明:'    Support OS Switching'
第二个参数为选项名称:
CONFIG_S3C2400_GAMEPARK_OSSWITCH
下面以该例说明bool的实现,
#
# bool processes a boolean argument
#
#       bool question define
#
#bool '    Support OS Switching' CONFIG_S3C2400_GAMEPARK_OSSWITCH

function bool () {
        #将$CONFIG_S3C2400_GAMEPARK_OSSWITCH的值赋给old
        #eval:再次执行命令行处理,相当于执行两次eval
        #如a=1
        #A1=666
        #echo \$A$a
        #$A1
        #eval echo \$A$a
        #666
        ōld=$(eval echo "\${$2}")
        #如果old有值,则采用old的值,否则为n
        def=${old:-'n'}
        case "$def" in
         "y" | "m") defprompt="Y/n/?"
              def="y"
              ;;
         "n") defprompt="N/y/?"
              ;;
        esac
        while :; do
#"    Support OS Switching ($CONFIG_S3C2400_GAMEPARK_OSSWITCH) [Y/n/?]" "y" "y"
#"    Support OS Switching ($CONFIG_S3C2400_GAMEPARK_OSSWITCH) [N/y/?]" "n" "n"
#"    Support OS Switching ($CONFIG_S3C2400_GAMEPARK_OSSWITCH) [N/y/?]" "n"
         
          readln "$1 ($2) [$defprompt] " "$def" "$old"
          #根据ans进行赋值
          case "$ans" in
            [yY] | [yY]es ) define_bool "$2" "y"
                            break;;
            [nN] | [nN]o )  define_bool "$2" "n"
                            break;;
            * )             help "$2"
                            ;;
          esac
        done
}




bool的实现分为3部分:
1 def赋值
def的默认值是n,但如果通过前面的 . .config-is-not.$$执行,给CONFIG_S3C2400_GAMEPARK_OSSWITCH赋了值,那么def就会取该值,具体
实现看上面代码,其中注意eval的用法。
2 ans赋值
通过
readln "$1 ($2) [$defprompt] " "$def" "$old"实现。
参数一为
"$1 ($2) [$defprompt] "
参数二为"$def"
参数三为"$old"
如果是"make config",则函数会提示用户输入配置。
如果是"make oldconfig", 且
CONFIG_S3C2400_GAMEPARK_OSSWITCH没有配置,函数
会提示用户输入配置。如果已经配置了,就会按照$def"进行赋值
3 将CONFIG_S3C2400_GAMEPARK_OSSWITCH的值写入.tmpconfig和.tmpconfig.h
这主要是
通过define_bool函数实现的。

bool的代码如上图所示,readln和define_bool的实现在后面贴出


TAG: ARM arm

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

我的栏目

日历

« 2008-12-05  
 123456
78910111213
14151617181920
21222324252627
28293031   

数据统计

  • 访问量: 4945
  • 日志数: 43
  • 建立时间: 2008-06-01
  • 更新时间: 2008-07-20

RSS订阅

Open Toolbar