@@ -100,7 +100,7 @@ if gitresult.returncode != 0 or not os.path.exists(f"{ROOT}/include/mbedtls"):
100
100
else :
101
101
# found root, construct the other paths
102
102
os .chdir (ROOT )
103
- TEST_DIR = ROOT + "/ tests"
103
+ TEST_DIR = " tests"
104
104
105
105
uname = subprocess .run (["uname" , "-m" ], stdout = subprocess .PIPE , stderr = subprocess .STDOUT ).stdout .decode ("utf-8" ).strip ()
106
106
if uname in ["aarch64" , "arm64" ]:
@@ -110,10 +110,10 @@ else:
110
110
else :
111
111
NATIVE_TARGET = uname
112
112
113
- CONFIG_FILE = ROOT + "/ include/mbedtls/mbedtls_config.h"
113
+ CONFIG_FILE = " include/mbedtls/mbedtls_config.h"
114
114
if not os .path .exists (CONFIG_FILE ):
115
115
# config file not found, assume we are on 2.x
116
- CONFIG_FILE = ROOT + "/ include/mbedtls/config.h"
116
+ CONFIG_FILE = " include/mbedtls/config.h"
117
117
118
118
BACKUP_SUFFIX = ".mtest_backup"
119
119
@@ -276,7 +276,7 @@ def toolchain(target, exit_on_failure=True):
276
276
# basic CFLAGS setup
277
277
# target_c_flags are options generated by mtest, which may get overridden by the user (and dropped from the resulting set of flags)
278
278
279
- target_c_flags = [f"-I { ROOT } /include " ] + COMPILER_FLAGS .get (target .compiler_family , [])
279
+ target_c_flags = [f"-Iinclude " ] + COMPILER_FLAGS .get (target .compiler_family , [])
280
280
281
281
if target .compiler_family != "iar" :
282
282
# IAR defaults to C99 and doesn't have an option for it to be explicitly specified
@@ -494,9 +494,9 @@ def git_history_contains(hash):
494
494
495
495
def get_crypto_config_file ():
496
496
# parse the config file and identify the crypto config file location
497
- cmd = ["clang" , "-dM" , "-E" , f"-I { ROOT } /include " , f"{ ROOT } / include/mbedtls/mbedtls_config.h" ]
497
+ cmd = ["clang" , "-dM" , "-E" , f"-Iinclude " , f"include/mbedtls/mbedtls_config.h" ]
498
498
output , _ = subrun (cmd , silent = True )
499
- path = f"{ ROOT } / include/psa/crypto_config.h"
499
+ path = f"include/psa/crypto_config.h"
500
500
for l in output .splitlines ():
501
501
if l .startswith ("#define MBEDTLS_PSA_CRYPTO_CONFIG_FILE " ):
502
502
path = l .split (" " )[- 1 ][1 :- 1 ]
@@ -516,14 +516,14 @@ def set_config_option(action, option, crypto_config_path, silent=True):
516
516
if not silent :
517
517
log (f"scripts/config.py -f { crypto_config_path } { action } { option } { '1' if action == 'set' else '' } " )
518
518
if action == "set" :
519
- output , success = subrun ([f"{ ROOT } / scripts/config.py" ] + force + ["--file" , crypto_config_path , action , option , "1" ], silent = True , ignore_failure = True )
519
+ output , success = subrun ([f"scripts/config.py" ] + force + ["--file" , crypto_config_path , action , option , "1" ], silent = True , ignore_failure = True )
520
520
else :
521
- output , success = subrun ([f"{ ROOT } / scripts/config.py" ] + force + ["--file" , crypto_config_path , action , option ], silent = True , ignore_failure = True )
521
+ output , success = subrun ([f"scripts/config.py" ] + force + ["--file" , crypto_config_path , action , option ], silent = True , ignore_failure = True )
522
522
else :
523
523
backup_config_options (CONFIG_FILE )
524
524
if not silent :
525
525
log (f"scripts/config.py { action } { option } " )
526
- output , success = subrun ([f"{ ROOT } / scripts/config.py" ] + force + [action , option ], silent = True , ignore_failure = True )
526
+ output , success = subrun ([f"scripts/config.py" ] + force + [action , option ], silent = True , ignore_failure = True )
527
527
if success != 0 :
528
528
error (output )
529
529
@@ -554,24 +554,24 @@ def configure_options(target):
554
554
# identify replacement config files, if any
555
555
if COPY_TFM_CONFIG in options :
556
556
config_is_tfm = True
557
- if os .path .exists (f" { ROOT } / configs/config-tfm.h" ):
558
- new_config = f" { ROOT } / configs/config-tfm.h"
557
+ if os .path .exists (" configs/config-tfm.h" ):
558
+ new_config = " configs/config-tfm.h"
559
559
else :
560
- new_config = f" { ROOT } / configs/tfm_mbedcrypto_config_profile_medium.h"
561
- new_crypto_config = f" { ROOT } / configs/crypto_config_profile_medium.h"
560
+ new_config = " configs/tfm_mbedcrypto_config_profile_medium.h"
561
+ new_crypto_config = " configs/crypto_config_profile_medium.h"
562
562
# for looking at old checkouts where these configs were not in the tree, fetch from
563
563
# date they were first created instead
564
564
for config in [new_config , new_crypto_config ]:
565
565
if not os .path .exists (config ):
566
566
hash = "2f1ae5a86ebd67faa50c3983b4567656c2234674"
567
- log (f"git show { hash } :configs/ { config } > configs/ { config } " )
568
- output , _ = subrun (["git" , "show" , f"{ hash } :configs/ { config } " ], silent = True )
569
- with open (f"{ ROOT } /configs/ { config } " , 'w' ) as f :
567
+ log (f"git show { hash } :{ config } > { config } " )
568
+ output , _ = subrun (["git" , "show" , f"{ hash } :{ config } " ], silent = True )
569
+ with open (f"{ config } " , 'w' ) as f :
570
570
f .write (output )
571
571
572
572
for config in header_options :
573
573
# a config file - overwrite existing config file
574
- path = config if os .path .exists (config ) else f"{ ROOT } / configs/{ config } "
574
+ path = config if os .path .exists (config ) else f"configs/{ config } "
575
575
if path .split ("/" )[- 1 ].startswith ("crypto_config_" ):
576
576
new_crypto_config = path
577
577
else :
@@ -582,12 +582,12 @@ def configure_options(target):
582
582
# backup and overwrite the config files
583
583
if new_config is not None :
584
584
backup_config_options (CONFIG_FILE )
585
- log (f"cp { new_config [ len ( ROOT ) + 1 :] } { CONFIG_FILE [ len ( ROOT ) + 1 :] } " )
585
+ log (f"cp { new_config } { CONFIG_FILE } " )
586
586
shutil .copy (new_config , CONFIG_FILE )
587
587
if new_crypto_config is not None :
588
588
crypto_config_file = get_crypto_config_file ()
589
589
backup_config_options (crypto_config_file )
590
- log (f"cp { new_crypto_config [ len ( ROOT ) + 1 :] } { crypto_config_file [ len ( ROOT ) + 1 :] } " )
590
+ log (f"cp { new_crypto_config } { crypto_config_file } " )
591
591
shutil .copy (new_crypto_config , crypto_config_file )
592
592
593
593
# apply bulk config.py settings to main config file
@@ -596,7 +596,7 @@ def configure_options(target):
596
596
# a configuration recognised by config.py, e.g. "baremetal"
597
597
backup_config_options (CONFIG_FILE )
598
598
log (f"scripts/config.py { config } " )
599
- subrun ([f"{ ROOT } / scripts/config.py" , config ], silent = True )
599
+ subrun ([f"scripts/config.py" , config ], silent = True )
600
600
601
601
if config_is_tfm :
602
602
# adjust options for older versions of the config files to allow TF-M config to build
@@ -643,7 +643,7 @@ def disassemble(target):
643
643
# run objdump -d to disassemble
644
644
objdump = toolchain (target )["OBJDUMP" ]
645
645
objfiles = ["library/libmbedcrypto.a" , "library/libmbedtls.a" , "library/libmbedx509.a" ] + args .build_targets
646
- objfiles = [f" { ROOT } / { f } " for f in objfiles if os .path .exists (f" { ROOT } / { f } " )]
646
+ objfiles = [f for f in objfiles if os .path .exists (f )]
647
647
result = []
648
648
for fn in args .disassemble :
649
649
if fn is None :
@@ -775,7 +775,7 @@ def run(target, tests, quiet=False):
775
775
for t in tests :
776
776
log (f"running { t } on { target .arch_isa } " )
777
777
if target .is_native :
778
- output , _ = subrun (f"{ TEST_DIR } /" + t , test_dir = True , silent = quiet )
778
+ output , _ = subrun (f"./ { t } " , test_dir = True , silent = quiet )
779
779
else :
780
780
qemu_exe = toolchain_exes (target )["qemu" ]
781
781
output , _ = subrun ([qemu_exe , t ], test_dir = True , silent = quiet )
@@ -792,7 +792,7 @@ def get_supported_configs():
792
792
s = [x [:24 ].split ()[0 ] for x in s if len (s ) >= 24 and len (x [:24 ].strip ()) > 0 ]
793
793
s = [x for x in s if x not in ["get" , "set" , "set-all" , "unset" , "unset-all" ] and "," not in x ]
794
794
# get the list of config files
795
- config_files = [x for x in os .listdir (f'{ ROOT } / configs' ) if x .endswith (".h" )]
795
+ config_files = [x for x in os .listdir (f'configs' ) if x .endswith (".h" )]
796
796
return s + config_files
797
797
798
798
@@ -931,7 +931,7 @@ Build targets: build the library by default, or files (e.g. aes.o), programs (e.
931
931
args .rest = [x for x in args .rest if not x .startswith ("CFLAGS=" ) and not x .startswith ("LDFLAGS=" ) and not x .startswith ("CC=" )]
932
932
933
933
# find any things in programs to build
934
- all_programs = [x [len ( ROOT ) + 1 :- 2 ] for x in glob .glob (f'{ ROOT } / programs/**/*.c' , recursive = True )]
934
+ all_programs = [x [:- 2 ] for x in glob .glob (f'programs/**/*.c' , recursive = True )]
935
935
args .build_targets = []
936
936
for x in list (args .rest ):
937
937
found = [p for p in all_programs if p .endswith ("/" + x )]
0 commit comments