blob: 1141e3e1a0f577396f9f11c3feacb3703bcbc5ce [file] [log] [blame]
Jim Stichnoth16178a12014-09-02 14:11:57 -07001import os
Karl Schimpfa667fb82014-05-19 14:56:51 -07002import subprocess
3import sys
4
5def shellcmd(command, echo=True):
Karl Schimpfa667fb82014-05-19 14:56:51 -07006 if not isinstance(command, str):
7 command = ' '.join(command)
8
Jim Stichnoth118ca792014-09-30 10:52:04 -07009 if echo: print '[cmd]', command
10
Karl Schimpfa667fb82014-05-19 14:56:51 -070011 stdout_result = subprocess.check_output(command, shell=True)
12 if echo: sys.stdout.write(stdout_result)
13 return stdout_result
Jim Stichnoth16178a12014-09-02 14:11:57 -070014
15def FindBaseNaCl():
16 """Find the base native_client/ directory."""
17 nacl = 'native_client'
18 path_list = os.getcwd().split(os.sep)
19 if nacl not in path_list:
20 return None
21 last_index = len(path_list) - path_list[::-1].index(nacl)
22 return os.sep.join(path_list[:last_index])