Skip to content

[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

Merged
merged 1 commit into from
Jun 27, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 14 additions & 36 deletions tools/default_settings.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
"""
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.
Expand All @@ -13,55 +16,30 @@
"""

from os.path import join, abspath, dirname
import logging

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

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

##############################################################################
# Build System Settings
##############################################################################
BUILD_DIR = abspath(join(ROOT, "build"))
#BUILD_DIR = abspath(join(ROOT, "build"))

# ARM
ARM_PATH = "C:/Program Files/ARM"
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_PATH = "C:/Program Files/ARM"
Copy link
Contributor

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...


# GCC ARM
GCC_ARM_PATH = ""
#GCC_ARM_PATH = ""

# GCC CodeRed
GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin"
#GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin"

# IAR
IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm"
#IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm"

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

# cppcheck path (command) and output message format
CPPCHECK_CMD = ["cppcheck", "--enable=all"]
CPPCHECK_MSG_FORMAT = ["--template=[{severity}] {file}@{line}: {id}:{message}"]

BUILD_OPTIONS = []
#BUILD_OPTIONS = []

# mbed.org username
MBED_ORG_USER = ""

##############################################################################
# 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"'
#MBED_ORG_USER = ""
86 changes: 46 additions & 40 deletions tools/settings.py
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 = ""
Expand All @@ -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']
Copy link
Contributor

@bridadan bridadan Jun 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should prefix the _ENV_PATHS with MBED_, so:

_ENV_PATHS = ['MBED_ARM_PATH', 'MBED_GCC_ARM_PATH', 'MBED_GCC_CR_PATH', 'MBED_IAR_PATH']

The reason is these variables are just general enough where they might conflict with some other environment variables on other people's machines.

Copy link
Contributor Author

@screamerbg screamerbg Jun 24, 2016

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The 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
##############################################################################
Expand All @@ -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"'
3 changes: 3 additions & 0 deletions tools/toolchains/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,10 @@ def __init__(self, target, options=None, notify=None, macros=None, silent=False,

# Build options passed by -o flag
self.options = options if options is not None else []

# Build options passed by settings.py or mbed_settings.py
self.options.extend(BUILD_OPTIONS)

if self.options:
self.info("Build Options: %s" % (', '.join(self.options)))

Expand Down