quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

generate_cpp_dummy_build.sh (2181B)


      1 #!/bin/sh
      2 
      3 DEFAULT_OUTPUT_FILE=programs/test/cpp_dummy_build.cpp
      4 
      5 if [ "$1" = "--help" ]; then
      6     cat <<EOF
      7 Usage: $0 [OUTPUT]
      8 Generate a C++ dummy build program that includes all the headers.
      9 OUTPUT defaults to "programs/test/cpp_dummy_build.cpp".
     10 Run this program from the root of an Mbed TLS directory tree or from
     11 its "programs" or "programs/test" subdirectory.
     12 EOF
     13     exit
     14 fi
     15 
     16 # Copyright The Mbed TLS Contributors
     17 # SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
     18 
     19 set -e
     20 
     21 # Ensure a reproducible order for *.h
     22 export LC_ALL=C
     23 
     24 print_cpp () {
     25     cat <<'EOF'
     26 /* Automatically generated file. Do not edit.
     27  *
     28  *  This program is a dummy C++ program to ensure Mbed TLS library header files
     29  *  can be included and built with a C++ compiler.
     30  *
     31  *  Copyright The Mbed TLS Contributors
     32  *  SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
     33  *
     34  */
     35 
     36 #include "mbedtls/build_info.h"
     37 
     38 EOF
     39 
     40     for header in include/mbedtls/*.h include/psa/*.h; do
     41         case ${header#include/} in
     42             mbedtls/mbedtls_config.h) :;; # not meant for direct inclusion
     43             mbedtls/config_*.h) :;; # not meant for direct inclusion
     44             psa/crypto_config.h) :;; # not meant for direct inclusion
     45             psa/crypto_ajdust_config*.h) :;; # not meant for direct inclusion
     46             # Some of the psa/crypto_*.h headers are not meant to be included
     47             # directly. They do have include guards that make them no-ops if
     48             # psa/crypto.h has been included before. Since psa/crypto.h comes
     49             # before psa/crypto_*.h in the wildcard enumeration, we don't need
     50             # to skip those headers.
     51             *) echo "#include \"${header#include/}\"";;
     52         esac
     53     done
     54 
     55     cat <<'EOF'
     56 
     57 int main()
     58 {
     59     mbedtls_platform_context *ctx = NULL;
     60     mbedtls_platform_setup(ctx);
     61     mbedtls_printf("CPP Build test passed\n");
     62     mbedtls_platform_teardown(ctx);
     63 }
     64 EOF
     65 }
     66 
     67 if [ -d include/mbedtls ]; then
     68     :
     69 elif [ -d ../include/mbedtls ]; then
     70     cd ..
     71 elif [ -d ../../include/mbedtls ]; then
     72     cd ../..
     73 else
     74     echo >&2 "This script must be run from an Mbed TLS source tree."
     75     exit 3
     76 fi
     77 
     78 print_cpp >"${1:-$DEFAULT_OUTPUT_FILE}"