brew 使用 make 生成 mif

brew项目测试中,经常需要改变被测试程序的版本号,每次都需要修改mif文件,每次都要打开mifeditor,很不方便,最好能用makefile来生成,这样可以与程序一起用make控制编译。于是,写了下面的makefile

DIST ?= .
filename ?= test
name ?= "test"
copyright ?= "--==rix==--"
ver ?= $(shell cat ../source/ver.h | echo)
clsid = "0x12300001"
type = ""
privileges = "File Network Web AddressBook"
imported = "0x01028839 0x0103d8e2 0x0103081d"
exec = "../../Tool/ResourceEditor/brewrc.exe"
image = "../../resource/icon/icon32.png ../../resource/icon/icon48.png ../../resource/icon/icon192.png"

all:
	filename=$(filename) name=$(name) copyright=$(copyright) ver=$(ver) clsid=$(clsid) image=$(image) privileges=$(privileges) imported=$(imported) exec=$(exec) type=$(type) ../../Tool/createmif.sh ../../$(DIST)

关于目录结构部分,主要用的目录结构是这样子的,我的每个项目基本上都是相同的目录结构,所以做成死得了。
test
├─Tool
├─project
│ ├─mif
│ ├─prj
│ └─source
└─resource
└─icon

下面是createmif.sh源文件:

#!/bin/bash
export LANG=C
if [ -z "$filename" ]
then
    filename="test"
fi

if [ -z "$author" ]
then
    author="--==rix==--"
fi

if [ -z "$name" ]
then
    name="test"
fi

if [ -z "$copyright" ]
then
    copyright="--==rix==--"
fi

if [ -z "$ver" ]
then
    ver="1.0.0"
fi

if [ -z "$clsid" ]
then
    clsid="0x12345678"
fi

echo -e "< ?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n\n\t\n\t\t$author\n\t\n\t\n\t\t$copyright\n\t\n\t\n\t\t$ver\n\t\n\t\n\t\t$name\n\t\n">$filename.mfx
echo -e "" >> $filename.mfx
echo -e "\n\n\t\n\t\t\n\t\t\n\t\t\n\t\t
" >> $filename.mfx
for i in $privileges
do
    echo -e "\t\t\t
" >> $filename.mfx
done
echo -e "\t\t\n\t\t\n\t\t\n\t\t" >> $filename.mfx
for i in $imported
do
    echo -e "\t\t\t" >> $filename.mfx
done
echo -e "\n\t\t\n\t\t\t\n\t\t\n\t\n\t\n\t\t\n\t\t\t" >> $filename.mfx
if [ -z "$image" ]
then
    echo -e ""
else
    echo -e "\t\t\t\n\t\t\t\n\t\t\t" >> $filename.mfx
fi
if [ -z "$type" ]
then
    echo -e "no type"
else
echo -e "\t\t\t$type"
fi
echo -e "\t\t\t0x00000000\n\t\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\n\n\n" >> $filename.mfx

if [ -z "$exec" ]
then
	echo -e "no find mif editor"
else
	$exec  -nh -o $1 $filename.mfx
fi

发布者

rix

如果连自己都不爱自己,哪还有谁来爱你