Skip to content

Commit

Permalink
Merge branch 'release/1.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
lasote committed Jan 22, 2018
2 parents 41190e7 + 25259d4 commit 112e3eb
Show file tree
Hide file tree
Showing 12 changed files with 131 additions and 52 deletions.
2 changes: 1 addition & 1 deletion conans/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
COMPLEX_SEARCH_CAPABILITY = "complex_search"
SERVER_CAPABILITIES = [COMPLEX_SEARCH_CAPABILITY, ]

__version__ = '1.0.2'
__version__ = '1.0.3'
22 changes: 16 additions & 6 deletions conans/client/build/autotools_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

from conans.client import join_arguments
from conans.tools import environment_append, args_to_string, cpu_count, cross_building, detected_architecture
from conans.client.tools.win import unix_path
from conans.client.tools.oss import OSInfo

sun_cc_libcxx_flags_dict = {"libCstd": "-library=Cstd",
"libstdcxx": "-library=stdcxx4",
Expand Down Expand Up @@ -48,6 +50,7 @@ class AutoToolsBuildEnvironment(object):
def __init__(self, conanfile, win_bash=False):
self._conanfile = conanfile
self._win_bash = win_bash
self.subsystem = OSInfo().detect_windows_subsystem() if self._win_bash else None
self._deps_cpp_info = conanfile.deps_cpp_info
self._arch = conanfile.settings.get_safe("arch")
self._build_type = conanfile.settings.get_safe("build_type")
Expand Down Expand Up @@ -160,21 +163,28 @@ def configure(self, configure_dir=None, args=None, build=None, host=None, target

with environment_append(pkg_env):
with environment_append(self.vars):
self._conanfile.run("%s/configure %s %s"
configure_dir = self._adjust_path(configure_dir)
self._conanfile.run('%s/configure %s %s'
% (configure_dir, args_to_string(args), " ".join(triplet_args)),
win_bash=self._win_bash)
win_bash=self._win_bash,
subsystem=self.subsystem)

def _adjust_path(self, path):
if self._win_bash:
path = unix_path(path, path_flavor=self.subsystem)
return '"%s"' % path if " " in path else path

def make(self, args="", make_program=None):
make_program = os.getenv("CONAN_MAKE_PROGRAM") or make_program or "make"
with environment_append(self.vars):
str_args = args_to_string(args)
cpu_count_option = ("-j%s" % cpu_count()) if "-j" not in str_args else None
self._conanfile.run("%s" % join_arguments([make_program, str_args, cpu_count_option]),
win_bash=self._win_bash)
win_bash=self._win_bash, subsystem=self.subsystem)

@property
def _sysroot_flag(self):
return "--sysroot=%s" % self._deps_cpp_info.sysroot if self._deps_cpp_info.sysroot else None
return "--sysroot=%s" % self._adjust_path(self._deps_cpp_info.sysroot) if self._deps_cpp_info.sysroot else None

def _configure_link_flags(self):
"""Not the -L"""
Expand Down Expand Up @@ -229,8 +239,8 @@ def append(*args):
ret.append(arg)
return ret

lib_paths = ['-L%s' % x.replace("\\", "/") for x in self.library_paths]
include_paths = ['-I%s' % x.replace("\\", "/") for x in self.include_paths]
lib_paths = ['-L%s' % self._adjust_path(x.replace("\\", "/")) for x in self.library_paths]
include_paths = ['-I%s' % self._adjust_path(x.replace("\\", "/")) for x in self.include_paths]

ld_flags = append(self.link_flags, lib_paths)
cpp_flags = append(include_paths, ["-D%s" % x for x in self.defines])
Expand Down
8 changes: 6 additions & 2 deletions conans/client/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,9 +999,13 @@ def get(self, *args):
return

def alias(self, *args):
""" Creates and exports an 'alias recipe'.
"""Creates and exports an 'alias package recipe'. An "alias" package is a
symbolic name (reference) for another package (target). When some
package depends on an alias, the target one will be retrieved and used
instead, so the alias reference, the symbolic name, does not appear
in the final dependency graph.
"""
parser = argparse.ArgumentParser(description=self.upload.__doc__,
parser = argparse.ArgumentParser(description=self.alias.__doc__,
prog="conan alias")
parser.add_argument('reference', help='Alias reference. e.j: mylib/1.X@user/channel')
parser.add_argument('target', help='Target reference. e.j: mylib/1.12@user/channel')
Expand Down
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
1 change: 0 additions & 1 deletion conans/client/tools/env.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import platform
import sys
from contextlib import contextmanager

Expand Down
31 changes: 0 additions & 31 deletions conans/client/tools/files.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import platform
import logging
import re
import os
import sys

Expand Down Expand Up @@ -220,36 +219,6 @@ def replace_prefix_in_pc_file(pc_file, new_prefix):
lines.append(line)
save(pc_file, "\n".join(lines))


MSYS2 = 'msys2'
MSYS = 'msys'
CYGWIN = 'cygwin'
WSL = 'wsl' # Windows Subsystem for Linux
SFU = 'sfu' # Windows Services for UNIX


def unix_path(path, path_flavor=None):
""""Used to translate windows paths to MSYS unix paths like
c/users/path/to/file. Not working in a regular console or MinGW!"""
if not path:
return None
from conans.client.tools.oss import os_info
path_flavor = path_flavor or os_info.detect_windows_subsystem() or MSYS2
path = path.replace(":/", ":\\")
pattern = re.compile(r'([a-z]):\\', re.IGNORECASE)
path = pattern.sub('/\\1/', path).replace('\\', '/')
if path_flavor in (MSYS, MSYS2):
return path.lower()
elif path_flavor == CYGWIN:
return '/cygdrive' + path.lower()
elif path_flavor == WSL:
return '/mnt' + path[0:2].lower() + path[2:]
elif path_flavor == SFU:
path = path.lower()
return '/dev/fs' + path[0] + path[1:].capitalize()
return None


def _path_equals(path1, path2):
path1 = os.path.normpath(path1)
path2 = os.path.normpath(path2)
Expand Down
2 changes: 1 addition & 1 deletion conans/client/tools/oss.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import os

from conans.client.tools.env import environment_append
from conans.client.tools.files import WSL, MSYS2, CYGWIN, MSYS
from conans.errors import ConanException
from conans.model.version import Version
from conans.util.log import logger
Expand Down Expand Up @@ -256,6 +255,7 @@ def uname(options=None):

@staticmethod
def detect_windows_subsystem():
from conans.client.tools.win import CYGWIN, MSYS2, MSYS, WSL
output = OSInfo.uname()
if not output:
return None
Expand Down
38 changes: 35 additions & 3 deletions conans/client/tools/win.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import glob
import os
import platform
import re

import subprocess
from contextlib import contextmanager

from conans.client.tools.env import environment_append
from conans.client.tools.files import unix_path, MSYS2, WSL, which
from conans.client.tools.oss import cpu_count, detected_architecture, os_info
from conans.errors import ConanException
from conans.util.files import decode_text
Expand Down Expand Up @@ -241,7 +241,7 @@ def get_cased_path(name):
if platform.system() != "Windows":
return name
if not os.path.isabs(name):
raise ConanException("get_cased_path requires an absolute path")
name = os.path.abspath(name)
dirs = name.split('\\')
# disk letter
test_name = [dirs[0].upper()]
Expand All @@ -254,6 +254,38 @@ def get_cased_path(name):
return None
return res[0]

MSYS2 = 'msys2'
MSYS = 'msys'
CYGWIN = 'cygwin'
WSL = 'wsl' # Windows Subsystem for Linux
SFU = 'sfu' # Windows Services for UNIX


def unix_path(path, path_flavor=None):
""""Used to translate windows paths to MSYS unix paths like
c/users/path/to/file. Not working in a regular console or MinGW!"""
if not path:
return None
from conans.client.tools.oss import os_info

if os.path.exists(path):
path = get_cased_path(path) # if the path doesn't exist (and abs) we cannot guess the casing

path_flavor = path_flavor or os_info.detect_windows_subsystem() or MSYS2
path = path.replace(":/", ":\\")
pattern = re.compile(r'([a-z]):\\', re.IGNORECASE)
path = pattern.sub('/\\1/', path).replace('\\', '/')
if path_flavor in (MSYS, MSYS2):
return path.lower()
elif path_flavor == CYGWIN:
return '/cygdrive' + path.lower()
elif path_flavor == WSL:
return '/mnt' + path[0:2].lower() + path[2:]
elif path_flavor == SFU:
path = path.lower()
return '/dev/fs' + path[0] + path[1:].capitalize()
return None


def run_in_windows_bash(conanfile, bashcmd, cwd=None, subsystem=None, msys_mingw=True, env=None):
""" Will run a unix command inside a bash terminal
Expand Down Expand Up @@ -301,7 +333,7 @@ def run_in_windows_bash(conanfile, bashcmd, cwd=None, subsystem=None, msys_mingw
if cwd and not os.path.isabs(cwd):
cwd = os.path.join(os.getcwd(), cwd)

curdir = unix_path(get_cased_path(cwd or os.getcwd()), path_flavor=subsystem)
curdir = unix_path(cwd or os.getcwd(), path_flavor=subsystem)
to_run = 'cd "%s"%s && %s ' % (curdir, hack_env, bashcmd)
bash_path = os_info.bash_path()
bash_path = '"%s"' % bash_path if " " in bash_path else bash_path
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
3 changes: 2 additions & 1 deletion conans/test/util/tools_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ def __init__(self, return_ok=True):
self.command_called = None
self.return_ok = return_ok

def __call__(self, command, output, win_bash=False): # @UnusedVariable
def __call__(self, command, output, win_bash=False, subsystem=None): # @UnusedVariable
self.command_called = command
self.win_bash = win_bash
self.subsystem = subsystem
return 0 if self.return_ok else 1


Expand Down

0 comments on commit 112e3eb

Please sign in to comment.