aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/build.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-04-02 00:15:22 +0300
committerGitHub <noreply@github.com>2017-04-02 00:15:22 +0300
commitc7f66c3a9e4f69e0bcde8819f15c9d8b972a2f75 (patch)
tree95785dfa61d2d01925f66498e16f4d4cadeb9760 /mesonbuild/build.py
parentd2548e6e839b2058aae7f242db35d6836ccbeef7 (diff)
parent8df671b6f3995ed3f31409677464fa2f8fd81af9 (diff)
downloadmeson-c7f66c3a9e4f69e0bcde8819f15c9d8b972a2f75.zip
meson-c7f66c3a9e4f69e0bcde8819f15c9d8b972a2f75.tar.gz
meson-c7f66c3a9e4f69e0bcde8819f15c9d8b972a2f75.tar.bz2
Merge pull request #1505 from centricular/dont-use-c++-for-assembly
Try harder to use the C compiler for compiling asm
Diffstat (limited to 'mesonbuild/build.py')
-rw-r--r--mesonbuild/build.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 41e21e3..ce5638d 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -12,15 +12,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import copy, os, re
+from collections import OrderedDict
+
from . import environment
from . import dependencies
from . import mlog
-import copy, os, re
from .mesonlib import File, MesonException
from .mesonlib import flatten, stringlistify, classify_unity_sources
from .mesonlib import get_filenames_templates_dict, substitute_values
from .environment import for_windows, for_darwin
-from .compilers import is_object, clike_langs, lang_suffixes
+from .compilers import is_object, clike_langs, sort_clike, lang_suffixes
known_basic_kwargs = {'install': True,
'c_pch': True,
@@ -291,7 +293,7 @@ class BuildTarget(Target):
self.is_unity = environment.coredata.get_builtin_option('unity')
self.environment = environment
self.sources = []
- self.compilers = {}
+ self.compilers = OrderedDict()
self.objects = []
self.external_deps = []
self.include_dirs = []
@@ -391,13 +393,6 @@ class BuildTarget(Target):
raise InvalidArguments(msg)
@staticmethod
- def can_compile_sources(compiler, sources):
- for s in sources:
- if compiler.can_compile(s):
- return True
- return False
-
- @staticmethod
def can_compile_remove_sources(compiler, sources):
removed = False
for s in sources[:]:
@@ -442,13 +437,18 @@ class BuildTarget(Target):
if not s.endswith(lang_suffixes['vala']):
sources.append(s)
if sources:
- # Add compilers based on the above sources
- for lang, compiler in compilers.items():
- # We try to be conservative because sometimes people add files
- # in the list of sources that we can't determine the type based
- # just on the suffix.
- if self.can_compile_sources(compiler, sources):
- self.compilers[lang] = compiler
+ # For each source, try to add one compiler that can compile it.
+ # It's ok if no compilers can do so, because users are expected to
+ # be able to add arbitrary non-source files to the sources list.
+ for s in sources:
+ for lang, compiler in compilers.items():
+ if compiler.can_compile(s):
+ if lang not in self.compilers:
+ self.compilers[lang] = compiler
+ break
+ # Re-sort according to clike_langs
+ self.compilers = OrderedDict(sorted(self.compilers.items(),
+ key=lambda t: sort_clike(t[0])))
else:
# No source files, target consists of only object files of unknown
# origin. Just add the first clike compiler that we have and hope