@@ -45,11 +45,15 @@ def get_mbed_official_psa_release():
4545 psa_targets_release_list = []
4646 psa_secure_targets = [t for t in TARGET_NAMES if Target .get_target (t ).is_PSA_secure_target ]
4747 for t in psa_secure_targets :
48+ delivery_dir = os .path .join (ROOT , 'targets' , TARGET_MAP [t ].delivery_dir )
49+ if not os .path .exists (delivery_dir ):
50+ raise Exception ("{} does not have delivery_dir" .format (TARGET_MAP [t ].name ))
4851 psa_targets_release_list .append (
4952 tuple (
5053 [
5154 TARGET_MAP [t ].name ,
52- TARGET_MAP [t ].default_toolchain
55+ TARGET_MAP [t ].default_toolchain ,
56+ delivery_dir ,
5357 ]
5458 )
5559 )
@@ -116,13 +120,35 @@ def build_tfm_platform(target, toolchain, profile='release'):
116120 ])
117121
118122
119- def build_psa_platform (target , toolchain , debug = False ):
123+ def commit_biannries (target , delivery_dir ):
124+ cmd = [
125+ 'git' ,
126+ '-C' , ROOT ,
127+ 'add' , os .path .relpath (delivery_dir , ROOT )
128+ ]
129+
130+ subprocess .call (cmd )
131+ commit_message = 'Update secure binaries for {}' .format (target )
132+ cmd = [
133+ 'git' ,
134+ '-C' , ROOT ,
135+ 'commit' ,
136+ '-m' , commit_message
137+ ]
138+
139+ subprocess .call (cmd )
140+
141+
142+ def build_psa_platform (target , toolchain , delivery_dir , debug = False , git_commit = False ):
120143 profile = 'debug' if debug else 'release'
121144 if _psa_backend (target ) is 'TFM' :
122145 build_tfm_platform (target , toolchain , profile )
123146 else :
124147 build_mbed_spm_platform (target , toolchain , profile )
125148
149+ if git_commit :
150+ commit_biannries (target , delivery_dir )
151+
126152
127153def get_parser ():
128154 parser = ArgumentParser ()
@@ -136,6 +162,11 @@ def get_parser():
136162 action = "store_true" ,
137163 default = False )
138164
165+ parser .add_argument ("--commit" ,
166+ help = "create a git commit for each platform" ,
167+ action = "store_true" ,
168+ default = False )
169+
139170 return parser
140171
141172
@@ -161,8 +192,8 @@ def main():
161192 if options .mcu is not '*' :
162193 target_filter_function = filter_target (options .mcu )
163194
164- for target , toolchain in filter (target_filter_function , psa_platforms_list ):
165- build_psa_platform (target , toolchain , options .debug )
195+ for target , toolchain , delivery_dir in filter (target_filter_function , psa_platforms_list ):
196+ build_psa_platform (target , toolchain , delivery_dir , options .debug , options . commit )
166197
167198
168199if __name__ == '__main__' :
0 commit comments