From 5d685e7a5c5d2705591d908ec985b6cc8994c4d9 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Tue, 2 Jul 2019 15:26:02 -0700 Subject: [PATCH] compilers: put elbrus in mixins --- mesonbuild/compilers/c.py | 2 +- mesonbuild/compilers/compilers.py | 40 ------------------ mesonbuild/compilers/cpp.py | 2 +- mesonbuild/compilers/fortran.py | 2 +- mesonbuild/compilers/mixins/elbrus.py | 59 +++++++++++++++++++++++++++ 5 files changed, 62 insertions(+), 43 deletions(-) create mode 100644 mesonbuild/compilers/mixins/elbrus.py diff --git a/mesonbuild/compilers/c.py b/mesonbuild/compilers/c.py index 336dc98b3..f787f2019 100644 --- a/mesonbuild/compilers/c.py +++ b/mesonbuild/compilers/c.py @@ -25,12 +25,12 @@ from .mixins.visualstudio import VisualStudioLikeCompiler from .mixins.gnu import GnuCompiler from .mixins.intel import IntelGnuLikeCompiler, IntelVisualStudioLikeCompiler from .mixins.clang import ClangCompiler +from .mixins.elbrus import ElbrusCompiler from .compilers import ( gnu_winlibs, msvc_winlibs, Compiler, CompilerType, - ElbrusCompiler, PGICompiler, ) diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py index b19eb4d25..6e914a61d 100644 --- a/mesonbuild/compilers/compilers.py +++ b/mesonbuild/compilers/compilers.py @@ -27,7 +27,6 @@ from ..mesonlib import ( from ..envconfig import ( Properties, ) -from .mixins.gnu import GnuCompiler """This file contains the data files of all compilers Meson knows about. To support a new compiler, add its information below. @@ -1342,42 +1341,3 @@ class PGICompiler: def get_always_args(self): return [] - - -class ElbrusCompiler(GnuCompiler): - # Elbrus compiler is nearly like GCC, but does not support - # PCH, LTO, sanitizers and color output as of version 1.21.x. - def __init__(self, compiler_type, defines): - GnuCompiler.__init__(self, compiler_type, defines) - self.id = 'lcc' - self.base_options = ['b_pgo', 'b_coverage', - 'b_ndebug', 'b_staticpic', - 'b_lundef', 'b_asneeded'] - - # FIXME: use _build_wrapper to call this so that linker flags from the env - # get applied - def get_library_dirs(self, env, elf_class = None): - os_env = os.environ.copy() - os_env['LC_ALL'] = 'C' - stdo = Popen_safe(self.exelist + ['--print-search-dirs'], env=os_env)[1] - paths = () - for line in stdo.split('\n'): - if line.startswith('libraries:'): - # lcc does not include '=' in --print-search-dirs output. - libstr = line.split(' ', 1)[1] - paths = (os.path.realpath(p) for p in libstr.split(':')) - break - return paths - - def get_program_dirs(self, env): - os_env = os.environ.copy() - os_env['LC_ALL'] = 'C' - stdo = Popen_safe(self.exelist + ['--print-search-dirs'], env=os_env)[1] - paths = () - for line in stdo.split('\n'): - if line.startswith('programs:'): - # lcc does not include '=' in --print-search-dirs output. - libstr = line.split(' ', 1)[1] - paths = (os.path.realpath(p) for p in libstr.split(':')) - break - return paths diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py index bf1c4894c..e1eecbe0f 100644 --- a/mesonbuild/compilers/cpp.py +++ b/mesonbuild/compilers/cpp.py @@ -24,7 +24,6 @@ from ..mesonlib import MesonException, MachineChoice, version_compare from .compilers import ( gnu_winlibs, msvc_winlibs, - ElbrusCompiler, PGICompiler, Compiler, ) @@ -36,6 +35,7 @@ from .mixins.visualstudio import VisualStudioLikeCompiler from .mixins.gnu import GnuCompiler from .mixins.intel import IntelGnuLikeCompiler, IntelVisualStudioLikeCompiler from .mixins.clang import ClangCompiler +from .mixins.elbrus import ElbrusCompiler def non_msvc_eh_options(eh, args): diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py index 93f991010..d519d8e0d 100644 --- a/mesonbuild/compilers/fortran.py +++ b/mesonbuild/compilers/fortran.py @@ -19,7 +19,6 @@ from .compilers import ( CompilerType, clike_debug_args, Compiler, - ElbrusCompiler, PGICompiler, ) from .mixins.clike import CLikeCompiler @@ -29,6 +28,7 @@ from .mixins.gnu import ( ) from .mixins.intel import IntelGnuLikeCompiler, IntelVisualStudioLikeCompiler from .mixins.clang import ClangCompiler +from .mixins.elbrus import ElbrusCompiler from .. import mlog from mesonbuild.mesonlib import ( diff --git a/mesonbuild/compilers/mixins/elbrus.py b/mesonbuild/compilers/mixins/elbrus.py new file mode 100644 index 000000000..a254a8b83 --- /dev/null +++ b/mesonbuild/compilers/mixins/elbrus.py @@ -0,0 +1,59 @@ +# Copyright 2019 The meson development team +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Abstractions for the Elbrus family of compilers.""" + +import os + +from .gnu import GnuCompiler +from ...mesonlib import Popen_safe + + +class ElbrusCompiler(GnuCompiler): + # Elbrus compiler is nearly like GCC, but does not support + # PCH, LTO, sanitizers and color output as of version 1.21.x. + def __init__(self, compiler_type, defines): + GnuCompiler.__init__(self, compiler_type, defines) + self.id = 'lcc' + self.base_options = ['b_pgo', 'b_coverage', + 'b_ndebug', 'b_staticpic', + 'b_lundef', 'b_asneeded'] + + # FIXME: use _build_wrapper to call this so that linker flags from the env + # get applied + def get_library_dirs(self, env, elf_class = None): + os_env = os.environ.copy() + os_env['LC_ALL'] = 'C' + stdo = Popen_safe(self.exelist + ['--print-search-dirs'], env=os_env)[1] + paths = () + for line in stdo.split('\n'): + if line.startswith('libraries:'): + # lcc does not include '=' in --print-search-dirs output. + libstr = line.split(' ', 1)[1] + paths = (os.path.realpath(p) for p in libstr.split(':')) + break + return paths + + def get_program_dirs(self, env): + os_env = os.environ.copy() + os_env['LC_ALL'] = 'C' + stdo = Popen_safe(self.exelist + ['--print-search-dirs'], env=os_env)[1] + paths = () + for line in stdo.split('\n'): + if line.startswith('programs:'): + # lcc does not include '=' in --print-search-dirs output. + libstr = line.split(' ', 1)[1] + paths = (os.path.realpath(p) for p in libstr.split(':')) + break + return paths \ No newline at end of file