summaryrefslogtreecommitdiff
path: root/bsp/nxp/lpc/lpc176x/SConstruct
blob: 0111742d25e9e98e8e871468991f8d21d6902a70 (plain)
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
import os
import sys
import rtconfig

if os.getenv('RTT_ROOT'):
    RTT_ROOT = os.getenv('RTT_ROOT')
else:
    RTT_ROOT = os.path.normpath(os.getcwd() + '/../../../..')
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
from building import *

def bsp_pkg_check():
    import subprocess

    check_paths = [
        os.path.join("packages", "nxp-lpc-series-latest"),
    ]

    need_update = not all(os.path.exists(p) for p in check_paths)

    if need_update:
        print("\n===============================================================================")
        print("Dependency packages missing, please running 'pkgs --update'...")
        print("If no packages are fetched, run 'pkgs --upgrade' first, then 'pkgs --update'...")
        print("===============================================================================")
        exit(1)

RegisterPreBuildingAction(bsp_pkg_check)

TARGET = 'rtthread-lpc17xx.' + rtconfig.TARGET_EXT

DefaultEnvironment(tools=[])
env = Environment(tools = ['mingw'],
    AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
    CC = rtconfig.CC, CFLAGS = rtconfig.CFLAGS,
    AR = rtconfig.AR, ARFLAGS = '-rc',
    LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)

if rtconfig.PLATFORM in ['iccarm']:
    env.Replace(CCCOM = ['$CC $CFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET $SOURCES'])
    env.Replace(ARFLAGS = [''])
    env.Replace(LINKCOM = ['$LINK $SOURCES $LINKFLAGS -o $TARGET --map project.map'])

Export('RTT_ROOT')
Export('rtconfig')

# prepare building environment
objs = PrepareBuilding(env, RTT_ROOT)

# make a building
DoBuilding(TARGET, objs)