|
| 1 | +# Copyright 2014-present PlatformIO <[email protected]> |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +# |
| 16 | +# Default flags for bare-metal programming (without any framework layers) |
| 17 | +# |
| 18 | + |
| 19 | +from SCons.Script import DefaultEnvironment |
| 20 | + |
| 21 | +env = DefaultEnvironment() |
| 22 | + |
| 23 | +env.Append( |
| 24 | + ASFLAGS=["-x", "assembler-with-cpp"], |
| 25 | + |
| 26 | + CCFLAGS=[ |
| 27 | + "-Os", # optimize for size |
| 28 | + "-ffunction-sections", # place each function in its own section |
| 29 | + "-fdata-sections", |
| 30 | + "-Wall", |
| 31 | + "-mthumb", |
| 32 | + "-nostdlib" |
| 33 | + ], |
| 34 | + |
| 35 | + CXXFLAGS=[ |
| 36 | + "-fno-rtti", |
| 37 | + "-fno-exceptions" |
| 38 | + ], |
| 39 | + |
| 40 | + CPPDEFINES=[ |
| 41 | + ("F_CPU", "$BOARD_F_CPU") |
| 42 | + ], |
| 43 | + |
| 44 | + LINKFLAGS=[ |
| 45 | + "-Os", |
| 46 | + "-Wl,--gc-sections,--relax", |
| 47 | + "-mthumb", |
| 48 | + "--specs=nano.specs", |
| 49 | + "--specs=nosys.specs" |
| 50 | + ], |
| 51 | + |
| 52 | + LIBS=["c", "gcc", "m", "stdc++", "nosys"] |
| 53 | +) |
| 54 | + |
| 55 | +if "BOARD" in env: |
| 56 | + env.Append( |
| 57 | + CCFLAGS=[ |
| 58 | + "-mcpu=%s" % env.BoardConfig().get("build.cpu") |
| 59 | + ], |
| 60 | + LINKFLAGS=[ |
| 61 | + "-mcpu=%s" % env.BoardConfig().get("build.cpu") |
| 62 | + ] |
| 63 | + ) |
| 64 | + |
| 65 | +# copy CCFLAGS to ASFLAGS (-x assembler-with-cpp mode) |
| 66 | +env.Append(ASFLAGS=env.get("CCFLAGS", [])[:]) |
0 commit comments