add `build_dir` parameter to EnvironmentFactory
This allows us to use a build_dir more than once, to leverage previously compiled files. This is immensely helpful for iterating on builds locally-- so we don't have to rebuild the world
diff --git a/tsqa/environment.py b/tsqa/environment.py
index 9e81186..c356949 100644
--- a/tsqa/environment.py
+++ b/tsqa/environment.py
@@ -47,7 +47,8 @@
source_dir,
env_cache_dir,
default_configure=None,
- default_env=None):
+ default_env=None,
+ build_dir=None):
# if no one made the cache class, make it
if self.class_environment_stash is None:
self.class_environment_stash = tsqa.utils.BuildCache(env_cache_dir)
@@ -66,6 +67,8 @@
else:
self.default_env = copy.copy(os.environ)
+ self.build_dir = build_dir
+
def autoreconf(self):
'''
Autoreconf to make the configure script
@@ -150,7 +153,9 @@
raise EnvironmentFactory.negative_cache[key]
try:
self.autoreconf()
- builddir = tempfile.mkdtemp()
+ # if we have a build dir configured, lets use thatm otherwise
+ # lets use a tmp one
+ builddir = self.build_dir or tempfile.mkdtemp()
kwargs = {
'cwd': builddir,
@@ -177,7 +182,9 @@
# make install
tsqa.utils.run_sync_command(['make', 'install', 'DESTDIR={0}'.format(installdir)], **kwargs)
- shutil.rmtree(builddir) # delete builddir, not useful after install
+ # if we had to create a tmp dir, we should delete it
+ if self.build_dir is None:
+ shutil.rmtree(builddir)
# stash the env
self.environment_stash[key] = {
'path': installdir,