Merge pull request #38955 from buchgr:fix-os-system
PiperOrigin-RevId: 308830458 Change-Id: I5ab69b0a20c218a92ef3a0d2c3c0ead9d1481489
This commit is contained in:
commit
c8375778c1
@ -151,6 +151,21 @@ def GetNvccOptions(argv):
|
|||||||
return ' '.join(['--'+a for a in options])
|
return ' '.join(['--'+a for a in options])
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
def system(cmd):
|
||||||
|
"""Invokes cmd with os.system().
|
||||||
|
|
||||||
|
Args:
|
||||||
|
cmd: The command.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The exit code if the process exited with exit() or -signal
|
||||||
|
if the process was terminated by a signal.
|
||||||
|
"""
|
||||||
|
retv = os.system(cmd)
|
||||||
|
if os.WIFEXITED(retv):
|
||||||
|
return os.WEXITSTATUS(retv)
|
||||||
|
else:
|
||||||
|
return -os.WTERMSIG(retv)
|
||||||
|
|
||||||
def InvokeNvcc(argv, log=False):
|
def InvokeNvcc(argv, log=False):
|
||||||
"""Call nvcc with arguments assembled from argv.
|
"""Call nvcc with arguments assembled from argv.
|
||||||
@ -160,7 +175,7 @@ def InvokeNvcc(argv, log=False):
|
|||||||
log: True if logging is requested.
|
log: True if logging is requested.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
The return value of calling os.system('nvcc ' + args)
|
The return value of calling system('nvcc ' + args)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
host_compiler_options = GetHostCompilerOptions(argv)
|
host_compiler_options = GetHostCompilerOptions(argv)
|
||||||
@ -231,7 +246,7 @@ def InvokeNvcc(argv, log=False):
|
|||||||
' -I .' +
|
' -I .' +
|
||||||
' -x cu ' + opt + includes + ' ' + srcs + ' -M -o ' + depfile)
|
' -x cu ' + opt + includes + ' ' + srcs + ' -M -o ' + depfile)
|
||||||
if log: Log(cmd)
|
if log: Log(cmd)
|
||||||
exit_status = os.system(cmd)
|
exit_status = system(cmd)
|
||||||
if exit_status != 0:
|
if exit_status != 0:
|
||||||
return exit_status
|
return exit_status
|
||||||
|
|
||||||
@ -245,7 +260,7 @@ def InvokeNvcc(argv, log=False):
|
|||||||
# Need to investigate and fix.
|
# Need to investigate and fix.
|
||||||
cmd = 'PATH=' + PREFIX_DIR + ':$PATH ' + cmd
|
cmd = 'PATH=' + PREFIX_DIR + ':$PATH ' + cmd
|
||||||
if log: Log(cmd)
|
if log: Log(cmd)
|
||||||
return os.system(cmd)
|
return system(cmd)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user