parent
bda799dff2
commit
18cfa545f0
14 changed files with 571 additions and 5 deletions
@ -0,0 +1,28 @@ |
||||
# This file assumes that the path to your Metrowerks Embedded ARM |
||||
# toolchain is added to the environment(PATH) variable, so that |
||||
# Meson can find the binaries while building. |
||||
|
||||
# You should also do one of the following to ensure Meson can |
||||
# locate the .lcf linker script: |
||||
# - Add the cross directory to PATH as well |
||||
# - Edit c_link_args and cpp_link_args with the full |
||||
# path to the .lcf file on your machine |
||||
|
||||
[binaries] |
||||
c = 'mwccarm' |
||||
c_ld = 'mwldarm' |
||||
cpp = 'mwccarm' |
||||
cpp_ld = 'mwldarm' |
||||
ar = 'mwldarm' |
||||
as = 'mwasmarm' |
||||
|
||||
[built-in options] |
||||
c_args = ['-lang', 'c99', '-D_NITRO', '-nosyspath'] |
||||
c_link_args = 'metrowerks.lcf' |
||||
cpp_args = ['-lang', 'c++', '-D_NITRO', '-nosyspath'] |
||||
cpp_link_args = 'metrowerks.lcf' |
||||
|
||||
[host_machine] |
||||
system = 'bare metal' |
||||
cpu_family = 'arm' |
||||
endian = 'little' |
@ -0,0 +1,28 @@ |
||||
# This file assumes that the path to your Metrowerks toolchain |
||||
# of choice is added to the environment(PATH) variable, so that |
||||
# Meson can find the binaries while building. |
||||
|
||||
# You should also do one of the following to ensure Meson can |
||||
# locate the .lcf linker script: |
||||
# - Add the cross directory to PATH as well |
||||
# - Edit c_link_args and cpp_link_args with the full |
||||
# path to the lcf file on your machine |
||||
|
||||
[binaries] |
||||
c = 'mwcceppc' |
||||
c_ld = 'mwldeppc' |
||||
cpp = 'mwcceppc' |
||||
cpp_ld = 'mwldeppc' |
||||
ar = 'mwldeppc' |
||||
as = 'mwasmeppc' |
||||
|
||||
[built-in options] |
||||
c_args = ['-lang', 'c99', '-nosyspath'] |
||||
c_link_args = 'metrowerks.lcf' |
||||
cpp_args = ['-lang', 'c++', '-nosyspath'] |
||||
cpp_link_args = 'metrowerks.lcf' |
||||
|
||||
[host_machine] |
||||
system = 'bare metal' |
||||
cpu_family = 'ppc' |
||||
endian = 'little' |
@ -0,0 +1,18 @@ |
||||
# General-purpose linker script for Metrowerks toolchains. |
||||
# This script will link a blank application. Its only purpose |
||||
# is to allow the toolchains to run Meson tests. To link an |
||||
# actual application, you need to write your own fine-tuned lcf. |
||||
|
||||
MEMORY { |
||||
TEST (RWX) : ORIGIN=0, LENGTH=0 |
||||
} |
||||
|
||||
SECTIONS { |
||||
.TEST:{ |
||||
* (.text) |
||||
* (.data) |
||||
* (.rodata) |
||||
* (.bss) |
||||
__startup=.; |
||||
} > TEST |
||||
} |
@ -0,0 +1,5 @@ |
||||
## Added Metrowerks C/C++ toolchains |
||||
|
||||
Added support for the Metrowerks Embedded ARM and Metrowerks Embedded PowerPC toolchains (https://www.nxp.com/docs/en/reference-manual/CWMCUKINCMPREF.pdf). |
||||
|
||||
The implementation is somewhat experimental. It has been tested on a few projects and works fairly well, but may have issues. |
@ -0,0 +1,232 @@ |
||||
# Copyright 2012-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. |
||||
from __future__ import annotations |
||||
|
||||
"""Representations specific to the Metrowerks/Freescale Embedded C/C++ compiler family.""" |
||||
|
||||
import os |
||||
import typing as T |
||||
|
||||
from ...mesonlib import EnvironmentException, OptionKey |
||||
|
||||
if T.TYPE_CHECKING: |
||||
from ...envconfig import MachineInfo |
||||
from ...compilers.compilers import Compiler, CompileCheckMode |
||||
else: |
||||
# This is a bit clever, for mypy we pretend that these mixins descend from |
||||
# Compiler, so we get all of the methods and attributes defined for us, but |
||||
# for runtime we make them descend from object (which all classes normally |
||||
# do). This gives up DRYer type checking, with no runtime impact |
||||
Compiler = object |
||||
|
||||
mwcc_buildtype_args = { |
||||
'plain': [], |
||||
'debug': ['-g'], |
||||
'debugoptimized': ['-g', '-O4'], |
||||
'release': ['-O4,p'], |
||||
'minsize': ['-Os'], |
||||
'custom': [], |
||||
} # type: T.Dict[str, T.List[str]] |
||||
|
||||
mwccarm_instruction_set_args = { |
||||
'generic': ['-proc', 'generic'], |
||||
'v4': ['-proc', 'v4'], |
||||
'v4t': ['-proc', 'v4t'], |
||||
'v5t': ['-proc', 'v5t'], |
||||
'v5te': ['-proc', 'v5te'], |
||||
'v6': ['-proc', 'v6'], |
||||
'arm7tdmi': ['-proc', 'arm7tdmi'], |
||||
'arm710t': ['-proc', 'arm710t'], |
||||
'arm720t': ['-proc', 'arm720t'], |
||||
'arm740t': ['-proc', 'arm740t'], |
||||
'arm7ej': ['-proc', 'arm7ej'], |
||||
'arm9tdmi': ['-proc', 'arm9tdmi'], |
||||
'arm920t': ['-proc', 'arm920t'], |
||||
'arm922t': ['-proc', 'arm922t'], |
||||
'arm940t': ['-proc', 'arm940t'], |
||||
'arm9ej': ['-proc', 'arm9ej'], |
||||
'arm926ej': ['-proc', 'arm926ej'], |
||||
'arm946e': ['-proc', 'arm946e'], |
||||
'arm966e': ['-proc', 'arm966e'], |
||||
'arm1020e': ['-proc', 'arm1020e'], |
||||
'arm1022e': ['-proc', 'arm1022e'], |
||||
'arm1026ej': ['-proc', 'arm1026ej'], |
||||
'dbmx1': ['-proc', 'dbmx1'], |
||||
'dbmxl': ['-proc', 'dbmxl'], |
||||
'XScale': ['-proc', 'XScale'], |
||||
'pxa255': ['-proc', 'pxa255'], |
||||
'pxa261': ['-proc', 'pxa261'], |
||||
'pxa262': ['-proc', 'pxa262'], |
||||
'pxa263': ['-proc', 'pxa263'] |
||||
} # type: T.Dict[str, T.List[str]] |
||||
|
||||
mwcceppc_instruction_set_args = { |
||||
'generic': ['-proc', 'generic'], |
||||
'401': ['-proc', '401'], |
||||
'403': ['-proc', '403'], |
||||
'505': ['-proc', '505'], |
||||
'509': ['-proc', '509'], |
||||
'555': ['-proc', '555'], |
||||
'601': ['-proc', '601'], |
||||
'602': ['-proc', '602'], |
||||
'603': ['-proc', '603'], |
||||
'603e': ['-proc', '603e'], |
||||
'604': ['-proc', '604'], |
||||
'604e': ['-proc', '604e'], |
||||
'740': ['-proc', '740'], |
||||
'750': ['-proc', '750'], |
||||
'801': ['-proc', '801'], |
||||
'821': ['-proc', '821'], |
||||
'823': ['-proc', '823'], |
||||
'850': ['-proc', '850'], |
||||
'860': ['-proc', '860'], |
||||
'7400': ['-proc', '7400'], |
||||
'7450': ['-proc', '7450'], |
||||
'8240': ['-proc', '8240'], |
||||
'8260': ['-proc', '8260'], |
||||
'e500': ['-proc', 'e500'], |
||||
'gekko': ['-proc', 'gekko'], |
||||
} # type: T.Dict[str, T.List[str]] |
||||
|
||||
mwcc_optimization_args = { |
||||
'plain': [], |
||||
'0': ['-O0'], |
||||
'g': ['-Op'], |
||||
'1': ['-O1'], |
||||
'2': ['-O2'], |
||||
'3': ['-O3'], |
||||
's': ['-Os'] |
||||
} # type: T.Dict[str, T.List[str]] |
||||
|
||||
mwcc_debug_args = { |
||||
False: [], |
||||
True: ['-g'] |
||||
} # type: T.Dict[bool, T.List[str]] |
||||
|
||||
|
||||
class MetrowerksCompiler(Compiler): |
||||
id = 'mwcc' |
||||
|
||||
# These compilers can actually invoke the linker, but they choke on |
||||
# linker-specific flags. So it's best to invoke the linker directly |
||||
INVOKES_LINKER = False |
||||
|
||||
def __init__(self) -> None: |
||||
if not self.is_cross: |
||||
raise EnvironmentException(f'{id} supports only cross-compilation.') |
||||
|
||||
self.base_options = { |
||||
OptionKey(o) for o in ['b_pch', 'b_ndebug']} |
||||
|
||||
default_warn_args = [] # type: T.List[str] |
||||
self.warn_args = {'0': ['-w', 'off'], |
||||
'1': default_warn_args, |
||||
'2': default_warn_args + ['-w', 'most'], |
||||
'3': default_warn_args + ['-w', 'all'], |
||||
'everything': default_warn_args + ['-w', 'full']} # type: T.Dict[str, T.List[str]] |
||||
|
||||
def depfile_for_object(self, objfile: str) -> T.Optional[str]: |
||||
# Earlier versions of these compilers do not support specifying |
||||
# a custom name for a depfile, and can only generate '<input_file>.d' |
||||
return os.path.splitext(objfile)[0] + '.' + self.get_depfile_suffix() |
||||
|
||||
def get_always_args(self) -> T.List[str]: |
||||
return ['-gccinc'] |
||||
|
||||
def get_buildtype_args(self, buildtype: str) -> T.List[str]: |
||||
return mwcc_buildtype_args[buildtype] |
||||
|
||||
def get_compiler_check_args(self, mode: CompileCheckMode) -> T.List[str]: |
||||
return [] |
||||
|
||||
def get_compile_only_args(self) -> T.List[str]: |
||||
return ['-c'] |
||||
|
||||
def get_debug_args(self, is_debug: bool) -> T.List[str]: |
||||
return mwcc_debug_args[is_debug] |
||||
|
||||
def get_dependency_gen_args(self, outtarget: str, outfile: str) -> T.List[str]: |
||||
# Check comment in depfile_for_object() |
||||
return ['-gccdep', '-MD'] |
||||
|
||||
def get_depfile_suffix(self) -> str: |
||||
return 'd' |
||||
|
||||
def get_include_args(self, path: str, is_system: bool) -> T.List[str]: |
||||
if not path: |
||||
path = '.' |
||||
return ['-I' + path] |
||||
|
||||
def get_no_optimization_args(self) -> T.List[str]: |
||||
return ['-opt', 'off'] |
||||
|
||||
def get_no_stdinc_args(self) -> T.List[str]: |
||||
return ['-nostdinc'] |
||||
|
||||
def get_no_stdlib_link_args(self) -> T.List[str]: |
||||
return ['-nostdlib'] |
||||
|
||||
def get_optimization_args(self, optimization_level: str) -> T.List[str]: |
||||
return mwcc_optimization_args[optimization_level] |
||||
|
||||
def get_output_args(self, target: str) -> T.List[str]: |
||||
return ['-o', target] |
||||
|
||||
def get_pic_args(self) -> T.List[str]: |
||||
return ['-pic'] |
||||
|
||||
def get_preprocess_only_args(self) -> T.List[str]: |
||||
return ['-E'] |
||||
|
||||
def get_preprocess_to_file_args(self) -> T.List[str]: |
||||
return ['-P'] |
||||
|
||||
def get_pch_use_args(self, pch_dir: str, header: str) -> T.List[str]: |
||||
return ['-prefix', self.get_pch_name(header)] |
||||
|
||||
def get_pch_name(self, name: str) -> str: |
||||
return os.path.basename(name) + '.' + self.get_pch_suffix() |
||||
|
||||
def get_pch_suffix(self) -> str: |
||||
return 'mch' |
||||
|
||||
def get_warn_args(self, level: str) -> T.List[str]: |
||||
return self.warn_args[level] |
||||
|
||||
def get_werror_args(self) -> T.List[str]: |
||||
return ['-w', 'error'] |
||||
|
||||
@classmethod |
||||
def _unix_args_to_native(cls, args: T.List[str], info: MachineInfo) -> T.List[str]: |
||||
result = [] |
||||
for i in args: |
||||
if i.startswith('-D'): |
||||
i = '-D' + i[2:] |
||||
if i.startswith('-I'): |
||||
i = '-I' + i[2:] |
||||
if i.startswith('-Wl,-rpath='): |
||||
continue |
||||
elif i == '--print-search-dirs': |
||||
continue |
||||
elif i.startswith('-L'): |
||||
continue |
||||
result.append(i) |
||||
return result |
||||
|
||||
def compute_parameters_with_absolute_paths(self, parameter_list: T.List[str], build_dir: str) -> T.List[str]: |
||||
for idx, i in enumerate(parameter_list): |
||||
if i[:2] == '-I': |
||||
parameter_list[idx] = i[:9] + os.path.normpath(os.path.join(build_dir, i[9:])) |
||||
|
||||
return parameter_list |
Loading…
Reference in new issue