为QT编译写的py脚本

为QT编译写的py脚本

# !/usr/bin/python
#
coding:utf-8
import  os,sys,string

argc 
=  len(sys.argv)
nResult 
=  0

dirname 
=  os.path.basename(os.getcwd())
proj
=  dirname  +   " .pro "
file_exe 
=  dirname


if  argc == 2 :
    para
= sys.argv[ 1 ]
    
if  para  ==   " --help "   or  para == " -h " :
        sys.exit(
" Usage:mk [rebuild|clean] " )
    
if  para == " clean " :
        cmd
= " make clean 2>/dev/null "
        
print  cmd
        os.system(cmd)
        cmd
= " rm -f Makefile "
        
print  cmd
        os.system(cmd)
        cmd
= " rm -f  " + proj
        
print  cmd
        os.system(cmd)
        cmd 
=   " rm -f  "   +  file_exe
        
print  cmd
        os.system(cmd)
        sys.exit(
" mk clean completed! " )
    
if  para ==   " rebuild " :
        cmd 
=   " mk clean "
        
print  cmd
        os.system(cmd)
        cmd 
=   " mk "
        
print  cmd
        os.system(cmd)
        sys.exit()

if   not  os.path.isfile(proj):
    cmd 
=   " qmake -project "
    
print  cmd
    os.system(cmd)

cmd 
=   " qmake  " + proj
print  cmd
os.system(cmd)

cmd
= " make "
print  cmd
nResult 
=  os.system(cmd)

print ( " \n--------------- " )
if  nResult == 0:
    
print ( " build Success " )
else :
    
print ( " build Failure " )

你可能感兴趣的:(为QT编译写的py脚本)