Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openssl: closes #4740 #5441

Merged
merged 2 commits into from
May 20, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few lines above, env_vars is already setting the CC environment variable.
Maybe combine the sanitizing done in _make_context with that or refactor the env_vars on the top into a _build_context helper method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few lines above, env_vars is already setting the CC environment variable.
Maybe combine the sanitizing done in _make_context with that or refactor the env_vars on the top into a _build_context helper method?

You can't do that easily: if your environment modification affects self._patch_configure(), the recipe will be broken because _patch_configure expects CC variable value without quotes. Anyway this _make_context solves one very special problem and IMHO should not be mixed with anything else.

self._make()

@property
def _cross_building(self):
Expand Down