Skip to content

Commit

Permalink
Merge branch 'release/0.29.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
lasote committed Nov 21, 2017
2 parents b10bc78 + 6242dc2 commit 1315c41
Show file tree
Hide file tree
Showing 86 changed files with 1,805 additions and 731 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,5 @@ cacert.pem
.conan_server/
.sudo_as_admin_successful

# add excluded
!conans/client/build
15 changes: 7 additions & 8 deletions conans/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
from conans.model.conan_file import ConanFile
from conans.model.options import Options
from conans.model.settings import Settings
from conans.client.cmake import CMake
from conans.client.meson import Meson
from conans.client.gcc import GCC
from conans.client.configure_environment import ConfigureEnvironment
from conans.client.configure_build_environment import (AutoToolsBuildEnvironment, VisualStudioBuildEnvironment)
from conans.client.build.cmake import CMake
from conans.client.build.meson import Meson
from conans.client.build.gcc import GCC
from conans.client.build.configure_environment import ConfigureEnvironment
from conans.client.build.autotools_environment import AutoToolsBuildEnvironment
from conans.client.build.visual_environment import VisualStudioBuildEnvironment
from conans.client.run_environment import RunEnvironment
from conans.util.files import load
import os

# complex_search: With ORs and not filtering by not restricted settings
COMPLEX_SEARCH_CAPABILITY = "complex_search"
SERVER_CAPABILITIES = [COMPLEX_SEARCH_CAPABILITY, ]


__version__ = '0.28.1'
__version__ = '0.29.0'
Empty file added conans/client/build/__init__.py
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -37,46 +37,6 @@ def stdlib_defines(compiler, libcxx):
return ret


class VisualStudioBuildEnvironment(object):
"""
- LIB: library paths with semicolon separator
- CL: /I (include paths)
"""
def __init__(self, conanfile):
"""
:param conanfile: ConanFile instance
:param quote_paths: The path directories will be quoted. If you are using the vars together with
environment_append keep it to True, for virtualbuildenv quote_paths=False is required.
"""
self.include_paths = conanfile.deps_cpp_info.include_paths
self.lib_paths = conanfile.deps_cpp_info.lib_paths

@property
def vars(self):
"""Used in conanfile with environment_append"""
cl_args = " ".join(['/I"%s"' % lib for lib in self.include_paths]) + environ_value_prefix("CL")
lib_paths = ";".join(['%s' % lib for lib in self.lib_paths]) + environ_value_prefix("LIB", ";")
return {"CL": cl_args,
"LIB": lib_paths}

@property
def vars_dict(self):
"""Used in virtualbuildenvironment"""
# Here we do not quote the include paths, it's going to be used by virtual environment
cl = ['/I%s' % lib for lib in self.include_paths]
lib = [lib for lib in self.lib_paths] # copy

if os.environ.get("CL", None):
cl.append(os.environ.get("CL"))

if os.environ.get("LIB", None):
lib.append(os.environ.get("LIB"))

ret = {"CL": cl,
"LIB": lib}
return ret


