Feiyun Wang 2024-02-02 23:39:45 +05:30 committed by GitHub
commit ccd208f4ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 24 additions and 27 deletions

View File

@ -11,41 +11,38 @@ def configure(env):
import subprocess import subprocess
def mySubProcess(cmdline, env): def mySubProcess(cmdline, env):
# print "SPAWNED : " + cmdline # print(cmdline)
startupinfo = subprocess.STARTUPINFO() rv = subprocess.run(args=cmdline, shell=True, env=env).returncode
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
proc = subprocess.Popen(
cmdline,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
startupinfo=startupinfo,
shell=False,
env=env,
)
data, err = proc.communicate()
rv = proc.wait()
if rv: if rv:
print("=====") print("=====")
print(err.decode("utf-8")) print("subprocess.run().returncode=", rv, "(", hex(rv), ")")
print("len(cmdline)=", len(cmdline))
print("=====") print("=====")
return rv return rv
def mySpawn(sh, escape, cmd, args, env): def mySpawn(sh, escape, cmd, args, env):
newargs = " ".join(args[1:])
cmdline = cmd + " " + newargs
rv = 0 rv = 0
if len(cmdline) > 32000 and cmd.endswith("ar"): if len(args) > 4 and cmd.endswith("ar"):
cmdline = cmd + " " + args[1] + " " + args[2] + " " # print("Long ar command is split.\nargc=", len(args))
for i in range(3, len(args)): lead = len(" ".join(args[0:3]))
rv = mySubProcess(cmdline + args[i], env) begin = 3
if rv: length = lead + 1 + len(args[begin])
break for i in range(4, len(args)):
length += 1 + len(args[i])
if length > 8158:
cmdline = " ".join(args[0:3] + args[begin:i])
# print("objs=", i - begin, ", length=", len(cmdline))
rv = mySubProcess(cmdline, env)
if rv:
break
begin = i
length = lead + 1 + len(args[begin])
if not rv:
cmdline = " ".join(args[0:3] + args[begin:])
# print("objs=", len(args) - begin, ", length=", len(cmdline))
rv = mySubProcess(cmdline, env)
else: else:
rv = mySubProcess(cmdline, env) rv = mySubProcess(" ".join(args), env)
return rv return rv
env["SPAWN"] = mySpawn env["SPAWN"] = mySpawn