OSDN Git Service

Better error message for running szbuild.py out of directory.
authorSean Klein <smklein@chromium.org>
Mon, 11 Jan 2016 18:49:25 +0000 (10:49 -0800)
committerSean Klein <smklein@chromium.org>
Mon, 11 Jan 2016 18:49:25 +0000 (10:49 -0800)
TEST=Run szbuild.py in a directory which does not include "native_client" as a subdirectory.
BUG=None
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1565963002 .

pydir/utils.py

index 6fdedfa..6039e77 100644 (file)
@@ -16,8 +16,11 @@ def FindBaseNaCl():
     """Find the base native_client/ directory."""
     nacl = 'native_client'
     path_list = os.getcwd().split(os.sep)
+    """Use the executable path if cwd does not contain 'native_client' """
+    path_list = path_list if nacl in path_list else sys.argv[0].split(os.sep)
     if nacl not in path_list:
-        return None
+        print "Script must be executed from within 'native_client' directory"
+        exit(1)
     last_index = len(path_list) - path_list[::-1].index(nacl)
     return os.sep.join(path_list[:last_index])