Skip to content

Commit dae119e

Browse files
committed
PSA release script changes.
Since the offline build is made to auto-generate PSA related components and services for Secure targets, we can change the output directory to update the files in the respective locations. TARGET_PSA --TARGET_MBED_SPM --COMPONENT_SPE psa_setup.c --TARGET_TFM --COMPONENT_SPE --inc tfm_partition_defs.inc tfm_partition_list.inc tfm_service_list.inc tfm_spm_signal_defs.h --services --inc autogen_sid.h mbed_spm_partitions.h The release script is been modified to commit these files if there are any changes detected when `--commit` argument is passed. Cleaning of auto-generated is been removed as it uses the main directory for its operations, but PSA auto-generation will work if any of the service and application-based manifests are updated. Signed-off-by: Vikas Katariya <[email protected]>
1 parent bd02761 commit dae119e

File tree

7 files changed

+42
-37
lines changed

7 files changed

+42
-37
lines changed

tools/build.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
from tools.utils import argparse_dir_not_parent
4545
from tools.utils import NoValidToolchainException
4646
from tools.utils import print_end_warnings
47-
from tools.psa import generate_psa_sources, clean_psa_autogen
47+
from tools.psa import generate_psa_sources
4848
from tools.resources import OsAndSpeResourceFilter
4949

5050
def main():
@@ -166,9 +166,6 @@ def main():
166166
skipped = []
167167
end_warnings = []
168168

169-
if options.clean:
170-
clean_psa_autogen()
171-
172169
for toolchain in toolchains:
173170
for target_name in targets:
174171
target = Target.get_target(target_name)

tools/make.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
from tools.utils import print_large_string
5656
from tools.settings import ROOT
5757
from tools.targets import Target
58-
from tools.psa import generate_psa_sources, clean_psa_autogen
58+
from tools.psa import generate_psa_sources
5959
from tools.resources import OsAndSpeResourceFilter
6060

6161
def default_args_dict(options):
@@ -305,10 +305,6 @@ def main():
305305
elif options.list_tests is True:
306306
print('\n'.join(map(str, sorted(TEST_MAP.values()))))
307307
else:
308-
309-
if options.clean:
310-
clean_psa_autogen()
311-
312308
# Target
313309
if options.mcu is None:
314310
args_error(parser, "argument -m/--mcu is required")

tools/project.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
from tools.utils import NotSupportedException
5454
from tools.options import extract_profile, list_profiles, extract_mcus
5555
from tools.notifier.term import TerminalNotifier
56-
from tools.psa import generate_psa_sources, clean_psa_autogen
56+
from tools.psa import generate_psa_sources
5757
from tools.resources import OsAndSpeResourceFilter
5858

5959
""" The CLI entry point for exporting projects from the mbed tools to any of the
@@ -380,7 +380,6 @@ def main():
380380

381381
if options.clean:
382382
clean(options.source_dir)
383-
clean_psa_autogen()
384383

385384
ide = resolve_exporter_alias(options.ide)
386385
exporter, toolchain_name = get_exporter_toolchain(ide)

tools/psa/__init__.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,11 @@ def find_secure_image(notify, resources, ns_image_path,
5757

5858
return secure_image
5959

60-
61-
def _get_psa_autogen_dir():
62-
return os.path.join(ROOT, 'PSA_AUTOGEN')
63-
64-
65-
def clean_psa_autogen():
66-
psa_out_dir = _get_psa_autogen_dir()
67-
68-
if os.path.isdir(psa_out_dir):
69-
shutil.rmtree(psa_out_dir)
70-
71-
7260
def generate_psa_sources(source_dirs, ignore_paths):
7361
services, apps = manifests_discovery(root_dirs=source_dirs,
7462
ignore_paths=ignore_paths + ['.git'])
7563
assert len(services + apps), 'PSA manifest discovery failed'
76-
psa_out_dir = _get_psa_autogen_dir()
64+
psa_out_dir = os.path.join(ROOT, 'components', 'TARGET_PSA')
7765

7866
generate_spm_code(services, apps, psa_out_dir)
7967
return psa_out_dir

tools/psa/release.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
'*psa-crypto_access_control': ['USE_PSA_TEST_PARTITIONS',
4949
'USE_CRYPTO_ACL_TEST']
5050
}
51-
51+
PSA_AUTOGEN_LOCATION = os.path.join(ROOT, 'components', 'TARGET_PSA')
5252

5353
def _psa_backend(target):
5454
"""
@@ -247,6 +247,34 @@ def commit_binaries(target, delivery_dir, toolchain):
247247
else:
248248
logger.info("No changes detected in {}, Skipping commit".format(target))
249249

