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
This commit is contained in:
Lucas De Marchi 2016-08-26 01:34:17 -03:00
parent 87862a08ab
commit fdafa4561c
1 changed files with 11 additions and 7 deletions

18
waf vendored
View File

@ -1,21 +1,25 @@
#!/usr/bin/python #!/usr/bin/python
from __future__ import print_function from __future__ import print_function
import os import subprocess
import os.path as p import os.path as p
import sys import sys
d = p.dirname(p.realpath(__file__)) d = p.dirname(p.realpath(__file__))
waf_light = p.join(d, 'modules', 'waf', 'waf-light')
try: try:
os.execv(os.path.join(d, 'modules/waf/waf-light'), sys.argv) subprocess.check_call(['python', waf_light] + sys.argv[1:])
except OSError: except subprocess.CalledProcessError as e:
if e.returncode != 2 or p.isfile(waf_light):
raise e
print('Missing waf submodule. Trying to get it') print('Missing waf submodule. Trying to get it')
from subprocess import check_call, CalledProcessError
try: try:
check_call(['git', 'submodule', 'update', '--init', 'modules/waf']) subprocess.check_call(['git', 'submodule', 'update', '--init',
except CalledProcessError: 'modules/waf'])
except subprocess.CalledProcessError:
print('Could not update submodule', file=sys.stderr) print('Could not update submodule', file=sys.stderr)
sys.exit(1) sys.exit(1)