class AutoToolsBuildEnvironment(object):
"""
- CPPFLAGS (C-PreProcesor-Flags NOT related with c++) (-I -D)
Expand Down Expand Up @@ -128,7 +88,7 @@ def _get_host_build_target_flags(self, arch_detected, os_detected):
host = "i686-w64-mingw32" if arch_setting == "x86" else "x86_64-w64-mingw32"
else: # Building for Linux or Android
build = "%s-%s" % (arch_detected, {"Linux": "linux-gnu",
"Darwin": "apple-macos"}.get(os_detected,
"Darwin": "apple-darwin"}.get(os_detected,
os_detected.lower()))
if arch_setting == "x86":
host_arch = "i686"
Expand All @@ -137,17 +97,23 @@ def _get_host_build_target_flags(self, arch_detected, os_detected):
else:
host_arch = "arm" if "arm" in arch_setting else arch_setting

host = "%s%s" % (host_arch, { "Linux": "-linux-gnueabi",
"Android": "-linux-android"}.get(os_setting, ""))
host = "%s%s" % (host_arch, {"Linux": "-linux-gnueabi",
"Android": "-linux-android",
"Macos": "-apple-darwin",
"iOS": "-apple-darwin",
"watchOS": "-apple-darwin",
"tvOS": "-apple-darwin"}.get(os_setting, ""))
if arch_setting == "armv7hf" and os_setting == "Linux":
host += "hf"
elif "arm" in arch_setting and arch_setting != "armv8" and os_setting == "Android":
host += "eabi"

return build, host, None

def configure(self, configure_dir=None, args=None, build=None, host=None, target=None):
def configure(self, configure_dir=None, args=None, build=None, host=None, target=None,
pkg_config_paths=None):
"""
:param pkg_config_paths: Optional paths to locate the *.pc files
:param configure_dir: Absolute or relative path to the configure script
:param args: Optional arguments to pass to configure.
:param build: In which system the program will be built. "False" skips the --build flag
Expand All @@ -173,19 +139,28 @@ def configure(self, configure_dir=None, args=None, build=None, host=None, target

if build is not False: # Skipped by user
if build or auto_build: # User specified value or automatic
triplet_args.append("--build %s" % (build or auto_build))
triplet_args.append("--build=%s" % (build or auto_build))

if host is not False: # Skipped by user
if host or auto_host: # User specified value or automatic
triplet_args.append("--host %s" % (host or auto_host))
triplet_args.append("--host=%s" % (host or auto_host))

if target is not False: # Skipped by user
if target or auto_target: # User specified value or automatic
triplet_args.append("--target %s" % (target or auto_target))
triplet_args.append("--target=%s" % (target or auto_target))

with environment_append(self.vars):
self._conanfile.run("%s/configure %s %s"
% (configure_dir, args_to_string(args), " ".join(triplet_args)))
if pkg_config_paths:
pkg_env = {"PKG_CONFIG_PATH": os.pathsep.join(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} \
if "pkg_config" in self._conanfile.generators else {}

with environment_append(pkg_env):
with environment_append(self.vars):
self._conanfile.run("%s/configure %s %s"
% (configure_dir, args_to_string(args), " ".join(triplet_args)))

def make(self, args="", make_program=None):
make_program = os.getenv("CONAN_MAKE_PROGRAM") or make_program or "make"
Expand Down Expand Up @@ -213,7 +188,8 @@ def _configure_flags(self):
if self._build_type == "Debug":
ret.append("-g") # default debug information
elif self._build_type == "Release" and self._compiler == "gcc":
ret.append("-s") # Remove all symbol table and relocation information from the executable.
# Remove all symbol table and relocation information from the executable.
ret.append("-s")
if self._sysroot_flag:
ret.append(self._sysroot_flag)
return ret
Expand Down Expand Up @@ -299,11 +275,11 @@ def vars(self):

ld_flags, cpp_flags, libs, cxx_flags, c_flags = self._get_vars()

cpp_flags = " ".join(cpp_flags) + environ_value_prefix("CPPFLAGS")
cxx_flags = " ".join(cxx_flags) + environ_value_prefix("CXXFLAGS")
cflags = " ".join(c_flags) + environ_value_prefix("CFLAGS")
ldflags = " ".join(ld_flags) + environ_value_prefix("LDFLAGS")
libs = " ".join(libs) + environ_value_prefix("LIBS")
cpp_flags = " ".join(cpp_flags) + _environ_value_prefix("CPPFLAGS")
cxx_flags = " ".join(cxx_flags) + _environ_value_prefix("CXXFLAGS")
cflags = " ".join(c_flags) + _environ_value_prefix("CFLAGS")
ldflags = " ".join(ld_flags) + _environ_value_prefix("LDFLAGS")
libs = " ".join(libs) + _environ_value_prefix("LIBS")

ret = {"CPPFLAGS": cpp_flags.strip(),
"CXXFLAGS": cxx_flags.strip(),
Expand All @@ -315,7 +291,7 @@ def vars(self):
return ret


def environ_value_prefix(var_name, prefix=" "):
def _environ_value_prefix(var_name, prefix=" "):
if os.environ.get(var_name, ""):
return "%s%s" % (prefix, os.environ.get(var_name, ""))
else:
Expand Down
103 changes: 26 additions & 77 deletions conans/client/cmake.py → conans/client/build/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,13 @@
from conans.client import defs_to_string, join_arguments
from conans.errors import ConanException
from conans.model.conan_file import ConanFile
from conans.model.settings import Settings
from conans.util.env_reader import get_env
from conans.util.files import mkdir
from conans.tools import cpu_count, args_to_string
from conans import tools
from conans.util.log import logger
from conans.util.config_parser import get_bool_from_text

# Deprecated in 0.22
deprecated_conanfile_param_message = '''
******************************* WARNING!!! ************************************
Do not pass 'self' to configure() nor build() methods, it is deprecated and will be removed.
Instance CMake with the conanfile instance instead:
cmake = CMake(self)
cmake.configure() # Optional args, defs, source_dir and build_dir parameters
cmake.build() # Optional args, build_dir and target
**********************************************************************************
'''


def _get_env_cmake_system_name():
env_system_name = get_env("CONAN_CMAKE_SYSTEM_NAME", "")
Expand All @@ -39,7 +22,7 @@ def _get_env_cmake_system_name():

class CMake(object):

def __init__(self, settings_or_conanfile, generator=None, cmake_system_name=True,
def __init__(self, conanfile, generator=None, cmake_system_name=True,
parallel=True, build_type=None, toolset=None):
"""
:param settings_or_conanfile: Conanfile instance (or settings for retro compatibility)
Expand All @@ -51,18 +34,11 @@ def __init__(self, settings_or_conanfile, generator=None, cmake_system_name=True
:param toolset: Toolset name to use (such as llvm-vs2014) or none for default one,
applies only to certain generators (e.g. Visual Studio)
"""
if isinstance(settings_or_conanfile, Settings):
self._settings = settings_or_conanfile
self._conanfile = None
self.configure = self._configure_old
self.build = self._build_old
elif isinstance(settings_or_conanfile, ConanFile):
self._settings = settings_or_conanfile.settings
self._conanfile = settings_or_conanfile
self.configure = self._configure_new
self.build = self._build_new
else:
raise ConanException("First parameter of CMake() has to be a ConanFile instance.")
if not isinstance(conanfile, ConanFile):
raise ConanException("First argument of CMake() has to be ConanFile. Use CMake(self)")

self._settings = conanfile.settings
self._conanfile = conanfile

self._os = self._settings.get_safe("os")
self._compiler = self._settings.get_safe("compiler")
Expand Down Expand Up @@ -103,19 +79,6 @@ def build_type(self, build_type):
def flags(self):
return defs_to_string(self.definitions)

@staticmethod
def options_cmd_line(options, option_upper=True, value_upper=True):
""" FIXME: this function seems weird, not tested, not used.
Probably should be deprecated
"""
result = []
for option, value in options.values.as_list():
if value is not None:
option = option.upper() if option_upper else option
value = value.upper() if value_upper else value
result.append("-D%s=%s" % (option, value))
return ' '.join(result)

def _generator(self):

if not self._compiler or not self._compiler_version or not self._arch:
Expand Down Expand Up @@ -148,9 +111,13 @@ def _generator(self):
return "Unix Makefiles"

def _toolset(self, toolset=None):
if "CONAN_CMAKE_TOOLSET" in os.environ:
return os.environ["CONAN_CMAKE_TOOLSET"]
return toolset
if toolset:
return toolset
elif self._settings.get_safe("compiler") == "Visual Studio":
subs_toolset = self._settings.get_safe("compiler.toolset")
if subs_toolset:
return subs_toolset
return None

def _cmake_compiler_options(self, the_os, arch):
cmake_definitions = OrderedDict()
Expand Down Expand Up @@ -296,34 +263,24 @@ def _get_cmake_definitions(self):
# Shared library
try:
ret["BUILD_SHARED_LIBS"] = "ON" if self._conanfile.options.shared else "OFF"
except:
except ConanException:
pass

# Install to package folder
try:
if self._conanfile.package_folder:
ret["CMAKE_INSTALL_PREFIX"] = self._conanfile.package_folder
except:
except AttributeError:
pass

if self._os == "Windows" and self._compiler == "Visual Studio":
if str(self._os) in ["Windows", "WindowsStore"] and self._compiler == "Visual Studio":
if self.parallel:
cpus = tools.cpu_count()
ret["CONAN_CXX_FLAGS"] = "/MP%s" % cpus
ret["CONAN_C_FLAGS"] = "/MP%s" % cpus
return ret

def _configure_old(self, conanfile, args=None, defs=None, source_dir=None, build_dir=None):
"""Deprecated in 0.22"""
if not isinstance(conanfile, ConanFile):
raise ConanException(deprecated_conanfile_param_message)
self._conanfile = conanfile
self._conanfile.output.warn(deprecated_conanfile_param_message)
return self._configure_new(args=args, defs=defs, source_dir=source_dir, build_dir=build_dir)

def _configure_new(self, args=None, defs=None, source_dir=None, build_dir=None):
if isinstance(args, ConanFile):
raise ConanException(deprecated_conanfile_param_message)
def configure(self, args=None, defs=None, source_dir=None, build_dir=None):
args = args or []
defs = defs or {}
source_dir = source_dir or self._conanfile.source_folder
Expand All @@ -343,17 +300,7 @@ def _configure_new(self, args=None, defs=None, source_dir=None, build_dir=None):
else:
self._conanfile.run(command)

def _build_old(self, conanfile, args=None, build_dir=None, target=None):
"""Deprecated in 0.22"""
if not isinstance(conanfile, ConanFile):
raise ConanException(deprecated_conanfile_param_message)
self._conanfile = conanfile
self._conanfile.output.warn(deprecated_conanfile_param_message)
return self._build_new(args=args, build_dir=build_dir, target=target)

def _build_new(self, args=None, build_dir=None, target=None):
if isinstance(args, ConanFile):
raise ConanException(deprecated_conanfile_param_message)
def build(self, args=None, build_dir=None, target=None):
args = args or []
build_dir = build_dir or self.build_dir or self._conanfile.build_folder
if target is not None:
Expand All @@ -364,6 +311,10 @@ def _build_new(self, args=None, build_dir=None, target=None):
if "--" not in args:
args.append("--")
args.append("-j%i" % cpu_count())
elif "Visual Studio" in self.generator:
if "--" not in args:
args.append("--")
args.append("/m:%i" % cpu_count())

arg_list = join_arguments([
args_to_string([build_dir]),
Expand All @@ -378,21 +329,19 @@ def install(self, args=None, build_dir=None):
if not self.definitions.get("CMAKE_INSTALL_PREFIX"):
raise ConanException("CMAKE_INSTALL_PREFIX not defined for 'cmake.install()'\n"
"Make sure 'package_folder' is defined")
self._build_new(args=args, build_dir=build_dir, target="install")
self.build(args=args, build_dir=build_dir, target="install")

def test(self, args=None, build_dir=None, target=None):
if isinstance(args, ConanFile):
raise ConanException(deprecated_conanfile_param_message)
if not target:
target = "RUN_TESTS" if self._compiler == "Visual Studio" else "test"
self._build_new(args=args, build_dir=build_dir, target=target)
target = "RUN_TESTS" if self.is_multi_configuration else "test"
self.build(args=args, build_dir=build_dir, target=target)

@property
def verbose(self):
try:
verbose = self.definitions["CMAKE_VERBOSE_MAKEFILE"]
return get_bool_from_text(str(verbose))
except:
except KeyError:
return False

@verbose.setter
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 1315c41

Please sign in to comment.