Skip to content

Commit

Permalink
Merge branch 'develop' into feature/7615
Browse files Browse the repository at this point in the history
  • Loading branch information
danimtb committed Dec 18, 2020
2 parents 4bdbed2 + 8aba58b commit 0866da8
Show file tree
Hide file tree
Showing 74 changed files with 842 additions and 259 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ License

`MIT LICENSE <./LICENSE.md>`__

.. |Build Status Develop| image:: https://conan-ci.jfrog.info/buildStatus/icon?job=ConanTestSuite/develop
:target: https://conan-ci.jfrog.info/job/ConanTestSuite/job/develop
.. |Build Status Develop| image:: https://ci.conan.io/buildStatus/icon?job=ConanTestSuite/develop
:target: https://ci.conan.io/job/ConanTestSuite/job/develop/

.. |Develop climate| image:: https://api.codeclimate.com/v1/badges/081b53e570d5220b34e4/maintainability.svg
:target: https://codeclimate.com/github/conan-io/conan/maintainability
Expand Down
7 changes: 3 additions & 4 deletions conan/tools/cmake/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# noinspection PyUnresolvedReferences

from .toolchain import CMakeToolchain
from .cmake import CMake
from conan.tools.cmake.toolchain import CMakeToolchain
from conan.tools.cmake.cmake import CMake
from conan.tools.cmake.cmakedeps import CMakeDeps
2 changes: 1 addition & 1 deletion conan/tools/cmake/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from conans.client.tools.files import which
from conans.errors import ConanException
from .base import CMakeToolchainBase
from conan.tools.cmake.base import CMakeToolchainBase


class CMakeAndroidToolchain(CMakeToolchainBase):
Expand Down
4 changes: 2 additions & 2 deletions conan/tools/cmake/cmake.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os
import platform

from conan.tools.cmake.utils import get_generator, is_multi_configuration
from conan.tools.cmake.base import CMakeToolchainBase
from conans.client import tools
from conans.client.build import join_arguments
from conans.client.build.cmake_flags import is_multi_configuration, get_generator
from conan.tools.cmake.base import CMakeToolchainBase
from conans.client.tools.files import chdir
from conans.client.tools.oss import cpu_count, args_to_string
from conans.errors import ConanException
Expand Down
7 changes: 7 additions & 0 deletions conan/tools/cmake/cmakedeps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# We need to evolve this generator for Conan 2.0 here, probably a copy,
# doing all breaking changes before 2.0

# Necessary to circumvent import errors
def CMakeDeps(conanfile):
from conans.client.generators.cmake_find_package_multi import CMakeFindPackageMultiGenerator
return CMakeFindPackageMultiGenerator(conanfile)
44 changes: 40 additions & 4 deletions conan/tools/cmake/generic.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,54 @@
import os
import textwrap

from conans.client.build.cmake_flags import get_generator, get_generator_platform, get_toolset, \
is_multi_configuration
from conans.client.build.compiler_flags import architecture_flag
from conans.client.tools import cpu_count
from conans.errors import ConanException
from .base import CMakeToolchainBase
from conan.tools.cmake.base import CMakeToolchainBase
from conan.tools.cmake.utils import get_generator, is_multi_configuration, architecture_flag


# https://stackoverflow.com/questions/30503631/cmake-in-which-order-are-files-parsed-cache-toolchain-etc
# https://cmake.org/cmake/help/v3.6/manual/cmake-toolchains.7.html
# https://github.com/microsoft/vcpkg/tree/master/scripts/buildsystems


def get_toolset(settings, generator):
compiler = settings.get_safe("compiler")
compiler_base = settings.get_safe("compiler.base")
if compiler == "Visual Studio":
subs_toolset = settings.get_safe("compiler.toolset")
if subs_toolset:
return subs_toolset
elif compiler == "intel" and compiler_base == "Visual Studio" and "Visual" in generator:
compiler_version = settings.get_safe("compiler.version")
if compiler_version:
compiler_version = compiler_version if "." in compiler_version else \
"%s.0" % compiler_version
return "Intel C++ Compiler " + compiler_version
return None


def get_generator_platform(settings, generator):
# Returns the generator platform to be used by CMake
if "CONAN_CMAKE_GENERATOR_PLATFORM" in os.environ:
return os.environ["CONAN_CMAKE_GENERATOR_PLATFORM"]

