Skip to content

Commit

Permalink
Merge branch 'release/1.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
lasote committed Jan 16, 2018
2 parents 16f0e4b + 5d05d77 commit 41190e7
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 23 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.1'
__version__ = '1.0.2'
12 changes: 6 additions & 6 deletions conans/client/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,9 @@ def source(self, *args):

def build(self, *args):
""" Calls your local conanfile.py 'build()' method.
The recipe will be built in the local directory specified by --build_folder,
reading the sources from --source_folder. If you are using a build helper, like CMake(), the
--package_folder will be configured as destination folder for the install step.
The recipe will be built in the local directory specified by --build-folder,
reading the sources from --source-folder. If you are using a build helper, like CMake(), the
--package-folder will be configured as destination folder for the install step.
"""

parser = argparse.ArgumentParser(description=self.build.__doc__, prog="conan build")
Expand Down Expand Up @@ -476,7 +476,7 @@ def package(self, *args):
""" Calls your local conanfile.py 'package()' method.
This command works locally, in the user space, and it will copy artifacts from the
--build_folder and --source_folder folder to the --package_folder one.
--build-folder and --source-folder folder to the --package-folder one.
It won't create a new package in the local cache, if you want to do it, use 'create' or use
'export-pkg' after a 'build' command.
Expand Down Expand Up @@ -557,8 +557,8 @@ def imports(self, *args):

def export_pkg(self, *args):
"""Exports a recipe & creates a package with given files calling 'package'.
It executes the package() method applied to the local folders '--source_folder' and
'--build_folder' and creates a new package in the local cache for the specified
It executes the package() method applied to the local folders '--source-folder' and
'--build-folder' and creates a new package in the local cache for the specified
'reference' and for the specified '--settings', '--options' and or '--profile'.
"""
parser = argparse.ArgumentParser(description=self.export_pkg.__doc__,
Expand Down
2 changes: 1 addition & 1 deletion conans/client/conf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
default_settings_yml = """
# Only for cross building, 'os_build/arch_build' is the system that runs Conan
os_build: [Windows, WindowsStore, Linux, Macos, FreeBSD, SunOS]
arch_build: [x86, x86_64]
arch_build: [x86, x86_64, ppc64le, ppc64, armv6, armv7, armv7hf, armv8, sparc, sparcv9, mips, mips64, avr, armv7s, armv7k]
# Only for building cross compilation tools, 'os_target/arch_target' is the system for
# which the tools generate code
Expand Down
2 changes: 2 additions & 0 deletions conans/client/generators/cmake_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ def generate_targets_section(dependencies):
if (CONAN_SETTINGS_COMPILER_TOOLSET MATCHES "LLVM" OR
CONAN_SETTINGS_COMPILER_TOOLSET MATCHES "clang")
set(EXPECTED_CMAKE_CXX_COMPILER_ID "Clang")
elseif (CONAN_SETTINGS_COMPILER_TOOLSET MATCHES "Intel")
set(EXPECTED_CMAKE_CXX_COMPILER_ID "Intel")
else()
set(EXPECTED_CMAKE_CXX_COMPILER_ID "MSVC")
endif()
Expand Down
2 changes: 1 addition & 1 deletion conans/client/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def local_package(self, package_folder, conanfile_path, build_folder, source_fol
install_folder):
if package_folder == build_folder:
raise ConanException("Cannot 'conan package' to the build folder. "
"--build_folder and package folder can't be the same")
"--build-folder and package folder can't be the same")
output = ScopedOutput("PROJECT", self._user_io.out)
conanfile = self._load_consumer_conanfile(conanfile_path, install_folder, output,
deps_info_required=True)
Expand Down
1 change: 0 additions & 1 deletion conans/client/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import six
from conans.util.files import decode_text
from conans.util.env_reader import get_env
from conans.errors import ConanException


class Color(object):
Expand Down
15 changes: 10 additions & 5 deletions conans/client/tools/oss.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

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
Expand Down Expand Up @@ -237,23 +238,27 @@ def bash_path():

@staticmethod
def uname(options=None):
options = options or ""
options = " %s" % options if options else ""
if platform.system() != "Windows":
raise ConanException("Command only for Windows operating system")
custom_bash_path = OSInfo.bash_path()
if not custom_bash_path:
raise ConanException("bash is not in the path")

command = '%s -c "uname %s"' % (custom_bash_path, options)
command = '"%s" -c "uname%s"' % (custom_bash_path, options)
try:
ret = subprocess.check_output(command).decode().strip().lower()
return ret
except:
# the uname executable is many times located in the same folder as bash.exe
with environment_append({"PATH": [os.path.dirname(custom_bash_path)]}):
ret = subprocess.check_output(command, shell=True, ).decode().strip().lower()
return ret
except Exception:
return None

@staticmethod
def detect_windows_subsystem():
output = OSInfo.uname()
if not output:
return None
if "cygwin" in output:
return CYGWIN
elif "msys" in output or "mingw" in output:
Expand Down
28 changes: 25 additions & 3 deletions conans/client/tools/win.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import glob
import os
import platform

