Merge pull request #9652 from kfnta/tools_fixes

Fix minor bugs in secure targets file filtering
pull/9670/head
Cruz Monrreal 2019-02-11 16:41:05 -06:00 committed by GitHub
commit f04d51b2cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 18 deletions

View File

@ -43,6 +43,7 @@ from tools.settings import CPPCHECK_CMD, CPPCHECK_MSG_FORMAT, CLI_COLOR_MAP
from tools.notifier.term import TerminalNotifier
from tools.utils import argparse_filestring_type, args_error, argparse_many
from tools.utils import argparse_filestring_type, argparse_dir_not_parent
from tools.paths import is_relative_to_root
if __name__ == '__main__':
start = time()
@ -188,19 +189,11 @@ if __name__ == '__main__':
mcu = TARGET_MAP[target]
profile = extract_profile(parser, options, toolchain)
if mcu.is_PSA_secure_target:
lib_build_res = build_library(
ROOT, options.build_dir, mcu, toolchain,
jobs=options.jobs,
clean=options.clean,
archive=(not options.no_archive),
macros=options.macros,
name=options.artifact_name,
build_profile=profile,
ignore=options.ignore,
notify=notifier,
)
elif options.source_dir:
if mcu.is_PSA_secure_target and \
not is_relative_to_root(options.source_dir):
options.source_dir = ROOT
if options.source_dir:
lib_build_res = build_library(
options.source_dir, options.build_dir, mcu, toolchain,
jobs=options.jobs,

View File

@ -34,6 +34,7 @@ from tools.paths import MBED_LIBRARIES
from tools.paths import RPC_LIBRARY
from tools.paths import USB_LIBRARIES
from tools.paths import DSP_LIBRARIES
from tools.paths import is_relative_to_root
from tools.tests import TESTS, Test, TEST_MAP
from tools.tests import TEST_MBED_LIB
from tools.tests import test_known, test_name_known
@ -307,8 +308,9 @@ if __name__ == '__main__':
args_error(parser, "argument -t/--tool is required")
toolchain = options.tool[0]
if Target.get_target(mcu).is_PSA_secure_target:
options.source_dir = ROOT
if Target.get_target(mcu).is_PSA_secure_target and \
not is_relative_to_root(options.source_dir):
options.source_dir = ROOT
if (options.program is None) and (not options.source_dir):
args_error(parser, "one of -p, -n, or --source is required")

View File

@ -14,7 +14,7 @@ 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
from os.path import join, commonprefix, realpath
from os import getenv
# Conventions about the directory structure
@ -85,3 +85,11 @@ CPPUTEST_TESTRUNNER_SCR = join(TEST_DIR, "utest", "testrunner")
CPPUTEST_TESTRUNNER_INC = join(TEST_DIR, "utest", "testrunner")
CPPUTEST_LIBRARY = join(BUILD_DIR, "cpputest")
def is_relative_to_root(dirs):
if not isinstance(dirs, list):
dirs = [dirs]
dirs = [realpath(d) for d in dirs]
out = commonprefix(dirs + [ROOT])
return out == ROOT

View File

@ -38,7 +38,7 @@ from collections import namedtuple, defaultdict
from copy import copy
from itertools import chain
from os import walk, sep
from os.path import (join, splitext, dirname, relpath, basename, split, normcase,
from os.path import (join, splitext, dirname, relpath, basename, split, normpath,
abspath, exists)
from .ignore import MbedIgnoreSet, IGNORE_FILENAME
@ -148,6 +148,11 @@ class Resources(object):
self._ignoreset = MbedIgnoreSet()
# make sure mbed-os root is added as include directory
script_dir = dirname(abspath(__file__))
mbed_os_root_dir = normpath(join(script_dir, '..', '..'))
self.add_file_ref(FileType.INC_DIR, mbed_os_root_dir, mbed_os_root_dir)
def ignore_dir(self, directory):
if self._collect_ignores:
self.ignored_dirs.append(directory)

View File

@ -45,6 +45,8 @@ from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS, TOOLCHAIN_CLASSES
from tools.settings import CLI_COLOR_MAP
from tools.settings import ROOT
from tools.targets import Target
from tools.paths import is_relative_to_root
if __name__ == '__main__':
try:
# Parse Options
@ -211,7 +213,7 @@ if __name__ == '__main__':
if not options.build_dir:
args_error(parser, "argument --build is required")
if mcu_secured:
if mcu_secured and not is_relative_to_root(options.source_dir):
base_source_paths = ROOT
else:
base_source_paths = options.source_dir