-
Notifications
You must be signed in to change notification settings - Fork 3k
[Tools] Add environmental variables support for toolchain paths #2005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,34 @@ | ||
""" | ||
mbed SDK | ||
Copyright (c) 2011-2013 ARM Limited | ||
Copyright (c) 2016 ARM Limited | ||
|
||
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 | ||
|
||
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 os.path import join, abspath, dirname | ||
from os import getenv | ||
from os.path import join, abspath, dirname, exists | ||
import logging | ||
|
||
ROOT = abspath(join(dirname(__file__), "..")) | ||
|
||
# These default settings have two purposes: | ||
# 1) Give a template for writing local "mbed_settings.py" | ||
# 2) Give default initialization fields for the "toolchains.py" constructors | ||
|
||
############################################################################## | ||
# Build System Settings | ||
# Toolchains and Build System Settings | ||
############################################################################## | ||
BUILD_DIR = abspath(join(ROOT, ".build")) | ||
|
||
# ARM | ||
armcc = "standalone" # "keil", or "standalone", or "ds-5" | ||
|
||
if armcc == "keil": | ||
ARM_PATH = "C:/Keil_v5/ARM/ARMCC" | ||
ARM_BIN = join(ARM_PATH, "bin") | ||
ARM_INC = join(ARM_PATH, "incldue") | ||
ARM_LIB = join(ARM_PATH, "lib") | ||
|
||
elif armcc == "standalone": | ||
ARM_PATH = "C:/Program Files (x86)/ARM_Compiler_5.06u1" | ||
ARM_BIN = join(ARM_PATH, "bin") | ||
ARM_INC = join(ARM_PATH, "include") | ||
ARM_LIB = join(ARM_PATH, "lib") | ||
|
||
elif armcc == "ds-5": | ||
ARM_PATH = "C:/Program Files (x86)/DS-5" | ||
ARM_BIN = join(ARM_PATH, "bin") | ||
ARM_INC = join(ARM_PATH, "include") | ||
ARM_LIB = join(ARM_PATH, "lib") | ||
|
||
ARM_CPPLIB = join(ARM_LIB, "cpplib") | ||
MY_ARM_CLIB = join(ARM_PATH, "lib", "microlib") | ||
# ARM Compiler 5 | ||
ARM_PATH = "C:/Keil_v5/ARM/ARMCC" | ||
|
||
# GCC ARM | ||
GCC_ARM_PATH = "" | ||
|
@@ -71,6 +51,42 @@ | |
# mbed.org username | ||
MBED_ORG_USER = "" | ||
|
||
|
||
############################################################################## | ||
# User Settings (file) | ||
############################################################################## | ||
try: | ||
# Allow to overwrite the default settings without the need to edit the | ||
# settings file stored in the repository | ||
from mbed_settings import * | ||
except ImportError: | ||
pass | ||
|
||
|
||
############################################################################## | ||
# User Settings (env vars) | ||
############################################################################## | ||
_ENV_PATHS = ['ARM_PATH', 'GCC_ARM_PATH', 'GCC_CR_PATH', 'IAR_PATH'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we should prefix the
The reason is these variables are just general enough where they might conflict with some other environment variables on other people's machines. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Googled ARM_PATH and GCC_ARM_PATH env variable. Not a single result. Don't think these are general. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, but if someone were to make a tool that used them, we would get unexpected behavior. I don't think anyone will klober our MBED_ prefixed environment variables. |
||
|
||
for _n in _ENV_PATHS: | ||
if getenv(_n): | ||
if exists(getenv(_n)): | ||
globals()[_n] = getenv(_n) | ||
else: | ||
print "WARNING: %s set as environment variable but doesn't exist" % _n | ||
|
||
|
||
############################################################################## | ||
# ARM Compiler Paths | ||
############################################################################## | ||
|
||
ARM_BIN = join(ARM_PATH, "bin") | ||
ARM_INC = join(ARM_PATH, "include") | ||
ARM_LIB = join(ARM_PATH, "lib") | ||
ARM_CPPLIB = join(ARM_LIB, "cpplib") | ||
MY_ARM_CLIB = join(ARM_LIB, "lib", "microlib") | ||
|
||
|
||
############################################################################## | ||
# Test System Settings | ||
############################################################################## | ||
|
@@ -92,13 +108,3 @@ | |
"peripherals": ["TMP102", "digital_loop", "port_loop", "analog_loop", "SD"] | ||
}, | ||
} | ||
|
||
############################################################################## | ||
# Private Settings | ||
############################################################################## | ||
try: | ||
# Allow to overwrite the default settings without the need to edit the | ||
# settings file stored in the repository | ||
from mbed_settings import * | ||
except ImportError: | ||
print '[WARNING] Using default settings. Define your settings in the file "./mbed_settings.py"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one day i'll convince you to set this path for Keil MDK rather than just the compiler... one day...