Skip to content

Commit

Permalink
Merge branch 'release/1.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
lasote committed May 30, 2018
2 parents c1254fd + 77a8812 commit 118eafb
Show file tree
Hide file tree
Showing 114 changed files with 3,543 additions and 1,100 deletions.
4 changes: 2 additions & 2 deletions .ci/jenkins/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ def slaves = ['Linux', 'Windows', 'Macos']

def pyvers
if (env.BRANCH_NAME =~ /(^release.*)|(^master)/) {
pyvers = ['py36', 'py27', 'py34']
pyvers = ['py36', 'py34', 'py27']
}
else{
pyvers = ['py27', 'py36']
pyvers = ['py36', 'py34', 'py27']
}

def module = "\"conans.test\""
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ lib64/
parts/
sdist/
var/
venv/
*.egg-info/
.installed.cfg
*.egg
Expand Down
2 changes: 1 addition & 1 deletion conans/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
SERVER_CAPABILITIES = [COMPLEX_SEARCH_CAPABILITY, ]


__version__ = '1.3.3'
__version__ = '1.4.0'
32 changes: 19 additions & 13 deletions conans/client/build/autotools_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from conans.tools import (environment_append, args_to_string, cpu_count, cross_building,
detected_architecture, get_gnu_triplet)
from conans.errors import ConanException
from conans.util.files import get_abs_path


class AutoToolsBuildEnvironment(object):
Expand All @@ -33,6 +34,7 @@ def __init__(self, conanfile, win_bash=False, include_rpath_flags=False):
self._include_rpath_flags = include_rpath_flags
self.subsystem = OSInfo().detect_windows_subsystem() if self._win_bash else None
self._deps_cpp_info = conanfile.deps_cpp_info
self._os = conanfile.settings.get_safe("os")
self._arch = conanfile.settings.get_safe("arch")
self._build_type = conanfile.settings.get_safe("build_type")
self._compiler = conanfile.settings.get_safe("compiler")
Expand All @@ -55,34 +57,37 @@ def __init__(self, conanfile, win_bash=False, include_rpath_flags=False):
self.cppstd_flag = cppstd_flag(self._compiler, self._compiler_version, self._cppstd)
# Not -L flags, ["-m64" "-m32"]
self.link_flags = self._configure_link_flags() # TEST!
# Not declared by default
self.fpic = None
# Precalculate -fPIC
self.fpic = self._configure_fpic()

# Precalculate build, host, target triplets
self.build, self.host, self.target = self._get_host_build_target_flags()

def _configure_fpic(self):
if str(self._os) not in ["Windows", "WindowsStore"]:
fpic = self._conanfile.options.get_safe("fPIC")
if fpic is not None:
shared = self._conanfile.options.get_safe("shared")
return True if (fpic or shared) else None

def _get_host_build_target_flags(self):
"""Based on google search for build/host triplets, it could need a lot
and complex verification"""

arch_detected = detected_architecture() or platform.machine()
os_detected = platform.system()
arch_settings = self._conanfile.settings.get_safe("arch")
os_settings = self._conanfile.settings.get_safe("os")
compiler = self._conanfile.settings.get_safe("compiler")

if (os_detected is None or arch_detected is None or arch_settings is None or
os_settings is None):
if os_detected is None or arch_detected is None or self._arch is None or self._os is None:
return False, False, False
if not cross_building(self._conanfile.settings, os_detected, arch_detected):
return False, False, False

