Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleaning gnu toolchain #8880

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion conan/tools/cmake/cmakedeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from jinja2 import Template

from conans.errors import ConanException
from conans.model.new_build_info import NewCppInfo
from conans.util.files import save

conan_message = textwrap.dedent("""
Expand Down
1 change: 0 additions & 1 deletion conan/tools/gnu/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from .make import MakeToolchain
from conan.tools.gnu.autotoolstoolchain import AutotoolsToolchain
from conan.tools.gnu.autotoolsdeps import AutotoolsDeps
from conan.tools.gnu.autotools import Autotools
Expand Down
29 changes: 2 additions & 27 deletions conan/tools/gnu/cross_building.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,8 @@
import warnings
from collections import namedtuple

from conan.tools.gnu.get_cross_building_settings import _get_cross_building_settings
from conans.errors import ConanException


def _cross_building(conanfile=None, self_os=None, self_arch=None, skip_x64_x86=False, settings=None):
# Handle input arguments (backwards compatibility with 'settings' as first argument)
# TODO: This can be promoted to a decorator pattern for tools if we adopt 'conanfile' as the
# first argument for all of them.
if conanfile and settings:
raise ConanException("Do not set both arguments, 'conanfile' and 'settings',"
" to call cross_building function")

from conans.model.conan_file import ConanFile
if conanfile and not isinstance(conanfile, ConanFile):
return _cross_building(settings=conanfile, self_os=self_os, self_arch=self_arch,
skip_x64_x86=skip_x64_x86)

if settings:
warnings.warn("Argument 'settings' has been deprecated, use 'conanfile' instead")

if conanfile:
ret = _get_cross_building_settings(conanfile, self_os, self_arch)
else:
# TODO: If Conan is using 'profile_build' here we don't have any information about it,
# we are falling back to the old behavior (which is probably wrong here)
conanfile = namedtuple('_ConanFile', ['settings'])(settings)
ret = _get_cross_building_settings(conanfile, self_os, self_arch)
def _cross_building(conanfile, self_os=None, self_arch=None, skip_x64_x86=False):
ret = _get_cross_building_settings(conanfile, self_os, self_arch)

build_os, build_arch, host_os, host_arch = ret

Expand Down
20 changes: 15 additions & 5 deletions conan/tools/gnu/get_cross_building_settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os
import platform

from conans.errors import ConanException
from conans.model.version import Version
from conans.util.runners import check_output_runner


class _OSInfo(object):
Expand All @@ -26,7 +28,7 @@ class _OSInfo(object):
def __init__(self):
system = platform.system()
self.os_version = None
self.os_version_name = None

self.is_linux = system == "Linux"
self.linux_distro = None
self.is_msys = system.startswith("MING") or system.startswith("MSYS_NT")
Expand All @@ -42,10 +44,6 @@ def _get_linux_distro_info(self):
import distro
self.linux_distro = distro.id()
self.os_version = Version(distro.version())
version_name = distro.codename()
self.os_version_name = version_name if version_name != "n/a" else ""
if not self.os_version_name and self.linux_distro == "debian":
self.os_version_name = self.get_debian_version_name(self.os_version)

@staticmethod
def get_aix_architecture():
Expand All @@ -57,6 +55,18 @@ def get_aix_architecture():
elif "rs6000" in processor:
return "ppc32"

@staticmethod
def get_aix_conf(options=None):
options = " %s" % options if options else ""
if not _OSInfo().is_aix:
raise ConanException("Command only for AIX operating system")

try:
ret = check_output_runner("getconf%s" % options).strip()
return ret
except Exception:
return None

@staticmethod
def get_solaris_architecture():
# under intel solaris, platform.machine()=='i86pc' so we need to handle
Expand Down
78 changes: 0 additions & 78 deletions conan/tools/gnu/make.py
Original file line number Diff line number Diff line change
@@ -1,83 +1,5 @@
import platform
import textwrap
from collections import OrderedDict

from jinja2 import Template

from conans.client.build.compiler_flags import build_type_define, libcxx_define
from conans.client.tools.oss import detected_architecture, detected_os, get_build_os_arch
from conans.util.files import save


def make_jobs_cmd_line_arg(conanfile):
njobs = conanfile.conf["tools.gnu.make"].jobs or \
conanfile.conf["tools.build"].processes
if njobs:
return "-j{}".format(njobs)


class MakeToolchain(object):
filename = "conan_toolchain.mak"

_template_toolchain = textwrap.dedent("""
# Conan generated toolchain file
ifndef CONAN_TOOLCHAIN_INCLUDED
CONAN_TOOLCHAIN_INCLUDED = TRUE

# Recipe-Defined Variables
{%- for it, value in variables.items() %}
{{ it }} = {{ value }}
{%- endfor %}

# Automatic Conan pre-processor definition: build_type_define
{%- if build_type_define %}
CONAN_TC_CPPFLAGS += -D{{build_type_define}}
{%- endif %}

# Automatic Conan pre-processor definition: glibcxx_define
{%- if glibcxx_define %}
CONAN_TC_CPPFLAGS += -D{{glibcxx_define}}
{%- endif %}

# Recipe-Defined pre-processor definitions
{%- if preprocessor_definitions %}
CONAN_TC_CPPFLAGS = -D{{ preprocessor_definitions|join(" -D")}}
{%- endif %}

endif

""")

def __init__(self, conanfile):
self._conanfile = conanfile
self._build_type = conanfile.settings.get_safe("build_type")

self._build_type_define = build_type_define(build_type=self._build_type)
self._glibcxx_define = libcxx_define(self._conanfile.settings)

self.variables = OrderedDict()
self.preprocessor_definitions = OrderedDict()

def _get_build_os_arch(self):
if hasattr(self._conanfile, 'settings_build'):
os_build, arch_build = get_build_os_arch(self._conanfile)
else:
# FIXME: Why not use 'os_build' and 'arch_build' from conanfile.settings?
os_build = detected_os() or platform.system()
arch_build = detected_architecture() or platform.machine()
return arch_build, os_build

def generate(self):
save(self.filename, self.content)

@property
def content(self):
context = {
"variables": self.variables,
"glibcxx_define": self._glibcxx_define,
"build_type_define": self._build_type_define,
"preprocessor_definitions": self.preprocessor_definitions,
}
t = Template(self._template_toolchain)
content = t.render(**context)
return content
Empty file removed conan/tools/oss/__init__.py
Empty file.
5 changes: 1 addition & 4 deletions conans/client/generators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self):
"make": MakeGenerator,
"deploy": DeployGenerator,
"markdown": MarkdownGenerator}
self._new_generators = ["CMakeToolchain", "CMakeDeps", "MakeToolchain", "MSBuildToolchain",
self._new_generators = ["CMakeToolchain", "CMakeDeps", "MSBuildToolchain",
"MesonToolchain", "MSBuildDeps", "QbsToolchain", "msbuild",
"VirtualEnv", "AutotoolsDeps", "AutotoolsToolchain", "AutotoolsGen"]

Expand Down Expand Up @@ -93,9 +93,6 @@ def _new_generator(self, generator_name, output):
elif generator_name == "CMakeDeps":
from conan.tools.cmake import CMakeDeps
return CMakeDeps
elif generator_name == "MakeToolchain":
from conan.tools.gnu import MakeToolchain
return MakeToolchain
elif generator_name == "AutotoolsDeps":
from conan.tools.gnu import AutotoolsDeps
return AutotoolsDeps
Expand Down