Skip to content

Commit faa427d

Browse files
committed
Add environmental variables support for toolchain paths
Also updated license of settings.py and default_settings.py and added comments
1 parent 6dd11c7 commit faa427d

File tree

3 files changed

+63
-76
lines changed

3 files changed

+63
-76
lines changed

tools/default_settings.py

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
"""
22
mbed SDK
3-
Copyright (c) 2011-2013 ARM Limited
3+
Copyright (c) 2016 ARM Limited
4+
45
Licensed under the Apache License, Version 2.0 (the "License");
56
you may not use this file except in compliance with the License.
67
You may obtain a copy of the License at
7-
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
811
Unless required by applicable law or agreed to in writing, software
912
distributed under the License is distributed on an "AS IS" BASIS,
1013
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -13,55 +16,30 @@
1316
"""
1417

1518
from os.path import join, abspath, dirname
16-
import logging
1719

18-
ROOT = abspath(join(dirname(__file__), ".."))
19-
20-
# These default settings have two purposes:
21-
# 1) Give a template for writing local "private_settings.py"
22-
# 2) Give default initialization fields for the "toolchains.py" constructors
20+
#ROOT = abspath(join(dirname(__file__), "."))
2321

2422
##############################################################################
2523
# Build System Settings
2624
##############################################################################
27-
BUILD_DIR = abspath(join(ROOT, "build"))
25+
#BUILD_DIR = abspath(join(ROOT, "build"))
2826

2927
# ARM
30-
ARM_PATH = "C:/Program Files/ARM"
31-
ARM_BIN = join(ARM_PATH, "bin")
32-
ARM_INC = join(ARM_PATH, "include")
33-
ARM_LIB = join(ARM_PATH, "lib")
34-
35-
ARM_CPPLIB = join(ARM_LIB, "cpplib")
36-
MY_ARM_CLIB = join(ARM_PATH, "lib", "microlib")
28+
#ARM_PATH = "C:/Program Files/ARM"
3729

3830
# GCC ARM
39-
GCC_ARM_PATH = ""
31+
#GCC_ARM_PATH = ""
4032

4133
# GCC CodeRed
42-
GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin"
34+
#GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin"
4335

4436
# IAR
45-
IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm"
37+
#IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm"
4638

4739
# Goanna static analyser. Please overload it in private_settings.py
48-
GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.2.3/bin"
40+
#GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.2.3/bin"
4941

50-
# cppcheck path (command) and output message format
51-
CPPCHECK_CMD = ["cppcheck", "--enable=all"]
52-
CPPCHECK_MSG_FORMAT = ["--template=[{severity}] {file}@{line}: {id}:{message}"]
53-
54-
BUILD_OPTIONS = []
42+
#BUILD_OPTIONS = []
5543

5644
# mbed.org username
57-
MBED_ORG_USER = ""
58-
59-
##############################################################################
60-
# Private Settings
61-
##############################################################################
62-
try:
63-
# Allow to overwrite the default settings without the need to edit the
64-
# settings file stored in the repository
65-
from mbed_settings import *
66-
except ImportError:
67-
print '[WARNING] Using default settings. Define your settings in the file "./mbed_settings.py"'
45+
#MBED_ORG_USER = ""

tools/settings.py

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,34 @@
11
"""
22
mbed SDK
3-
Copyright (c) 2011-2013 ARM Limited
3+
Copyright (c) 2016 ARM Limited
4+
45
Licensed under the Apache License, Version 2.0 (the "License");
56
you may not use this file except in compliance with the License.
67
You may obtain a copy of the License at
7-
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
811
Unless required by applicable law or agreed to in writing, software
912
distributed under the License is distributed on an "AS IS" BASIS,
1013
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1114
See the License for the specific language governing permissions and
1215
limitations under the License.
1316
"""
1417

15-
from os.path import join, abspath, dirname
18+
from os import getenv
19+
from os.path import join, abspath, dirname, exists
1620
import logging
1721

1822
ROOT = abspath(join(dirname(__file__), ".."))
1923

20-
# These default settings have two purposes:
21-
# 1) Give a template for writing local "mbed_settings.py"
22-
# 2) Give default initialization fields for the "toolchains.py" constructors
2324