try:
build = get_gnu_triplet(os_detected, arch_detected, compiler)
build = get_gnu_triplet(os_detected, arch_detected, self._compiler)
except ConanException:
build = None
try:
host = get_gnu_triplet(os_settings, arch_settings, compiler)
host = get_gnu_triplet(self._os, self._arch, self._compiler)
except ConanException:
host = None
return build, host, None
Expand Down Expand Up @@ -127,11 +132,13 @@ def configure(self, configure_dir=None, args=None, build=None, host=None, target
triplet_args.append("--target=%s" % (target or self.target))

if pkg_config_paths:
pkg_env = {"PKG_CONFIG_PATH": os.pathsep.join(pkg_config_paths)}
pkg_env = {"PKG_CONFIG_PATH":
os.pathsep.join(get_abs_path(f, self._conanfile.install_folder)
for f in pkg_config_paths)}
else:
# If we are using pkg_config generator automate the pcs location, otherwise it could
# read wrong files
pkg_env = {"PKG_CONFIG_PATH": self._conanfile.build_folder} \
pkg_env = {"PKG_CONFIG_PATH": self._conanfile.install_folder} \
if "pkg_config" in self._conanfile.generators else {}

if self._conanfile.package_folder is not None:
Expand Down Expand Up @@ -184,8 +191,7 @@ def _configure_link_flags(self):
ret.append(sysf)

if self._include_rpath_flags:
the_os = self._conanfile.settings.get_safe("os_build") or \
self._conanfile.settings.get_safe("os")
the_os = self._conanfile.settings.get_safe("os_build") or self._os
ret.extend(rpath_flags(the_os, self._compiler, self._deps_cpp_info.lib_paths))

return ret
Expand Down
57 changes: 45 additions & 12 deletions conans/client/build/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from conans.model.conan_file import ConanFile
from conans.model.version import Version
from conans.util.env_reader import get_env
from conans.util.files import mkdir
from conans.util.files import mkdir, get_abs_path
from conans.tools import cpu_count, args_to_string
from conans import tools
from conans.util.log import logger
Expand All @@ -28,7 +28,8 @@ def _get_env_cmake_system_name():
class CMake(object):

def __init__(self, conanfile, generator=None, cmake_system_name=True,
parallel=True, build_type=None, toolset=None, make_program=None, set_cmake_flags=False):
parallel=True, build_type=None, toolset=None, make_program=None,
set_cmake_flags=False):
"""
:param settings_or_conanfile: Conanfile instance (or settings for retro compatibility)
:param generator: Generator name to use or none to autodetect
Expand All @@ -53,7 +54,10 @@ def __init__(self, conanfile, generator=None, cmake_system_name=True,
self._compiler = self._settings.get_safe("compiler")
self._compiler_version = self._settings.get_safe("compiler.version")
self._arch = self._settings.get_safe("arch")
self._op_system_version = self._settings.get_safe("os.version")

os_ver_str = "os.api_level" if self._os == "Android" else "os.version"
self._op_system_version = self._settings.get_safe(os_ver_str)

self._libcxx = self._settings.get_safe("compiler.libcxx")
self._runtime = self._settings.get_safe("compiler.runtime")
self._build_type = self._settings.get_safe("build_type")
Expand Down Expand Up @@ -112,8 +116,11 @@ def _generator(self):
return os.environ["CONAN_CMAKE_GENERATOR"]

if not self._compiler or not self._compiler_version or not self._arch:
raise ConanException("You must specify compiler, compiler.version and arch in "
"your settings to use a CMake generator")
if self._os_build == "Windows":
raise ConanException("You must specify compiler, compiler.version and arch in "
"your settings to use a CMake generator. You can also declare "
"the env variable CONAN_CMAKE_GENERATOR.")
return "Unix Makefiles"

if self._compiler == "Visual Studio":
_visuals = {'8': '8 2005',
Expand Down Expand Up @@ -331,6 +338,10 @@ def add_cmake_flag(cmake_flags, name, flag):
shared = self._conanfile.options.get_safe("shared")
ret["CONAN_CMAKE_POSITION_INDEPENDENT_CODE"] = "ON" if (fpic or shared) else "OFF"

# Adjust automatically the module path in case the conanfile is using the cmake_find_package
if "cmake_find_package" in self._conanfile.generators:
ret["CMAKE_MODULE_PATH"] = self._conanfile.install_folder.replace("\\", "/")

return ret

def _get_dirs(self, source_folder, build_folder, source_dir, build_dir, cache_build_folder):
Expand All @@ -356,8 +367,16 @@ def get_dir(folder, origin):

return source_ret, build_ret

def _run(self, command):
if self._compiler == 'Visual Studio' and self.generator in ['Ninja', 'NMake Makefiles', 'NMake Makefiles JOM']:
with tools.vcvars(self._settings, force=True, filter_known_paths=False):
self._conanfile.run(command)
else:
self._conanfile.run(command)

def configure(self, args=None, defs=None, source_dir=None, build_dir=None,
source_folder=None, build_folder=None, cache_build_folder=None):
source_folder=None, build_folder=None, cache_build_folder=None,
pkg_config_paths=None):

# TODO: Deprecate source_dir and build_dir in favor of xxx_folder
if not self._conanfile.should_configure:
Expand All @@ -374,12 +393,26 @@ def configure(self, args=None, defs=None, source_dir=None, build_dir=None,
defs_to_string(defs),
args_to_string([source_dir])
])
command = "cd %s && cmake %s" % (args_to_string([self.build_dir]), arg_list)
if platform.system() == "Windows" and self.generator == "MinGW Makefiles":
with tools.remove_from_path("sh"):
self._conanfile.run(command)


if pkg_config_paths:
pkg_env = {"PKG_CONFIG_PATH":
os.pathsep.join(get_abs_path(f, self._conanfile.install_folder)
for f in pkg_config_paths)}
else:
self._conanfile.run(command)
# If we are using pkg_config generator automate the pcs location, otherwise it could
# read wrong files
set_env = "pkg_config" in self._conanfile.generators \
and "PKG_CONFIG_PATH" not in os.environ
pkg_env = {"PKG_CONFIG_PATH": self._conanfile.install_folder} if set_env else {}

with tools.environment_append(pkg_env):
command = "cd %s && cmake %s" % (args_to_string([self.build_dir]), arg_list)
if platform.system() == "Windows" and self.generator == "MinGW Makefiles":
with tools.remove_from_path("sh"):
self._conanfile.run(command)
else:
self._conanfile.run(command)

def build(self, args=None, build_dir=None, target=None):
if not self._conanfile.should_build:
Expand All @@ -406,7 +439,7 @@ def build(self, args=None, build_dir=None, target=None):
args_to_string(args)
])
command = "cmake --build %s" % arg_list
self._conanfile.run(command)
self._run(command)

def install(self, args=None, build_dir=None):
if not self._conanfile.should_install:
Expand Down
42 changes: 31 additions & 11 deletions conans/client/build/cppstd_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ def cppstd_default(compiler, compiler_version):


def _clang_cppstd_default(compiler_version):
return "gnu98" if Version(compiler_version) < "6.0" else "gnu14"
# Official docs are wrong, in 6.0 the default is gnu14 to follow gcc's choice
return "gnu98" if Version(compiler_version) < "6" else "gnu14"


def _gcc_cppstd_default(compiler_version):
return "gnu98" if Version(compiler_version) < "6.1" else "gnu14"
return "gnu98" if Version(compiler_version) < "6" else "gnu14"


def _visual_cppstd_default(compiler_version):
Expand All @@ -46,17 +47,19 @@ def _visual_cppstd_default(compiler_version):


def _cppstd_visualstudio(visual_version, cppstd):

# https://docs.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version
v14 = None
v17 = None
v20 = None

if Version(visual_version) >= "14":
v14 = "c++14"
v17 = "c++latest"
if Version(visual_version) >= "15":
v17 = "c++17"
v20 = "c++latest"

flag = {"14": v14, "17": v17}.get(str(cppstd), None)
flag = {"14": v14, "17": v17, "20": v20}.get(str(cppstd), None)
return "/std:%s" % flag if flag else None


Expand All @@ -66,7 +69,7 @@ def _cppstd_apple_clang(clang_version, cppstd):
https://github.com/Kitware/CMake/blob/master/Modules/Compiler/AppleClang-CXX.cmake
"""

