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

@jgsogo
Copy link
Member

@jgsogo jgsogo 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
Copy link
Member Author

@jgsogo jgsogo 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
Copy link
Member Author

@jgsogo jgsogo Sep 3, 2018

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
Copy link
Member Author

@jgsogo jgsogo Sep 3, 2018

(@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))
Copy link
Member Author

@jgsogo jgsogo Sep 3, 2018

I would like to return just self._verbose and let the setter validate the input... any reason not to do 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())
Copy link
Member Author

@jgsogo jgsogo Sep 3, 2018

self._build_type_definition() doesn't exists!

Copy link
Contributor

@lasote lasote Sep 5, 2018

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

Copy link
Member Author

@jgsogo jgsogo Sep 5, 2018

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

Copy link
Contributor

@lasote lasote Sep 5, 2018

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

Copy link
Member

@memsharded memsharded Sep 6, 2018

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")
Copy link
Member

@memsharded memsharded Sep 6, 2018

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

Copy link
Member Author

@jgsogo jgsogo Sep 6, 2018

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())
Copy link
Member

@memsharded memsharded Sep 6, 2018

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

@memsharded memsharded merged commit 0940d7e into conan-io:develop Sep 6, 2018
2 checks passed
@ghost ghost removed the stage: review label Sep 6, 2018
@jgsogo jgsogo deleted the issue/2408 branch Sep 19, 2018
grisumbras pushed a commit to grisumbras/conan that referenced this issue Dec 27, 2018
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
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants