@@ -273,6 +273,15 @@ class MakefileMaker:
273273 MakefileMaker(options, source_path).generate()
274274 """
275275
276+ PSA_CRYPTO_DRIVER_WRAPPERS_DEPENDENCIES = frozenset ([
277+ 'include/psa/crypto_driver_common.h' ,
278+ 'include/psa/crypto_platform.h' ,
279+ 'include/psa/crypto_types.h' ,
280+ 'include/psa/crypto_values.h' ,
281+ 'library/psa_crypto_core.h' ,
282+ 'library/psa_crypto_driver_wrappers.h' ,
283+ ])
284+
276285 def __init__ (self , options , source_path ):
277286 """Initialize a makefile generator.
278287
@@ -299,7 +308,12 @@ class MakefileMaker:
299308 self .static_libraries = None
300309 self .help = {}
301310 self .clean = []
302- self .dependency_cache = {}
311+ self .dependency_cache = {
312+ # TODO: arrange to find dependencies of this generated file.
313+ # They're hard-coded for now, but that won't work if the
314+ # dependencies change over time.
315+ 'library/psa_crypto_driver_wrappers.c' : self .PSA_CRYPTO_DRIVER_WRAPPERS_DEPENDENCIES ,
316+ }
303317 self .submodules = [submodule for submodule in _submodule_names
304318 if self .source_exists (submodule )]
305319 if self .source_exists ('tests/scripts/generate_test_code.py' ):
@@ -692,6 +706,17 @@ class MakefileMaker:
692706 base = 'mbed' + base
693707 return '-l' + base
694708
709+ def psa_crypto_driver_wrappers_subsection (self , contents ):
710+ generated = 'library/psa_crypto_driver_wrappers.c'
711+ script_path = self .crypto_file_path ('scripts/psa_crypto_driver_wrappers.py' )
712+ sources = [self .crypto_file_path (drv )
713+ for drv in self .options .psa_driver ]
714+ contents ['crypto' ].append (os .path .splitext (generated )[0 ])
715+ self .target (generated ,
716+ [script_path ] + sources ,
717+ [sjoin (script_path , '-o $@' , * sources )])
718+ self .object_target ('LIBRARY' , GeneratedFile (generated ), [])
719+
695720 def list_source_files (self , root , pattern ):
696721 """List the source files matching the specified pattern.
697722
@@ -750,6 +775,8 @@ class MakefileMaker:
750775 contents [lib ] = []
751776 for module in modules :
752777 contents [self .library_of (module .base ())].append (module .base ())
778+ if self .options .psa_driver :
779+ self .psa_crypto_driver_wrappers_subsection (contents )
753780 libraries = [lib for lib in self ._potential_libraries
754781 if contents [lib ]]
755782 for lib in libraries :
@@ -1607,6 +1634,9 @@ def main():
16071634 parser .add_argument ('--preset' , '-p' ,
16081635 choices = sorted (_preset_options .keys ()),
16091636 help = 'Apply a preset configuration before processing other options' )
1637+ parser .add_argument ('--psa-driver' ,
1638+ action = 'append' , default = [],
1639+ help = 'PSA crypto driver description file' )
16101640 parser .add_argument ('--shared-library-extension' ,
16111641 help = 'File extension for shared libraries' )
16121642 parser .add_argument ('--source' , '-s' ,
0 commit comments