From 5f7c6518d25f731290a671b30af922746c1c8f03 Mon Sep 17 00:00:00 2001 From: memsharded Date: Mon, 15 Jan 2018 00:35:18 +0100 Subject: [PATCH 1/7] version bump --- conans/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conans/__init__.py b/conans/__init__.py index d570ccbef1b..f7894006871 100644 --- a/conans/__init__.py +++ b/conans/__init__.py @@ -15,4 +15,4 @@ COMPLEX_SEARCH_CAPABILITY = "complex_search" SERVER_CAPABILITIES = [COMPLEX_SEARCH_CAPABILITY, ] -__version__ = '1.0.1' +__version__ = '1.0.2' From 0a2d2bba14bc9dfa494cfb230d536bd8b8854092 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 15 Jan 2018 12:13:11 +0100 Subject: [PATCH 2/7] adding warning message for cross-build settings (#2309) * adding warning message for cross-build settings * fix broken tests --- conans/client/output.py | 1 - conans/model/conan_file.py | 13 +++++++++++++ conans/test/generators/cmake_test.py | 8 ++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/conans/client/output.py b/conans/client/output.py index c5511ebe0bd..da8864d3a2c 100644 --- a/conans/client/output.py +++ b/conans/client/output.py @@ -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): diff --git a/conans/model/conan_file.py b/conans/model/conan_file.py index e2c20e73a17..46bc5a5f3b8 100644 --- a/conans/model/conan_file.py +++ b/conans/model/conan_file.py @@ -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): @@ -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 diff --git a/conans/test/generators/cmake_test.py b/conans/test/generators/cmake_test.py index 0ceb4530c0d..e57a13d6ddb 100644 --- a/conans/test/generators/cmake_test.py +++ b/conans/test/generators/cmake_test.py @@ -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" @@ -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' From 039fbde203615c83f4c1152f4b7cef473104eaef Mon Sep 17 00:00:00 2001 From: James Date: Mon, 15 Jan 2018 12:13:33 +0100 Subject: [PATCH 3/7] add more arch_build values (#2308) --- conans/client/conf/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conans/client/conf/__init__.py b/conans/client/conf/__init__.py index fbcd5eca07a..0206c410aec 100644 --- a/conans/client/conf/__init__.py +++ b/conans/client/conf/__init__.py @@ -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 From da9d9c55880ad16ca1cfec4d5c9730d4df3750a8 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 15 Jan 2018 14:09:57 +0100 Subject: [PATCH 4/7] not throw if intel in cmake (#2311) --- conans/client/generators/cmake_common.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conans/client/generators/cmake_common.py b/conans/client/generators/cmake_common.py index bd77b90afb9..1cc62e49a99 100644 --- a/conans/client/generators/cmake_common.py +++ b/conans/client/generators/cmake_common.py @@ -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() From 14cc8b113d6e7bb0e88d0103f931d390bde43fb7 Mon Sep 17 00:00:00 2001 From: Luis Martinez de Bartolome Izquierdo Date: Tue, 16 Jan 2018 09:03:27 +0100 Subject: [PATCH 5/7] Feature/fix quote escape win bash (#2313) * Fixing quotes * Fixing quotes * details * Only quotes when spaces * 1.0.2 * added test --- conans/client/tools/oss.py | 15 ++++++++++----- conans/client/tools/win.py | 26 ++++++++++++++++++++++++-- conans/test/util/tools_test.py | 6 +++++- 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/conans/client/tools/oss.py b/conans/client/tools/oss.py index 34419a4eb8c..913cf77d5e4 100644 --- a/conans/client/tools/oss.py +++ b/conans/client/tools/oss.py @@ -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 @@ -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: diff --git a/conans/client/tools/win.py b/conans/client/tools/win.py index d62a7940f09..3ebbe28e0e1 100644 --- a/conans/client/tools/win.py +++ b/conans/client/tools/win.py @@ -1,3 +1,4 @@ +import glob import os import platform @@ -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 @@ -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) diff --git a/conans/test/util/tools_test.py b/conans/test/util/tools_test.py index 9b36034f173..573b56f0482 100644 --- a/conans/test/util/tools_test.py +++ b/conans/test/util/tools_test.py @@ -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() From da62df124347a13bcf57f73993ad66cfc04b4663 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 16 Jan 2018 13:17:05 +0100 Subject: [PATCH 6/7] fixed underscores (#2319) --- conans/client/command.py | 12 ++++++------ conans/client/manager.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/conans/client/command.py b/conans/client/command.py index cd4cc29a48c..2a5a8c90aa2 100644 --- a/conans/client/command.py +++ b/conans/client/command.py @@ -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") @@ -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. @@ -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__, diff --git a/conans/client/manager.py b/conans/client/manager.py index 75df238da26..473397639d2 100644 --- a/conans/client/manager.py +++ b/conans/client/manager.py @@ -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) From 5d05d770e9f7e097c6ed9c9fd390fb81887e68c4 Mon Sep 17 00:00:00 2001 From: Luis Martinez de Bartolome Izquierdo Date: Tue, 16 Jan 2018 15:09:23 +0100 Subject: [PATCH 7/7] Keep system32 and windows paths (#2321) --- conans/client/tools/win.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conans/client/tools/win.py b/conans/client/tools/win.py index 3ebbe28e0e1..9f6f80ede98 100644 --- a/conans/client/tools/win.py +++ b/conans/client/tools/win.py @@ -209,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(";")