mirror of https://github.com/ARMmbed/mbed-os.git
Check source relative to ROOT on secure targets
When building secure targets, we would like compile only files that are in the the mbe-os root folder. This Fixes an issue when sending multiple --source parameters that are all inside the mbed-os treepull/9652/head
parent
8fb2467608
commit
0ca2615a72
|
@ -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,
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,8 +213,8 @@ if __name__ == '__main__':
|
|||
if not options.build_dir:
|
||||
args_error(parser, "argument --build is required")
|
||||
|
||||
if mcu_secured:
|
||||
base_source_paths = ROOT
|
||||
if mcu_secured and not is_relative_to_root(options.source_dir):
|
||||
options.source_dir = ROOT
|
||||
else:
|
||||
base_source_paths = options.source_dir
|
||||
|
||||
|
|
Loading…
Reference in New Issue