Expand Down Expand Up @@ -208,7 +209,7 @@ def vcvars_dict(settings, arch=None, compiler_version=None, force=False, filter_
if filter_known_paths:
def relevant_path(path):
path = path.replace("\\", "/").lower()
keywords = "msbuild", "visual", "microsoft", "/msvc/", "/vc/"
keywords = "msbuild", "visual", "microsoft", "/msvc/", "/vc/", "system32", "windows"
return any(word in path for word in keywords)

path = new_env.get("PATH", "").split(";")
Expand Down Expand Up @@ -236,6 +237,24 @@ def escape_windows_cmd(command):
return "".join(["^%s" % arg if arg in r'()%!^"<>&|' else arg for arg in quoted_arg])


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")
dirs = name.split('\\')
# disk letter
test_name = [dirs[0].upper()]
for d in dirs[1:]:
test_name += ["%s[%s]" % (d[:-1], d[-1])] # This brackets do the trick to match cased

res = glob.glob('\\'.join(test_name))
if not res:
# File not found
return None
return res[0]


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
It requires to have MSYS2, CYGWIN, or WSL
Expand Down Expand Up @@ -281,8 +300,11 @@ def run_in_windows_bash(conanfile, bashcmd, cwd=None, subsystem=None, msys_mingw
# Needed to change to that dir inside the bash shell
if cwd and not os.path.isabs(cwd):
cwd = os.path.join(os.getcwd(), cwd)
curdir = unix_path(cwd or os.getcwd(), path_flavor=subsystem)

curdir = unix_path(get_cased_path(cwd or os.getcwd()), path_flavor=subsystem)
to_run = 'cd "%s"%s && %s ' % (curdir, hack_env, bashcmd)
wincmd = '"%s" --login -c %s' % (os_info.bash_path(), escape_windows_cmd(to_run))
bash_path = os_info.bash_path()
bash_path = '"%s"' % bash_path if " " in bash_path else bash_path
wincmd = '%s --login -c %s' % (bash_path, escape_windows_cmd(to_run))
conanfile.output.info('run_in_windows_bash: %s' % wincmd)
return conanfile.run(wincmd, win_bash=False)
13 changes: 13 additions & 0 deletions conans/model/conan_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from conans.model.user_info import DepsUserInfo
from conans.paths import RUN_LOG_NAME
from conans.tools import environment_append, no_op
from conans.client.output import Color


def create_options(conanfile):
Expand Down Expand Up @@ -106,6 +107,18 @@ def __init__(self, output, runner, settings, user=None, channel=None):
self.options = create_options(self)
self.requires = create_requirements(self)
self.settings = create_settings(self, settings)
try:
if self.settings.os_build and self.settings.os:
output.writeln("*"*60, front=Color.BRIGHT_RED)
output.writeln(" This package defines both 'os' and 'os_build' ",
front=Color.BRIGHT_RED)
output.writeln(" Please use 'os' for libraries and 'os_build'",
front=Color.BRIGHT_RED)
output.writeln(" only for build-requires used for cross-building",
front=Color.BRIGHT_RED)
output.writeln("*"*60, front=Color.BRIGHT_RED)
except ConanException:
pass
self.exports = create_exports(self)
self.exports_sources = create_exports_sources(self)
# needed variables to pack the project
Expand Down
8 changes: 4 additions & 4 deletions conans/test/generators/cmake_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def variables_setup_test(self):
self.assertIn('set(CONAN_USER_LIB2_MYVAR2 "myvalue4")', cmake_lines)

def variables_cmake_multi_user_vars_test(self):
settings_mock = namedtuple("Settings", "build_type, constraint")
conanfile = ConanFile(None, None, settings_mock("Release", lambda x: x), None)
settings_mock = namedtuple("Settings", "build_type, os, os_build, constraint")
conanfile = ConanFile(None, None, settings_mock("Release", None, None, lambda x: x), None)
conanfile.deps_user_info["LIB1"].myvar = "myvalue"
conanfile.deps_user_info["LIB1"].myvar2 = "myvalue2"
conanfile.deps_user_info["lib2"].MYVAR2 = "myvalue4"
Expand All @@ -56,8 +56,8 @@ def variables_cmake_multi_user_vars_test(self):
self.assertIn('set(CONAN_USER_LIB2_MYVAR2 "myvalue4")', cmake_lines)

def variables_cmake_multi_user_vars_escape_test(self):
settings_mock = namedtuple("Settings", "build_type, constraint")
conanfile = ConanFile(None, None, settings_mock("Release", lambda x: x), None)
settings_mock = namedtuple("Settings", "build_type, os, os_build, constraint")
conanfile = ConanFile(None, None, settings_mock("Release", None, None, lambda x: x), None)
conanfile.deps_user_info["FOO"].myvar = 'my"value"'
conanfile.deps_user_info["FOO"].myvar2 = 'my${value}'
conanfile.deps_user_info["FOO"].myvar3 = 'my\\value'
Expand Down
6 changes: 5 additions & 1 deletion conans/test/util/tools_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,11 @@ def run(self, command, win_bash=False):

with tools.environment_append({"CONAN_BASH_PATH": "path\\to\\mybash.exe"}):
tools.run_in_windows_bash(conanfile, "a_command.bat", subsystem="cygwin")
self.assertIn('"path\\to\\mybash.exe" --login -c', conanfile.command)
self.assertIn('path\\to\\mybash.exe --login -c', conanfile.command)

with tools.environment_append({"CONAN_BASH_PATH": "path with spaces\\to\\mybash.exe"}):
tools.run_in_windows_bash(conanfile, "a_command.bat", subsystem="cygwin")
self.assertIn('"path with spaces\\to\\mybash.exe" --login -c', conanfile.command)

# try to append more env vars
conanfile = MockConanfile()
Expand Down

0 comments on commit 41190e7

Please sign in to comment.