diff options
author | Bert Belder <bertbelder@gmail.com> | 2019-08-09 09:58:34 +0200 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2019-08-22 14:12:49 -0700 |
commit | 31aa7c1a5d8a27c720b6255dc3eceda3707b1826 (patch) | |
tree | c08fdea438d9f9e8a8798ba91a3d8b3143c16519 /build_extra/rust/run.py | |
parent | 6c7d337960b3745a7b614a18150862279ef1c942 (diff) |
build: support rust crates that generate sources in their build script
Diffstat (limited to 'build_extra/rust/run.py')
-rw-r--r-- | build_extra/rust/run.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/build_extra/rust/run.py b/build_extra/rust/run.py index 3f1adcc55..36d1ab83a 100644 --- a/build_extra/rust/run.py +++ b/build_extra/rust/run.py @@ -7,6 +7,7 @@ import sys import os import re +args = sys.argv[1:] env = os.environ.copy() if sys.platform == 'win32': @@ -26,9 +27,19 @@ if sys.platform == 'win32': env["GN_OUT_DIR"] = os.path.abspath(".") assert os.path.isdir(env["GN_OUT_DIR"]) +# Some crates (e.g. 'typenum') generate source files and place them in the +# directory indicated by the 'OUT_DIR' environment variable, which is normally +# set by Cargo. We pre-generate these files and store them in the source repo. +# Therefore, set 'OUT_DIR' so these crates can find their generated sources. +for i, arg in enumerate(args): + match = re.search('--generated-source-dir=(.*)', arg) + if match: + env["OUT_DIR"] = os.path.abspath(match.group(1)) + del args[i] + break + # 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: |