2018-10-31 03:32:42 -04:00
|
|
|
#!/usr/bin/env python
|
2018-12-13 16:16:58 -05:00
|
|
|
# This file just executes its arguments, except that also adds GN_OUT_DIR and
|
|
|
|
# CARGO_PKG_VERSION to the environ. This is for compatibility with cargo.
|
2018-10-31 03:32:42 -04:00
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
import os
|
2018-12-13 16:16:58 -05:00
|
|
|
import re
|
2018-10-31 03:32:42 -04:00
|
|
|
|
2018-11-01 01:06:55 -04:00
|
|
|
# This is for src/msg.rs to know where to find msg_generated.rs.
|
|
|
|
# When building with Cargo this variable is set by build.rs.
|
|
|
|
os.environ["GN_OUT_DIR"] = os.path.abspath(".")
|
|
|
|
assert os.path.isdir(os.environ["GN_OUT_DIR"])
|
2018-10-31 14:11:10 -04:00
|
|
|
|
2018-12-13 16:16:58 -05:00
|
|
|
# Set the CARGO_PKG_VERSION env variable if provided as an argument
|
|
|
|
# When building with Cargo this variable is set automatically
|
|
|
|
args = sys.argv[1:]
|
|
|
|
for i, arg in enumerate(args):
|
|
|
|
match = re.search('--cargo-pkg-version="?([^"]*)"?', arg)
|
|
|
|
if match:
|
|
|
|
os.environ["CARGO_PKG_VERSION"] = match.group(1)
|
|
|
|
del args[i]
|
|
|
|
break
|
|
|
|
|
|
|
|
sys.exit(subprocess.call(args))
|