Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
lasote committed Feb 27, 2018
2 parents 5c0e6bb + 79563f2 commit 6c51957
Show file tree
Hide file tree
Showing 112 changed files with 3,626 additions and 729 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.4'
__version__ = '1.1.0'
143 changes: 72 additions & 71 deletions conans/client/build/autotools_environment.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,18 @@
import copy
import platform
import os
import platform

from conans.client import join_arguments
from conans.tools import environment_append, args_to_string, cpu_count, cross_building, detected_architecture
from conans.client.tools.win import unix_path
from conans.client.build.compiler_flags import (architecture_flag, format_libraries,
format_library_paths, format_defines,
sysroot_flag, format_include_paths,
build_type_flag, libcxx_flag, build_type_define,
libcxx_define, pic_flag, rpath_flags)
from conans.client.build.cppstd_flags import cppstd_flag
from conans.client.tools.oss import OSInfo

sun_cc_libcxx_flags_dict = {"libCstd": "-library=Cstd",
"libstdcxx": "-library=stdcxx4",
"libstlport": "-library=stlport4",
"libstdc++": "-library=stdcpp"}

architecture_dict = {"x86_64": "-m64", "x86": "-m32"}


def stdlib_flags(compiler, libcxx):
ret = []
if compiler and "clang" in compiler:
if libcxx == "libc++":
ret.append("-stdlib=libc++")
else:
ret.append("-stdlib=libstdc++")
elif compiler == "sun-cc":
flag = sun_cc_libcxx_flags_dict.get(libcxx, None)
if flag:
ret.append(flag)
return ret


def stdlib_defines(compiler, libcxx):
ret = []
if compiler == "gcc" or compiler == "clang": # Maybe clang is using the standard library from g++
if libcxx == "libstdc++":
ret.append("_GLIBCXX_USE_CXX11_ABI=0")
elif str(libcxx) == "libstdc++11":
ret.append("_GLIBCXX_USE_CXX11_ABI=1")
return ret
from conans.client.tools.win import unix_path
from conans.tools import (environment_append, args_to_string, cpu_count, cross_building,
detected_architecture)


