gyp performance: don't invoke python to check dir existance
We spend a few tenths of a second every gyp invocation starting
the dir_exists.py program. Seems a bit unnecessary.
BUG=362075
[email protected]
Review URL: https://codereview.chromium.org/234963003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@264316 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/build/dir_exists.py b/build/dir_exists.py
index 0a89bc8..70d367ec 100755
--- a/build/dir_exists.py
+++ b/build/dir_exists.py
@@ -8,8 +8,16 @@
import sys
def main():
- sys.stdout.write(str(os.path.isdir(sys.argv[1])))
+ sys.stdout.write(_is_dir(sys.argv[1]))
return 0
+def _is_dir(dir_name):
+ return str(os.path.isdir(dir_name))
+
+def DoMain(args):
+ """Hook to be called from gyp without starting a separate python
+ interpreter."""
+ return _is_dir(args[0])
+
if __name__ == '__main__':
sys.exit(main())