diff options
author | Elliott Hughes <enh@google.com> | 2020-04-11 00:32:30 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-04-11 00:32:30 +0000 |
commit | 286d215d8c29a33f824c99d3d9460273e7696a9e (patch) | |
tree | 840d011605f0f014f7dcb5891dc3850977d1295a | |
parent | 58d3371a2f96a4c695f8a3f5b3cf85e33c3d63e4 (diff) | |
parent | 788a0c1874cfdd78617e6716a6e240c1b965273a (diff) | |
download | ndk-286d215d8c29a33f824c99d3d9460273e7696a9e.tar.gz |
Merge "Add `env` option to `AutoconfModule`."
-rw-r--r-- | ndk/autoconf.py | 11 | ||||
-rw-r--r-- | ndk/builds.py | 6 |
2 files changed, 14 insertions, 3 deletions
diff --git a/ndk/autoconf.py b/ndk/autoconf.py index b17e023ab..95384c1ea 100644 --- a/ndk/autoconf.py +++ b/ndk/autoconf.py @@ -51,7 +51,8 @@ class AutoconfBuilder: use_clang: bool = False, no_build_or_host: bool = False, no_strip: bool = False, - additional_flags: List[str] = None) -> None: + additional_flags: List[str] = None, + additional_env: Optional[Dict[str, str]] = None) -> None: """Initializes an autoconf builder. Args: @@ -66,6 +67,9 @@ class AutoconfBuilder: use_clang: Set to True to use Clang to build this project. no_build_or_host: Don't pass --build or --host to configure. no_strip: Don't pass -s to compiler. + additional_flags: Additional flags to pass to the compiler. + additional_env: Additional environment to set, used during + configure, build, and install. """ self.configure_script = configure_script self.build_directory = build_dir @@ -75,6 +79,7 @@ class AutoconfBuilder: self.no_build_or_host = no_build_or_host self.no_strip = no_strip self.additional_flags = additional_flags + self.additional_env = additional_env self.working_directory = self.build_directory / 'build' self.install_directory = self.build_directory / 'install' @@ -124,6 +129,10 @@ class AutoconfBuilder: subproc_env = dict(os.environ) if env: subproc_env.update(env) + if self.additional_env: + subproc_env.update(env) + + if subproc_env != os.environ: pp_env = pprint.pformat(env, indent=4) print('Running: {} with env:\n{}'.format(pp_cmd, pp_env)) else: diff --git a/ndk/builds.py b/ndk/builds.py index e80333679..71a5d80ee 100644 --- a/ndk/builds.py +++ b/ndk/builds.py @@ -29,7 +29,7 @@ from pathlib import Path import shutil import stat import subprocess -from typing import Iterable, List, Optional, Set +from typing import Dict, Iterable, List, Optional, Set import ndk.abis from ndk.autoconf import AutoconfBuilder @@ -354,6 +354,7 @@ class Module: class AutoconfModule(Module): # Path to the source code src: Path + env: Optional[Dict[str, str]] = None _builder: Optional[AutoconfBuilder] = None @@ -365,7 +366,8 @@ class AutoconfModule(Module): self.src / 'configure', self.intermediate_out_dir, self.host, - use_clang=True) + use_clang=True, + additional_env=self.env) return self._builder @property |