python-简单的makefile生成程序-没有注释
来源:互联网 发布:游戏模型制作软件 编辑:程序博客网 时间:2024/06/05 16:34
- build.py
#!/usr/bin/python# -*- coding:utf-8 -*-import os, sys, threading, reclass R(): def __init__(self): pass newline = "\n" subMakefile = '''all:\t$(CC) $(CFLAGS) $(INC) -c *.c $(LIBS)clean:\trm -f *.o''' mainMakefile = '''all:$(SUBTASK)\t$(CC) $(CFLAGS) $(INC) -c *.c $(LIBS)\t$(CC) -o $(APP) *.o $(SUBOBJS) $(LIBS)clean:\trm -f *.o $(APP)'''class MakeTool(threading.Thread): def __init__(self, app = "hello", dir = ".", cc = "gcc"): threading.Thread.__init__(self) self.dir = dir self.app = app self.cc = cc def hasCFile(self, dirName): r = re.compile(".*.\.c$") for fileName in os.listdir(dirName): m = r.search(fileName) if m:# print fileName return True return False def run(self): head = "export CC=" + self.cc + R.newline head += "export MAKE=make -w" + R.newline if "mipsel-linux-gcc" == self.cc: head += "export INC=-I. -I.. -I/root/RT288x_SDK/source/user/openssl-0.9.8e/include" + R.newline head += "export LIBS=-L/root/RT288x_SDK/source/romfs/lib -lpthread -lssl -lcrypto" + R.newline elif "gcc" == self.cc: head += "export INC=-I. -I.." + R.newline head += "export LIBS=-lpthread -lssl -lcrypto" + R.newline head += "APP=" + self.app + R.newline predef = "-D_TEST" head += "export CFLAGS=" + predef + R.newline subObjs = "SUBOBJS=" subMakeAll = "SUBTASK:" + R.newline subClean = "" hasDir = False if not os.path.isdir(self.dir): return for root, dirs, files in os.walk(self.dir): for dir in dirs: fileName = root + "/" + dir if self.hasCFile(fileName):# print "dirname", fileName subObjs += fileName + "/*.o " subMakeAll += "\t$(MAKE) -C " + fileName + R.newline subClean += "\t$(MAKE) -C " + fileName + " clean" + R.newline file = open(fileName + "/Makefile", "w") file.write(R.subMakefile) file.close() hasDir = True if not hasDir: subMakeAll = "" s = head + subObjs + R.newline + subMakeAll + R.newline + R.mainMakefile + subClean print s print R.subMakefile file = open(self.dir + "/Makefile", "w") file.write(s) file.close()def help(): s = '''python autoconfig.py [mips|gcc]''' print sdef main(argv): appName = os.path.basename(os.path.abspath(".")) if len(argv) == 1: tool = MakeTool(appName, ".", "mipsel-linux-gcc") tool.run() elif len(argv) == 2: if "gcc" == argv[1]: tool = MakeTool(appName, ".", "gcc") tool.run() elif "mips" == argv[1] or "mipsel" == argv[1] or "mipsel-linux-gcc" == argv[1]: tool = MakeTool(appName, ".", "mipsel-linux-gcc") tool.run() else: help() else: help() os.system("kill -9 " + str(os.getpid())) #杀掉进程if __name__ == "__main__": main(sys.argv)
0 0
- python-简单的makefile生成程序-没有注释
- 一个简单的makefile示例及其注释
- 一个简单的makefile示例及其注释
- 一个简单的makefile示例及其注释
- 一个简单的makefile示例及其注释
- 一个简单的makefile示例及其注释
- 一个简单的makefile示例及其注释
- 一个简单的makefile示例及其注释
- 一个简单的makefile示例及其注释
- 一个简单的makefile示例及其注释
- 程序没有注释
- 一个简单的执行程序的GNU automake自动生成Makefile的方法及案例
- 一个简单的执行程序的GNU automake自动生成Makefile的方法及案例
- 一个简单的执行程序的GNU automake自动生成Makefile的方法及案例
- 简单工程Makefile的自动生成
- 简单工程Makefile的自动生成
- 简单工程Makefile的自动生成
- 简单工程Makefile的自动生成
- 快速排序的各种方法
- 201509-1_数列分段
- iOS 开放之asyncsocket 的 简明教程
- virtualbox--错误
- 最小生成树的Kruskal算法
- python-简单的makefile生成程序-没有注释
- matlab神经网络工具箱创建神经网络
- set
- 除了影响因子 还有哪些指标可以评价论文的价值
- BestCoder Round #66 (div.2) 1002.GTW likes gt
- linux gdb调试程序 - 信号
- OC学习_5_关于NSString和单例
- 20151216 OCP 047 100-120meta character syntaxes and the
- 错误1error C2062: 意外的类型“float”龙书\13075875\part ii code\chapter 8