class AutoToolsBuildEnvironment(object):
Expand All @@ -47,15 +23,21 @@ class AutoToolsBuildEnvironment(object):
- LDFLAGS (-L, others like -m64 -m32) linker
"""

def __init__(self, conanfile, win_bash=False):
def __init__(self, conanfile, win_bash=False, include_rpath_flags=False):
"""
FIXME: include_rpath_flags CONAN 2.0 to default True? Could break many packages in center
"""
self._conanfile = conanfile
self._win_bash = win_bash
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._arch = conanfile.settings.get_safe("arch")
self._build_type = conanfile.settings.get_safe("build_type")
self._compiler = conanfile.settings.get_safe("compiler")
self._compiler_version = conanfile.settings.get_safe("compiler.version")
self._libcxx = conanfile.settings.get_safe("compiler.libcxx")
self._cppstd = conanfile.settings.get_safe("cppstd")

# Set the generic objects before mapping to env vars to let the user
# alter some value
Expand All @@ -68,6 +50,8 @@ def __init__(self, conanfile, win_bash=False):
self.flags = self._configure_flags()
# Only c++ flags [-stdlib, -library], will go to CXXFLAGS
self.cxx_flags = self._configure_cxx_flags()
# cpp standard
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
Expand Down Expand Up @@ -122,8 +106,10 @@ def configure(self, configure_dir=None, args=None, build=None, host=None, target
:param args: Optional arguments to pass to configure.
:param build: In which system the program will be built. "False" skips the --build flag
:param host: In which system the generated program will run. "False" skips the --host flag
:param target: This option is only used to build a cross-compiling toolchain. "False" skips the --target flag
When the tool chain generates executable program, in which target system the program will run.
:param target: This option is only used to build a cross-compiling toolchain.
"False" skips the --target flag
When the tool chain generates executable program, in which target system
the program will run.
:return: None
http://jingfenghanmax.blogspot.com.es/2010/09/configure-with-host-target-and-build.html
Expand All @@ -136,9 +122,8 @@ def configure(self, configure_dir=None, args=None, build=None, host=None, target
configure_dir = "."
auto_build, auto_host, auto_target = None, None, None
if build is None or host is None or target is None:
auto_build, auto_host, auto_target = self._get_host_build_target_flags(detected_architecture(),
platform.system())

flags = self._get_host_build_target_flags(detected_architecture(), platform.system())
auto_build, auto_host, auto_target = flags
triplet_args = []

if build is not False: # Skipped by user
Expand Down Expand Up @@ -174,60 +159,74 @@ def _adjust_path(self, path):
path = unix_path(path, path_flavor=self.subsystem)
return '"%s"' % path if " " in path else path

def make(self, args="", make_program=None):
def make(self, args="", make_program=None, target=None):
make_program = os.getenv("CONAN_MAKE_PROGRAM") or make_program or "make"
with environment_append(self.vars):
str_args = args_to_string(args)
cpu_count_option = ("-j%s" % cpu_count()) if "-j" not in str_args else None
self._conanfile.run("%s" % join_arguments([make_program, str_args, cpu_count_option]),
self._conanfile.run("%s" % join_arguments([make_program, target, str_args,
cpu_count_option]),
win_bash=self._win_bash, subsystem=self.subsystem)

@property
def _sysroot_flag(self):
return "--sysroot=%s" % self._adjust_path(self._deps_cpp_info.sysroot) if self._deps_cpp_info.sysroot else None

def _configure_link_flags(self):
"""Not the -L"""
ret = copy.copy(self._deps_cpp_info.sharedlinkflags)
ret.extend(self._deps_cpp_info.exelinkflags)
ret.append(self._architecture_flag)
if self._sysroot_flag:
ret.append(self._sysroot_flag)
arch_flag = architecture_flag(compiler=self._compiler, arch=self._arch)
if arch_flag:
ret.append(arch_flag)

sysf = sysroot_flag(self._deps_cpp_info.sysroot, win_bash=self._win_bash,
subsystem=self.subsystem,
compiler=self._compiler)
if sysf:
ret.append(sysf)

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

return ret

def _configure_flags(self):
ret = copy.copy(self._deps_cpp_info.cflags)
ret.append(self._architecture_flag)
if self._build_type == "Debug":
ret.append("-g") # default debug information
elif self._build_type == "Release" and self._compiler == "gcc":
# Remove all symbol table and relocation information from the executable.
ret.append("-s")
if self._sysroot_flag:
ret.append(self._sysroot_flag)
arch_flag = architecture_flag(compiler=self._compiler, arch=self._arch)
if arch_flag:
ret.append(arch_flag)
btf = build_type_flag(compiler=self._compiler, build_type=self._build_type)
if btf:
ret.append(btf)
srf = sysroot_flag(self._deps_cpp_info.sysroot, win_bash=self._win_bash,
subsystem=self.subsystem,
compiler=self._compiler)
if srf:
ret.append(srf)

return ret

def _configure_cxx_flags(self):
ret = copy.copy(self._deps_cpp_info.cppflags)
ret.extend(stdlib_flags(self._compiler, self._libcxx))
cxxf = libcxx_flag(compiler=self._compiler, libcxx=self._libcxx)
if cxxf:
ret.append(cxxf)
return ret

def _configure_defines(self):
# requires declared defines
ret = copy.copy(self._deps_cpp_info.defines)

# Debug definition for GCC
if self._build_type == "Release" and self._compiler == "gcc":
ret.append("NDEBUG")
btf = build_type_define(build_type=self._build_type)
if btf:
ret.append(btf)

# CXX11 ABI
ret.extend(stdlib_defines(self._compiler, self._libcxx))
abif = libcxx_define(compiler=self._compiler, libcxx=self._libcxx)
if abif:
ret.append(abif)
return ret

@property
def _architecture_flag(self):
return architecture_dict.get(self._arch, "")

def _get_vars(self):
def append(*args):
ret = []
Expand All @@ -239,18 +238,20 @@ def append(*args):
ret.append(arg)
return ret

lib_paths = ['-L%s' % self._adjust_path(x.replace("\\", "/")) for x in self.library_paths]
include_paths = ['-I%s' % self._adjust_path(x.replace("\\", "/")) for x in self.include_paths]
lib_paths = format_library_paths(self.library_paths, win_bash=self._win_bash,
subsystem=self.subsystem, compiler=self._compiler)
include_paths = format_include_paths(self.include_paths, win_bash=self._win_bash,
subsystem=self.subsystem, compiler=self._compiler)

ld_flags = append(self.link_flags, lib_paths)
cpp_flags = append(include_paths, ["-D%s" % x for x in self.defines])
libs = ['-l%s' % lib for lib in self.libs]
cpp_flags = append(include_paths, format_defines(self.defines, self._compiler))
libs = format_libraries(self.libs, compiler=self._compiler)

tmp_compilation_flags = copy.copy(self.flags)
if self.fpic:
tmp_compilation_flags.append("-fPIC")
tmp_compilation_flags.append(pic_flag(self._compiler))

cxx_flags = append(tmp_compilation_flags, self.cxx_flags)
cxx_flags = append(tmp_compilation_flags, self.cxx_flags, self.cppstd_flag)
c_flags = tmp_compilation_flags

return ld_flags, cpp_flags, libs, cxx_flags, c_flags
Expand Down
Loading

0 comments on commit 6c51957

Please sign in to comment.