u-boot.cfg转eclipse_xml小脚本
手动复制粘贴版本
cat u-boot.cfg | awk '{if(length($3)){$3 = substr($0, length($1)+length($2)+3); gsub("\"","\\"",$3); gsub("<","\\<",$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="gpt""/>
#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 << 20))"/>
自动生成配置文件导入版本
#!/bin/bash
cat head.xml
#cat $1 | awk '{if(length($3)){$3 = substr($0, length($1)+length($2)+3); gsub("\"","\\"",$3); gsub("<","\\<",$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("<","\\<",$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("\"","\\"",$3); gsub("<","\\<",$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("<","\\<",$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>