File tree 3 files changed +70
-16
lines changed
3 files changed +70
-16
lines changed Original file line number Diff line number Diff line change @@ -131,22 +131,9 @@ pre_set_shell_options () {
131
131
set -e -o pipefail -u
132
132
}
133
133
134
- # For project detection
135
- in_mbedtls_repo () {
136
- test " $PROJECT_NAME " = " Mbed TLS"
137
- }
138
-
139
- in_tf_psa_crypto_repo () {
140
- test " $PROJECT_NAME " = " TF-PSA-Crypto"
141
- }
142
-
143
134
pre_check_environment () {
144
- # For project detection
145
- PROJECT_NAME_FILE=' ./scripts/project_name.txt'
146
- if read -r PROJECT_NAME < " $PROJECT_NAME_FILE " ; then : ; else
147
- echo " $PROJECT_NAME_FILE does not exist... Exiting..." >&2
148
- exit 1
149
- fi
135
+
136
+ source $FRAMEWORK /scripts/project_detection.sh
150
137
151
138
if in_mbedtls_repo || in_tf_psa_crypto_repo; then : ; else
152
139
echo " Must be run from Mbed TLS / TF-PSA-Crypto root" >&2
Original file line number Diff line number Diff line change @@ -133,7 +133,7 @@ def guess_tf_psa_crypto_root(root: Optional[str] = None) -> str:
133
133
def is_mbedtls_3_6 () -> bool :
134
134
"""Whether the working tree is an Mbed TLS 3.6 one or not
135
135
136
- Return false in we are in TF-PSA-Crypto or in Mbed TLS but with a version
136
+ Return false if we are in TF-PSA-Crypto or in Mbed TLS but with a version
137
137
different from 3.6.x.
138
138
Raise an exception if we are neither in Mbed TLS nor in TF-PSA-Crypto.
139
139
"""
Original file line number Diff line number Diff line change
1
+ # project-detection.sh
2
+ #
3
+ # Copyright The Mbed TLS Contributors
4
+ # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
5
+ #
6
+ # Purpose
7
+ #
8
+ # This script contains functions for shell scripts to
9
+ # help detect which project (Mbed TLS, TF-PSA-Crypto)
10
+ # or which Mbed TLS branch they are in.
11
+
12
+ # Project detection
13
+ read_project_name_file () {
14
+ SCRIPT_DIR=$( pwd)
15
+
16
+ PROJECT_NAME_FILE=" scripts/project_name.txt"
17
+
18
+ if read -r PROJECT_NAME < " $PROJECT_NAME_FILE " ; then : ; else
19
+ echo " $PROJECT_NAME_FILE does not exist... Exiting..." >&2
20
+ exit 1
21
+ fi
22
+ }
23
+
24
+ in_mbedtls_repo () {
25
+ read_project_name_file
26
+ test " $PROJECT_NAME " = " Mbed TLS"
27
+ }
28
+
29
+ in_tf_psa_crypto_repo () {
30
+ read_project_name_file
31
+ test " $PROJECT_NAME " = " TF-PSA-Crypto"
32
+ }
33
+
34
+ # Branch detection
35
+ read_build_info () {
36
+ SCRIPT_DIR=$( pwd)
37
+
38
+ BUILD_INFO_FILE=" include/mbedtls/build_info.h"
39
+
40
+ if [ ! -f " $BUILD_INFO_FILE " ]; then
41
+ echo " File $BUILD_INFO_FILE not found."
42
+ exit 1
43
+ fi
44
+
45
+ MBEDTLS_VERSION_MAJOR=$( grep " ^#define MBEDTLS_VERSION_MAJOR" " $BUILD_INFO_FILE " | awk ' {print $3}' )
46
+ MBEDTLS_VERSION_MINOR=$( grep " ^#define MBEDTLS_VERSION_MINOR" " $BUILD_INFO_FILE " | awk ' {print $3}' )
47
+
48
+ if [ -z " $MBEDTLS_VERSION_MAJOR " ]; then
49
+ echo " MBEDTLS_VERSION_MAJOR not found in $BUILD_INFO_FILE ."
50
+ exit 1
51
+ fi
52
+
53
+ if [ -z " $MBEDTLS_VERSION_MINOR " ]; then
54
+ echo " MBEDTLS_VERSION_MINOR not found in $BUILD_INFO_FILE ."
55
+ exit 1
56
+ fi
57
+ }
58
+
59
+ in_3_6_branch () {
60
+ read_build_info
61
+ test $MBEDTLS_VERSION_MAJOR = " 3" && test $MBEDTLS_VERSION_MINOR = " 6"
62
+ }
63
+
64
+ in_4_x_branch () {
65
+ read_build_info
66
+ test $MBEDTLS_VERSION_MAJOR = " 4"
67
+ }
You can’t perform that action at this time.
0 commit comments