Skip to content

Commit

Permalink
fixing the local flow when settings are removed (#2331)
Browse files Browse the repository at this point in the history
* Contributing guides and templates (#2123)

* Contributing guides and templates

* Typo

* Review

* Bad quote

* Review

* maintainers and contributors

* some minor fixes

* Dummy change

* dummy change2

* Removed weird new line

* Fix diamond test function (#2220)

* Dev version

* Fixes issue #2285 where Visual Studio users using a clang toolset would not be able to compile due to the compiler check failing. (#2287)

* fixing the local flow when settings are removed

* new options setting

* fixed error with settings_preprocessor

* fixed broken test in linux
  • Loading branch information
memsharded authored and lasote committed Jan 22, 2018
1 parent 6dab5af commit 2490486
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 6 deletions.
4 changes: 2 additions & 2 deletions conans/client/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, runner, settings, profile):
self._env_values = profile.env_values
self.dev_reference = None

def load_conan(self, conanfile_path, output, consumer=False, reference=None):
def load_conan(self, conanfile_path, output, consumer=False, reference=None, local=False):
""" loads a ConanFile object from the given file
"""
result = load_conanfile_class(conanfile_path)
Expand All @@ -52,7 +52,7 @@ def load_conan(self, conanfile_path, output, consumer=False, reference=None):
user, channel = None, None

# Instance the conanfile
result = result(output, self._runner, tmp_settings, user, channel)
result = result(output, self._runner, tmp_settings, user, channel, local)

# Assign environment
result._env_values.update(self._env_values)
Expand Down
5 changes: 3 additions & 2 deletions conans/client/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def _load_consumer_conanfile(self, conanfile_path, info_folder, output,
profile = read_conaninfo_profile(info_folder) or self._client_cache.default_profile
loader = self.get_loader(profile, local=True)
if conanfile_path.endswith(".py"):
conanfile = loader.load_conan(conanfile_path, output, consumer=True)
conanfile = loader.load_conan(conanfile_path, output, consumer=True, local=True)
else:
conanfile = loader.load_conan_txt(conanfile_path, output)
if deps_info_required is not None:
Expand Down Expand Up @@ -145,9 +145,10 @@ def get_loader(self, profile, local=False):
"""
cache_settings = self._client_cache.settings.copy()
cache_settings.values = profile.settings_values
self._settings_preprocessor.preprocess(cache_settings)
if local:
cache_settings.remove_undefined()
else:
self._settings_preprocessor.preprocess(cache_settings)
return ConanFileLoader(self._runner, cache_settings, profile)

def export(self, conanfile_path, name, version, user, channel, keep_source=False):
Expand Down
4 changes: 2 additions & 2 deletions conans/model/conan_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class ConanFile(object):
short_paths = False
apply_env = True # Apply environment variables from requires deps_env_info and profiles

def __init__(self, output, runner, settings, user=None, channel=None):
def __init__(self, output, runner, settings, user=None, channel=None, local=None):
# User defined generators
self.generators = self.generators if hasattr(self, "generators") else ["txt"]
if isinstance(self.generators, str):
Expand All @@ -106,7 +106,7 @@ def __init__(self, output, runner, settings, user=None, channel=None):
# User defined options
self.options = create_options(self)
self.requires = create_requirements(self)
self.settings = create_settings(self, settings)
self.settings = create_settings(self, settings) if not local else settings
try:
if self.settings.os_build and self.settings.os:
output.writeln("*"*60, front=Color.BRIGHT_RED)
Expand Down
63 changes: 63 additions & 0 deletions conans/test/remove_subsetting_test.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,72 @@
import unittest
from conans.test.utils.tools import TestClient
from conans.util.files import mkdir
import os


class RemoveSubsettingTest(unittest.TestCase):

def remove_options_test(self):
# https://github.com/conan-io/conan/issues/2327
client = TestClient()
conanfile = """from conans import ConanFile
class Pkg(ConanFile):
options = {"opt1": [True, False], "opt2": [True, False]}
default_options = "opt1=True", "opt2=False"
def config_options(self):
del self.options.opt2
"""
client.save({"conanfile.py": conanfile})
build_folder = os.path.join(client.current_folder, "build")
mkdir(build_folder)
client.current_folder = build_folder
client.run("install ..")
client.run("build ..")

def remove_setting_test(self):
# https://github.com/conan-io/conan/issues/2327
client = TestClient()
conanfile = """from conans import ConanFile
class Pkg(ConanFile):
settings = "os", "build_type"
def configure(self):
del self.settings.build_type
"""
client.save({"conanfile.py": conanfile})
build_folder = os.path.join(client.current_folder, "build")
mkdir(build_folder)
client.current_folder = build_folder
client.run("install ..")
# This raised an error because build_type wasn't defined
client.run("build ..")

def remove_runtime_test(self):
# https://github.com/conan-io/conan/issues/2327
client = TestClient()
conanfile = """from conans import ConanFile, CMake
class Pkg(ConanFile):
settings = "os", "compiler", "arch"
def configure(self):
del self.settings.compiler.runtime
def build(self):
try:
self.settings.compiler.runtime
except Exception as e:
self.output.info(str(e))
cmake = CMake(self)
self.output.info(cmake.command_line)
"""
client.save({"conanfile.py": conanfile})
build_folder = os.path.join(client.current_folder, "build")
mkdir(build_folder)
client.current_folder = build_folder
client.run('install .. -s os=Windows -s compiler="Visual Studio" -s compiler.version=15 -s arch=x86')
# This raised an error because build_type wasn't defined
client.run("build ..")
self.assertIn("'settings.compiler.runtime' doesn't exist for 'Visual Studio'", client.out)
self.assertNotIn("CONAN_LINK_RUNTIME", client.out)
self.assertIn('-DCONAN_COMPILER="Visual Studio"', client.out)

def remove_subsetting_test(self):
# https://github.com/conan-io/conan/issues/2049
client = TestClient()
Expand Down

0 comments on commit 2490486

Please sign in to comment.