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 1 commit
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
7 changes: 7 additions & 0 deletions recipes/openssl/1.x.x/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,13 @@ def _make(self):
if self._use_nmake and self._full_version >= "1.1.0":
self._replace_runtime_in_file(os.path.join("Configurations", "10-main.conf"))

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
for v in ['CC', 'CXX', 'RC']:
if v in os.environ and not '"' in os.environ[v]:
os.environ[v] = '"' + os.environ[v].replace('/', '\\') + '"'
Copy link
Contributor

Choose a reason for hiding this comment

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

This modifies the environment permanently.
When using a context, the changes to the environment are undone.

e.g.

from contextlib import contextmanager

@contextmanager
def _build_context(self):
    if self._use_nmake:
        def sanitize_env_var(var):
            return '"{}"'.format(var) if '"' not in var else var
        env = {key: sanitize_env_var(tools.get_env(key)) for key in ("CC", "CXX", "RC") if tools.get_env(key)}
        with tools.environment_append(env):
            yield
    else:
        yield

def build(self):
    with self._build_context():
        self.run("perl ./Configure")
        ...
        self._run_make()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it sounds reasonable. But the environment modification should only be done for nmake (it breaks perl configure). I've committed the appropriate changes.

self.run('{perl} ./Configure {args}'.format(perl=self._perl, args=args), win_bash=self._win_bash)

self._patch_install_name()
Expand Down