compiler = settings.get_safe("compiler")
compiler_base = settings.get_safe("compiler.base")
arch = settings.get_safe("arch")

if settings.get_safe("os") == "WindowsCE":
return settings.get_safe("os.platform")

if (compiler == "Visual Studio" or compiler_base == "Visual Studio") and \
generator and "Visual" in generator:
return {"x86": "Win32",
"x86_64": "x64",
"armv7": "ARM",
"armv8": "ARM64"}.get(arch)
return None


class CMakeGenericToolchain(CMakeToolchainBase):
_toolchain_tpl = textwrap.dedent("""
{% extends 'base_toolchain' %}
Expand Down
2 changes: 1 addition & 1 deletion conan/tools/cmake/ios.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import textwrap

from .base import CMakeToolchainBase
from conan.tools.cmake.base import CMakeToolchainBase


class CMakeiOSToolchain(CMakeToolchainBase):
Expand Down
6 changes: 3 additions & 3 deletions conan/tools/cmake/toolchain.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .android import CMakeAndroidToolchain
from .ios import CMakeiOSToolchain
from .generic import CMakeGenericToolchain
from conan.tools.cmake.android import CMakeAndroidToolchain
from conan.tools.cmake.ios import CMakeiOSToolchain
from conan.tools.cmake.generic import CMakeGenericToolchain


def CMakeToolchain(conanfile, **kwargs):
Expand Down
84 changes: 84 additions & 0 deletions conan/tools/cmake/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import os

from conans.util.log import logger


def is_multi_configuration(generator):
if not generator:
return False
return "Visual" in generator or "Xcode" in generator


def architecture_flag(settings):
"""
returns flags specific to the target architecture and compiler
"""
compiler = settings.get_safe("compiler")
compiler_base = settings.get_safe("compiler.base")
arch = settings.get_safe("arch")
the_os = settings.get_safe("os")
if not compiler or not arch:
return ""

if str(compiler) in ['gcc', 'apple-clang', 'clang', 'sun-cc']:
if str(arch) in ['x86_64', 'sparcv9', 's390x']:
return '-m64'
elif str(arch) in ['x86', 'sparc']:
return '-m32'
elif str(arch) in ['s390']:
return '-m31'
elif str(the_os) == 'AIX':
if str(arch) in ['ppc32']:
return '-maix32'
elif str(arch) in ['ppc64']:
return '-maix64'
elif str(compiler) == "intel":
# https://software.intel.com/en-us/cpp-compiler-developer-guide-and-reference-m32-m64-qm32-qm64
if str(arch) == "x86":
return "/Qm32" if str(compiler_base) == "Visual Studio" else "-m32"
elif str(arch) == "x86_64":
return "/Qm64" if str(compiler_base) == "Visual Studio" else "-m64"
return ""


def get_generator(conanfile):
# Returns the name of the generator to be used by CMake
if "CONAN_CMAKE_GENERATOR" in os.environ:
return os.environ["CONAN_CMAKE_GENERATOR"]

compiler = conanfile.settings.get_safe("compiler")
compiler_base = conanfile.settings.get_safe("compiler.base")
arch = conanfile.settings.get_safe("arch")
compiler_version = conanfile.settings.get_safe("compiler.version")
compiler_base_version = conanfile.settings.get_safe("compiler.base.version")
if hasattr(conanfile, 'settings_build'):
os_build = conanfile.settings_build.get_safe('os')
else:
os_build = conanfile.settings.get_safe('os_build')
if os_build is None: # Assume is the same specified in host settings, not cross-building
os_build = conanfile.settings.get_safe("os")

if not compiler or not compiler_version or not arch:
if os_build == "Windows":
logger.warning("CMake generator could not be deduced from settings")
return None
return "Unix Makefiles"

if compiler == "Visual Studio" or compiler_base == "Visual Studio":
version = compiler_base_version or compiler_version
_visuals = {'8': '8 2005',
'9': '9 2008',
'10': '10 2010',
'11': '11 2012',
'12': '12 2013',
'14': '14 2015',
'15': '15 2017',
'16': '16 2019'}.get(version, "UnknownVersion %s" % version)
base = "Visual Studio %s" % _visuals
return base

# The generator depends on the build machine, not the target
if os_build == "Windows" and compiler != "qcc":
return "MinGW Makefiles" # it is valid only under Windows

return "Unix Makefiles"
9 changes: 6 additions & 3 deletions conan/tools/microsoft/msbuilddeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class MSBuildDeps(object):
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="ConanVariables">
<Conan{name}RootFolder>{root_folder}</Conan{name}RootFolder>
<Conan{name}CompilerFlags>{compiler_flags}</Conan{name}CompilerFlags>
<Conan{name}LinkerFlags>{linker_flags}</Conan{name}LinkerFlags>
<Conan{name}PreprocessorDefinitions>{definitions}</Conan{name}PreprocessorDefinitions>
Expand Down Expand Up @@ -151,6 +152,7 @@ def add_valid_ext(libname):

fields = {
'name': name,
'root_folder': cpp_info.rootpath,
'bin_dirs': "".join("%s;" % p for p in cpp_info.bin_paths),
'res_dirs': "".join("%s;" % p for p in cpp_info.res_paths),
'include_dirs': "".join("%s;" % p for p in cpp_info.include_paths),
Expand Down Expand Up @@ -215,11 +217,12 @@ def _content(self):
if not self._conanfile.settings.get_safe("build_type"):
raise ConanException("The 'msbuild' generator requires a 'build_type' setting value")
result = {}
general_name = "conan_deps.props"
general_name = "conandeps.props"
conf_name = self._config_filename()
condition = self._condition()
public_deps = self._conanfile.requires.keys()
result[general_name] = self._deps_props(general_name, public_deps)
# Include all direct build_requires for host context. This might change
direct_deps = self._conanfile.deps_cpp_info.direct_host_deps
result[general_name] = self._deps_props(general_name, direct_deps)
for dep_name, cpp_info in self._conanfile.deps_cpp_info.dependencies:
# One file per configuration, with just the variables
vars_props_name = "conan_%s%s.props" % (dep_name, conf_name)
Expand Down
2 changes: 1 addition & 1 deletion conans/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ def CMakeToolchain(conanfile, **kwargs):
SERVER_CAPABILITIES = [COMPLEX_SEARCH_CAPABILITY, REVISIONS] # Server is always with revisions
DEFAULT_REVISION_V1 = "0"

__version__ = '1.32.0-dev'
__version__ = '1.33.0-dev'
6 changes: 3 additions & 3 deletions conans/client/cmd/copy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import shutil

from conans.client.source import complete_recipe_sources
from conans.client.source import retrieve_exports_sources
from conans.errors import ConanException
from conans.model.ref import ConanFileReference, PackageReference
from conans.util.files import rmdir
Expand All @@ -10,7 +10,7 @@
def _prepare_sources(cache, ref, remote_manager, loader, remotes):
conan_file_path = cache.package_layout(ref).conanfile()
conanfile = loader.load_basic(conan_file_path)
complete_recipe_sources(remote_manager, cache, conanfile, ref, remotes)
retrieve_exports_sources(remote_manager, cache, conanfile, ref, remotes)
return conanfile.short_paths


Expand All @@ -19,7 +19,7 @@ def cmd_copy(ref, user_channel, package_ids, cache, user_io, remote_manager, loa
"""
param package_ids: Falsey=do not copy binaries. True=All existing. []=list of ids
"""
# It is important to get the revision early, so "complete_recipe_sources" can
# It is important to get the revision early, so "retrieve_exports_sources" can
# get the right revision sources, not latest
layout = cache.package_layout(ref)
src_metadata = layout.load_metadata()
Expand Down
4 changes: 2 additions & 2 deletions conans/client/cmd/download.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from conans.client.output import ScopedOutput
from conans.client.source import complete_recipe_sources
from conans.client.source import retrieve_exports_sources
from conans.model.ref import ConanFileReference, PackageReference
from conans.errors import NotFoundException, RecipeNotFoundException
from multiprocessing.pool import ThreadPool
Expand All @@ -22,7 +22,7 @@ def download(app, ref, package_ids, remote, recipe, recorder, remotes):
conanfile = loader.load_basic(conan_file_path)

# Download the sources too, don't be lazy
complete_recipe_sources(remote_manager, cache, conanfile, ref, remotes)
retrieve_exports_sources(remote_manager, cache, conanfile, ref, remotes)

if not recipe: # Not only the recipe
if not package_ids: # User didn't specify a specific package binary
Expand Down
1 change: 1 addition & 0 deletions conans/client/cmd/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ def _replace_scm_data_in_recipe(package_layout, scm_data, scm_to_conandata):
conandata_yml = {}
if os.path.exists(conandata_path):
conandata_yml = yaml.safe_load(load(conandata_path))
conandata_yml = conandata_yml or {} # In case the conandata is a blank file
if '.conan' in conandata_yml:
raise ConanException("Field '.conan' inside '{}' file is reserved to "
"Conan usage.".format(DATA_YML))
Expand Down
5 changes: 3 additions & 2 deletions conans/client/cmd/new.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,10 +409,11 @@ def cmd_new(ref, header=False, pure_c=False, test=False, exports_sources=False,
user=user, channel=channel,
package_name=package_name)
if pure_c:
files["test_package/example.c"] = test_main.format(name=name, version=version)
files["test_package/example.c"] = test_main.format(name=name)
files["test_package/CMakeLists.txt"] = test_cmake_pure_c
else:
files["test_package/example.cpp"] = test_main.format(name=name, version=version)
include_name = name if exports_sources else "hello"
files["test_package/example.cpp"] = test_main.format(name=include_name)
files["test_package/CMakeLists.txt"] = test_cmake

if gitignore:
Expand Down
3 changes: 2 additions & 1 deletion conans/client/cmd/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def install_build_and_test(app, conanfile_abs_path, reference, graph_info,
manifest_interactive=manifest_interactive,
keep_build=keep_build,
recorder=recorder)
cmd_build(app, conanfile_abs_path, base_folder, test_build_folder, package_folder=None,
cmd_build(app, conanfile_abs_path, base_folder, test_build_folder,
package_folder=os.path.join(test_build_folder, "package"),
install_folder=test_build_folder, test=reference)
finally:
if delete_after_build:
Expand Down
6 changes: 3 additions & 3 deletions conans/client/cmd/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from conans.util.env_reader import get_env
from conans.util.progress_bar import left_justify_message
from conans.client.remote_manager import is_package_snapshot_complete, calc_files_checksum
from conans.client.source import complete_recipe_sources
from conans.client.source import retrieve_exports_sources
from conans.errors import ConanException, NotFoundException
from conans.model.manifest import gather_files, FileTreeManifest
from conans.model.ref import ConanFileReference, PackageReference, check_valid_ref
Expand Down Expand Up @@ -159,7 +159,7 @@ class CmdUpload(object):
changes, do not allow uploading if the remote date is newer than the
local cache one
- Retrieve the sources (exports_sources), if they are not cached, and
uploading to a different remote. "complete_recipe_sources"
uploading to a different remote. "retrieve_exports_sources"
- Gather files and create 2 .tgz (exports, exports_sources) with
"_compress_recipe_files"
- Decide which files have to be uploaded and deleted from the server
Expand Down Expand Up @@ -296,7 +296,7 @@ def _upload_recipe(self, ref, conanfile, retry, retry_wait, policy, remote, remo
current_remote_name = layout.load_metadata().recipe.remote

if remote.name != current_remote_name:
complete_recipe_sources(self._remote_manager, self._cache, conanfile, ref, remotes)
retrieve_exports_sources(self._remote_manager, self._cache, conanfile, ref, remotes)

conanfile_path = layout.conanfile()
self._hook_manager.execute("pre_upload_recipe", conanfile_path=conanfile_path,
Expand Down
1 change: 0 additions & 1 deletion conans/client/conan_command_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from conans.search.binary_html_table import html_binary_graph
from conans.unicode import get_cwd
from conans.util.dates import iso8601_to_str
from conans.util.env_reader import get_env
from conans.util.files import save
from conans import __version__ as client_version
from conans.util.misc import make_tuple
Expand Down
1 change: 0 additions & 1 deletion conans/client/downloaders/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from .download import run_downloader
Loading

0 comments on commit 0866da8

Please sign in to comment.