Skip to content

Commit

Permalink
(#5441) openssl: closes #4740
Browse files Browse the repository at this point in the history
* openssl: closes #4740

* Avoid permanent environment modification
  • Loading branch information
db4 authored May 20, 2021
1 parent ade1798 commit fc395df
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion recipes/openssl/1.x.x/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import fnmatch
import textwrap
from contextlib import contextmanager
from functools import total_ordering
from conans.errors import ConanInvalidConfiguration
from conans import ConanFile, AutoToolsBuildEnvironment, tools
Expand Down Expand Up @@ -680,6 +681,20 @@ def _cc(self):
return "gcc"
return "cc"

@contextmanager
def _make_context(self):
if self._use_nmake:
# Windows: when cmake generates its cache, it populates some environment variables as well.
# If cmake also initiates openssl build, their values (containing spaces and forward slashes)
# break nmake (don't know about mingw make). So we fix them
def sanitize_env_var(var):
return '"{}"'.format(var).replace('/', '\\') if '"' not in var else var
env = {key: sanitize_env_var(tools.get_env(key)) for key in ("CC", "RC") if tools.get_env(key)}
with tools.environment_append(env):
yield
else:
yield

def build(self):
with tools.vcvars(self.settings) if self._use_nmake else tools.no_op():
env_vars = {"PERL": self._perl}
Expand All @@ -699,7 +714,8 @@ def build(self):
else:
self._patch_configure()
self._patch_makefile_org()
self._make()
with self._make_context():
self._make()

@property
def _cross_building(self):
Expand Down

0 comments on commit fc395df

Please sign in to comment.