v98 = vgnu98 = v11 = vgnu11 = v14 = vgnu14 = v17 = vgnu17 = None
v98 = vgnu98 = v11 = vgnu11 = v14 = vgnu14 = v17 = vgnu17 = v20 = vgnu20 = None

if Version(clang_version) >= "4.0":
v98 = "c++98"
Expand All @@ -93,7 +96,8 @@ def _cppstd_apple_clang(clang_version, cppstd):
flag = {"98": v98, "gnu98": vgnu98,
"11": v11, "gnu11": vgnu11,
"14": v14, "gnu14": vgnu14,
"17": v17, "gnu17": vgnu17}.get(cppstd, None)
"17": v17, "gnu17": vgnu17,
"20": v20, "gnu20": vgnu20}.get(cppstd, None)

return "-std=%s" % flag if flag else None

Expand All @@ -103,8 +107,10 @@ def _cppstd_clang(clang_version, cppstd):
Inspired in:
https://github.com/Kitware/CMake/blob/
1fe2dc5ef2a1f262b125a2ba6a85f624ce150dd2/Modules/Compiler/Clang-CXX.cmake
https://clang.llvm.org/cxx_status.html
"""
v98 = vgnu98 = v11 = vgnu11 = v14 = vgnu14 = v17 = vgnu17 = None
v98 = vgnu98 = v11 = vgnu11 = v14 = vgnu14 = v17 = vgnu17 = v20 = vgnu20 = None

if Version(clang_version) >= "2.1":
v98 = "c++98"
Expand All @@ -131,17 +137,22 @@ def _cppstd_clang(clang_version, cppstd):
v17 = "c++1z"
vgnu17 = "gnu++1z"

if Version(clang_version) >= "6":
v20 = "c++2a"
vgnu20 = "gnu++2a"

flag = {"98": v98, "gnu98": vgnu98,
"11": v11, "gnu11": vgnu11,
"14": v14, "gnu14": vgnu14,
"17": v17, "gnu17": vgnu17}.get(cppstd, None)
"17": v17, "gnu17": vgnu17,
"20": v20, "gnu20": vgnu20}.get(cppstd, None)
return "-std=%s" % flag if flag else None


def _cppstd_gcc(gcc_version, cppstd):
"""https://github.com/Kitware/CMake/blob/master/Modules/Compiler/GNU-CXX.cmake"""
# https://gcc.gnu.org/projects/cxx-status.html#cxx98
v98 = vgnu98 = v11 = vgnu11 = v14 = vgnu14 = v17 = vgnu17 = None
# https://gcc.gnu.org/projects/cxx-status.html
v98 = vgnu98 = v11 = vgnu11 = v14 = vgnu14 = v17 = vgnu17 = v20 = vgnu20 = None

