File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed
features/mbedtls/importer Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,19 @@ conf() {
25
25
$SCRIPT -f $FILE --force $@
26
26
}
27
27
28
- add_code () {
28
+ # Add code before the matching line
29
+ prepend_code () {
30
+ MATCH_PATTERN=" $1 "
31
+ shift
32
+ CODE=$( IFS=" " ; printf " %s" " $* " )
33
+
34
+ perl -i -pe \
35
+ " s/$MATCH_PATTERN /$CODE$MATCH_PATTERN /igs" \
36
+ " $FILE "
37
+ }
38
+
39
+ # Add code after the matching line
40
+ append_code () {
29
41
MATCH_PATTERN=" $1 "
30
42
shift
31
43
CODE=$( IFS=" " ; printf " %s" " $* " )
@@ -37,7 +49,7 @@ add_code() {
37
49
38
50
# add an #ifndef to include config-no-entropy.h when the target does not have
39
51
# an entropy source we can use.
40
- add_code \
52
+ append_code \
41
53
" #ifndef MBEDTLS_CONFIG_H\n" \
42
54
" \n" \
43
55
" #include \" platform\/inc\/platform_mbed.h\" \n" \
@@ -56,8 +68,8 @@ add_code
56
68
" \n" \
57
69
" #else\n"
58
70
59
- add_code \
60
- " #include \" mbedtls\/check_config.h \" \n " \
71
+ prepend_code \
72
+ " #endif \/\* MBEDTLS_CONFIG_H \*\/ " \
61
73
" \n" \
62
74
" #endif \/* !MBEDTLS_ENTROPY_HARDWARE_ALT && !MBEDTLS_TEST_NULL_ENTROPY && !MBEDTLS_ENTROPY_NV_SEED *\/\n" \
63
75
" \n" \
@@ -70,7 +82,8 @@ add_code
70
82
" !defined(MBEDTLS_ENTROPY_HARDWARE_ALT) && !defined(MBEDTLS_ENTROPY_NV_SEED)\n" \
71
83
" #error \" No entropy source was found at build time, so TLS \" \\\\ \n" \
72
84
" \" functionality is not available\" \n" \
73
- " #endif\n"
85
+ " #endif\n" \
86
+ " \n"
74
87
75
88
# not supported on mbed OS, nor used by mbed Client
76
89
conf unset MBEDTLS_NET_C
You can’t perform that action at this time.
0 commit comments