2425
##############################################################################
25-
# Build System Settings
26+
# Toolchains and Build System Settings
2627
##############################################################################
2728
BUILD_DIR = abspath(join(ROOT, ".build"))
2829

29-
# ARM
30-
armcc = "standalone" # "keil", or "standalone", or "ds-5"
31-
32-
if armcc == "keil":
33-
ARM_PATH = "C:/Keil_v5/ARM/ARMCC"
34-
ARM_BIN = join(ARM_PATH, "bin")
35-
ARM_INC = join(ARM_PATH, "incldue")
36-
ARM_LIB = join(ARM_PATH, "lib")
37-
38-
elif armcc == "standalone":
39-
ARM_PATH = "C:/Program Files (x86)/ARM_Compiler_5.06u1"
40-
ARM_BIN = join(ARM_PATH, "bin")
41-
ARM_INC = join(ARM_PATH, "include")
42-
ARM_LIB = join(ARM_PATH, "lib")
43-
44-
elif armcc == "ds-5":
45-
ARM_PATH = "C:/Program Files (x86)/DS-5"
46-
ARM_BIN = join(ARM_PATH, "bin")
47-
ARM_INC = join(ARM_PATH, "include")
48-
ARM_LIB = join(ARM_PATH, "lib")
49-
50-
ARM_CPPLIB = join(ARM_LIB, "cpplib")
51-
MY_ARM_CLIB = join(ARM_PATH, "lib", "microlib")
30+
# ARM Compiler 5
31+
ARM_PATH = "C:/Keil_v5/ARM/ARMCC"
5232

5333
# GCC ARM
5434
GCC_ARM_PATH = ""
@@ -71,6 +51,42 @@
7151
# mbed.org username
7252
MBED_ORG_USER = ""
7353

54+
55+
##############################################################################
56+
# User Settings (file)
57+
##############################################################################
58+
try:
59+
# Allow to overwrite the default settings without the need to edit the
60+
# settings file stored in the repository
61+
from mbed_settings import *
62+
except ImportError:
63+
pass
64+
65+
66+
##############################################################################
67+
# User Settings (env vars)
68+
##############################################################################
69+
_ENV_PATHS = ['ARM_PATH', 'GCC_ARM_PATH', 'GCC_CR_PATH', 'IAR_PATH']
70+
71+
for _n in _ENV_PATHS:
72+
if getenv(_n):
73+
if exists(getenv(_n)):
74+
globals()[_n] = getenv(_n)
75+
else:
76+
print "WARNING: %s set as environment variable but doesn't exist" % _n
77+
78+
79+
##############################################################################
80+
# ARM Compiler Paths
81+
##############################################################################
82+
83+
ARM_BIN = join(ARM_PATH, "bin")
84+
ARM_INC = join(ARM_PATH, "include")
85+
ARM_LIB = join(ARM_PATH, "lib")
86+
ARM_CPPLIB = join(ARM_LIB, "cpplib")
87+
MY_ARM_CLIB = join(ARM_LIB, "lib", "microlib")
88+
89+
7490
##############################################################################
7591
# Test System Settings
7692
##############################################################################
@@ -92,13 +108,3 @@
92108
"peripherals": ["TMP102", "digital_loop", "port_loop", "analog_loop", "SD"]
93109
},
94110
}
95-
96-
##############################################################################
97-
# Private Settings
98-
##############################################################################
99-
try:
100-
# Allow to overwrite the default settings without the need to edit the
101-
# settings file stored in the repository
102-
from mbed_settings import *
103-
except ImportError:
104-
print '[WARNING] Using default settings. Define your settings in the file "./mbed_settings.py"'

tools/toolchains/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,10 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,
285285

286286
# Build options passed by -o flag
287287
self.options = options if options is not None else []
288+
289+
# Build options passed by settings.py or mbed_settings.py
288290
self.options.extend(BUILD_OPTIONS)
291+
289292
if self.options:
290293
self.info("Build Options: %s" % (', '.join(self.options)))
291294

0 commit comments

Comments
 (0)