-
Notifications
You must be signed in to change notification settings - Fork 128
/
module_c.lb
51 lines (38 loc) · 1.52 KB
/
module_c.lb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2016-2017, Niklas Hauser
# Copyright (c) 2017-2018, Fabian Greif
# Copyright (c) 2018, Christopher Durand
#
# This file is part of the modm project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# -----------------------------------------------------------------------------
def init(module):
module.name = ":stdc"
module.description = """\
# C Standard Environment
Refines the C language to make it easier to use on embedded targets.
## ARM Cortex-M
Additional compiler options:
- `--specs=nano.specs`: use Newlib Nano (when not using exceptions).
- `--specs=nosys.specs`: No additional C library features are implemented.
"""
def prepare(module, options):
core = options[":target"].get_driver("core")["type"]
if core.startswith("avr") or core.startswith("cortex-m"):
module.depends(":architecture:assert")
return True
def build(env):
core = env[":target"].get_driver("core")["type"]
if core.startswith("cortex-m"):
env.outbasepath = "modm/ext/gcc"
env.copy("cabi_cortex.c", "cabi.c")
# Compiler options for targets
env.collect(":build:linkflags", "--specs=nosys.specs")
if not env.get(":stdc++:exceptions", False):
# Newlib Nano does not support C++ exceptions at all
env.collect(":build:linkflags", "--specs=nano.specs")