Skip to content

Fix bug that killed the BOT when argument validation was on #2010

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 15 commits into from
Jul 8, 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
67 changes: 26 additions & 41 deletions tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,149 +35,134 @@
from tools.build_api import static_analysis_scan, static_analysis_scan_lib, static_analysis_scan_library
from tools.build_api import print_build_results
from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT
from utils import argparse_filestring_type

if __name__ == '__main__':
start = time()

# Parse Options
parser = get_default_options_parser()

parser.add_option("--source", dest="source_dir",
default=None, help="The source (input) directory", action="append")
parser.add_argument("--source", dest="source_dir", type=argparse_filestring_type,
default=None, help="The source (input) directory", action="append")

parser.add_option("--build", dest="build_dir",
parser.add_argument("--build", dest="build_dir",
default=None, help="The build (output) directory")

parser.add_option("--no-archive", dest="no_archive", action="store_true",
parser.add_argument("--no-archive", dest="no_archive", action="store_true",
default=False, help="Do not produce archive (.ar) file, but rather .o")

# Extra libraries
parser.add_option("-r", "--rtos",
parser.add_argument("-r", "--rtos",
action="store_true",
dest="rtos",
default=False,
help="Compile the rtos")

parser.add_option("--rpc",
parser.add_argument("--rpc",
action="store_true",
dest="rpc",
default=False,
help="Compile the rpc library")

parser.add_option("-e", "--eth",
parser.add_argument("-e", "--eth",
action="store_true", dest="eth",
default=False,
help="Compile the ethernet library")

parser.add_option("-U", "--usb_host",
parser.add_argument("-U", "--usb_host",
action="store_true",
dest="usb_host",
default=False,
help="Compile the USB Host library")

parser.add_option("-u", "--usb",
parser.add_argument("-u", "--usb",
action="store_true",
dest="usb",
default=False,
help="Compile the USB Device library")

parser.add_option("-d", "--dsp",
parser.add_argument("-d", "--dsp",
action="store_true",
dest="dsp",
default=False,
help="Compile the DSP library")

parser.add_option("-F", "--fat",
parser.add_argument("-F", "--fat",
action="store_true",
dest="fat",
default=False,
help="Compile FS and SD card file system library")

parser.add_option("-b", "--ublox",
parser.add_argument("-b", "--ublox",
action="store_true",
dest="ublox",
default=False,
help="Compile the u-blox library")

parser.add_option("", "--cpputest",
parser.add_argument( "--cpputest",
action="store_true",
dest="cpputest_lib",
default=False,
help="Compiles 'cpputest' unit test library (library should be on the same directory level as mbed repository)")

parser.add_option("-D", "",
parser.add_argument("-D",
action="append",
dest="macros",
help="Add a macro definition")

parser.add_option("-S", "--supported-toolchains",
parser.add_argument("-S", "--supported-toolchains",
action="store_true",
dest="supported_toolchains",
default=False,
help="Displays supported matrix of MCUs and toolchains")

parser.add_option('-f', '--filter',
parser.add_argument('-f', '--filter',
dest='general_filter_regex',
default=None,
help='For some commands you can use filter to filter out results')

parser.add_option("", "--cppcheck",
parser.add_argument("--cppcheck",
action="store_true",
dest="cppcheck_validation",
default=False,
help="Forces 'cppcheck' static code analysis")

parser.add_option("-j", "--jobs", type="int", dest="jobs",
parser.add_argument("-j", "--jobs", type=int, dest="jobs",
default=0, help="Number of concurrent jobs. Default: 0/auto (based on host machine's number of CPUs)")
parser.add_option("-N", "--artifact-name", dest="artifact_name",
parser.add_argument("-N", "--artifact-name", dest="artifact_name",
default=None, help="The built project's name")

parser.add_option("-v", "--verbose",
parser.add_argument("-v", "--verbose",
action="store_true",
dest="verbose",
default=False,
help="Verbose diagnostic output")

parser.add_option("--silent",
parser.add_argument("--silent",
action="store_true",
dest="silent",
default=False,
help="Silent diagnostic output (no copy, compile notification)")

parser.add_option("-x", "--extra-verbose-notifications",
parser.add_argument("-x", "--extra-verbose-notifications",
action="store_true",
dest="extra_verbose_notify",
default=False,
help="Makes compiler more verbose, CI friendly.")

(options, args) = parser.parse_args()
options = parser.parse_args()

# Only prints matrix of supported toolchains
if options.supported_toolchains:
print mcu_toolchain_matrix(platform_filter=options.general_filter_regex)
exit(0)

# Get target list
if options.mcu:
mcu_list = (options.mcu).split(",")
for mcu in mcu_list:
if mcu not in TARGET_NAMES:
print "Given MCU '%s' not into the supported list:\n%s" % (mcu, TARGET_NAMES)
sys.exit(1)
targets = mcu_list
else:
targets = TARGET_NAMES
targets = options.mcu if options.mcu else TARGET_NAMES

# Get toolchains list
if options.tool:
toolchain_list = (options.tool).split(",")
for tc in toolchain_list:
if tc not in TOOLCHAINS:
print "Given toolchain '%s' not into the supported list:\n%s" % (tc, TOOLCHAINS)
sys.exit(1)
toolchains = toolchain_list
else:
toolchains = TOOLCHAINS
toolchains = options.tool if options.tool else TOOLCHAINS

# Get libraries list
libraries = []
Expand Down
8 changes: 4 additions & 4 deletions tools/detect_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,24 @@
# Parse Options
parser = get_default_options_parser()

parser.add_option("-S", "--supported-toolchains",
parser.add_argument("-S", "--supported-toolchains",
action="store_true",
dest="supported_toolchains",
default=False,
help="Displays supported matrix of targets and toolchains")

parser.add_option('-f', '--filter',
parser.add_argument('-f', '--filter',
dest='general_filter_regex',
default=None,
help='Filter targets')

parser.add_option("-v", "--verbose",
parser.add_argument("-v", "--verbose",
action="store_true",
dest="verbose",
default=False,
help="Verbose diagnostic output")

(options, args) = parser.parse_args()
options = parser.parse_args()

# Only prints matrix of supported toolchains
if options.supported_toolchains:
Expand Down
21 changes: 9 additions & 12 deletions tools/get_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from tools.options import get_default_options_parser
from tools.build_api import get_config
from config import Config
from utils import argparse_filestring_type
try:
import tools.private_settings as ps
except:
Expand All @@ -36,28 +37,24 @@
if __name__ == '__main__':
# Parse Options
parser = get_default_options_parser(add_clean=False, add_options=False)
parser.add_option("--source", dest="source_dir",
default=None, help="The source (input) directory", action="append")
parser.add_option("--prefix", dest="prefix", action="append",
default=None, help="Restrict listing to parameters that have this prefix")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
parser.add_argument("--source", dest="source_dir", type=argparse_filestring_type,
default=[], help="The source (input) directory", action="append")
parser.add_argument("--prefix", dest="prefix", action="append",
default=[], help="Restrict listing to parameters that have this prefix")
parser.add_argument("-v", "--verbose", action="store_true", dest="verbose",
default=False, help="Verbose diagnostic output")

(options, args) = parser.parse_args()
options = parser.parse_args()

for path in options.source_dir :
if not isdir(path) :
args_error(parser, "[ERROR] you passed \"{}\" to --source, which does not exist".
format(path))
# Target
if options.mcu is None :
Copy link
Contributor

Choose a reason for hiding this comment

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

@theotherjimmy I just noticed this line, will this ever be true now that the --mcu option is using an argpars_many type? Or will it just be an empty array? This line should probably just change to a "falsey" check instead of an explicit check for None:

if options.mcu:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, I don't think that will fail. The default is None.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

$ python tools/get_config.py

[ERROR] You should specify an MCU
...

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool, thanks for checking!

args_error(parser, "[ERROR] You should specify an MCU")
target = options.mcu
target = options.mcu[0]

# Toolchain
if options.tool is None:
args_error(parser, "[ERROR] You should specify a TOOLCHAIN")
toolchain = options.tool
toolchain = options.tool[0]

options.prefix = options.prefix or [""]

Expand Down
4 changes: 2 additions & 2 deletions tools/host_tests/host_tests_plugins/module_copy_smart.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from host_test_plugins import HostTestPluginBase

sys.path.append(abspath(join(dirname(__file__), "../../../")))
from tools.test_api import get_autodetected_MUTS_list
import tools.test_api

class HostTestPluginCopyMethod_Smart(HostTestPluginBase):

Expand Down Expand Up @@ -74,7 +74,7 @@ def execute(self, capability, *args, **kwargs):

for i in range(0, 60):
print('Looking for %s with MBEDLS' % target_mcu)
muts_list = get_autodetected_MUTS_list(platform_name_filter=platform_name_filter)
muts_list = tools.test_api.get_autodetected_MUTS_list(platform_name_filter=platform_name_filter)

if 1 in muts_list:
mut = muts_list[1]
Expand Down
Loading