电子说
打开工程目录下 SConstruct 文件:
在 objs = PrepareBuilding(env, RTT_ROOT) 这一行后面添加如下代码
prepare building environment
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=False)
set spawn
def ourspawn(sh, escape, cmd, args, e):
filename = str(uuid.uuid4())
newargs = ' '.join(args[1:])
cmdline = cmd + " " + newargs
if (len(cmdline) > 16 * 1024):
f = open(filename, 'w')
f.write(' '.join(args[1:]).replace('', '/'))
f.close()
cmdline = cmd + " @" + filename
proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, shell = False, env = e)
data, err = proc.communicate()
rv = proc.wait()
def res_output(_output, _s):
if len(_s):
if isinstance(_s, str):
_output(_s)
elif isinstance(_s, bytes):
_output(str(_s, 'UTF-8'))
else:
_output(str(_s))
res_output(sys.stderr.write, err)
res_output(sys.stdout.write, data)
if os.path.isfile(filename):
os.remove(filename)
return rv
if platform.system() == 'Windows':
env['SPAWN'] = ourspawn
在文件头部导入相应的模块
import subprocess
import platform
import uuid
将命令行参数写入文件中,让 gcc 工具链读取文件编译或链接。
全部0条评论
快来发表一下你的评论吧 !