Include mbedtls/platform_time.h conditionally on MBEDTLS_HAVE_TIME

Work around https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/393

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
diff --git a/scripts/data_files/query_config.fmt b/scripts/data_files/query_config.fmt
index 559734a..c60458b 100644
--- a/scripts/data_files/query_config.fmt
+++ b/scripts/data_files/query_config.fmt
@@ -12,6 +12,11 @@
 #include "mbedtls/platform.h"
 #include <string.h>
 
+/* Work around https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/393 */
+#if defined(MBEDTLS_HAVE_TIME)
+#include <mbedtls/platform_time.h>
+#endif
+
 INCLUDE_HEADERS
 
 /*
diff --git a/scripts/generate_query_config.pl b/scripts/generate_query_config.pl
index e99d633..49e363d 100755
--- a/scripts/generate_query_config.pl
+++ b/scripts/generate_query_config.pl
@@ -121,7 +121,11 @@
     map {s!^\Q$root/!!} @paths;
     # Exclude some headers that are included by build_info.h and cannot
     # be included directly.
-    push @header_files, grep {!m!_config\.h|[/_]adjust[/_]!} @paths;
+    push @header_files, grep {!m[
+            ^mbedtls/platform_time\.h$ | # errors without time.h
+            _config\.h |
+            [/_]adjust[/_]
+        ]x} @paths;
 }
 my $include_headers = join('', map {"#include <$_>\n"} @header_files);