if Version(gcc_version) >= "3.4":
v98 = "c++98"
Expand All @@ -165,8 +176,17 @@ def _cppstd_gcc(gcc_version, cppstd):
v17 = "c++1z"
vgnu17 = "gnu++1z"

if Version(gcc_version) >= "5.2": # Not sure if even in 5.1 gnu17 is valid, but gnu1z is
v17 = "c++17"
vgnu17 = "gnu++17"

if Version(gcc_version) >= "8":
v20 = "c++2a"
vgnu20 = "gnu++2a"

flag = {"98": v98, "gnu98": vgnu98,
"11": v11, "gnu11": vgnu11,
"14": v14, "gnu14": vgnu14,
"17": v17, "gnu17": vgnu17}.get(cppstd)
"17": v17, "gnu17": vgnu17,
"20": v20, "gnu20": vgnu20}.get(cppstd)
return "-std=%s" % flag if flag else None
18 changes: 5 additions & 13 deletions conans/client/build/meson.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from conans.client import join_arguments, defs_to_string
from conans.errors import ConanException
from conans.tools import args_to_string
from conans.util.files import mkdir
from conans.util.files import mkdir, get_abs_path


class Meson(object):
Expand Down Expand Up @@ -53,14 +53,6 @@ def build_folder(self):
def build_folder(self, value):
self.build_dir = value

@staticmethod
def _get_dir(folder, origin):
if folder:
if os.path.isabs(folder):
return folder
return os.path.join(origin, folder)
return origin

def _get_dirs(self, source_folder, build_folder, source_dir, build_dir, cache_build_folder):
if (source_folder or build_folder) and (source_dir or build_dir):
raise ConanException("Use 'build_folder'/'source_folder'")
Expand All @@ -69,11 +61,11 @@ def _get_dirs(self, source_folder, build_folder, source_dir, build_dir, cache_bu
build_ret = build_dir or self.build_dir or self._conanfile.build_folder
source_ret = source_dir or self._conanfile.source_folder
else:
build_ret = self._get_dir(build_folder, self._conanfile.build_folder)
source_ret = self._get_dir(source_folder, self._conanfile.source_folder)
build_ret = get_abs_path(build_folder, self._conanfile.build_folder)
source_ret = get_abs_path(source_folder, self._conanfile.source_folder)

if self._conanfile.in_local_cache and cache_build_folder:
build_ret = self._get_dir(cache_build_folder, self._conanfile.build_folder)
build_ret = get_abs_path(cache_build_folder, self._conanfile.build_folder)

return source_ret, build_ret

Expand All @@ -90,7 +82,7 @@ def configure(self, args=None, defs=None, source_dir=None, build_dir=None,
cache_build_folder)

if pkg_config_paths:
pc_paths = os.pathsep.join(self._get_dir(f, self._conanfile.install_folder)
pc_paths = os.pathsep.join(get_abs_path(f, self._conanfile.install_folder)
for f in pkg_config_paths)
else:
pc_paths = self._conanfile.install_folder
Expand Down
Loading

0 comments on commit 118eafb

Please sign in to comment.