u-boot.cfg转eclipse_xml小脚本

手动复制粘贴版本

cat u-boot.cfg | awk '{if(length($3)){$3 = substr($0, length($1)+length($2)+3); gsub("\"","\\&quot;",$3); gsub("<","\\&lt;",$3); print "<listOptionValue builtIn=""\"""false""\""" value=""\""$2"="$3"\"""/>"}else{print "<listOptionValue builtIn=""\"""false""\""" value=""\""$2"\"""/>"}}'

#define CONFIG_SPI_FLASH_WINBOND 1

<listOptionValue builtIn="false" value="CONFIG_SPI_FLASH_WINBOND=1"/>

#define CONFIG_ENV_OVERWRITE 

<listOptionValue builtIn="false" value="CONFIG_ENV_OVERWRITE"/>

#define CONFIG_FASTBOOT_GPT_NAME "gpt"

<listOptionValue builtIn="false" value="CONFIG_FASTBOOT_GPT_NAME=&quot;gpt&quot;"/>

#define CONFIG_SYS_SPL_ARGS_ADDR (CONFIG_SYS_SDRAM_BASE + (128 << 20))

<listOptionValue builtIn="false" value="CONFIG_SYS_SPL_ARGS_ADDR=(CONFIG_SYS_SDRAM_BASE + (128 &lt;&lt; 20))"/>

自动生成配置文件导入版本

#!/bin/bash
cat head.xml
#cat $1 | awk '{if(length($3)){$3 = substr($0, length($1)+length($2)+3); gsub("\"","\\&quot;",$3); gsub("<","\\&lt;",$3); print "<listOptionValue builtIn=""\"""false""\""" value=""\""$2"="$3"\"""/>"}else{print "<listOptionValue builtIn=""\"""false""\""" value=""\""$2"\"""/>"}}'
cat $1 | awk '{if(length($3)){$3 = substr($0, length($1)+length($2)+3); gsub("<","\\&lt;",$3); print "<macro><name>"$2"</name><value>"$3"</value></macro>"}else{print "<macro><name>"$2"</name><value/></macro>"}}'
cat central.xml
#cat $1 | awk '{if(length($3)){$3 = substr($0, length($1)+length($2)+3); gsub("\"","\\&quot;",$3); gsub("<","\\&lt;",$3); print "<listOptionValue builtIn=""\"""false""\""" value=""\""$2"="$3"\"""/>"}else{print "<listOptionValue builtIn=""\"""false""\""" value=""\""$2"\"""/>"}}'
cat $1 | awk '{if(length($3)){$3 = substr($0, length($1)+length($2)+3); gsub("<","\\&lt;",$3); print "<macro><name>"$2"</name><value>"$3"</value></macro>"}else{print "<macro><name>"$2"</name><value/></macro>"}}'
cat tail.xml

head.xml

<?xml version="1.0" encoding="UTF-8"?>
<cdtprojectproperties>
<section name="org.eclipse.cdt.internal.ui.wizards.settingswizards.Macros">
<language name="C Source File">

central.xml

</language>
<language name="C++ Source File">

tail.xml

</language>
<language name="Object File">

</language>
<language name="Assembly Source File">

</language>
</section>
</cdtprojectproperties>

下载地址

posted @ 2019-02-21 15:59  阿C  阅读(210)  评论(0编辑  收藏  举报