diff --git a/static/buildResourceCode.sh b/static/buildResourceCode.sh new file mode 100755 index 000000000..2c00414e6 --- /dev/null +++ b/static/buildResourceCode.sh @@ -0,0 +1,42 @@ +#!/bin/sh +SCRIPT_DIR=$(dirname $0) +RESOURCE_FILE=$SCRIPT_DIR/../src/common/resourceTools.h +MAP="static std::map createResourceMap() { \n" +MAP=$MAP"\tstd::map m; \n" + +# Delete old version of the file +rm -f "$RESOURCE_FILE" + +# Create header of resourceTools.h +cat << EOF > "$RESOURCE_FILE" +#ifndef KIWIX_RESOURCETOOLS_H +#define KIWIX_RESOURCETOOLS_H + +#include +#include + +std::string getResourceAsString(const std::string &name); + +EOF + +# Goes through all files in /static/ +for FILE in `find . -type f | sed 's/\.\///' | grep -v .svn | grep -v Makefile | grep -v .sh | grep -v ~` +do + echo "Inserting $FILE..." + FILE_ID=`echo "$FILE" | sed "s/\//_/" | sed "s/\./_/"` + reswrap -s -t -oa $RESOURCE_FILE -r $FILE_ID $FILE + MAP=$MAP"\tm[\""$FILE"\"] = "$FILE_ID"; \n"; +done; +MAP=$MAP"\treturn m; \n"; +MAP=$MAP"} \n\n" +MAP=$MAP"static std::map resourceMap = createResourceMap(); \n\n" + +# Create the map table +# map m = map_list_of (1,2) (3,4) (5,6) (7,8); +echo $MAP >> "$RESOURCE_FILE" + +# Create the footer +cat << EOF >> "$RESOURCE_FILE" +#endif + +EOF