following is code.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
import re
if __name__ == '__main__':
if len(sys.argv) != 3:
print 'invalid arguments'
sys.exit(1)
print 'compiling starts'
opt_array = ['-fconstant-string-class=NSConstantString',
'-IC:\GNUstep\GNUstep\System\Library\Headers',
'-LC:\GNUstep\GNUstep\System\Library\Libraries',
'-lgnustep-base',
'-lobjc'
]
base_dir = os.getcwd()
filter = re.compile('\.m$')
linker = []
input = sys.argv[1]
output = sys.argv[2]
for dirpath, dirnames, filenames in os.walk(base_dir):
for filename in filenames:
if filter.search(filename):
if filename == input:
continue
filename, ext = filename.split('.')
filename = os.path.join(dirpath, filename)
action = 'gcc -O %s -c %s.%s -o %s.o' %\
((' ').join(opt_array), filename, ext, filename)
print action
linker.append("%s.o" % filename)
os.system(action)
break
action = "gcc -O %s %s %s -o %s" %\
((' ').join(linker), input, (' ').join(opt_array),output)
print action
os.system(action)
print 'compiling ends'
0 件のコメント:
コメントを投稿