250+
def commit_psa_autogen():
251+
"""
252+
Commit changes related to auto-generated PSA components and services
253+
"""
254+
changes_made = verbose_check_call([
255+
'git',
256+
'-C', ROOT,
257+
'diff', '--exit-code', '--quiet',
258+
PSA_AUTOGEN_LOCATION], check_call=False)
259+
260+
if changes_made:
261+
logger.info("Change in PSA auto-generated files has been detected")
262+
verbose_check_call([
263+
'git',
264+
'-C', ROOT,
265+
'add', PSA_AUTOGEN_LOCATION])
266+
267+
logger.info("Committing changes...")
268+
commit_message = ('--message=Update PSA auto-generated components and '
269+
'services')
270+
verbose_check_call([
271+
'git',
272+
'-C', ROOT,
273+
'commit',
274+
commit_message])
275+
else:
276+
logger.info("No changes has been detected for PSA autogen, "
277+
"Skipping commit")
250278

251279
def build_psa_platform(target, toolchain, delivery_dir, debug, git_commit,
252280
skip_tests, args):
@@ -268,6 +296,7 @@ def build_psa_platform(target, toolchain, delivery_dir, debug, git_commit,
268296
build_default_image(target, toolchain, profile, args)
269297
if git_commit:
270298
commit_binaries(target, delivery_dir, toolchain)
299+
commit_psa_autogen()
271300

272301

273302
def get_parser():

tools/psa/spm_template_file_list.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,36 @@
22
{
33
"name": "Secure Partition ID definitions",
44
"template": "tools/psa/templates/tfm_partition_defs.inc.tpl",
5-
"output": "COMPONENT_SPE/TARGET_TFM/tfm_partition_defs.inc"
5+
"output": "TARGET_TFM/COMPONENT_SPE/inc/tfm_partition_defs.inc"
66
},
77
{
88
"name": "Secure Partition declarations",
99
"template": "tools/psa/templates/tfm_partition_list.inc.tpl",
10-
"output": "COMPONENT_SPE/TARGET_TFM/tfm_partition_list.inc"
10+
"output": "TARGET_TFM/COMPONENT_SPE/inc/tfm_partition_list.inc"
1111
},
1212
{
1313
"name": "Secure Service list",
1414
"template": "tools/psa/templates/tfm_service_list.inc.tpl",
15-
"output": "COMPONENT_SPE/TARGET_TFM/tfm_service_list.inc"
15+
"output": "TARGET_TFM/COMPONENT_SPE/inc/tfm_service_list.inc"
1616
},
1717
{
1818
"name": "Secure Service signals list",
1919
"template": "tools/psa/templates/tfm_spm_signal_defs.h.tpl",
20-
"output": "COMPONENT_SPE/TARGET_TFM/tfm_spm_signal_defs.h"
20+
"output": "TARGET_TFM/COMPONENT_SPE/inc/tfm_spm_signal_defs.h"
2121
},
2222
{
2323
"name": "mbed-SPM database",
2424
"template": "tools/psa/templates/psa_setup.c.tpl",
25-
"output": "COMPONENT_SPE/TARGET_MBED_SPM/psa_setup.c"
25+
"output": "TARGET_MBED_SPM/COMPONENT_SPE/psa_setup.c"
2626
},
2727
{
2828
"name": "Mappings from RoT Service names to SIDs",
2929
"template": "tools/psa/templates/sid.h.tpl",
30-
"output": "autogen_sid.h"
30+
"output": "services/inc/autogen_sid.h"
3131
},
3232
{
3333
"name": "Details partition defines and structures",
3434
"template": "tools/psa/templates/mbed_spm_partitions.h.tpl",
35-
"output": "mbed_spm_partitions.h"
35+
"output": "services/inc/mbed_spm_partitions.h"
3636
}
3737
]

tools/test.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
from tools.utils import print_end_warnings
4444
from tools.settings import ROOT
4545
from tools.targets import Target
46-
from tools.psa import generate_psa_sources, clean_psa_autogen
46+
from tools.psa import generate_psa_sources
4747
from tools.resources import OsAndSpeResourceFilter, SpeOnlyResourceFilter
4848

4949
def main():
@@ -220,10 +220,6 @@ def main():
220220
print_tests(tests, options.format)
221221
sys.exit(0)
222222
else:
223-
224-
if options.clean:
225-
clean_psa_autogen()
226-
227223
# Build all tests
228224
if not options.build_dir:
229225
args_error(parser, "argument --build is required")

0 commit comments

Comments
 (0)