I feel your pain. All those have to be flattened or changed to something consistent. I used a bash script with a few sed
statements to quickly change all the strings that were needed across the project. Attached is the script I used to quickly port the development version of TclTcpLibrary / mbedtls. I am currently attempting to port axTLS.
#include <types.h>
should work too.
pattern match "wolfssl/wolfcrypt/" to ""
#!/bin/bash
# Use sed to quickly update a downloaded library from
# mbed to put in a form needed by the Particle build
# cloud
##
# Save the operating ROOT directory
##
ROOT=`pwd`
PARTICLE_PROJECT_DIR=/Users/cermak/Particle/projects
# Define a mbedtls source directory (SRC)
# Define the target Particle project directory (PPD)
#SRC=${ROOT}/mbedtls-2.4.2
#PPD=${PARTICLE_PROJECT_DIR}/UbidotsDataFillNew/lib/tls
SRC=${ROOT}/mbedtls-development
PPD=${PARTICLE_PROJECT_DIR}/UbidotsDataFillDev/lib/tls
# Special patch files
##
PATCHDIR=${ROOT}/mbedtls-patches
# Original particle project tree
##
ORIG=${PARTICLE_PROJECT_DIR}/UbidotsDataFill/lib/tls
# Update C library, turn into C++ library
##
cd ${SRC}/library
if [ -e "error.c" ];
then
echo "Converting c to cpp";
for i in $(ls *.c); do
mv $i ${i}pp
done
else
echo "Source files already cpp";
fi
# Do mass updates
# Mostly to flatten include statements
# fix casts on "volatile unsigned char *p = v" to
# "volatile unsigned char *p = (volatile unsigned char*)v"
##
echo "Flatting include statements in cpp and copying";
for i in $(ls *.cpp); do
sed -i .x -e '1,$s%#include "mbedtls/%#include "%g' $i
if [ -e "${i}.x" ];
then
rm ${i}.x
fi
sed -i .x -e '1,$s%volatile unsigned char \*p = (unsigned char\*)v%volatile unsigned char \*p = (volatile unsigned char\*)v%g' $i
if [ -e "${i}.x" ];
then
rm ${i}.x
fi
sed -i .x -e '1,$s%volatile unsigned char \*p = v%volatile unsigned char \*p = (volatile unsigned char\*)v%g' $i
if [ -e "${i}.x" ];
then
rm ${i}.x
fi
cp $i ${PPD}/
if [ -e "${ORIG}/$i" ];
then
#diff -u ${PPD}/$i ${ORIG}/$i > /dev/null
diff -u ${PPD}/$i ${ORIG}/$i
fi
done
# Update include files
##
echo "Copying include files";
cd ${SRC}/include/mbedtls
for i in $(ls *.h); do
sed -i .x -e '1,$s%#include "mbedtls/%#include "%g' $i
if [ -e "${i}.x" ];
then
rm ${i}.x
fi
cp $i ${PPD}/
if [ -e "${ORIG}/$i" ];
then
#diff -u ${PPD}/$i ${ORIG}/$i > /dev/null
diff -u ${PPD}/$i ${ORIG}/$i
fi
done
# Do special patching in final directory
##
echo "Performing patching on specific files:"
cd ${PPD}
for i in $(ls *.cpp *.h); do
if [ -e "${PATCHDIR}/${i}.patch" ];
then
echo -n " ";
patch -p0 < ${PATCHDIR}/${i}.patch
fi
done
# Make sure NET_C is turned off, it does
# not apply to embedded projects
##
sed -i .x -e '1,$s%^#define MBEDTLS_NET_C%//#define MBEDTLS_NET_C%' config.h
rm -f config.h.x