Skip to content

Commit 92cc3d0

Browse files
orenc17Oren Cohen
authored andcommitted
Add git commit option
1 parent 91dabb5 commit 92cc3d0

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

tools/psa/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,18 @@ Each implementation requires a set of autogenerated files describing the secure
3434
`release.py` is the script assigned with compiling the secure images:
3535

3636
```
37-
usage: release.py [-h] [-m MCU] [-d]
37+
usage: release.py [-h] [-m MCU] [-d] [--commit]
3838
3939
optional arguments:
4040
-h, --help show this help message and exit
4141
-m MCU, --mcu MCU build for the given MCU
4242
-d, --debug set build profile to debug
43+
--commit create a git commit for each platform
4344
```
4445

4546
* When `MCU ` is not specified, the script compiles all the images for all the targets.
4647
* When `-d/--debug` is not specified, the script compiles the images using the release profile.
48+
* When `--commit` is not specified, the script will not commit the images to git.
4749

4850
This script should be run in following scenarios:
4951

tools/psa/release.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

127153
def 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

168199
if __name__ == '__main__':

0 commit comments

Comments
 (0)