From fdafa4561cf838346d67698809ba7533bb39436d Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Fri, 26 Aug 2016 01:34:17 -0300 Subject: [PATCH] waf: allow to run wrapper on windows On Windows we have 2 issues with the current wrapper: 1. We can't call the binary directly relying on shebang. Now we call python and pass the script as an argument 2. Use os.path.join() with all components to derive the right waf-light location --- waf | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/waf b/waf index 7bc5368b05..e5b89b5188 100755 --- a/waf +++ b/waf @@ -1,21 +1,25 @@ #!/usr/bin/python from __future__ import print_function -import os +import subprocess import os.path as p import sys d = p.dirname(p.realpath(__file__)) +waf_light = p.join(d, 'modules', 'waf', 'waf-light') + try: - os.execv(os.path.join(d, 'modules/waf/waf-light'), sys.argv) -except OSError: - print('Missing waf submodule. Trying to get it') + subprocess.check_call(['python', waf_light] + sys.argv[1:]) +except subprocess.CalledProcessError as e: + if e.returncode != 2 or p.isfile(waf_light): + raise e - from subprocess import check_call, CalledProcessError + print('Missing waf submodule. Trying to get it') try: - check_call(['git', 'submodule', 'update', '--init', 'modules/waf']) - except CalledProcessError: + subprocess.check_call(['git', 'submodule', 'update', '--init', + 'modules/waf']) + except subprocess.CalledProcessError: print('Could not update submodule', file=sys.stderr) sys.exit(1)