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

Add CONAN_IN_LOCAL_CACHE variable in CMake build_helper #3450

Merged
merged 8 commits into from Sep 6, 2018

Conversation

Projects
None yet
4 participants
@jgsogo
Copy link
Member

commented Aug 31, 2018

  • #2408 (do not close)
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch: conan-io/docs#804
  • Add tests

As suggested here this PR adds a variable CMAKE_IN_LOCAL_CACHE available in CMake (only when it is called from Conan) that contains the same value as attribute conanfile.in_local_cache.

Changelog: Feature: Added a definition CONAN_IN_LOCAL_CACHE to the CMake() build helper.

@ghost ghost assigned jgsogo Aug 31, 2018

@ghost ghost added the stage: review label Aug 31, 2018

@jgsogo jgsogo requested review from lasote and memsharded Aug 31, 2018

@jgsogo

This comment has been minimized.

Copy link
Member Author

commented Aug 31, 2018

The issue #2408 is about CONAN_EXPORTED, but the functionality requested by the user is given in this new variable CONAN_IN_LOCAL_CACHE.

About CONAN_EXPORTED, we have to decide if we document it or not (conan-io/docs#518) and if we add one variable with the same meaning but with a better naming before deprecating it.

self._build_type = self._settings.get_safe("build_type")
if build_type and build_type != self._build_type:
# Call the setter to warn and update the definitions if needed
self.build_type = build_type
self._verbose = None

This comment has been minimized.

Copy link
@jgsogo

jgsogo Sep 3, 2018

Author Member

I would like to initialize it to True/False, what do you think?

definitions.update(build_type_definition(self._build_type, self.generator))
if self._verbose is not None:
definitions.update(verbose_definition(self._verbose))
return definitions

This comment has been minimized.

Copy link
@jgsogo

jgsogo Sep 3, 2018

Author Member

(@lasote) being a property it will always have up-to-date values, but on the other hand, you cannot modify the dictionary and get the class members updated (see deleted tests here: https://github.com/conan-io/conan/pull/3450/files#diff-cd58cd0dfc3250b46311d65eb7f413d0L835). But I think this is much better.

@@ -232,14 +237,21 @@ def test(self, args=None, build_dir=None, target=None):
@property
def verbose(self):
try:
verbose = self.definitions[verbose_definition_name]
return get_bool_from_text(str(verbose))
return get_bool_from_text(str(self._verbose))

This comment has been minimized.

Copy link
@jgsogo

jgsogo Sep 3, 2018

Author Member

I would like to return just self._verbose and let the setter validate the input... any reason not to do it?

jgsogo added some commits Sep 3, 2018

cmake.definitions are initialized in __init__ with conanfile values a…
…nd then the user can change them (but won't get syncronized with conanfile ones)
@@ -43,7 +44,6 @@ def build_type(self, build_type):
'Set build type "%s" is different than the settings build_type "%s"'
% (build_type, settings_build_type))
self._build_type = build_type
self.definitions.update(self._build_type_definition())

This comment has been minimized.

Copy link
@jgsogo

jgsogo Sep 3, 2018

Author Member

self._build_type_definition() doesn't exists!

This comment has been minimized.

Copy link
@lasote

lasote Sep 5, 2018

Contributor

I don't understand this diff, the code in develop has self.definitions.update(build_type_definition(build_type, self.generator)) that indeed exist.

This comment has been minimized.

Copy link
@jgsogo

jgsogo Sep 5, 2018

Author Member

In cmake.py it does, but not in meson.py

This comment has been minimized.

Copy link
@lasote

lasote Sep 5, 2018

Contributor

LoL.
I think the self.definitions can be removed from meson too, it is not used nor documented.

This comment has been minimized.

Copy link
@memsharded

memsharded Sep 6, 2018

Contributor

Yes, remove self.definitions if not used nor documented.

@lasote

lasote approved these changes Sep 5, 2018

@lasote lasote added this to the 1.8 milestone Sep 5, 2018

@danimtb

danimtb approved these changes Sep 6, 2018

@@ -172,6 +172,9 @@ def aux_cmake_test_setup_test(self):
if(CONAN_EXPORTED)
message(STATUS "Conan: called by CMake conan helper")
endif()
if(CONAN_IN_LOCAL_CACHE)
message(STATUS "Conan: called inside local cache")

This comment has been minimized.

Copy link
@memsharded

memsharded Sep 6, 2018

Contributor

Who is checking this message? If nobody is checking it, why adding it?

This comment has been minimized.

Copy link
@jgsogo

jgsogo Sep 6, 2018

Author Member

It is added to the output here: https://github.com/conan-io/conan/pull/3450/files/45ee0fa7fb7d1e17c18ada5baa38778abdbb05c9#diff-4ace401e8414c1a6556986dc05a638d8, so the test need it too.

We can remove it from both places or leave it.

@@ -43,7 +44,6 @@ def build_type(self, build_type):
'Set build type "%s" is different than the settings build_type "%s"'
% (build_type, settings_build_type))
self._build_type = build_type
self.definitions.update(self._build_type_definition())

This comment has been minimized.

Copy link
@memsharded

memsharded Sep 6, 2018

Contributor

Yes, remove self.definitions if not used nor documented.

@memsharded memsharded merged commit 0940d7e into conan-io:develop Sep 6, 2018

2 checks passed

continuous-integration/jenkins/pr-head This commit looks good
Details
license/cla Contributor License Agreement is signed.
Details

@ghost ghost removed the stage: review label Sep 6, 2018

@jgsogo jgsogo deleted the jgsogo:issue/2408 branch Sep 19, 2018

grisumbras pushed a commit to grisumbras/conan that referenced this pull request Dec 27, 2018

Merge pull request conan-io#3450 from jgsogo/issue/2408
Add CONAN_IN_LOCAL_CACHE variable in CMake build_helper
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.